1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 13:28:33 +00:00

UI - Fixed various rename dialogs cancelling instead of submitting when pressing enter

Submission wizard - Allow window to scroll when setting up layer adaption hints
Local web API - Added status endpoint to determine whether webserver is running
This commit is contained in:
Robert 2023-09-17 11:35:19 +02:00
parent d96581f11c
commit 8d5640aba3
11 changed files with 79 additions and 51 deletions

View File

@ -45,4 +45,5 @@
<StyleInclude Source="/Styles/NumberBox.axaml" />
<StyleInclude Source="/Styles/TreeView.axaml" />
<StyleInclude Source="/Styles/Plugins.axaml" />
<StyleInclude Source="/Styles/ScrollViewer.axaml" />
</Styles>

View File

@ -0,0 +1,15 @@
<Style xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<Border Padding="20">
<ScrollViewer Classes="with-padding" Height="100">
<Rectangle Fill="Blue" Width="50" Height="200"></Rectangle>
</ScrollViewer>
</Border>
</Design.PreviewWith>
<!-- Add Styles Here -->
<Style Selector="ScrollViewer.with-padding /template/ ScrollContentPresenter#PART_ContentPresenter">
<Setter Property="Grid.ColumnSpan" Value="1"></Setter>
</Style>
</Style>

View File

@ -20,6 +20,12 @@ public class RemoteController : WebApiController
_mainWindowService = mainWindowService;
}
[Route(HttpVerbs.Any, "/status")]
public void GetStatus()
{
HttpContext.Response.StatusCode = 200;
}
[Route(HttpVerbs.Post, "/remote/bring-to-foreground")]
public void PostBringToForeground()
{

View File

@ -7,9 +7,6 @@
x:Class="Artemis.UI.Screens.ProfileEditor.ProfileTree.ContentDialogs.ProfileElementRenameView"
x:DataType="contentDialogs:ProfileElementRenameViewModel">
<StackPanel>
<StackPanel.KeyBindings>
<KeyBinding Gesture="Enter" Command="{CompiledBinding Enter}" />
</StackPanel.KeyBindings>
<TextBox Name="NameTextBox" Text="{CompiledBinding ProfileElementName}" Watermark="Profile element name" />
</StackPanel>
</UserControl>

View File

@ -22,7 +22,6 @@ public class ProfileElementRenameViewModel : ContentDialogViewModelBase
_profileElementName = profileElement.Name;
Confirm = ReactiveCommand.Create(ExecuteConfirm, ValidationContext.Valid);
Enter = ReactiveCommand.Create(() => ContentDialog?.Hide(ContentDialogResult.Primary), Confirm.CanExecute);
this.ValidationRule(vm => vm.ProfileElementName, name => !string.IsNullOrWhiteSpace(name), "You must specify a valid name");
}
@ -33,7 +32,6 @@ public class ProfileElementRenameViewModel : ContentDialogViewModelBase
}
public ReactiveCommand<Unit, Unit> Enter { get; }
public ReactiveCommand<Unit, Unit> Confirm { get; }
private void ExecuteConfirm()

View File

@ -7,9 +7,6 @@
x:Class="Artemis.UI.Screens.ProfileEditor.Properties.Tree.ContentDialogs.LayerEffectRenameView"
x:DataType="contentDialogs:LayerEffectRenameViewModel">
<StackPanel>
<StackPanel.KeyBindings>
<KeyBinding Gesture="Enter" Command="{CompiledBinding Enter}" />
</StackPanel.KeyBindings>
<TextBox Name="NameTextBox" Text="{CompiledBinding LayerEffectName}" Watermark="Layer effect name" />
</StackPanel>
</UserControl>

View File

@ -22,7 +22,6 @@ public class LayerEffectRenameViewModel : ContentDialogViewModelBase
_layerEffectName = layerEffect.Name;
Confirm = ReactiveCommand.Create(ExecuteConfirm, ValidationContext.Valid);
Enter = ReactiveCommand.Create(() => ContentDialog?.Hide(ContentDialogResult.Primary), Confirm.CanExecute);
this.ValidationRule(vm => vm.LayerEffectName, categoryName => !string.IsNullOrWhiteSpace(categoryName), "You must specify a valid name");
}
@ -33,7 +32,6 @@ public class LayerEffectRenameViewModel : ContentDialogViewModelBase
}
public ReactiveCommand<Unit, Unit> Confirm { get; }
public ReactiveCommand<Unit, Unit> Enter { get; }
private void ExecuteConfirm()
{

View File

@ -7,9 +7,6 @@
x:Class="Artemis.UI.Screens.Sidebar.SidebarCategoryEditView"
x:DataType="sidebar:SidebarCategoryEditViewModel">
<StackPanel>
<StackPanel.KeyBindings>
<KeyBinding Gesture="Enter" Command="{CompiledBinding Enter}" />
</StackPanel.KeyBindings>
<TextBox Text="{CompiledBinding CategoryName}" Watermark="Category name"/>
<TextBox Name="NameTextBox" Text="{CompiledBinding CategoryName}" Watermark="Category name"/>
</StackPanel>
</UserControl>

View File

@ -1,6 +1,7 @@
using System.Threading.Tasks;
using Artemis.UI.Shared.Extensions;
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
using Avalonia.Threading;
using ReactiveUI;
namespace Artemis.UI.Screens.Sidebar;
@ -10,7 +11,18 @@ public partial class SidebarCategoryEditView : ReactiveUserControl<SidebarCatego
public SidebarCategoryEditView()
{
InitializeComponent();
this.WhenActivated(_ => this.ClearAllDataValidationErrors());
this.WhenActivated(_ =>
{
this.ClearAllDataValidationErrors();
Dispatcher.UIThread.Post(DelayedAutoFocus);
});
}
private async void DelayedAutoFocus()
{
// Don't ask
await Task.Delay(200);
NameTextBox.SelectAll();
NameTextBox.Focus();
}
}

