mirror of
https://github.com/Stone-Red-Code/ClipCMD.git
synced 2026-09-04 00:46:10 +02:00
Small code improvments
This commit is contained in:
@@ -36,22 +36,19 @@ public partial class App : Application
|
|||||||
|
|
||||||
desktop.MainWindow.Closing += (sender, e) =>
|
desktop.MainWindow.Closing += (sender, e) =>
|
||||||
{
|
{
|
||||||
|
e.Cancel = true;
|
||||||
|
|
||||||
|
desktop.MainWindow.Hide();
|
||||||
|
|
||||||
Settings.SaveSettings();
|
Settings.SaveSettings();
|
||||||
clipCmdCommandHandler.SaveCommands();
|
clipCmdCommandHandler.SaveCommands();
|
||||||
};
|
};
|
||||||
|
|
||||||
clipCmdCommandHandler.Start();
|
clipCmdCommandHandler.Start();
|
||||||
}
|
}
|
||||||
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
|
else
|
||||||
{
|
{
|
||||||
/*
|
throw new PlatformNotSupportedException();
|
||||||
singleViewPlatform.MainView = new MainView()
|
|
||||||
{
|
|
||||||
DataContext = new MainViewModel()
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
base.OnFrameworkInitializationCompleted();
|
base.OnFrameworkInitializationCompleted();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
|
using Avalonia.Styling;
|
||||||
|
|
||||||
using AvaloniaEdit;
|
using AvaloniaEdit;
|
||||||
using AvaloniaEdit.TextMate;
|
using AvaloniaEdit.TextMate;
|
||||||
@@ -35,7 +36,14 @@ public partial class EditorWindow : Window
|
|||||||
CheckScript(editorViewModel);
|
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);
|
TextMate.Installation _textMateInstallation = textEditor.InstallTextMate(registryOptions);
|
||||||
|
|
||||||
_textMateInstallation.SetGrammar(registryOptions.GetScopeByLanguageId(registryOptions.GetLanguageByExtension(".ps1").Id));
|
_textMateInstallation.SetGrammar(registryOptions.GetScopeByLanguageId(registryOptions.GetLanguageByExtension(".ps1").Id));
|
||||||
|
|||||||
@@ -9,8 +9,7 @@
|
|||||||
x:Class="ClipCmd.Views.MainWindow"
|
x:Class="ClipCmd.Views.MainWindow"
|
||||||
x:DataType="vm:ViewModelBase"
|
x:DataType="vm:ViewModelBase"
|
||||||
Icon="/Assets/logo.ico"
|
Icon="/Assets/logo.ico"
|
||||||
Title="{Binding Title}" Width="800" Height="450"
|
Title="{Binding Title}" Width="800" Height="450">
|
||||||
Closing="Window_Closing">
|
|
||||||
|
|
||||||
<views:MainView />
|
<views:MainView />
|
||||||
</Window>
|
</Window>
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
|
||||||
|
|
||||||
namespace ClipCmd.Views;
|
namespace ClipCmd.Views;
|
||||||
|
|
||||||
@@ -9,13 +8,4 @@ public partial class MainWindow : Window
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user