Remove deprecated dependencies

- Remove CommonServiceLocator
- Remove GalaSoft.MvvmLight
- Add CommunityToolkit.Mvvm
This commit is contained in:
Adrien Allard 2024-01-17 16:13:54 +01:00
parent 51b14edda9
commit 2c8fe8a4c7
37 changed files with 376 additions and 465 deletions

View File

@ -1,14 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Languages"/>
<probing privatePath="Languages" />
<dependentAssembly>
<assemblyIdentity name="CommonServiceLocator" publicKeyToken="489b6accfaf20ef0" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.6.0" newVersion="2.0.6.0"/>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ComponentModel.Annotations" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

View File

@ -17,9 +17,6 @@
<!--Global View Model Locator-->
<viewModels:ViewModelLocator x:Key="Locator" />
<services:NavigationService x:Key="Navigation" />
<services:ConversionService x:Key="Conversions" />
<services:SettingsService x:Key="Settings" />
<services:UpgradeService x:Key="Upgrade" />
<!-- Markdown style -->

View File

@ -22,12 +22,13 @@ namespace FileConverter
using System.Threading;
using System.Windows;
using CommunityToolkit.Mvvm.DependencyInjection;
using FileConverter.ConversionJobs;
using FileConverter.Services;
using FileConverter.ViewModels;
using FileConverter.Views;
using GalaSoft.MvvmLight.Ioc;
using Microsoft.Extensions.DependencyInjection;
using Debug = FileConverter.Diagnostics.Debug;
public partial class Application : System.Windows.Application
@ -77,7 +78,7 @@ namespace FileConverter
this.Initialize();
// Navigate to the wanted view.
INavigationService navigationService = SimpleIoc.Default.GetInstance<INavigationService>();
INavigationService navigationService = Ioc.Default.GetRequiredService<INavigationService>();
if (this.showHelp)
{
@ -89,7 +90,7 @@ namespace FileConverter
{
navigationService.Show(Pages.Main);
IConversionService conversionService = SimpleIoc.Default.GetInstance<IConversionService>();
IConversionService conversionService = Ioc.Default.GetRequiredService<IConversionService>();
conversionService.ConversionJobsTerminated += this.ConversionService_ConversionJobsTerminated;
conversionService.ConvertFilesAsync();
}
@ -111,7 +112,7 @@ namespace FileConverter
Debug.Log("Exit application.");
IUpgradeService upgradeService = SimpleIoc.Default.GetInstance<IUpgradeService>();
IUpgradeService upgradeService = Ioc.Default.GetRequiredService<IUpgradeService>();
if (!this.isSessionEnding && upgradeService.UpgradeVersionDescription != null && upgradeService.UpgradeVersionDescription.NeedToUpgrade)
{
@ -161,37 +162,36 @@ namespace FileConverter
private void RegisterServices()
{
if (this.TryFindResource("Settings") == null)
{
Debug.LogError("Can't retrieve conversion service.");
this.Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
}
var services = new ServiceCollection();
if (this.TryFindResource("Locator") == null)
if (this.TryFindResource("Locator") is ViewModelLocator viewModelLocator)
{
viewModelLocator.RegisterViewModels(services);
}
else
{
Debug.LogError("Can't retrieve view model locator.");
this.Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
}
if (this.TryFindResource("Conversions") == null)
if (this.TryFindResource("Upgrade") is UpgradeService upgradeService)
{
Debug.LogError("Can't retrieve conversion service.");
services.AddSingleton<IUpgradeService>(upgradeService);
}
else
{
Debug.LogError("Can't retrieve Upgrade service.");
this.Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
}
if (this.TryFindResource("Navigation") == null)
{
Debug.LogError("Can't retrieve navigation service.");
this.Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
}
services
.AddSingleton<INavigationService, NavigationService>()
.AddSingleton<IConversionService, ConversionService>()
.AddSingleton<ISettingsService, SettingsService>();
if (this.TryFindResource("Upgrade") == null)
{
Debug.LogError("Can't retrieve navigation service.");
this.Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
}
Ioc.Default.ConfigureServices(services.BuildServiceProvider());
INavigationService navigationService = SimpleIoc.Default.GetInstance<INavigationService>();
INavigationService navigationService = Ioc.Default.GetRequiredService<INavigationService>();
navigationService.RegisterPage<HelpWindow>(Pages.Help, false, true);
navigationService.RegisterPage<MainWindow>(Pages.Main, false, true);
@ -228,7 +228,7 @@ namespace FileConverter
return;
}
ISettingsService settingsService = SimpleIoc.Default.GetInstance<ISettingsService>();
ISettingsService settingsService = Ioc.Default.GetRequiredService<ISettingsService>();
// Parse arguments.
bool quitAfterStartup = false;
@ -364,7 +364,7 @@ namespace FileConverter
// Check for upgrade.
if (settingsService.Settings.CheckUpgradeAtStartup)
{
IUpgradeService upgradeService = SimpleIoc.Default.GetInstance<IUpgradeService>();
IUpgradeService upgradeService = Ioc.Default.GetRequiredService<IUpgradeService>();
upgradeService.NewVersionAvailable += this.UpgradeService_NewVersionAvailable;
upgradeService.CheckForUpgrade();
}
@ -383,7 +383,7 @@ namespace FileConverter
if (conversionPreset != null)
{
IConversionService conversionService = SimpleIoc.Default.GetInstance<IConversionService>();
IConversionService conversionService = Ioc.Default.GetRequiredService<IConversionService>();
// Create conversion jobs.
Debug.Log("Create jobs for conversion preset: '{0}'", conversionPreset.FullName);
@ -409,18 +409,18 @@ namespace FileConverter
private void UpgradeService_NewVersionAvailable(object sender, UpgradeVersionDescription e)
{
SimpleIoc.Default.GetInstance<INavigationService>().Show(Pages.Upgrade);
Ioc.Default.GetRequiredService<INavigationService>().Show(Pages.Upgrade);
IUpgradeService upgradeService = SimpleIoc.Default.GetInstance<IUpgradeService>();
IUpgradeService upgradeService = Ioc.Default.GetRequiredService<IUpgradeService>();
upgradeService.NewVersionAvailable -= this.UpgradeService_NewVersionAvailable;
}
private void ConversionService_ConversionJobsTerminated(object sender, ConversionJobsTerminatedEventArgs e)
{
IConversionService conversionService = SimpleIoc.Default.GetInstance<IConversionService>();
IConversionService conversionService = Ioc.Default.GetRequiredService<IConversionService>();
conversionService.ConversionJobsTerminated -= this.ConversionService_ConversionJobsTerminated;
ISettingsService settingsService = SimpleIoc.Default.GetInstance<ISettingsService>();
ISettingsService settingsService = Ioc.Default.GetRequiredService<ISettingsService>();
if (!settingsService.Settings.ExitApplicationWhenConversionsFinished)
{

View File

@ -6,11 +6,11 @@ namespace FileConverter.ConversionJobs
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Input;
using CommunityToolkit.Mvvm.Input;
using FileConverter.Diagnostics;
using GalaSoft.MvvmLight.Command;
public class ConversionJob : INotifyPropertyChanged
{
private float progress = 0f;
@ -192,7 +192,7 @@ namespace FileConverter.ConversionJobs
}
}
protected virtual bool IsCancelable => this.State == ConversionState.InProgress;
protected virtual bool IsCancelable() => this.State == ConversionState.InProgress;
protected string[] OutputFilePaths
{
@ -363,7 +363,7 @@ namespace FileConverter.ConversionJobs
public virtual void Cancel()
{
if (!this.IsCancelable)
if (!this.IsCancelable())
{
return;
}

View File

@ -28,7 +28,7 @@ namespace FileConverter.ConversionJobs
protected override ApplicationName Application => ApplicationName.Excel;
protected override bool IsCancelable => false;
protected override bool IsCancelable() => false;
protected override int GetOutputFilesCount()
{

View File

@ -26,7 +26,7 @@ namespace FileConverter.ConversionJobs
get;
}
protected override bool IsCancelable => false;
protected override bool IsCancelable() => false;
protected override void Initialize()
{

View File

@ -29,7 +29,7 @@ namespace FileConverter.ConversionJobs
protected override ApplicationName Application => ApplicationName.PowerPoint;
protected override bool IsCancelable => false;
protected override bool IsCancelable() => false;
protected override int GetOutputFilesCount()
{

View File

@ -28,7 +28,7 @@ namespace FileConverter.ConversionJobs
protected override ApplicationName Application => ApplicationName.Word;
protected override bool IsCancelable => false;
protected override bool IsCancelable() => false;
protected override int GetOutputFilesCount()
{

View File

@ -6,11 +6,11 @@ namespace FileConverter
using System.Collections.Generic;
using System.Globalization;
using System.Xml.Serialization;
using CommunityToolkit.Mvvm.ComponentModel;
using FileConverter.Controls;
using GalaSoft.MvvmLight;
[XmlRoot]
[XmlType]
public class ConversionPreset : ObservableObject, IXmlSerializable
@ -109,7 +109,7 @@ namespace FileConverter
set
{
this.shortName = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -129,7 +129,7 @@ namespace FileConverter
{
this.outputType = value;
this.InitializeDefaultSettings(this.outputType);
this.RaisePropertyChanged();
this.OnPropertyChanged();
this.CoerceInputTypes();
}
}
@ -157,7 +157,7 @@ namespace FileConverter
this.inputTypes[index] = this.inputTypes[index].ToLowerInvariant();
}
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -172,7 +172,7 @@ namespace FileConverter
set
{
this.inputPostConversionAction = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -216,7 +216,7 @@ namespace FileConverter
}
}
this.RaisePropertyChanged(nameof(this.Settings));
this.OnPropertyChanged(nameof(this.Settings));
}
}
@ -231,7 +231,7 @@ namespace FileConverter
set
{
this.outputFileNameTemplate = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -268,7 +268,7 @@ namespace FileConverter
}
}
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -308,14 +308,14 @@ namespace FileConverter
}
this.inputTypes.Add(inputType);
this.RaisePropertyChanged(nameof(this.InputTypes));
this.OnPropertyChanged(nameof(this.InputTypes));
}
public void RemoveInputType(string inputType)
{
if (this.inputTypes.Remove(inputType))
{
this.RaisePropertyChanged(nameof(this.InputTypes));
this.OnPropertyChanged(nameof(this.InputTypes));
}
}
@ -348,7 +348,7 @@ namespace FileConverter
this.settings[settingsKey] = value;
this.RaisePropertyChanged(nameof(this.Settings));
this.OnPropertyChanged(nameof(this.Settings));
}
public string GetSettingsValue(string settingsKey)
@ -544,7 +544,7 @@ namespace FileConverter
throw new System.Exception("Missing default settings for type " + outputType);
}
this.RaisePropertyChanged(nameof(this.Settings));
this.OnPropertyChanged(nameof(this.Settings));
}
private void InitializeSettingsValue(string settingsKey, string value, bool force = false)

