mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Scripting - Add confirm dialog when discarding changes
Editor - Fix missing repeat mode button Editor - Auto-save 1 sec after last change General UI - Fix main window drag handle
This commit is contained in:
1 parent
e3907e6a76
commit
311bdee8da
13 files changed
+103
-25
No files matched your search
@@ -9,9 +9,11 @@
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.UI.Screens.Scripting.ScriptsDialogView"
|
||||
x:DataType="scripting:ScriptsDialogViewModel"
|
||||
Title="ScriptsDialogView">
|
||||
Title="Artemis | Scripts"
|
||||
Width="1200"
|
||||
Height="750">
|
||||
<DockPanel>
|
||||
<ScrollViewer DockPanel.Dock="Left" VerticalScrollBarVisibility="Auto" Width="240">
|
||||
<ScrollViewer DockPanel.Dock="Left" VerticalScrollBarVisibility="Auto" Width="300" Margin="10">
|
||||
<StackPanel>
|
||||
<ListBox Items="{CompiledBinding ScriptConfigurations}" SelectedItem="{CompiledBinding SelectedScript}">
|
||||
<ListBox.ItemTemplate>
|
||||
@@ -29,7 +31,8 @@
|
||||
Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
Text="{CompiledBinding ScriptConfiguration.Name}"
|
||||
IsVisible="{CompiledBinding !ScriptConfiguration.HasChanges}" />
|
||||
IsVisible="{CompiledBinding !ScriptConfiguration.HasChanges}"
|
||||
TextTrimming="CharacterEllipsis" />
|
||||
<StackPanel Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
@@ -78,7 +81,7 @@
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
|
||||
<Border DockPanel.Dock="Top" Classes="router-container">
|
||||
<Border DockPanel.Dock="Top" Classes="router-container" Margin="0 10 0 0">
|
||||
<ContentControl Content="{CompiledBinding ScriptEditorViewModel}" />
|
||||
</Border>
|
||||
</DockPanel>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Avalonia;
|
||||
using System.ComponentModel;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
@@ -6,12 +7,28 @@ namespace Artemis.UI.Screens.Scripting;
|
||||
|
||||
public partial class ScriptsDialogView : ReactiveCoreWindow<ScriptsDialogViewModel>
|
||||
{
|
||||
private bool _canClose;
|
||||
|
||||
public ScriptsDialogView()
|
||||
{
|
||||
InitializeComponent();
|
||||
#if DEBUG
|
||||
this.AttachDevTools();
|
||||
#endif
|
||||
Closing += OnClosing;
|
||||
}
|
||||
|
||||
private async void OnClosing(object? sender, CancelEventArgs e)
|
||||
{
|
||||
if (_canClose)
|
||||
return;
|
||||
|
||||
e.Cancel = true;
|
||||
if (ViewModel == null || await ViewModel.CanClose())
|
||||
{
|
||||
_canClose = true;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
|
||||
@@ -143,4 +143,18 @@ public class ScriptsDialogViewModel : DialogViewModelBase<object?>
|
||||
// Select the new script
|
||||
SelectedScript = ScriptConfigurations.LastOrDefault();
|
||||
}
|
||||
|
||||
public async Task<bool> CanClose()
|
||||
{
|
||||
if (!ScriptConfigurations.Any(s => s.ScriptConfiguration.HasChanges))
|
||||
return true;
|
||||
|
||||
bool result = await _windowService.ShowConfirmContentDialog("Discard changes", "One or more scripts still have pending changes, do you want to discard them?");
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
foreach (ScriptConfigurationViewModel scriptConfigurationViewModel in ScriptConfigurations)
|
||||
scriptConfigurationViewModel.ScriptConfiguration.DiscardPendingChanges();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user