View File

@ -24,7 +24,6 @@ public class SidebarCategoryEditViewModel : ContentDialogViewModelBase
_categoryName = _category.Name;
Confirm = ReactiveCommand.Create(ExecuteConfirm, ValidationContext.Valid);
Enter = ReactiveCommand.Create(() => ContentDialog?.Hide(ContentDialogResult.Primary), Confirm.CanExecute);
this.ValidationRule(vm => vm.CategoryName, categoryName => !string.IsNullOrWhiteSpace(categoryName?.Trim()), "You must specify a valid name");
this.ValidationRule(vm => vm.CategoryName, categoryName => profileService.ProfileCategories.All(c => c.Name != categoryName?.Trim()), "You must specify a unique name");
}
@ -36,7 +35,6 @@ public class SidebarCategoryEditViewModel : ContentDialogViewModelBase
}
public ReactiveCommand<Unit, Unit> Confirm { get; }
public ReactiveCommand<Unit, Unit> Enter { get; }
private void ExecuteConfirm()
{

View File

@ -31,37 +31,46 @@
Learn more about adaption hints
</controls:HyperlinkButton>
<ItemsRepeater ItemsSource="{CompiledBinding Layers}" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="0 10 0 0">
<ItemsRepeater.ItemTemplate>
<DataTemplate DataType="profile:ProfileAdaptionHintsLayerViewModel">
<StackPanel>
<Border Classes="card-separator" />
<Grid ColumnDefinitions="Auto,*,Auto" RowDefinitions="*,*">
<avalonia:MaterialIcon Grid.Column="0"
Grid.Row="0"
Grid.RowSpan="2"
Width="25"
Height="25"
Margin="5 0 10 0"
Kind="{CompiledBinding Layer.LayerBrush.Descriptor.Icon, FallbackValue=QuestionMark}" />
<TextBlock Grid.Column="1" Grid.Row="0" Text="{CompiledBinding Layer.Name}" />
<TextBlock Grid.Column="1"
Grid.Row="1"
VerticalAlignment="Top"
Classes="subtitle"
Classes.danger="{CompiledBinding !AdaptionHintCount}"
Text="{CompiledBinding AdaptionHintText}">
</TextBlock>
<Button Grid.Column="2"
Grid.Row="0"
Grid.RowSpan="2"
Command="{Binding EditAdaptionHints}">
Edit hints
</Button>
</Grid>
</StackPanel>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
<ScrollViewer Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="2"
Margin="0 10 0 0"
Classes="with-padding"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto"
VerticalAlignment="Top">
<ItemsRepeater ItemsSource="{CompiledBinding Layers}">
<ItemsRepeater.ItemTemplate>
<DataTemplate DataType="profile:ProfileAdaptionHintsLayerViewModel">
<StackPanel>
<Border Classes="card-separator" />
<Grid ColumnDefinitions="Auto,*,Auto" RowDefinitions="*,*">
<avalonia:MaterialIcon Grid.Column="0"
Grid.Row="0"
Grid.RowSpan="2"
Width="25"
Height="25"
Margin="5 0 10 0"
Kind="{CompiledBinding Layer.LayerBrush.Descriptor.Icon, FallbackValue=QuestionMark}" />
<TextBlock Grid.Column="1" Grid.Row="0" Text="{CompiledBinding Layer.Name}" />
<TextBlock Grid.Column="1"
Grid.Row="1"
VerticalAlignment="Top"
Classes="subtitle"
Classes.danger="{CompiledBinding !AdaptionHintCount}"
Text="{CompiledBinding AdaptionHintText}">
</TextBlock>
<Button Grid.Column="2"
Grid.Row="0"
Grid.RowSpan="2"
Command="{Binding EditAdaptionHints}">
Edit hints
</Button>
</Grid>
</StackPanel>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
</ScrollViewer>
</Grid>
</UserControl>