View File

@ -69,18 +69,8 @@
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommonServiceLocator, Version=2.0.7.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
<HintPath>..\..\packages\CommonServiceLocator.2.0.7\lib\net48\CommonServiceLocator.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="GalaSoft.MvvmLight, Version=5.4.1.0, Culture=neutral, PublicKeyToken=e7570ab207bcb616, processorArchitecture=MSIL">
<HintPath>..\..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Extras, Version=5.4.1.0, Culture=neutral, PublicKeyToken=669f0b5e8f868abf, processorArchitecture=MSIL">
<HintPath>..\..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Extras.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Platform, Version=5.4.1.0, Culture=neutral, PublicKeyToken=5f873c45e98af8a1, processorArchitecture=MSIL">
<HintPath>..\..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath>
<Reference Include="CommunityToolkit.Mvvm, Version=8.2.0.0, Culture=neutral, PublicKeyToken=4aff67a105548ee2, processorArchitecture=MSIL">
<HintPath>..\..\packages\CommunityToolkit.Mvvm.8.2.2\lib\netstandard2.0\CommunityToolkit.Mvvm.dll</HintPath>
</Reference>
<Reference Include="Magick.NET-Q16-AnyCPU, Version=13.5.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
<HintPath>..\..\packages\Magick.NET-Q16-AnyCPU.13.5.0\lib\netstandard20\Magick.NET-Q16-AnyCPU.dll</HintPath>
@ -93,6 +83,15 @@
<Reference Include="Markdown.Xaml">
<HintPath>..\..\Middleware\Markdown.Xaml.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.DependencyInjection.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Office.Interop.Excel.15.0.4795.1000\lib\net20\Microsoft.Office.Interop.Excel.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
@ -105,6 +104,9 @@
<HintPath>..\..\packages\Microsoft.Office.Interop.Word.15.0.4797.1003\lib\net20\Microsoft.Office.Interop.Word.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.77\lib\net462\Microsoft.Xaml.Behaviors.dll</HintPath>
</Reference>
<Reference Include="Office, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
<HintPath>..\..\packages\Office.12.0.0\lib\net40\Office.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
@ -118,12 +120,29 @@
<HintPath>..\..\packages\SharpShell.2.7.2\lib\net40-client\SharpShell.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll</HintPath>
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.Annotations, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Drawing" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
@ -448,7 +467,9 @@ if %25errorlevel%25 leq 1 exit 0 else exit %25errorlevel%25</PostBuildEvent>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\Magick.NET-Q16-AnyCPU.13.5.0\build\netstandard20\Magick.NET-Q16-AnyCPU.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Magick.NET-Q16-AnyCPU.13.5.0\build\netstandard20\Magick.NET-Q16-AnyCPU.targets'))" />
<Error Condition="!Exists('..\..\packages\CommunityToolkit.Mvvm.8.2.2\build\netstandard2.0\CommunityToolkit.Mvvm.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\CommunityToolkit.Mvvm.8.2.2\build\netstandard2.0\CommunityToolkit.Mvvm.targets'))" />
</Target>
<Import Project="..\..\packages\CommunityToolkit.Mvvm.8.2.2\build\netstandard2.0\CommunityToolkit.Mvvm.targets" Condition="Exists('..\..\packages\CommunityToolkit.Mvvm.8.2.2\build\netstandard2.0\CommunityToolkit.Mvvm.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View File

