mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 11:17:53 +01:00
* [Analyzers] Remove duplicate pascal case style from .editorconfig * [Analyzers] Configured severity for individual IDE and CA rules showing as errors in VS Set severity for IDE0005, IDE0008, IDE0016, IDE0018, IDE0019, IDE0021, IDE0022, IDE0023, IDE0025, IDE0027, IDE0028, IDE0029, IDE0031, IDE0032, IDE0034, IDE0036, IDE0039, IDE0042, IDE0044, IDE0045, IDE0046, IDE0047, IDE0057, IDE0051, IDE0052, IDE0054, IDE0055, IDE0056, IDE0057, IDE0059, IDE0060, IDE0061, IDE0063, IDE0071, IDE0073, IDE0074, IDE0075, IDE0077, IDE0078, IDE0083, IDE0090, IDE0100, IDE0130, IDE160, IDE180, IDE0200, IDE0240, IDE0250, IDE0251, IDE0260, IDE0270, IDE0290, IDE0300, IDE0301, IDE0305, IDE1005, IDE1006, CA1859, CA2022, CA2263 * [Analyzers] Fix mismatched analyzer descriptions * [Analyzers] Fix misspelling * Update .editorconfig Made the following style rules `silent` instead of `suggestion`: - Use explicit type instead of 'var' - Use expression body for ... - Use block-scoped namespace * [Analyzers] Set IDE0290 to silent * [Analyzers] Remove IDE1006 configuration from .editorconfig in favor of making exclusions for the few entries * [Analyzers][Indexer] Add IDE1006 suppressions * [Analyzers][Peek] Add IDE1006 suppression * [Analyzers][MWB] Add IDE1006 suppression. * [Analyzers][Plugins] Add IDE1006 suppression * [Analyzers][ImageResizer] Suppress IDE0073 to retain original copyright * [Analyzers] Remove IDE0073 severity change in .editorconfig --------- Co-authored-by: Ani <115020168+drawbyperpetual@users.noreply.github.com>
107 lines
3.2 KiB
C#
107 lines
3.2 KiB
C#
#pragma warning disable IDE0073
|
|
// Copyright (c) Brice Lambson
|
|
// The Brice Lambson licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information. Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/
|
|
#pragma warning restore IDE0073
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Windows.Input;
|
|
|
|
using Common.UI;
|
|
using ImageResizer.Helpers;
|
|
using ImageResizer.Models;
|
|
using ImageResizer.Properties;
|
|
using ImageResizer.Views;
|
|
|
|
namespace ImageResizer.ViewModels
|
|
{
|
|
public class InputViewModel : Observable
|
|
{
|
|
private readonly ResizeBatch _batch;
|
|
private readonly MainViewModel _mainViewModel;
|
|
private readonly IMainView _mainView;
|
|
|
|
public enum Dimension
|
|
{
|
|
Width,
|
|
Height,
|
|
}
|
|
|
|
public class KeyPressParams
|
|
{
|
|
public double Value { get; set; }
|
|
|
|
public Dimension Dimension { get; set; }
|
|
}
|
|
|
|
public InputViewModel(
|
|
Settings settings,
|
|
MainViewModel mainViewModel,
|
|
IMainView mainView,
|
|
ResizeBatch batch)
|
|
{
|
|
_batch = batch;
|
|
_mainViewModel = mainViewModel;
|
|
_mainView = mainView;
|
|
|
|
Settings = settings;
|
|
if (settings != null)
|
|
{
|
|
settings.CustomSize.PropertyChanged += (sender, e) => settings.SelectedSize = (CustomSize)sender;
|
|
}
|
|
|
|
ResizeCommand = new RelayCommand(Resize);
|
|
CancelCommand = new RelayCommand(Cancel);
|
|
OpenSettingsCommand = new RelayCommand(OpenSettings);
|
|
EnterKeyPressedCommand = new RelayCommand<KeyPressParams>(HandleEnterKeyPress);
|
|
}
|
|
|
|
public Settings Settings { get; }
|
|
|
|
public IEnumerable<ResizeFit> ResizeFitValues => Enum.GetValues(typeof(ResizeFit)).Cast<ResizeFit>();
|
|
|
|
public IEnumerable<ResizeUnit> ResizeUnitValues => Enum.GetValues(typeof(ResizeUnit)).Cast<ResizeUnit>();
|
|
|
|
public ICommand ResizeCommand { get; }
|
|
|
|
public ICommand CancelCommand { get; }
|
|
|
|
public ICommand OpenSettingsCommand { get; }
|
|
|
|
public ICommand EnterKeyPressedCommand { get; private set; }
|
|
|
|
// Any of the files is a gif
|
|
public bool TryingToResizeGifFiles =>
|
|
_batch.Files.Any(filename => filename.EndsWith(".gif", System.StringComparison.InvariantCultureIgnoreCase));
|
|
|
|
public void Resize()
|
|
{
|
|
Settings.Save();
|
|
_mainViewModel.CurrentPage = new ProgressViewModel(_batch, _mainViewModel, _mainView);
|
|
}
|
|
|
|
public static void OpenSettings()
|
|
{
|
|
SettingsDeepLink.OpenSettings(SettingsDeepLink.SettingsWindow.ImageResizer, false);
|
|
}
|
|
|
|
private void HandleEnterKeyPress(KeyPressParams parameters)
|
|
{
|
|
switch (parameters.Dimension)
|
|
{
|
|
case Dimension.Width:
|
|
Settings.CustomSize.Width = parameters.Value;
|
|
break;
|
|
case Dimension.Height:
|
|
Settings.CustomSize.Height = parameters.Value;
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void Cancel()
|
|
=> _mainView.Close();
|
|
}
|
|
}
|