mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
[Image Resizer] Upgraded to .NET Core 3.1 (#7317)
* project converted to sdk style * image resizer core31 * image resizer test core31 * project and setup fixes
This commit is contained in:
committed by
GitHub
parent
e2c94b592f
commit
aa0947061a
@@ -135,11 +135,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KeyboardManager", "src\modu
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "imageresizer", "imageresizer", "{6C7F47CC-2151-44A3-A546-41C70025132C}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "imageresizer", "imageresizer", "{6C7F47CC-2151-44A3-A546-41C70025132C}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageResizerUI", "src\modules\imageresizer\ui\ImageResizerUI.csproj", "{2BE46397-4DFA-414C-9BD4-41E4BBF8CB34}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageResizerUI", "src\modules\imageresizer\ui\ImageResizerUI.csproj", "{2BE46397-4DFA-414C-9BD4-41E4BBF8CB34}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImageResizerExt", "src\modules\imageresizer\dll\ImageResizerExt.vcxproj", "{0B43679E-EDFA-4DA0-AD30-F4628B308B1B}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImageResizerExt", "src\modules\imageresizer\dll\ImageResizerExt.vcxproj", "{0B43679E-EDFA-4DA0-AD30-F4628B308B1B}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageResizerUITest", "src\modules\imageresizer\tests\ImageResizerUITest.csproj", "{E0CC7526-D85E-43AC-844F-D5DF0D2F5AB8}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageResizerUITest", "src\modules\imageresizer\tests\ImageResizerUITest.csproj", "{E0CC7526-D85E-43AC-844F-D5DF0D2F5AB8}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KeyboardManagerUI", "src\modules\keyboardmanager\ui\KeyboardManagerUI.vcxproj", "{EAF23649-EF6E-478B-980E-81FAD96CCA2A}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KeyboardManagerUI", "src\modules\keyboardmanager\ui\KeyboardManagerUI.vcxproj", "{EAF23649-EF6E-478B-980E-81FAD96CCA2A}"
|
||||||
EndProject
|
EndProject
|
||||||
|
|||||||
@@ -492,14 +492,11 @@
|
|||||||
<File Source="$(var.BinX64Dir)modules\$(var.ImageResizerProjectName)\ImageResizer.exe">
|
<File Source="$(var.BinX64Dir)modules\$(var.ImageResizerProjectName)\ImageResizer.exe">
|
||||||
<netfx:NativeImage Id="ImageResizer.exe" Platform="all" Priority="0" />
|
<netfx:NativeImage Id="ImageResizer.exe" Platform="all" Priority="0" />
|
||||||
</File>
|
</File>
|
||||||
<File Source="$(var.BinX64Dir)modules\$(var.ImageResizerProjectName)\GalaSoft.MvvmLight.dll" />
|
|
||||||
<File Source="$(var.BinX64Dir)modules\$(var.ImageResizerProjectName)\GalaSoft.MvvmLight.Platform.dll" />
|
|
||||||
<File Source="$(var.BinX64Dir)modules\$(var.ImageResizerProjectName)\GalaSoft.MvvmLight.Extras.dll" />
|
|
||||||
<File Source="$(var.BinX64Dir)modules\$(var.ImageResizerProjectName)\System.Windows.Interactivity.dll">
|
|
||||||
<!-- NB: Needed since it's only referenced in XAML. -->
|
|
||||||
<netfx:NativeImage Id="Interactivity" Platform="all" Priority="0"/>
|
|
||||||
</File>
|
|
||||||
<File Source="$(var.BinX64Dir)modules\$(var.ImageResizerProjectName)\Newtonsoft.Json.dll" />
|
<File Source="$(var.BinX64Dir)modules\$(var.ImageResizerProjectName)\Newtonsoft.Json.dll" />
|
||||||
|
<File Source="$(var.BinX64Dir)modules\$(var.ImageResizerProjectName)\ImageResizer.dll" />
|
||||||
|
<File Source="$(var.BinX64Dir)modules\$(var.ImageResizerProjectName)\ImageResizer.deps.json" />
|
||||||
|
<File Source="$(var.BinX64Dir)modules\$(var.ImageResizerProjectName)\ImageResizer.runtimeconfig.json" />
|
||||||
|
<File Id="Module_ImageResizer_Microsoft_Xaml_Behaviors" Source="$(var.BinX64Dir)modules\$(var.ImageResizerProjectName)\Microsoft.Xaml.Behaviors.dll" />
|
||||||
<File Source="$(var.BinX64Dir)modules\$(var.ImageResizerProjectName)\ImageResizerExt.dll" KeyPath="yes" />
|
<File Source="$(var.BinX64Dir)modules\$(var.ImageResizerProjectName)\ImageResizerExt.dll" KeyPath="yes" />
|
||||||
<File Id="ImageResizer_interop" Source="$(var.BinX64Dir)modules\$(var.ImageResizerProjectName)\PowerToysInterop.dll" />
|
<File Id="ImageResizer_interop" Source="$(var.BinX64Dir)modules\$(var.ImageResizerProjectName)\PowerToysInterop.dll" />
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<configuration>
|
|
||||||
<startup>
|
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
|
|
||||||
</startup>
|
|
||||||
</configuration>
|
|
||||||
@@ -1,114 +1,44 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
||||||
<Import Project="..\..\..\Version.props" />
|
<Import Project="..\..\..\Version.props" />
|
||||||
<!-- We don't have GenerateAssemblyInfo task until we use .net core, so we generate it with WriteLinesToFile -->
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<AssemblyTitle>ImageResizerUITest</AssemblyTitle>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<AssemblyCompany>Microsoft Corp.</AssemblyCompany>
|
|
||||||
<AssemblyCopyright>Copyright (C) 2020 Microsoft Corp.</AssemblyCopyright>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<AssemblyVersionFiles Include="Generated Files\AssemblyInfo.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Target Name="GenerateAssemblyInfo" BeforeTargets="PrepareForBuild">
|
|
||||||
<ItemGroup>
|
|
||||||
<HeaderLines Include="// Copyright (c) Microsoft Corporation" />
|
|
||||||
<HeaderLines Include="// The Microsoft Corporation licenses this file to you under the MIT license." />
|
|
||||||
<HeaderLines Include="// See the LICENSE file in the project root for more information." />
|
|
||||||
<HeaderLines Include="#pragma warning disable SA1516" />
|
|
||||||
<HeaderLines Include="using System.Reflection%3b" />
|
|
||||||
<HeaderLines Include="using System.Runtime.InteropServices%3b" />
|
|
||||||
<HeaderLines Include="using System.Windows%3b" />
|
|
||||||
<HeaderLines Include="[assembly: AssemblyTitle("$(AssemblyTitle)")]" />
|
|
||||||
<HeaderLines Include="[assembly: AssemblyDescription("")]" />
|
|
||||||
<HeaderLines Include="[assembly: AssemblyConfiguration("")]" />
|
|
||||||
<HeaderLines Include="[assembly: AssemblyCompany("$(AssemblyCompany)")]" />
|
|
||||||
<HeaderLines Include="[assembly: AssemblyCopyright("$(AssemblyCopyright)")]" />
|
|
||||||
<HeaderLines Include="[assembly: AssemblyProduct("$(AssemblyTitle)")]" />
|
|
||||||
<HeaderLines Include="[assembly: AssemblyTrademark("")]" />
|
|
||||||
<HeaderLines Include="[assembly: AssemblyCulture("")]" />
|
|
||||||
<HeaderLines Include="[assembly: ComVisible(false)]" />
|
|
||||||
<HeaderLines Include="[assembly: AssemblyVersion("$(Version).0")]" />
|
|
||||||
<HeaderLines Include="[assembly: AssemblyFileVersion("$(Version).0")]" />
|
|
||||||
</ItemGroup>
|
|
||||||
<WriteLinesToFile File="Generated Files\AssemblyInfo.cs" Lines="@(HeaderLines)" Overwrite="true" Encoding="Unicode" WriteOnlyWhenDifferent="true" />
|
|
||||||
</Target>
|
|
||||||
<PropertyGroup>
|
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
|
||||||
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
|
|
||||||
<ProjectGuid>{E0CC7526-D85E-43AC-844F-D5DF0D2F5AB8}</ProjectGuid>
|
<ProjectGuid>{E0CC7526-D85E-43AC-844F-D5DF0D2F5AB8}</ProjectGuid>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>ImageResizer</RootNamespace>
|
<RootNamespace>ImageResizer</RootNamespace>
|
||||||
<AssemblyName>ImageResizer.Test</AssemblyName>
|
<AssemblyName>ImageResizer.Test</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
<AssemblyCompany>Microsoft Corp.</AssemblyCompany>
|
||||||
<FileAlignment>512</FileAlignment>
|
<AssemblyCopyright>Copyright (C) 2020 Microsoft Corp.</AssemblyCopyright>
|
||||||
<TargetFrameworkProfile>
|
<Version>$(Version).0</Version>
|
||||||
</TargetFrameworkProfile>
|
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\modules\ImageResizer\$(AssemblyName)\</OutputPath>
|
||||||
|
<CodeAnalysisRuleSet>..\..\..\codeAnalysis\Rules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<Platforms>x64</Platforms>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<Platform Condition="'$(Platform)'==''">x64</Platform>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
<IntermediateOutputPath>$(SolutionDir)$(Platform)\$(Configuration)\obj\$(AssemblyName)\</IntermediateOutputPath>
|
<IntermediateOutputPath>$(SolutionDir)$(Platform)\$(Configuration)\obj\$(AssemblyName)\</IntermediateOutputPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<DebugType>full</DebugType>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\modules\ImageResizer\$(AssemblyName)\</OutputPath>
|
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
|
||||||
<CodeAnalysisRuleSet>..\..\..\codeAnalysis\Rules.ruleset</CodeAnalysisRuleSet>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<DebugType>pdbonly</DebugType>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\modules\ImageResizer\$(AssemblyName)\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
|
||||||
<CodeAnalysisRuleSet>..\..\..\codeAnalysis\Rules.ruleset</CodeAnalysisRuleSet>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="PresentationCore" />
|
<ProjectReference Include="..\ui\ImageResizerUI.csproj" />
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="WindowsBase" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\ui\ImageResizerUI.csproj">
|
|
||||||
<Project>{2be46397-4dfa-414c-9bd4-41e4bbf8cb34}</Project>
|
|
||||||
<Name>ImageResizerUI</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AdditionalFiles Include="..\..\..\codeAnalysis\StyleCop.json">
|
<AdditionalFiles Include="..\..\..\codeAnalysis\StyleCop.json">
|
||||||
<Link>StyleCop.json</Link>
|
<Link>StyleCop.json</Link>
|
||||||
</AdditionalFiles>
|
</AdditionalFiles>
|
||||||
<None Include="..\..\..\..\.editorconfig">
|
|
||||||
<Link>.editorconfig</Link>
|
|
||||||
</None>
|
|
||||||
<None Include="App.config">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\codeAnalysis\GlobalSuppressions.cs">
|
<Compile Include="..\codeAnalysis\GlobalSuppressions.cs" Link="GlobalSuppressions.cs" />
|
||||||
<Link>GlobalSuppressions.cs</Link>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Generated Files\AssemblyInfo.cs">
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Models\CustomSizeTests.cs" />
|
|
||||||
<Compile Include="Models\ResizeSizeTests.cs" />
|
|
||||||
<Compile Include="Models\ResizeBatchTests.cs" />
|
|
||||||
<Compile Include="Models\ResizeOperationTests.cs" />
|
|
||||||
<Compile Include="Properties\AppFixture.cs" />
|
|
||||||
<Compile Include="Properties\SettingsTests.cs" />
|
|
||||||
<Compile Include="Test\AssertEx.cs" />
|
|
||||||
<Compile Include="Test\BitmapSourceExtensions.cs" />
|
|
||||||
<Compile Include="Test\TestDirectory.cs" />
|
|
||||||
<Compile Include="Views\TimeRemainingConverterTests.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Test.gif">
|
<Content Include="Test.gif">
|
||||||
@@ -131,33 +61,18 @@
|
|||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers">
|
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
|
||||||
<Version>3.3.0</Version>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Moq">
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||||
<Version>4.14.5</Version>
|
<PackageReference Include="Moq" Version="4.14.5" />
|
||||||
</PackageReference>
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||||
<PackageReference Include="StyleCop.Analyzers">
|
|
||||||
<Version>1.1.118</Version>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="System.ValueTuple">
|
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||||
<Version>4.5.0</Version>
|
<PackageReference Include="xunit" Version="2.4.1" />
|
||||||
</PackageReference>
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||||
<PackageReference Include="xunit">
|
|
||||||
<Version>2.4.1</Version>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="xunit.runner.visualstudio">
|
|
||||||
<Version>2.4.3</Version>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<configuration>
|
|
||||||
<startup>
|
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
|
|
||||||
</startup>
|
|
||||||
</configuration>
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:m="clr-namespace:ImageResizer.Models"
|
xmlns:m="clr-namespace:ImageResizer.Models"
|
||||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
xmlns:sys="clr-namespace:System;assembly=System.Runtime"
|
||||||
xmlns:v="clr-namespace:ImageResizer.Views">
|
xmlns:v="clr-namespace:ImageResizer.Views">
|
||||||
|
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using GalaSoft.MvvmLight.Threading;
|
|
||||||
using ImageResizer.Models;
|
using ImageResizer.Models;
|
||||||
using ImageResizer.Properties;
|
using ImageResizer.Properties;
|
||||||
using ImageResizer.Utilities;
|
using ImageResizer.Utilities;
|
||||||
@@ -19,7 +18,6 @@ namespace ImageResizer
|
|||||||
static App()
|
static App()
|
||||||
{
|
{
|
||||||
Console.InputEncoding = Encoding.Unicode;
|
Console.InputEncoding = Encoding.Unicode;
|
||||||
DispatcherHelper.Initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnStartup(StartupEventArgs e)
|
protected override void OnStartup(StartupEventArgs e)
|
||||||
|
|||||||
27
src/modules/imageresizer/ui/Helpers/Observable.cs
Normal file
27
src/modules/imageresizer/ui/Helpers/Observable.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
namespace ImageResizer.Helpers
|
||||||
|
{
|
||||||
|
public class Observable : INotifyPropertyChanged
|
||||||
|
{
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
protected void Set<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
|
||||||
|
{
|
||||||
|
if (Equals(storage, value))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
storage = value;
|
||||||
|
OnPropertyChanged(propertyName);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
|
}
|
||||||
|
}
|
||||||
61
src/modules/imageresizer/ui/Helpers/RelayCommand.cs
Normal file
61
src/modules/imageresizer/ui/Helpers/RelayCommand.cs
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
|
namespace ImageResizer.Helpers
|
||||||
|
{
|
||||||
|
public class RelayCommand : ICommand
|
||||||
|
{
|
||||||
|
private readonly Action _execute;
|
||||||
|
private readonly Func<bool> _canExecute;
|
||||||
|
|
||||||
|
public event EventHandler CanExecuteChanged;
|
||||||
|
|
||||||
|
public RelayCommand(Action execute)
|
||||||
|
: this(execute, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public RelayCommand(Action execute, Func<bool> canExecute)
|
||||||
|
{
|
||||||
|
_execute = execute ?? throw new ArgumentNullException(nameof(execute));
|
||||||
|
_canExecute = canExecute;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanExecute(object parameter) => _canExecute == null || _canExecute();
|
||||||
|
|
||||||
|
public void Execute(object parameter) => _execute();
|
||||||
|
|
||||||
|
public void OnCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "abstract T and abstract")]
|
||||||
|
public class RelayCommand<T> : ICommand
|
||||||
|
{
|
||||||
|
private readonly Action<T> execute;
|
||||||
|
|
||||||
|
private readonly Func<T, bool> canExecute;
|
||||||
|
|
||||||
|
public event EventHandler CanExecuteChanged;
|
||||||
|
|
||||||
|
public RelayCommand(Action<T> execute)
|
||||||
|
: this(execute, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public RelayCommand(Action<T> execute, Func<T, bool> canExecute)
|
||||||
|
{
|
||||||
|
this.execute = execute ?? throw new ArgumentNullException(nameof(execute));
|
||||||
|
this.canExecute = canExecute;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanExecute(object parameter) => canExecute == null || canExecute((T)parameter);
|
||||||
|
|
||||||
|
public void Execute(object parameter) => execute((T)parameter);
|
||||||
|
|
||||||
|
public void OnCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,193 +1,60 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
||||||
<Import Project="..\..\..\Version.props" />
|
<Import Project="..\..\..\Version.props" />
|
||||||
<!-- We don't have GenerateAssemblyInfo task until we use .net core, so we generate it with WriteLinesToFile -->
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<AssemblyTitle>ImageResizer</AssemblyTitle>
|
<AssemblyTitle>ImageResizer</AssemblyTitle>
|
||||||
<AssemblyCompany>Microsoft Corp.</AssemblyCompany>
|
<AssemblyCompany>Microsoft Corp.</AssemblyCompany>
|
||||||
<AssemblyCopyright>Copyright (C) 2019 Microsoft Corp.</AssemblyCopyright>
|
<AssemblyCopyright>Copyright (C) 2019 Microsoft Corp.</AssemblyCopyright>
|
||||||
|
<CodeAnalysisRuleSet>..\..\..\codeAnalysis\Rules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\modules\ImageResizer</OutputPath>
|
||||||
|
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||||
|
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||||
|
<UseWPF>true</UseWPF>
|
||||||
|
<Platforms>x64</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
|
||||||
<AssemblyVersionFiles Include="Generated Files\AssemblyInfo.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Target Name="GenerateAssemblyInfo" BeforeTargets="PrepareForBuild">
|
|
||||||
<ItemGroup>
|
|
||||||
<HeaderLines Include="// Copyright (c) Microsoft Corporation" />
|
|
||||||
<HeaderLines Include="// The Microsoft Corporation licenses this file to you under the MIT license." />
|
|
||||||
<HeaderLines Include="// See the LICENSE file in the project root for more information." />
|
|
||||||
<HeaderLines Include="#pragma warning disable SA1516" />
|
|
||||||
<HeaderLines Include="using System.Reflection%3b" />
|
|
||||||
<HeaderLines Include="using System.Resources%3b" />
|
|
||||||
<HeaderLines Include="using System.Runtime.InteropServices%3b" />
|
|
||||||
<HeaderLines Include="using System.Windows%3b" />
|
|
||||||
<HeaderLines Include="[assembly: AssemblyTitle("$(AssemblyTitle)")]" />
|
|
||||||
<HeaderLines Include="[assembly: AssemblyDescription("")]" />
|
|
||||||
<HeaderLines Include="[assembly: AssemblyConfiguration("")]" />
|
|
||||||
<HeaderLines Include="[assembly: AssemblyCompany("$(AssemblyCompany)")]" />
|
|
||||||
<HeaderLines Include="[assembly: AssemblyCopyright("$(AssemblyCopyright)")]" />
|
|
||||||
<HeaderLines Include="[assembly: AssemblyProduct("$(AssemblyTitle)")]" />
|
|
||||||
<HeaderLines Include="[assembly: AssemblyTrademark("")]" />
|
|
||||||
<HeaderLines Include="[assembly: AssemblyCulture("")]" />
|
|
||||||
<HeaderLines Include="[assembly: ComVisible(false)]" />
|
|
||||||
<HeaderLines Include="[assembly: NeutralResourcesLanguage("en-US")]" />
|
|
||||||
<HeaderLines Include="[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]" />
|
|
||||||
<HeaderLines Include="[assembly: AssemblyVersion("$(Version).0")]" />
|
|
||||||
<HeaderLines Include="[assembly: AssemblyFileVersion("$(Version).0")]" />
|
|
||||||
</ItemGroup>
|
|
||||||
<WriteLinesToFile File="Generated Files\AssemblyInfo.cs" Lines="@(HeaderLines)" Overwrite="true" Encoding="Unicode" WriteOnlyWhenDifferent="true" />
|
|
||||||
</Target>
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Platform Condition="'$(Platform)'==''">x64</Platform>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
|
|
||||||
<ProjectGuid>{2BE46397-4DFA-414C-9BD4-41E4BBF8CB34}</ProjectGuid>
|
<ProjectGuid>{2BE46397-4DFA-414C-9BD4-41E4BBF8CB34}</ProjectGuid>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<RootNamespace>ImageResizer</RootNamespace>
|
<RootNamespace>ImageResizer</RootNamespace>
|
||||||
<AssemblyName>ImageResizer</AssemblyName>
|
<AssemblyName>ImageResizer</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<FileAlignment>512</FileAlignment>
|
|
||||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
<TargetFrameworkProfile>
|
|
||||||
</TargetFrameworkProfile>
|
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
<IntermediateOutputPath>$(SolutionDir)$(Platform)\$(Configuration)\obj\$(AssemblyName)\</IntermediateOutputPath>
|
<IntermediateOutputPath>$(SolutionDir)$(Platform)\$(Configuration)\obj\$(AssemblyName)\</IntermediateOutputPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\modules\ImageResizer</OutputPath>
|
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
|
||||||
<CodeAnalysisRuleSet>..\..\..\codeAnalysis\Rules.ruleset</CodeAnalysisRuleSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
|
||||||
<DebugType>pdbonly</DebugType>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\modules\ImageResizer</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
|
||||||
<CodeAnalysisRuleSet>..\..\..\codeAnalysis\Rules.ruleset</CodeAnalysisRuleSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ApplicationIcon>Resources\ImageResizer.ico</ApplicationIcon>
|
<ApplicationIcon>Resources\ImageResizer.ico</ApplicationIcon>
|
||||||
|
<NeutralLanguage>en-US</NeutralLanguage>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Microsoft.VisualBasic" />
|
<Compile Include="..\codeAnalysis\GlobalSuppressions.cs" Link="GlobalSuppressions.cs" />
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Xaml" />
|
|
||||||
<Reference Include="WindowsBase" />
|
|
||||||
<Reference Include="PresentationCore" />
|
|
||||||
<Reference Include="PresentationFramework" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ApplicationDefinition Include="App.xaml">
|
<EmbeddedResource Update="Properties\Resources.resx">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</ApplicationDefinition>
|
|
||||||
<Compile Include="..\codeAnalysis\GlobalSuppressions.cs">
|
|
||||||
<Link>GlobalSuppressions.cs</Link>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Extensions\BitmapEncoderExtensions.cs" />
|
|
||||||
<Compile Include="Extensions\ICollectionExtensions.cs" />
|
|
||||||
<Compile Include="Extensions\TimeSpanExtensions.cs" />
|
|
||||||
<Compile Include="Models\AdvancedSettings.cs" />
|
|
||||||
<Compile Include="Models\ResizeError.cs" />
|
|
||||||
<Compile Include="Properties\Settings.cs" />
|
|
||||||
<Compile Include="Models\CustomSize.cs" />
|
|
||||||
<Compile Include="Properties\InternalsVisibleTo.cs" />
|
|
||||||
<Compile Include="Models\ResizeBatch.cs" />
|
|
||||||
<Compile Include="Models\ResizeFit.cs" />
|
|
||||||
<Compile Include="Models\ResizeOperation.cs" />
|
|
||||||
<Compile Include="Models\ResizeSize.cs" />
|
|
||||||
<Compile Include="Models\ResizeUnit.cs" />
|
|
||||||
<Compile Include="Utilities\MathHelpers.cs" />
|
|
||||||
<Compile Include="Utilities\NativeMethods.cs" />
|
|
||||||
<Compile Include="ViewModels\AdvancedViewModel.cs" />
|
|
||||||
<Compile Include="ViewModels\InputViewModel.cs" />
|
|
||||||
<Compile Include="ViewModels\ITabViewModel.cs" />
|
|
||||||
<Compile Include="Views\AutoDoubleValidationRule.cs" />
|
|
||||||
<Compile Include="Views\BoolValueConverter.cs" />
|
|
||||||
<Compile Include="Views\ContainerFormatConverter.cs" />
|
|
||||||
<Compile Include="Views\AutoDoubleConverter.cs" />
|
|
||||||
<Compile Include="Views\IMainView.cs" />
|
|
||||||
<Compile Include="ViewModels\MainViewModel.cs" />
|
|
||||||
<Compile Include="ViewModels\ProgressViewModel.cs" />
|
|
||||||
<Compile Include="ViewModels\ResultsViewModel.cs" />
|
|
||||||
<Compile Include="Views\AdvancedWindow.xaml.cs">
|
|
||||||
<DependentUpon>AdvancedWindow.xaml</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Views\TiffCompressOptionConverter.cs" />
|
|
||||||
<Compile Include="Views\EnumValueConverter.cs" />
|
|
||||||
<Compile Include="Views\ProgressPage.xaml.cs">
|
|
||||||
<DependentUpon>ProgressPage.xaml</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Views\ResizeUnitConverter.cs" />
|
|
||||||
<Compile Include="Views\ResultsPage.xaml.cs">
|
|
||||||
<DependentUpon>ResultsPage.xaml</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Views\TimeRemainingConverter.cs" />
|
|
||||||
<Page Include="Views\AdvancedWindow.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Page>
|
|
||||||
<Page Include="Views\InputPage.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Page>
|
|
||||||
<Page Include="Views\MainWindow.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</Page>
|
|
||||||
<Compile Include="App.xaml.cs">
|
|
||||||
<DependentUpon>App.xaml</DependentUpon>
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Views\InputPage.xaml.cs">
|
|
||||||
<DependentUpon>InputPage.xaml</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Views\MainWindow.xaml.cs">
|
|
||||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Page Include="Views\ProgressPage.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Page>
|
|
||||||
<Page Include="Views\ResultsPage.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Page>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="Generated Files\AssemblyInfo.cs">
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Properties\Resources.Designer.cs">
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
|
||||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Properties\Resources.*.resx" />
|
<EmbeddedResource Include="Properties\Resources.*.resx" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AdditionalFiles Include="..\..\..\codeAnalysis\StyleCop.json" />
|
<AdditionalFiles Include="..\..\..\codeAnalysis\StyleCop.json" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<None Include="App.config" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Resource Include="Resources\ImageResizer.ico" />
|
<Resource Include="Resources\ImageResizer.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -195,31 +62,23 @@
|
|||||||
<Resource Include="Resources\ImageResizer.png" />
|
<Resource Include="Resources\ImageResizer.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers">
|
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
|
||||||
<Version>3.3.0</Version>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="MvvmLightLibs">
|
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.19" />
|
||||||
<Version>5.4.1.1</Version>
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
</PackageReference>
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||||
<PackageReference Include="Newtonsoft.Json">
|
|
||||||
<Version>12.0.3</Version>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="StyleCop.Analyzers">
|
|
||||||
<Version>1.1.118</Version>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\..\common\interop\interop.vcxproj">
|
<ProjectReference Include="..\..\..\common\interop\interop.vcxproj" />
|
||||||
<Project>{f055103b-f80b-4d0c-bf48-057c55620033}</Project>
|
</ItemGroup>
|
||||||
<Name>interop</Name>
|
<ItemGroup>
|
||||||
</ProjectReference>
|
<Compile Update="Properties\Resources.Designer.cs">
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFrameworkSDKToolsDirectory Condition=" '$(Platform)' == 'x64'">$(TargetFrameworkSDKToolsDirectory)$(Platform)\</TargetFrameworkSDKToolsDirectory>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -4,14 +4,14 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using GalaSoft.MvvmLight;
|
using ImageResizer.Helpers;
|
||||||
using ImageResizer.Properties;
|
using ImageResizer.Properties;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace ImageResizer.Models
|
namespace ImageResizer.Models
|
||||||
{
|
{
|
||||||
[JsonObject(MemberSerialization.OptIn)]
|
[JsonObject(MemberSerialization.OptIn)]
|
||||||
public class ResizeSize : ObservableObject
|
public class ResizeSize : Observable
|
||||||
{
|
{
|
||||||
private static readonly IDictionary<string, string> _tokens = new Dictionary<string, string>
|
private static readonly IDictionary<string, string> _tokens = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
@@ -45,7 +45,7 @@ namespace ImageResizer.Models
|
|||||||
public virtual string Name
|
public virtual string Name
|
||||||
{
|
{
|
||||||
get => _name;
|
get => _name;
|
||||||
set => Set(nameof(Name), ref _name, ReplaceTokens(value));
|
set => Set(ref _name, ReplaceTokens(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonProperty(PropertyName = "fit")]
|
[JsonProperty(PropertyName = "fit")]
|
||||||
@@ -54,7 +54,8 @@ namespace ImageResizer.Models
|
|||||||
get => _fit;
|
get => _fit;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (Set(nameof(Fit), ref _fit, value))
|
Set(ref _fit, value);
|
||||||
|
if (!Equals(_fit, value))
|
||||||
{
|
{
|
||||||
UpdateShowHeight();
|
UpdateShowHeight();
|
||||||
}
|
}
|
||||||
@@ -65,14 +66,14 @@ namespace ImageResizer.Models
|
|||||||
public double Width
|
public double Width
|
||||||
{
|
{
|
||||||
get => _width;
|
get => _width;
|
||||||
set => Set(nameof(Width), ref _width, value);
|
set => Set(ref _width, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonProperty(PropertyName = "height")]
|
[JsonProperty(PropertyName = "height")]
|
||||||
public double Height
|
public double Height
|
||||||
{
|
{
|
||||||
get => _height;
|
get => _height;
|
||||||
set => Set(nameof(Height), ref _height, value);
|
set => Set(ref _height, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ShowHeight
|
public bool ShowHeight
|
||||||
@@ -87,7 +88,8 @@ namespace ImageResizer.Models
|
|||||||
get => _unit;
|
get => _unit;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (Set(nameof(Unit), ref _unit, value))
|
Set(ref _unit, value);
|
||||||
|
if (!Equals(_unit, value))
|
||||||
{
|
{
|
||||||
UpdateShowHeight();
|
UpdateShowHeight();
|
||||||
}
|
}
|
||||||
@@ -113,7 +115,6 @@ namespace ImageResizer.Models
|
|||||||
|
|
||||||
private void UpdateShowHeight()
|
private void UpdateShowHeight()
|
||||||
=> Set(
|
=> Set(
|
||||||
nameof(ShowHeight),
|
|
||||||
ref _showHeight,
|
ref _showHeight,
|
||||||
Fit == ResizeFit.Stretch || Unit != ResizeUnit.Percent);
|
Fit == ResizeFit.Stretch || Unit != ResizeUnit.Percent);
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// The Brice Lambson licenses this file to you under the MIT license.
|
// 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/
|
// See the LICENSE file in the project root for more information. Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
@@ -65,14 +66,14 @@ namespace ImageResizer.Properties
|
|||||||
public string FileNameFormat
|
public string FileNameFormat
|
||||||
=> _fileNameFormat
|
=> _fileNameFormat
|
||||||
?? (_fileNameFormat = FileName
|
?? (_fileNameFormat = FileName
|
||||||
.Replace("{", "{{")
|
.Replace("{", "{{", StringComparison.OrdinalIgnoreCase)
|
||||||
.Replace("}", "}}")
|
.Replace("}", "}}", StringComparison.OrdinalIgnoreCase)
|
||||||
.Replace("%1", "{0}")
|
.Replace("%1", "{0}", StringComparison.OrdinalIgnoreCase)
|
||||||
.Replace("%2", "{1}")
|
.Replace("%2", "{1}", StringComparison.OrdinalIgnoreCase)
|
||||||
.Replace("%3", "{2}")
|
.Replace("%3", "{2}", StringComparison.OrdinalIgnoreCase)
|
||||||
.Replace("%4", "{3}")
|
.Replace("%4", "{3}", StringComparison.OrdinalIgnoreCase)
|
||||||
.Replace("%5", "{4}")
|
.Replace("%5", "{4}", StringComparison.OrdinalIgnoreCase)
|
||||||
.Replace("%6", "{5}"));
|
.Replace("%6", "{5}", StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
public ResizeSize SelectedSize
|
public ResizeSize SelectedSize
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,14 +7,13 @@ using System.Collections.Generic;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using GalaSoft.MvvmLight;
|
using ImageResizer.Helpers;
|
||||||
using GalaSoft.MvvmLight.Command;
|
|
||||||
using ImageResizer.Models;
|
using ImageResizer.Models;
|
||||||
using ImageResizer.Properties;
|
using ImageResizer.Properties;
|
||||||
|
|
||||||
namespace ImageResizer.ViewModels
|
namespace ImageResizer.ViewModels
|
||||||
{
|
{
|
||||||
public class AdvancedViewModel : ViewModelBase
|
public class AdvancedViewModel : Observable
|
||||||
{
|
{
|
||||||
private static Dictionary<Guid, string> InitEncoderMap()
|
private static Dictionary<Guid, string> InitEncoderMap()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,15 +4,14 @@
|
|||||||
// ShowAdvancedCommand = new RelayCommand(ShowAdvanced);
|
// ShowAdvancedCommand = new RelayCommand(ShowAdvanced);
|
||||||
|
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using GalaSoft.MvvmLight;
|
using ImageResizer.Helpers;
|
||||||
using GalaSoft.MvvmLight.Command;
|
|
||||||
using ImageResizer.Models;
|
using ImageResizer.Models;
|
||||||
using ImageResizer.Properties;
|
using ImageResizer.Properties;
|
||||||
using ImageResizer.Views;
|
using ImageResizer.Views;
|
||||||
|
|
||||||
namespace ImageResizer.ViewModels
|
namespace ImageResizer.ViewModels
|
||||||
{
|
{
|
||||||
public class InputViewModel : ViewModelBase
|
public class InputViewModel : Observable
|
||||||
{
|
{
|
||||||
private readonly ResizeBatch _batch;
|
private readonly ResizeBatch _batch;
|
||||||
private readonly MainViewModel _mainViewModel;
|
private readonly MainViewModel _mainViewModel;
|
||||||
|
|||||||
@@ -4,15 +4,14 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using GalaSoft.MvvmLight;
|
using ImageResizer.Helpers;
|
||||||
using GalaSoft.MvvmLight.Command;
|
|
||||||
using ImageResizer.Models;
|
using ImageResizer.Models;
|
||||||
using ImageResizer.Properties;
|
using ImageResizer.Properties;
|
||||||
using ImageResizer.Views;
|
using ImageResizer.Views;
|
||||||
|
|
||||||
namespace ImageResizer.ViewModels
|
namespace ImageResizer.ViewModels
|
||||||
{
|
{
|
||||||
public class MainViewModel : ViewModelBase
|
public class MainViewModel : Observable
|
||||||
{
|
{
|
||||||
private readonly Settings _settings;
|
private readonly Settings _settings;
|
||||||
private readonly ResizeBatch _batch;
|
private readonly ResizeBatch _batch;
|
||||||
@@ -32,13 +31,13 @@ namespace ImageResizer.ViewModels
|
|||||||
public object CurrentPage
|
public object CurrentPage
|
||||||
{
|
{
|
||||||
get => _currentPage;
|
get => _currentPage;
|
||||||
set => Set(nameof(CurrentPage), ref _currentPage, value);
|
set => Set(ref _currentPage, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double Progress
|
public double Progress
|
||||||
{
|
{
|
||||||
get => _progress;
|
get => _progress;
|
||||||
set => Set(nameof(Progress), ref _progress, value);
|
set => Set(ref _progress, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Load(IMainView view)
|
public void Load(IMainView view)
|
||||||
|
|||||||
@@ -8,14 +8,13 @@ using System.Linq;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using GalaSoft.MvvmLight;
|
using ImageResizer.Helpers;
|
||||||
using GalaSoft.MvvmLight.Command;
|
|
||||||
using ImageResizer.Models;
|
using ImageResizer.Models;
|
||||||
using ImageResizer.Views;
|
using ImageResizer.Views;
|
||||||
|
|
||||||
namespace ImageResizer.ViewModels
|
namespace ImageResizer.ViewModels
|
||||||
{
|
{
|
||||||
public class ProgressViewModel : ViewModelBase, IDisposable
|
public class ProgressViewModel : Observable, IDisposable
|
||||||
{
|
{
|
||||||
private readonly MainViewModel _mainViewModel;
|
private readonly MainViewModel _mainViewModel;
|
||||||
private readonly ResizeBatch _batch;
|
private readonly ResizeBatch _batch;
|
||||||
@@ -43,13 +42,13 @@ namespace ImageResizer.ViewModels
|
|||||||
public double Progress
|
public double Progress
|
||||||
{
|
{
|
||||||
get => _progress;
|
get => _progress;
|
||||||
set => Set(nameof(Progress), ref _progress, value);
|
set => Set(ref _progress, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeSpan TimeRemaining
|
public TimeSpan TimeRemaining
|
||||||
{
|
{
|
||||||
get => _timeRemaining;
|
get => _timeRemaining;
|
||||||
set => Set(nameof(TimeRemaining), ref _timeRemaining, value);
|
set => Set(ref _timeRemaining, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICommand StartCommand { get; }
|
public ICommand StartCommand { get; }
|
||||||
|
|||||||
@@ -4,14 +4,13 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using GalaSoft.MvvmLight;
|
using ImageResizer.Helpers;
|
||||||
using GalaSoft.MvvmLight.Command;
|
|
||||||
using ImageResizer.Models;
|
using ImageResizer.Models;
|
||||||
using ImageResizer.Views;
|
using ImageResizer.Views;
|
||||||
|
|
||||||
namespace ImageResizer.ViewModels
|
namespace ImageResizer.ViewModels
|
||||||
{
|
{
|
||||||
public class ResultsViewModel : ViewModelBase
|
public class ResultsViewModel : Observable
|
||||||
{
|
{
|
||||||
private readonly IMainView _mainView;
|
private readonly IMainView _mainView;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Window x:Class="ImageResizer.Views.MainWindow"
|
<Window x:Class="ImageResizer.Views.MainWindow"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
|
||||||
xmlns:local="clr-namespace:ImageResizer.Views"
|
xmlns:local="clr-namespace:ImageResizer.Views"
|
||||||
xmlns:p="clr-namespace:ImageResizer.Properties"
|
xmlns:p="clr-namespace:ImageResizer.Properties"
|
||||||
xmlns:vm="clr-namespace:ImageResizer.ViewModels"
|
xmlns:vm="clr-namespace:ImageResizer.ViewModels"
|
||||||
@@ -29,10 +29,10 @@
|
|||||||
<TaskbarItemInfo ProgressState="Normal" ProgressValue="{Binding Progress}"/>
|
<TaskbarItemInfo ProgressState="Normal" ProgressValue="{Binding Progress}"/>
|
||||||
</Window.TaskbarItemInfo>
|
</Window.TaskbarItemInfo>
|
||||||
|
|
||||||
<i:Interaction.Triggers>
|
<behaviors:Interaction.Triggers>
|
||||||
<i:EventTrigger EventName="Loaded">
|
<behaviors:EventTrigger EventName="Loaded">
|
||||||
<i:InvokeCommandAction Command="{Binding LoadCommand}" CommandParameter="{Binding ElementName=_this}"/>
|
<behaviors:InvokeCommandAction Command="{Binding LoadCommand}" CommandParameter="{Binding ElementName=_this}"/>
|
||||||
</i:EventTrigger>
|
</behaviors:EventTrigger>
|
||||||
</i:Interaction.Triggers>
|
</behaviors:Interaction.Triggers>
|
||||||
|
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<UserControl x:Class="ImageResizer.Views.ProgressPage"
|
<UserControl x:Class="ImageResizer.Views.ProgressPage"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
|
||||||
xmlns:local="clr-namespace:ImageResizer.Views"
|
xmlns:local="clr-namespace:ImageResizer.Views"
|
||||||
xmlns:p="clr-namespace:ImageResizer.Properties"
|
xmlns:p="clr-namespace:ImageResizer.Properties"
|
||||||
MinWidth="350">
|
MinWidth="350">
|
||||||
@@ -10,11 +10,11 @@
|
|||||||
<local:TimeRemainingConverter x:Key="TimeRemainingConverter"/>
|
<local:TimeRemainingConverter x:Key="TimeRemainingConverter"/>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
|
|
||||||
<i:Interaction.Triggers>
|
<behaviors:Interaction.Triggers>
|
||||||
<i:EventTrigger EventName="Loaded">
|
<behaviors:EventTrigger EventName="Loaded">
|
||||||
<i:InvokeCommandAction Command="{Binding StartCommand}"/>
|
<behaviors:InvokeCommandAction Command="{Binding StartCommand}"/>
|
||||||
</i:EventTrigger>
|
</behaviors:EventTrigger>
|
||||||
</i:Interaction.Triggers>
|
</behaviors:Interaction.Triggers>
|
||||||
|
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock Margin="11,11,11,0"
|
<TextBlock Margin="11,11,11,0"
|
||||||
|
|||||||
Reference in New Issue
Block a user