@ -15,9 +15,9 @@ namespace FileConverter
using SharpShell;
using SharpShell.ServerRegistration;
using GalaSoft.MvvmLight.Ioc;
using Microsoft.Win32;
using CommunityToolkit.Mvvm.DependencyInjection;
public static class Helpers
{
@ -243,7 +243,7 @@ namespace FileConverter
public static Thread InstantiateThread(string name, ThreadStart threadStart)
{
ISettingsService settingsService = SimpleIoc.Default.GetInstance<ISettingsService>();
ISettingsService settingsService = Ioc.Default.GetRequiredService<ISettingsService>();
CultureInfo currentCulture = settingsService?.Settings?.ApplicationLanguage;
Thread thread = new Thread(threadStart);
@ -260,7 +260,7 @@ namespace FileConverter
public static Thread InstantiateThread(string name, ParameterizedThreadStart parameterizedThreadStart)
{
ISettingsService settingsService = SimpleIoc.Default.GetInstance<ISettingsService>();
ISettingsService settingsService = Ioc.Default.GetRequiredService<ISettingsService>();
CultureInfo currentCulture = settingsService?.Settings?.ApplicationLanguage;
Thread thread = new Thread(parameterizedThreadStart);

View File

@ -7,23 +7,26 @@ namespace FileConverter.Services
using System.Collections.ObjectModel;
using System.Threading;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.DependencyInjection;
using FileConverter.ConversionJobs;
using FileConverter.Diagnostics;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Ioc;
public class ConversionService : ObservableObject, IConversionService
{
private readonly List<ConversionJob> conversionJobs = new List<ConversionJob>();
private readonly int numberOfConversionThread = 1;
public ConversionService()
public ConversionService(ISettingsService settingsService)
{
this.ConversionJobs = this.conversionJobs.AsReadOnly();
if (settingsService == null)
{
throw new ArgumentNullException(nameof(settingsService));
}
ISettingsService settingsService = SimpleIoc.Default.GetInstance<ISettingsService>();
this.ConversionJobs = this.conversionJobs.AsReadOnly();
this.numberOfConversionThread = settingsService.Settings.MaximumNumberOfSimultaneousConversions;
Diagnostics.Debug.Log("Maximum number of conversion threads: {0}", this.numberOfConversionThread);
@ -33,8 +36,6 @@ namespace FileConverter.Services
this.numberOfConversionThread = System.Math.Max(1, Environment.ProcessorCount / 2);
Diagnostics.Debug.Log("The number of processors on this computer is {0}. Set the default number of conversion threads to {0}", settingsService.Settings.MaximumNumberOfSimultaneousConversions);
}
SimpleIoc.Default.Register<IConversionService>(() => this);
}
public event System.EventHandler<ConversionJobsTerminatedEventArgs> ConversionJobsTerminated;
@ -48,7 +49,7 @@ namespace FileConverter.Services
public void RegisterConversionJob(ConversionJob conversionJob)
{
this.conversionJobs.Add(conversionJob);
this.RaisePropertyChanged(nameof(this.ConversionJobs));
this.OnPropertyChanged(nameof(this.ConversionJobs));
}
public void ConvertFilesAsync()

View File

@ -6,10 +6,10 @@ namespace FileConverter.Services
using System.Collections.Generic;
using System.Windows;
using FileConverter.Annotations;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.DependencyInjection;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Ioc;
using FileConverter.Annotations;
using Application = FileConverter.Application;
@ -21,8 +21,6 @@ namespace FileConverter.Services
public NavigationService()
{
this.pageInfoByType = new Dictionary<string, PageInfo>();
SimpleIoc.Default.Register<INavigationService>(() => this);
}
public void Show([NotNull] string pageKey)
@ -104,7 +102,7 @@ namespace FileConverter.Services
// If this is the last window.
if (this.numberOfPageShowed == 0)
{
IUpgradeService upgradeService = SimpleIoc.Default.GetInstance<IUpgradeService>();
IUpgradeService upgradeService = Ioc.Default.GetRequiredService<IUpgradeService>();
bool upgradeInProgress = upgradeService.UpgradeVersionDescription != null &&
upgradeService.UpgradeVersionDescription.NeedToUpgrade &&
!upgradeService.UpgradeVersionDescription.InstallerDownloadDone;
@ -118,7 +116,7 @@ namespace FileConverter.Services
}
else
{
INavigationService navigationService = SimpleIoc.Default.GetInstance<INavigationService>();
INavigationService navigationService = Ioc.Default.GetRequiredService<INavigationService>();
navigationService.Show(Pages.Upgrade);
Diagnostics.Debug.Log("There is an upgrade in progress, display the upgrade window.");
}

View File

@ -9,8 +9,7 @@ namespace FileConverter.Services
using System.IO;
using System.Windows;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Ioc;
using CommunityToolkit.Mvvm.ComponentModel;
using Debug = FileConverter.Diagnostics.Debug;
@ -21,8 +20,6 @@ namespace FileConverter.Services
// Load settigns.
Debug.Log("Load settings...");
this.Settings = this.Load();
SimpleIoc.Default.Register<ISettingsService>(() => this);
}
public Settings Settings

View File

@ -3,7 +3,6 @@
namespace FileConverter.Services
{
using System;
using System.ComponentModel;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;
@ -11,12 +10,11 @@ namespace FileConverter.Services
using System.Xml;
using System.Xml.Serialization;
using CommunityToolkit.Mvvm.ComponentModel;
using FileConverter.Annotations;
using FileConverter.Diagnostics;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Ioc;
public class UpgradeService : ObservableObject, IUpgradeService
{
#if DEBUG
@ -33,7 +31,6 @@ namespace FileConverter.Services
public UpgradeService()
{
this.UpgradeVersionDescription = new UpgradeVersionDescription();
SimpleIoc.Default.Register<IUpgradeService>(() => this);
}
public event EventHandler<UpgradeVersionDescription> NewVersionAvailable;
@ -44,7 +41,7 @@ namespace FileConverter.Services
private set
{
this.upgradeVersionDescription = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}

View File

@ -4,7 +4,7 @@ namespace FileConverter.Services
{
using System.Xml.Serialization;
using GalaSoft.MvvmLight;
using CommunityToolkit.Mvvm.ComponentModel;
public class UpgradeVersionDescription : ObservableObject
{
@ -34,7 +34,7 @@ namespace FileConverter.Services
set
{
this.changeLog = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -53,9 +53,9 @@ namespace FileConverter.Services
set
{
this.installerDownloadInProgress = value;
this.RaisePropertyChanged();
this.RaisePropertyChanged(nameof(this.InstallerDownloadDone));
this.RaisePropertyChanged(nameof(this.InstallerDownloadNotStarted));
this.OnPropertyChanged();
this.OnPropertyChanged(nameof(this.InstallerDownloadDone));
this.OnPropertyChanged(nameof(this.InstallerDownloadNotStarted));
}
}
@ -67,9 +67,9 @@ namespace FileConverter.Services
set
{
this.installerDownloadProgress = value;
this.RaisePropertyChanged();
this.RaisePropertyChanged(nameof(this.InstallerDownloadDone));
this.RaisePropertyChanged(nameof(this.InstallerDownloadNotStarted));
this.OnPropertyChanged();
this.OnPropertyChanged(nameof(this.InstallerDownloadDone));
this.OnPropertyChanged(nameof(this.InstallerDownloadNotStarted));
}
}

View File

@ -2,13 +2,12 @@
namespace FileConverter
{
using System.ComponentModel;
using System.Linq;
using System.Xml.Serialization;
using System.Collections.ObjectModel;
using System.Globalization;
using GalaSoft.MvvmLight;
using CommunityToolkit.Mvvm.ComponentModel;
[XmlRoot]
[XmlType]
@ -86,7 +85,7 @@ namespace FileConverter
System.Threading.Thread.CurrentThread.CurrentUICulture = this.applicationLanguage;
}
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -126,7 +125,7 @@ namespace FileConverter
set
{
this.conversionPresets = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -141,7 +140,7 @@ namespace FileConverter
set
{
this.exitApplicationWhenConversionsFinished = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -156,7 +155,7 @@ namespace FileConverter
set
{
this.durationBetweenEndOfConversionsAndApplicationExit = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -171,7 +170,7 @@ namespace FileConverter
set
{
this.maximumNumberOfSimultaneousConversions = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -203,7 +202,7 @@ namespace FileConverter
set
{
this.checkUpgradeAtStartup = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}

View File

@ -7,8 +7,8 @@ namespace FileConverter.ValueConverters
using System.Linq;
using System.Windows.Data;
using CommonServiceLocator;
using CommunityToolkit.Mvvm.DependencyInjection;
using FileConverter.ViewModels;
public class OutputTypeEnumToViewModel : IValueConverter
@ -22,7 +22,7 @@ namespace FileConverter.ValueConverters
OutputType outputType = (OutputType)value;
SettingsViewModel settingsViewModel = ServiceLocator.Current.GetInstance<SettingsViewModel>();
SettingsViewModel settingsViewModel = Ioc.Default.GetRequiredService<SettingsViewModel>();
return settingsViewModel.OutputTypes.Cast<OutputTypeViewModel>()
.FirstOrDefault(match => match.Type == outputType);

View File

@ -5,25 +5,16 @@ namespace FileConverter.ViewModels
using System.ComponentModel;
using System.Windows.Input;
using FileConverter.Services;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.DependencyInjection;
using CommunityToolkit.Mvvm.Input;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Ioc;
using FileConverter.Services;
/// <summary>
/// This class contains properties that the diagnostics View can data bind to.
/// <para>
/// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
/// </para>
/// <para>
/// You can also use Blend to data bind with the tool's support.
/// </para>
/// <para>
/// See http://www.galasoft.ch/mvvm
/// </para>
/// </summary>
public class DiagnosticsViewModel : ViewModelBase
public class DiagnosticsViewModel : ObservableRecipient
{
private RelayCommand<CancelEventArgs> closeCommand;
@ -32,13 +23,6 @@ namespace FileConverter.ViewModels
/// </summary>
public DiagnosticsViewModel()
{
if (this.IsInDesignMode)
{
// Code runs in Blend --> create design time data.
}
else
{
}
}
public ICommand CloseCommand
@ -56,7 +40,7 @@ namespace FileConverter.ViewModels
private void Close(CancelEventArgs args)
{
INavigationService navigationService = SimpleIoc.Default.GetInstance<INavigationService>();
INavigationService navigationService = Ioc.Default.GetRequiredService<INavigationService>();
navigationService.Close(Pages.Diagnostics, args != null);
}
}

View File

@ -5,25 +5,16 @@ namespace FileConverter.ViewModels
using System.ComponentModel;
using System.Windows.Input;
using FileConverter.Services;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.DependencyInjection;
using CommunityToolkit.Mvvm.Input;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Ioc;
using FileConverter.Services;
/// <summary>
/// This class contains properties that the main View can data bind to.
/// <para>
/// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
/// </para>
/// <para>
/// You can also use Blend to data bind with the tool's support.
/// </para>
/// <para>
/// See http://www.galasoft.ch/mvvm
/// </para>
/// </summary>
public class HelpViewModel : ViewModelBase
public class HelpViewModel : ObservableRecipient
{
private RelayCommand<CancelEventArgs> closeCommand;
@ -32,13 +23,6 @@ namespace FileConverter.ViewModels
/// </summary>
public HelpViewModel()
{
if (this.IsInDesignMode)
{
// Code runs in Blend --> create design time data.
}
else
{
}
}
public ICommand CloseCommand
@ -56,7 +40,7 @@ namespace FileConverter.ViewModels
private void Close(CancelEventArgs args)
{
INavigationService navigationService = SimpleIoc.Default.GetInstance<INavigationService>();
INavigationService navigationService = Ioc.Default.GetRequiredService<INavigationService>();
navigationService.Close(Pages.Help, args != null);
}
}

View File

@ -4,10 +4,9 @@ namespace FileConverter.ViewModels
{
using System.Windows.Media;
using CommonServiceLocator;
using GalaSoft.MvvmLight;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.DependencyInjection;
using FileConverter.Annotations;
using FileConverter.ConversionJobs;
public class InputExtension : ObservableObject
@ -56,7 +55,7 @@ namespace FileConverter.ViewModels
set
{
this.name = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -67,7 +66,7 @@ namespace FileConverter.ViewModels
set
{
this.foregroundBrush = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -78,7 +77,7 @@ namespace FileConverter.ViewModels
set
{
this.toolTip = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -86,7 +85,7 @@ namespace FileConverter.ViewModels
{
get
{
SettingsViewModel settingsViewModel = ServiceLocator.Current.GetInstance<SettingsViewModel>();
SettingsViewModel settingsViewModel = Ioc.Default.GetRequiredService<SettingsViewModel>();
PresetNode selectedPreset = settingsViewModel.SelectedPreset;
if (selectedPreset == null)
{
@ -98,7 +97,7 @@ namespace FileConverter.ViewModels
set
{
SettingsViewModel settingsViewModel = ServiceLocator.Current.GetInstance<SettingsViewModel>();
SettingsViewModel settingsViewModel = Ioc.Default.GetRequiredService<SettingsViewModel>();
PresetNode selectedPreset = settingsViewModel.SelectedPreset;
if (value)
@ -110,8 +109,13 @@ namespace FileConverter.ViewModels
selectedPreset?.Preset.RemoveInputType(this.name.ToLowerInvariant());
}
this.RaisePropertyChanged(nameof(this.IsChecked));
this.OnPropertyChanged(nameof(this.IsChecked));
}
}
internal void OnCategoryChanged()
{
this.OnPropertyChanged(nameof(this.IsChecked));
}
}
}

View File

@ -2,11 +2,12 @@
namespace FileConverter.ViewModels
{
using CommonServiceLocator;
using GalaSoft.MvvmLight;
using System.ComponentModel;
using System.Collections.Generic;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.DependencyInjection;
public class InputExtensionCategory : ObservableObject
{
private readonly List<InputExtension> inputExtensions = new List<InputExtension>();
@ -24,7 +25,7 @@ namespace FileConverter.ViewModels
set
{
this.name = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -51,9 +52,9 @@ namespace FileConverter.ViewModels
inputExtension.PropertyChanged += this.OnExtensionPropertyChange;
this.RaisePropertyChanged(nameof(this.InputExtensions));
this.RaisePropertyChanged(nameof(this.InputExtensionNames));
this.RaisePropertyChanged(nameof(this.IsChecked));
this.OnPropertyChanged(nameof(this.InputExtensions));
this.OnPropertyChanged(nameof(this.InputExtensionNames));
this.OnPropertyChanged(nameof(this.IsChecked));
}
}
@ -61,7 +62,7 @@ namespace FileConverter.ViewModels
{
get
{
SettingsViewModel settingsViewModel = ServiceLocator.Current.GetInstance<SettingsViewModel>();
SettingsViewModel settingsViewModel = Ioc.Default.GetRequiredService<SettingsViewModel>();
PresetNode selectedPreset = settingsViewModel.SelectedPreset;
if (selectedPreset == null)
{
@ -91,7 +92,7 @@ namespace FileConverter.ViewModels
set
{
SettingsViewModel settingsViewModel = ServiceLocator.Current.GetInstance<SettingsViewModel>();
SettingsViewModel settingsViewModel = Ioc.Default.GetRequiredService<SettingsViewModel>();
PresetNode selectedPreset = settingsViewModel.SelectedPreset;
foreach (string extension in this.InputExtensionNames)
@ -109,16 +110,16 @@ namespace FileConverter.ViewModels
// Raise property change for extensions.
foreach (InputExtension inputExtension in this.InputExtensions)
{
inputExtension.RaisePropertyChanged(nameof(inputExtension.IsChecked));
inputExtension.OnCategoryChanged();
}
this.RaisePropertyChanged(nameof(this.IsChecked));
this.OnPropertyChanged(nameof(this.IsChecked));
}
}
private void OnExtensionPropertyChange(object sender, PropertyChangedEventArgs e)
{
this.RaisePropertyChanged(nameof(this.IsChecked));
this.OnPropertyChanged(nameof(this.IsChecked));
}
}
}

View File

@ -6,26 +6,17 @@ namespace FileConverter.ViewModels
using System.ComponentModel;
using System.Windows.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.DependencyInjection;
using CommunityToolkit.Mvvm.Input;
using FileConverter.ConversionJobs;
using FileConverter.Services;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Ioc;
/// <summary>
/// This class contains properties that the main View can data bind to.
/// <para>
/// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
/// </para>
/// <para>
/// You can also use Blend to data bind with the tool's support.
/// </para>
/// <para>
/// See http://www.galasoft.ch/mvvm
/// </para>
/// </summary>
public class MainViewModel : ViewModelBase
public class MainViewModel : ObservableRecipient
{
private string informationMessage;
private ObservableCollection<ConversionJob> conversionJobs;
@ -39,21 +30,11 @@ namespace FileConverter.ViewModels
/// </summary>
public MainViewModel()
{
if (this.IsInDesignMode)
{
// Code runs in Blend --> create design time data.
this.InformationMessage = "Design time mode.";
this.ConversionJobs = new ObservableCollection<ConversionJob>();
//this.ConversionJobs.Add(new ConversionJob());
}
else
{
IConversionService settingsService = SimpleIoc.Default.GetInstance<IConversionService>();
this.ConversionJobs = new ObservableCollection<ConversionJob>(settingsService.ConversionJobs);
IConversionService settingsService = Ioc.Default.GetRequiredService<IConversionService>();
this.ConversionJobs = new ObservableCollection<ConversionJob>(settingsService.ConversionJobs);
Application application = Application.Current as Application;
application.OnApplicationTerminate += this.Application_OnApplicationTerminate;
}
Application application = Application.Current as Application;
application.OnApplicationTerminate += this.Application_OnApplicationTerminate;
}
public string InformationMessage
@ -62,7 +43,7 @@ namespace FileConverter.ViewModels
private set
{
this.Set(ref this.informationMessage, value);
this.SetProperty(ref this.informationMessage, value);
}
}
@ -72,7 +53,7 @@ namespace FileConverter.ViewModels
private set
{
this.Set(ref this.conversionJobs, value);
this.SetProperty(ref this.conversionJobs, value);
foreach (var job in this.conversionJobs)
{
@ -87,7 +68,7 @@ namespace FileConverter.ViewModels
{
if (this.showSettingsCommand == null)
{
this.showSettingsCommand = new RelayCommand(() => SimpleIoc.Default.GetInstance<INavigationService>().Show(Pages.Settings));
this.showSettingsCommand = new RelayCommand(() => Ioc.Default.GetRequiredService<INavigationService>().Show(Pages.Settings));
}
return this.showSettingsCommand;
@ -100,7 +81,7 @@ namespace FileConverter.ViewModels
{
if (this.showDiagnosticsCommand == null)
{
this.showDiagnosticsCommand = new RelayCommand(() => SimpleIoc.Default.GetInstance<INavigationService>().Show(Pages.Diagnostics));
this.showDiagnosticsCommand = new RelayCommand(() => Ioc.Default.GetRequiredService<INavigationService>().Show(Pages.Diagnostics));
}
return this.showDiagnosticsCommand;
@ -122,7 +103,7 @@ namespace FileConverter.ViewModels
private void Close(CancelEventArgs args)
{
INavigationService navigationService = SimpleIoc.Default.GetInstance<INavigationService>();
INavigationService navigationService = Ioc.Default.GetRequiredService<INavigationService>();
navigationService.Close(Pages.Main, args != null);
}
@ -133,7 +114,7 @@ namespace FileConverter.ViewModels
return;
}
this.RaisePropertyChanged(nameof(this.ConversionJobs));
this.OnPropertyChanged(nameof(this.ConversionJobs));
}
private void Application_OnApplicationTerminate(object sender, ApplicationTerminateArgs eventArgs)

View File

@ -1,12 +1,13 @@
// <copyright file="PresetNode.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using GalaSoft.MvvmLight;
namespace FileConverter.ViewModels
{
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using CommunityToolkit.Mvvm.ComponentModel;
public abstract class AbstractTreeNode : ObservableObject, IDataErrorInfo
{
private PresetFolderNode parent;
@ -28,7 +29,7 @@ namespace FileConverter.ViewModels
set
{
this.parent = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -135,8 +136,8 @@ namespace FileConverter.ViewModels
set
{
this.Preset.ShortName = value;
this.RaisePropertyChanged();
this.RaisePropertyChanged(nameof(this.HasError));
this.OnPropertyChanged();
this.OnPropertyChanged(nameof(this.HasError));
}
}
@ -147,7 +148,7 @@ namespace FileConverter.ViewModels
set
{
this.Preset.OutputFileNameTemplate = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -255,8 +256,8 @@ namespace FileConverter.ViewModels
set
{
this.name = value;
this.RaisePropertyChanged();
this.RaisePropertyChanged(nameof(this.HasError));
this.OnPropertyChanged();
this.OnPropertyChanged(nameof(this.HasError));
}
}
@ -267,7 +268,7 @@ namespace FileConverter.ViewModels
set
{
this.children = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}

View File

@ -9,34 +9,23 @@ namespace FileConverter.ViewModels
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Windows;
using System.Windows.Data;
using System.Windows.Input;
using Microsoft.Win32;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.DependencyInjection;
using CommunityToolkit.Mvvm.Input;
using FileConverter.Annotations;
using FileConverter.Services;
using FileConverter.Views;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Ioc;
using GalaSoft.MvvmLight.Messaging;
using Microsoft.Win32;
/// <summary>
/// This class contains properties that the main View can data bind to.
/// <para>
/// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
/// </para>
/// <para>
/// You can also use Blend to data bind with the tool's support.
/// </para>
/// <para>
/// See http://www.galasoft.ch/mvvm
/// </para>
/// This class contains properties that the settings View can data bind to.
/// </summary>
public class SettingsViewModel : ViewModelBase, IDataErrorInfo
public class SettingsViewModel : ObservableRecipient, IDataErrorInfo
{
private InputExtensionCategory[] inputCategories;
private PresetFolderNode presetsRootFolder;
@ -59,6 +48,9 @@ namespace FileConverter.ViewModels
private ListCollectionView outputTypes;
private CultureInfo[] supportedCultures;
public event Action OnPresetCreated;
public event Action OnFolderCreated;
/// <summary>
/// Initializes a new instance of the SettingsViewModel class.
/// </summary>
@ -75,42 +67,33 @@ namespace FileConverter.ViewModels
this.saveCommand = new RelayCommand(this.SaveSettings, this.CanSaveSettings);
this.closeCommand = new RelayCommand<CancelEventArgs>(this.CloseSettings);
if (this.IsInDesignMode)
{
// Code runs in Blend --> create design time data.
this.Settings = new Settings();
this.Settings.ConversionPresets.Add(new ConversionPreset("Test", OutputType.Mp3));
}
else
{
ISettingsService settingsService = SimpleIoc.Default.GetInstance<ISettingsService>();
this.Settings = settingsService.Settings;
ISettingsService settingsService = Ioc.Default.GetRequiredService<ISettingsService>();
this.Settings = settingsService.Settings;
List<OutputTypeViewModel> outputTypeViewModels = new List<OutputTypeViewModel>();
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Ogg));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Mp3));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Aac));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Flac));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Wav));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Mkv));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Mp4));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Ogv));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Webm));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Avi));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Png));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Jpg));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Webp));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Ico));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Gif));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Pdf));
this.outputTypes = new ListCollectionView(outputTypeViewModels);
this.outputTypes.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
List<OutputTypeViewModel> outputTypeViewModels = new List<OutputTypeViewModel>();
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Ogg));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Mp3));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Aac));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Flac));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Wav));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Mkv));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Mp4));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Ogv));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Webm));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Avi));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Png));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Jpg));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Webp));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Ico));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Gif));
outputTypeViewModels.Add(new OutputTypeViewModel(OutputType.Pdf));
this.outputTypes = new ListCollectionView(outputTypeViewModels);
this.outputTypes.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
this.SupportedCultures = Helpers.GetSupportedCultures().ToArray();
this.SupportedCultures = Helpers.GetSupportedCultures().ToArray();
this.InitializeCompatibleInputExtensions();
this.InitializePresetFolders();
}
this.InitializeCompatibleInputExtensions();
this.InitializePresetFolders();
}
public IEnumerable<InputExtensionCategory> InputCategories
@ -147,7 +130,7 @@ namespace FileConverter.ViewModels
set
{
this.presetsRootFolder = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -181,7 +164,7 @@ namespace FileConverter.ViewModels
this.SelectedFolder = null;
}
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -193,11 +176,11 @@ namespace FileConverter.ViewModels
{
this.selectedFolder = value;
this.RaisePropertyChanged();
this.RaisePropertyChanged(nameof(this.SelectedItem));
this.removePresetCommand?.RaiseCanExecuteChanged();
this.exportPresetCommand?.RaiseCanExecuteChanged();
this.duplicatePresetCommand?.RaiseCanExecuteChanged();
this.OnPropertyChanged();
this.OnPropertyChanged(nameof(this.SelectedItem));
this.removePresetCommand?.NotifyCanExecuteChanged();
this.exportPresetCommand?.NotifyCanExecuteChanged();
this.duplicatePresetCommand?.NotifyCanExecuteChanged();
}
}
@ -219,12 +202,12 @@ namespace FileConverter.ViewModels
this.selectedPreset.Preset.PropertyChanged += this.SelectedPresetPropertyChanged;
}
this.RaisePropertyChanged();
this.RaisePropertyChanged(nameof(this.SelectedItem));
this.RaisePropertyChanged(nameof(this.InputCategories));
this.removePresetCommand?.RaiseCanExecuteChanged();
this.exportPresetCommand?.RaiseCanExecuteChanged();
this.duplicatePresetCommand?.RaiseCanExecuteChanged();
this.OnPropertyChanged();
this.OnPropertyChanged(nameof(this.SelectedItem));
this.OnPropertyChanged(nameof(this.InputCategories));
this.removePresetCommand?.NotifyCanExecuteChanged();
this.exportPresetCommand?.NotifyCanExecuteChanged();
this.duplicatePresetCommand?.NotifyCanExecuteChanged();
}
}
@ -235,7 +218,7 @@ namespace FileConverter.ViewModels
set
{
this.settings = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -245,7 +228,7 @@ namespace FileConverter.ViewModels
set
{
this.supportedCultures = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -255,7 +238,7 @@ namespace FileConverter.ViewModels
set
{
this.outputTypes = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -270,7 +253,7 @@ namespace FileConverter.ViewModels
{
this.displaySeeChangeLogLink = value;
this.RaisePropertyChanged();
this.OnPropertyChanged();
}
}
@ -375,20 +358,20 @@ namespace FileConverter.ViewModels
{
if (eventArgs.PropertyName == "OutputType")
{
this.RaisePropertyChanged(nameof(this.InputCategories));
this.OnPropertyChanged(nameof(this.InputCategories));
}
this.saveCommand.RaiseCanExecuteChanged();
this.saveCommand.NotifyCanExecuteChanged();
}
private void NodePropertyChanged(object sender, PropertyChangedEventArgs eventArgs)
{
this.saveCommand.RaiseCanExecuteChanged();
this.saveCommand.NotifyCanExecuteChanged();
}
private void DownloadChangeLogAction()
{
IUpgradeService upgradeService = SimpleIoc.Default.GetInstance<IUpgradeService>();
IUpgradeService upgradeService = Ioc.Default.GetRequiredService<IUpgradeService>();
upgradeService.DownloadChangeLog();
this.DisplaySeeChangeLogLink = false;
}
@ -411,7 +394,7 @@ namespace FileConverter.ViewModels
}
this.inputCategories = categories.ToArray();
this.RaisePropertyChanged(nameof(this.InputCategories));
this.OnPropertyChanged(nameof(this.InputCategories));
}
private void InitializePresetFolders()
@ -434,7 +417,7 @@ namespace FileConverter.ViewModels
this.CreatePresetNode(preset, parent);
}
this.RaisePropertyChanged(nameof(this.PresetsRootFolder));
this.OnPropertyChanged(nameof(this.PresetsRootFolder));
}
private void ComputePresetsParentFoldersNamesAndFillSettings(AbstractTreeNode node, List<string> folderNamesCache)
@ -465,10 +448,10 @@ namespace FileConverter.ViewModels
private void CloseSettings(CancelEventArgs args)
{
ISettingsService settingsService = SimpleIoc.Default.GetInstance<ISettingsService>();
ISettingsService settingsService = Ioc.Default.GetRequiredService<ISettingsService>();
settingsService.RevertSettings();
INavigationService navigationService = SimpleIoc.Default.GetInstance<INavigationService>();
INavigationService navigationService = Ioc.Default.GetRequiredService<INavigationService>();
navigationService.Close(Pages.Settings, args != null);
}
@ -484,10 +467,10 @@ namespace FileConverter.ViewModels
this.ComputePresetsParentFoldersNamesAndFillSettings(this.presetsRootFolder, new List<string>());
// Save changes.
ISettingsService settingsService = SimpleIoc.Default.GetInstance<ISettingsService>();
ISettingsService settingsService = Ioc.Default.GetRequiredService<ISettingsService>();
settingsService.SaveSettings();
INavigationService navigationService = SimpleIoc.Default.GetInstance<INavigationService>();
INavigationService navigationService = Ioc.Default.GetRequiredService<INavigationService>();
navigationService.Close(Pages.Settings, false);
}
@ -530,9 +513,9 @@ namespace FileConverter.ViewModels
this.SelectedItem = newFolder;
this.saveCommand.RaiseCanExecuteChanged();
this.saveCommand.NotifyCanExecuteChanged();
Messenger.Default.Send<string>("FolderName", "DoFocus");
this.OnFolderCreated();
}
private bool CanDuplicateSelectedPreset()
@ -590,10 +573,10 @@ namespace FileConverter.ViewModels
this.SelectedItem = node;
Messenger.Default.Send<string>("PresetName", "DoFocus");
this.OnPresetCreated.Invoke();
this.removePresetCommand.RaiseCanExecuteChanged();
this.saveCommand.RaiseCanExecuteChanged();
this.removePresetCommand.NotifyCanExecuteChanged();
this.saveCommand.NotifyCanExecuteChanged();
}
private void ImportPreset()
@ -699,8 +682,8 @@ namespace FileConverter.ViewModels
this.SelectedItem = null;
this.removePresetCommand.RaiseCanExecuteChanged();
this.saveCommand.RaiseCanExecuteChanged();
this.removePresetCommand.NotifyCanExecuteChanged();
this.saveCommand.NotifyCanExecuteChanged();
}
private bool CanRemoveSelectedPreset()
@ -708,9 +691,9 @@ namespace FileConverter.ViewModels
return this.SelectedItem != null;
}
public override void Cleanup()
protected override void OnDeactivated()
{
base.Cleanup();
base.OnDeactivated();
this.UnbindNode(this.presetsRootFolder);
}

