Small code improvments

This commit is contained in:
Stone_Red
2024-05-07 16:58:26 +02:00
parent 93dbf73b23
commit 08a65eb017
4 changed files with 16 additions and 22 deletions
+6 -9
View File
@@ -36,22 +36,19 @@ public partial class App : Application
desktop.MainWindow.Closing += (sender, e) =>
{
e.Cancel = true;
desktop.MainWindow.Hide();
Settings.SaveSettings();
clipCmdCommandHandler.SaveCommands();
};
clipCmdCommandHandler.Start();
}
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
else
{
/*
singleViewPlatform.MainView = new MainView()
{
DataContext = new MainViewModel()
}
*/
throw new NotImplementedException();
throw new PlatformNotSupportedException();
}
base.OnFrameworkInitializationCompleted();
+9 -1
View File
@@ -1,5 +1,6 @@
using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.Styling;
using AvaloniaEdit;
using AvaloniaEdit.TextMate;
@@ -35,7 +36,14 @@ public partial class EditorWindow : Window
CheckScript(editorViewModel);
};
RegistryOptions registryOptions = new RegistryOptions(ThemeName.DarkPlus);
ThemeName editorTheme = ThemeName.DarkPlus;
if (Avalonia.Application.Current?.ActualThemeVariant == ThemeVariant.Light)
{
editorTheme = ThemeName.LightPlus;
}
RegistryOptions registryOptions = new RegistryOptions(editorTheme);
TextMate.Installation _textMateInstallation = textEditor.InstallTextMate(registryOptions);
_textMateInstallation.SetGrammar(registryOptions.GetScopeByLanguageId(registryOptions.GetLanguageByExtension(".ps1").Id));
+1 -2
View File
@@ -9,8 +9,7 @@
x:Class="ClipCmd.Views.MainWindow"
x:DataType="vm:ViewModelBase"
Icon="/Assets/logo.ico"
Title="{Binding Title}" Width="800" Height="450"
Closing="Window_Closing">
Title="{Binding Title}" Width="800" Height="450">
<views:MainView />
</Window>
-10
View File
@@ -1,5 +1,4 @@
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
namespace ClipCmd.Views;
@@ -9,13 +8,4 @@ public partial class MainWindow : Window
{
InitializeComponent();
}
private void Window_Closing(object? sender, WindowClosingEventArgs e)
{
if (Avalonia.Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop && desktop.MainWindow is not null)
{
desktop.MainWindow.Hide();
e.Cancel = true;
}
}
}