Skip to content

Commit

Permalink
Remove unsued code
Browse files Browse the repository at this point in the history
Remove unsued command classes
  • Loading branch information
XanatosX committed Jun 14, 2023
1 parent 3a73c0d commit bc8e154
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 192 deletions.
28 changes: 0 additions & 28 deletions src/XmlFormatterOsIndependent/Commands/BaseCommand.cs

This file was deleted.

26 changes: 0 additions & 26 deletions src/XmlFormatterOsIndependent/Commands/BaseTriggerCommand.cs

This file was deleted.

65 changes: 0 additions & 65 deletions src/XmlFormatterOsIndependent/Commands/SwitchStyleCommand.cs

This file was deleted.

73 changes: 1 addition & 72 deletions src/XmlFormatterOsIndependent/ViewModels/ViewModelBase.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using PluginFramework.Interfaces.Manager;
using ReactiveUI;
using System;
using System.Runtime.InteropServices;
using System.Windows.Input;
using XmlFormatterModel.Setting;
using XmlFormatterOsIndependent.Commands;
using XmlFormatterOsIndependent.DataSets;
using XmlFormatterOsIndependent.Enums;

namespace XmlFormatterOsIndependent.ViewModels
{
Expand Down Expand Up @@ -61,88 +58,20 @@ public ViewModelBase(ISettingsManager settingsManager, IPluginManager pluginMana
settingsPath += System.IO.Path.DirectorySeparatorChar + "settings.set";

settingsManager.Load(settingsPath);
ChangeTheme();
DoOSSpecific();
}

/// <summary>
/// Do something os specific
/// </summary>
protected virtual void DoOSSpecific()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
IsWindowsOs();
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
IsLinuxOs();
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
IsOsX();
}
}

/// <summary>
/// This system is a osx system
/// </summary>
protected virtual void IsOsX()
{

}

/// <summary>
/// This system is a linux system
/// </summary>
protected virtual void IsLinuxOs()
{

}

/// <summary>
/// This system is a windows system
/// </summary>
protected virtual void IsWindowsOs()
{

}

/// <summary>
/// Change the theme for this window
/// </summary>
protected void ChangeTheme()
{
IDataCommand themeCommand = new GetThemeCommand();
ExecuteCommand(themeCommand, this.settingsManager);
ICommand themeSwitchCommand = new SwitchStyleCommand();
ExecuteCommand(themeSwitchCommand, new ThemeSwitchData(view, themeCommand.GetData<ThemeEnum>()));
}

/// <summary>
/// Execute a given command if possible
/// </summary>
/// <param name="command">The command to execute</param>
/// <param name="parameter">The parameter to use</param>
[Obsolete]
protected void ExecuteCommand(ICommand command, object parameter)
{
if (command.CanExecute(parameter))
{
command.Execute(parameter);
}
}

/// <summary>
/// Execute a async command
/// </summary>
/// <param name="command">The command to use</param>
/// <param name="parameter">The parameter to use</param>
protected void ExecuteAsyncCommand(IDataCommand command, object parameter)
{
if (command.CanExecute(parameter))
{
command.AsyncExecute(parameter);
}
}
}
}
2 changes: 1 addition & 1 deletion src/XmlFormatterOsIndependent/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public MainWindow()
Close();
});

WeakReferenceMessenger.Default.Register<RequestMainWindowMessage>(this, async (_, e) =>
WeakReferenceMessenger.Default.Register<RequestMainWindowMessage>(this, (_, e) =>
{
e.Reply(this);
});
Expand Down

0 comments on commit bc8e154

Please sign in to comment.