View File

@ -5,25 +5,16 @@ namespace FileConverter.ViewModels
using System.ComponentModel;
using System.Windows.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.DependencyInjection;
using CommunityToolkit.Mvvm.Input;
using FileConverter.Services;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Ioc;
/// <summary>
/// This class contains properties that the main View can data bind to.
/// <para>
/// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
/// </para>
/// <para>
/// You can also use Blend to data bind with the tool's support.
/// </para>
/// <para>
/// See http://www.galasoft.ch/mvvm
/// </para>
/// This class contains properties that the upgrade View can data bind to.
/// </summary>
public class UpgradeViewModel : ViewModelBase
public class UpgradeViewModel : ObservableRecipient
{
private readonly IUpgradeService upgradeService;
@ -36,7 +27,7 @@ namespace FileConverter.ViewModels
/// </summary>
public UpgradeViewModel()
{
this.upgradeService = SimpleIoc.Default.GetInstance<IUpgradeService>();
this.upgradeService = Ioc.Default.GetRequiredService<IUpgradeService>();
this.upgradeService.DownloadChangeLog();
}
@ -83,19 +74,19 @@ namespace FileConverter.ViewModels
{
this.upgradeService.StartUpgrade();
INavigationService navigationService = SimpleIoc.Default.GetInstance<INavigationService>();
INavigationService navigationService = Ioc.Default.GetRequiredService<INavigationService>();
navigationService.Close(Pages.Upgrade, false);
}
private void ExecuteLaunchInstallerCommand()
{
INavigationService navigationService = SimpleIoc.Default.GetInstance<INavigationService>();
INavigationService navigationService = Ioc.Default.GetRequiredService<INavigationService>();
navigationService.Close(Pages.Upgrade, false);
}
private void Close(CancelEventArgs args)
{
INavigationService navigationService = SimpleIoc.Default.GetInstance<INavigationService>();
INavigationService navigationService = Ioc.Default.GetRequiredService<INavigationService>();
navigationService.Close(Pages.Upgrade, args != null);
}
}

View File

@ -9,21 +9,12 @@
In the View:
DataContext="{Binding Source={StaticResource Locator}, Path=ViewModelName}"
You can also use Blend to do all this with the tool's support.
See http://www.galasoft.ch/mvvm
*/
namespace FileConverter.ViewModels
{
using System;
using CommonServiceLocator;
using FileConverter.Views;
using GalaSoft.MvvmLight.Ioc;
using GalaSoft.MvvmLight.Views;
using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
/// <summary>
/// This class contains static references to all the view models in the
@ -36,34 +27,26 @@ namespace FileConverter.ViewModels
/// </summary>
public ViewModelLocator()
{
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
////if (ViewModelBase.IsInDesignModeStatic)
////{
//// // Create design time view services and models
//// SimpleIoc.Default.Register<IDataService, DesignDataService>();
////}
////else
////{
//// // Create run time view services and models
//// SimpleIoc.Default.Register<IDataService, DataService>();
////}
SimpleIoc.Default.Register<HelpViewModel>();
SimpleIoc.Default.Register<MainViewModel>();
SimpleIoc.Default.Register<UpgradeViewModel>();
SimpleIoc.Default.Register<SettingsViewModel>();
SimpleIoc.Default.Register<DiagnosticsViewModel>();
}
public HelpViewModel Help => ServiceLocator.Current.GetInstance<HelpViewModel>();
public HelpViewModel Help => Ioc.Default.GetRequiredService<HelpViewModel>();
public MainViewModel Main => ServiceLocator.Current.GetInstance<MainViewModel>();
public MainViewModel Main => Ioc.Default.GetRequiredService<MainViewModel>();
public UpgradeViewModel Upgrade => ServiceLocator.Current.GetInstance<UpgradeViewModel>();
public UpgradeViewModel Upgrade => Ioc.Default.GetRequiredService<UpgradeViewModel>();
public SettingsViewModel Settings => ServiceLocator.Current.GetInstance<SettingsViewModel>();
public SettingsViewModel Settings => Ioc.Default.GetRequiredService<SettingsViewModel>();
public DiagnosticsViewModel Diagnostics => ServiceLocator.Current.GetInstance<DiagnosticsViewModel>();
public DiagnosticsViewModel Diagnostics => Ioc.Default.GetRequiredService<DiagnosticsViewModel>();
internal void RegisterViewModels(ServiceCollection services)
{
services
.AddSingleton<HelpViewModel>()
.AddSingleton<MainViewModel>()
.AddSingleton<UpgradeViewModel>()
.AddSingleton<SettingsViewModel>()
.AddSingleton<DiagnosticsViewModel>();
}
}
}

View File

@ -3,7 +3,7 @@
using System.Collections.Specialized;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interactivity;
using Microsoft.Xaml.Behaviors;
namespace FileConverter.Views
{

View File

@ -6,16 +6,15 @@
xmlns:diagnostics="clr-namespace:FileConverter.Diagnostics"
xmlns:project="clr-namespace:FileConverter.Properties"
xmlns:local="clr-namespace:FileConverter"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:command="http://www.galasoft.ch/mvvmlight"
xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
mc:Ignorable="d"
Height="600" Width="800" Icon="/FileConverter;component/Resources/ApplicationIcon.ico"
DataContext="{Binding Diagnostics, Source={StaticResource Locator}}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Closing">
<command:EventToCommand Command="{Binding CloseCommand}" PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
<behaviors:Interaction.Triggers>
<behaviors:EventTrigger EventName="Closing">
<behaviors:InvokeCommandAction Command="{Binding CloseCommand}" PassEventArgsToCommand="True" />
</behaviors:EventTrigger>
</behaviors:Interaction.Triggers>
<Window.Title>
<Binding Converter="{StaticResource ApplicationVersionToApplicationName}" Mode="OneWay" Path="(local:Application.ApplicationVersion)"/>
</Window.Title>

View File

@ -6,16 +6,15 @@
xmlns:fileConverter="clr-namespace:FileConverter"
xmlns:project="clr-namespace:FileConverter.Properties"
xmlns:gif="http://wpfanimatedgif.codeplex.com"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:command="http://www.galasoft.ch/mvvmlight"
xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
mc:Ignorable="d" Icon="/FileConverter;component/Resources/ApplicationIcon.ico" WindowStartupLocation="CenterScreen" WindowStyle="ToolWindow" ResizeMode="NoResize"
Width="640" Height="545"
DataContext="{Binding Help, Source={StaticResource Locator}}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Closing">
<command:EventToCommand Command="{Binding CloseCommand}" PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
<behaviors:Interaction.Triggers>
<behaviors:EventTrigger EventName="Closing">
<behaviors:InvokeCommandAction Command="{Binding CloseCommand}" PassEventArgsToCommand="True" />
</behaviors:EventTrigger>
</behaviors:Interaction.Triggers>
<Window.Resources>
</Window.Resources>
<Window.Title>

View File

@ -6,16 +6,15 @@
xmlns:valueConverters="clr-namespace:FileConverter.ValueConverters"
xmlns:project="clr-namespace:FileConverter.Properties"
xmlns:controls="clr-namespace:FileConverter.Controls"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:command="http://www.galasoft.ch/mvvmlight"
xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
mc:Ignorable="d" x:Class="FileConverter.Views.MainWindow"
Height="500" Width="950" MinHeight="480" MinWidth="640" WindowStartupLocation="CenterScreen" Icon="/FileConverter;component/Resources/ApplicationIcon.ico"
DataContext="{Binding Main, Source={StaticResource Locator}}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Closing">
<command:EventToCommand Command="{Binding CloseCommand}" PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
<behaviors:Interaction.Triggers>
<behaviors:EventTrigger EventName="Closing">
<behaviors:InvokeCommandAction Command="{Binding CloseCommand}" PassEventArgsToCommand="True" />
</behaviors:EventTrigger>
</behaviors:Interaction.Triggers>
<Window.Resources>
<valueConverters:ConversionJobsToProgressState x:Key="ConversionJobsToProgressState" />
<valueConverters:ConversionJobsToProgressValue x:Key="ConversionJobsToProgressValue" />

View File

@ -6,8 +6,7 @@
xmlns:project="clr-namespace:FileConverter.Properties"
xmlns:views="clr-namespace:FileConverter.Views"
xmlns:viewModels="clr-namespace:FileConverter.ViewModels"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:command="http://www.galasoft.ch/mvvmlight"
xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
xmlns:generic="clr-namespace:FileConverter.ValueConverters.Generic"
xmlns:controls="clr-namespace:FileConverter.Controls"
x:Class="FileConverter.Views.SettingsWindow"
@ -17,11 +16,11 @@
mc:Ignorable="d"
DataContext="{Binding Settings, Source={StaticResource Locator}}"
d:DataContext="{d:DesignData /SampleData/SettingsSampleData.xaml}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Closing">
<command:EventToCommand Command="{Binding CloseCommand}" PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
<behaviors:Interaction.Triggers>
<behaviors:EventTrigger EventName="Closing">
<behaviors:InvokeCommandAction Command="{Binding CloseCommand}" PassEventArgsToCommand="True" />
</behaviors:EventTrigger>
</behaviors:Interaction.Triggers>
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
@ -292,12 +291,12 @@
<EventSetter Event="MouseMove" Handler="TreeView_MouseMove"/>
</Style>
</TreeView.ItemContainerStyle>
<i:Interaction.Behaviors>
<behaviors:Interaction.Behaviors>
<views:TreeViewSelectionBehavior
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
HierarchyPredicate="{Binding PresetsHierarchyPredicate}"
ExpandSelected="False"/>
</i:Interaction.Behaviors>
</behaviors:Interaction.Behaviors>
<TreeView.ContextMenu>
<ContextMenu>
<MenuItem Header="{x:Static project:Resources.CreateANewFolder}" Command="{Binding CreateFolderCommand}">

View File

@ -2,8 +2,7 @@
namespace FileConverter.Views
{
using System;
using System.Linq;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
@ -12,8 +11,6 @@ namespace FileConverter.Views
using FileConverter.Diagnostics;
using FileConverter.ViewModels;
using GalaSoft.MvvmLight.Messaging;
/// <summary>
/// Interaction logic for Settings.
/// </summary>
@ -35,14 +32,30 @@ namespace FileConverter.Views
{
this.InitializeComponent();
Messenger.Default.Register<string>(this, "DoFocus", this.DoFocus);
SettingsViewModel settingsViewModel = this.DataContext as SettingsViewModel;
settingsViewModel.OnPresetCreated += this.SettingsWindow_OnPresetCreated;
settingsViewModel.OnFolderCreated += this.SettingsWindow_OnFolderCreated;
(this.DataContext as SettingsViewModel).PropertyChanged += this.SettingsWindow_PropertyChanged;
settingsViewModel.PropertyChanged += this.SettingsWindow_PropertyChanged;
this.PresetTreeView.MouseDown += this.TreeView_MouseDown;
this.PresetTreeView.MouseUp += this.TreeView_MouseUp;
}
private void SettingsWindow_OnPresetCreated()
{
this.focusMessage = "PresetName";
this.selectedPresetNameTextBox?.Focus();
this.selectedPresetNameTextBox?.SelectAll();
}
private void SettingsWindow_OnFolderCreated()
{
this.focusMessage = "FolderName";
this.selectedFolderNameTextBox?.Focus();
this.selectedFolderNameTextBox?.SelectAll();
}
private void SettingsWindow_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs args)
{
if (args.PropertyName == "SelectedItem")
@ -52,23 +65,6 @@ namespace FileConverter.Views
}
}
public void DoFocus(string message)
{
this.focusMessage = message;
switch (message)
{
case "PresetName":
this.selectedPresetNameTextBox?.Focus();
this.selectedPresetNameTextBox?.SelectAll();
break;
case "FolderName":
this.selectedFolderNameTextBox?.Focus();
this.selectedFolderNameTextBox?.SelectAll();
break;
}
}
private void TreeView_MouseDown(object sender, MouseButtonEventArgs args)
{
FrameworkElement element = args.OriginalSource as FrameworkElement;
@ -345,7 +341,7 @@ namespace FileConverter.Views
this.selectedPresetNameTextBox = (TextBox)sender;
if (this.focusMessage == "PresetName")
{
this.DoFocus(this.focusMessage);
this.selectedPresetNameTextBox.Focus();
this.focusMessage = null;
}
}
@ -355,7 +351,7 @@ namespace FileConverter.Views
this.selectedFolderNameTextBox = (TextBox)sender;
if (this.focusMessage == "FolderName")
{
this.DoFocus(this.focusMessage);
this.selectedFolderNameTextBox.Focus();
this.focusMessage = null;
}
}

View File

@ -4,19 +4,18 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:project="clr-namespace:FileConverter.Properties"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:command="http://www.galasoft.ch/mvvmlight"
xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
mc:Ignorable="d"
Title="{x:Static project:Resources.UpgradeWindowTitle}"
WindowStartupLocation="CenterScreen" Icon="/FileConverter;component/Resources/ApplicationIcon.ico"
MinHeight="300" MinWidth="450"
Height="450" Width="450" WindowStyle="ToolWindow"
DataContext="{Binding Upgrade, Source={StaticResource Locator}}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Closing">
<command:EventToCommand Command="{Binding CloseCommand}" PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
<behaviors:Interaction.Triggers>
<behaviors:EventTrigger EventName="Closing">
<behaviors:InvokeCommandAction Command="{Binding CloseCommand}" PassEventArgsToCommand="True" />
</behaviors:EventTrigger>
</behaviors:Interaction.Triggers>
<Window.Resources>
</Window.Resources>
<Grid>

View File

@ -2,12 +2,6 @@
namespace FileConverter
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
public class XmlHelpers
{
public static void LoadFromFile<T>(string root, string path, out T deserializedObject)

View File

@ -1,14 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonServiceLocator" version="2.0.7" targetFramework="net48" />
<package id="CommunityToolkit.Mvvm" version="8.2.2" targetFramework="net48" />
<package id="Magick.NET.Core" version="13.5.0" targetFramework="net48" />
<package id="Magick.NET-Q16-AnyCPU" version="13.5.0" targetFramework="net48" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.DependencyInjection" version="8.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="8.0.0" targetFramework="net48" />
<package id="Microsoft.Office.Interop.Excel" version="15.0.4795.1000" targetFramework="net45" />
<package id="Microsoft.Office.Interop.PowerPoint" version="12.0.4518.1014" targetFramework="net45" />
<package id="Microsoft.Office.Interop.Word" version="15.0.4797.1003" targetFramework="net45" />
<package id="MvvmLight" version="5.4.1.1" targetFramework="net45" />
<package id="MvvmLightLibs" version="5.4.1.1" targetFramework="net45" />
<package id="Microsoft.Xaml.Behaviors.Wpf" version="1.1.77" targetFramework="net48" />
<package id="Office" version="12.0.0" targetFramework="net45" />
<package id="SharpShell" version="2.7.2" targetFramework="net462" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.ComponentModel.Annotations" version="5.0.0" targetFramework="net48" />
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
<package id="WpfAnimatedGif" version="2.0.2" targetFramework="net462" />
</packages>

View File

@ -84,22 +84,6 @@
</Component>
<!-- Third parties -->
<Component Guid="{FF99FD36-9C73-472D-AA18-9384DB7708A6}">
<File Id="CommonServiceLocator.dll" KeyPath="yes" Source="$(var.FileConverter.TargetDir)CommonServiceLocator.dll" Checksum="yes" />
</Component>
<Component Guid="{2D5509A2-A752-4E4D-A706-E90F041D0B7D}">
<File Id="GalaSoft.MvvmLight.dll" KeyPath="yes" Source="$(var.FileConverter.TargetDir)GalaSoft.MvvmLight.dll" Checksum="yes" />
</Component>
<Component Guid="{D4F2C1DD-800D-407D-B863-1FE6C3069D3C}">
<File Id="GalaSoft.MvvmLight.Extras.dll" KeyPath="yes" Source="$(var.FileConverter.TargetDir)GalaSoft.MvvmLight.Extras.dll" Checksum="yes" />
</Component>
<Component Guid="{48D1EE43-F7D7-4611-B3AC-B2652ED68261}">
<File Id="GalaSoft.MvvmLight.Platform.dll" KeyPath="yes" Source="$(var.FileConverter.TargetDir)GalaSoft.MvvmLight.Platform.dll" Checksum="yes" />
</Component>
<Component Guid="{08FB2B2B-7686-4698-B864-0AD39CF3128D}">
<File Id="System.Windows.Interactivity.dll" KeyPath="yes" Source="$(var.FileConverter.TargetDir)System.Windows.Interactivity.dll" Checksum="yes" />
</Component>
<Component Guid="{BEEAAC73-C479-4080-83B1-2B1448C7378C}">
<File Id="___var.FileConverter.TargetDir_ffmpeg.exe" Source="$(var.FileConverter.TargetDir)ffmpeg.exe" KeyPath="yes" Checksum="yes" />
</Component>