Profile editor - Added profile rename

Profile editor - Cleaned up buttons next to profile selection
This commit is contained in:
Robert committed 2020-12-17 21:09:42 +01:00
1 parent 3792dd53d2
commit e61a031485
8 files changed
+174 -56

No files matched your search

@@ -0,0 +1,29 @@
<UserControl x:Class="Artemis.UI.Screens.ProfileEditor.Dialogs.ProfileEditView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="213.053" d:DesignWidth="254.425">
<StackPanel Margin="16">
<TextBlock Style="{StaticResource MaterialDesignHeadline6TextBlock}">
Edit profile
</TextBlock>
<TextBox materialDesign:HintAssist.Hint="Profile name"
Margin="0 8 0 16"
Style="{StaticResource MaterialDesignFloatingHintTextBox}"
Text="{Binding ProfileName, UpdateSourceTrigger=PropertyChanged}" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Style="{StaticResource MaterialDesignFlatButton}" IsCancel="True" Margin="0 8 8 0" Command="{s:Action Cancel}">
CANCEL
</Button>
<Button Style="{StaticResource MaterialDesignFlatButton}" IsDefault="True" Margin="0 8 8 0" Command="{s:Action Accept}">
ACCEPT
</Button>
</StackPanel>
</StackPanel>
</UserControl>
@@ -0,0 +1,42 @@
using System.Threading.Tasks;
using Artemis.Core;
using Artemis.UI.Shared.Services;
using FluentValidation;
using Stylet;
namespace Artemis.UI.Screens.ProfileEditor.Dialogs
{
public class ProfileEditViewModel : DialogViewModelBase
{
private string _profileName;
public ProfileEditViewModel(IModelValidator<ProfileEditViewModel> validator, Profile profile) : base(validator)
{
ProfileName = profile.Name;
}
public string ProfileName
{
get => _profileName;
set => SetAndNotify(ref _profileName, value);
}
public async Task Accept()
{
await ValidateAsync();
if (HasErrors)
return;
Session.Close(ProfileName);
}
}
public class ProfileEditViewModelValidator : AbstractValidator<ProfileEditViewModel>
{
public ProfileEditViewModelValidator()
{
RuleFor(m => m.ProfileName).NotEmpty().WithMessage("Profile name may not be empty");
}
}
}
@@ -17,11 +17,19 @@
Export current profile
</TextBlock>
<TextBlock Margin="0 10" TextAlignment="Justify" TextWrapping="Wrap" Grid.Row="1">
<TextBlock Grid.Row="1"
Margin="0 10"
TextWrapping="Wrap"
Style="{StaticResource MaterialDesignSubtitle1TextBlock}"
Foreground="{DynamicResource MaterialDesignBodyLight}">
Please note that exporting profiles like this is placeholder functionality. The idea is that this will eventually happen via the workshop.
</TextBlock>
<TextBlock Margin="0 10" TextAlignment="Justify" TextWrapping="Wrap" Grid.Row="2">
<TextBlock Grid.Row="2"
Margin="0 10"
TextWrapping="Wrap"
Style="{StaticResource MaterialDesignSubtitle1TextBlock}"
Foreground="{DynamicResource MaterialDesignBodyLight}">
The workshop will include tools to make profiles convert easily and look good on different layouts.
That means right now when someone imports this export unless they have the exact same setup as
you, they'll have to select LEDs for each layer in the profile.
@@ -19,11 +19,19 @@
Import profile to current module
</TextBlock>
<TextBlock Margin="0 10" TextAlignment="Justify" TextWrapping="Wrap" Grid.Row="1">
<TextBlock Grid.Row="1"
Margin="0 10"
TextWrapping="Wrap"
Style="{StaticResource MaterialDesignSubtitle1TextBlock}"
Foreground="{DynamicResource MaterialDesignBodyLight}">
Please note that importing profiles like this is placeholder functionality. The idea is that this will eventually happen via the workshop.
</TextBlock>
<TextBlock Margin="0 10" TextAlignment="Justify" TextWrapping="Wrap" Grid.Row="2">
<TextBlock Grid.Row="2"
Margin="0 10"
TextWrapping="Wrap"
Style="{StaticResource MaterialDesignSubtitle1TextBlock}"
Foreground="{DynamicResource MaterialDesignBodyLight}">
The workshop will include tools to make profiles convert easily and look good on different layouts.
That means right now when you import this profile unless you have the exact same setup as
the person who exported it, you'll have to select LEDs for each layer in the profile.
@@ -123,8 +123,6 @@
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ComboBox Height="26"
VerticalAlignment="Top"
@@ -139,46 +137,52 @@
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
<Button Style="{StaticResource MaterialDesignFloatingActionMiniButton}"
<Button Style="{StaticResource MaterialDesignIconForegroundButton}"
ToolTip="Add a new profile"
Margin="5 0"
Margin="5 0 0 0"
Grid.Column="1"
Width="26"
Height="26"
VerticalAlignment="Top"
Command="{s:Action AddProfile}">
<materialDesign:PackIcon Kind="Add" Height="14" Width="14" />
</Button>
<Button Style="{StaticResource MaterialDesignFloatingActionMiniDarkButton}"
ToolTip="Delete the current profile"
Margin="5 0"
Grid.Column="2"
Width="26"
Height="26"
VerticalAlignment="Top"
Command="{s:Action DeleteActiveProfile}">
<materialDesign:PackIcon Kind="TrashCanOutline" Height="14" Width="14" />
</Button>
<Button Style="{StaticResource MaterialDesignFloatingActionMiniButton}"
ToolTip="Export the current profile"
Margin="5 0"
Grid.Column="3"
Width="26"
Height="26"
VerticalAlignment="Top"
Command="{s:Action ExportActiveProfile}">
<materialDesign:PackIcon Kind="Export" Height="14" Width="14" />
</Button>
<Button Style="{StaticResource MaterialDesignFloatingActionMiniButton}"
ToolTip="Import an existing profile"
Margin="5 0 0 0"
Grid.Column="4"
Width="26"
Height="26"
VerticalAlignment="Top"
Command="{s:Action ImportProfile}">
<materialDesign:PackIcon Kind="Import" Height="14" Width="14" />
<materialDesign:PackIcon Kind="Add" Height="20" Width="20" />
</Button>
<materialDesign:PopupBox Grid.Column="2" Margin="0 -10 0 0" PlacementMode="BottomAndAlignRightEdges">
<StackPanel>
<Button Command="{s:Action RenameActiveProfile}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="RenameBox" Margin="0 0 15 0" />
<TextBlock>Rename profile</TextBlock>
</StackPanel>
</Button>
<Button Command="{s:Action DuplicateActiveProfile}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="ContentDuplicate" Margin="0 0 15 0" />
<TextBlock>Duplicate profile</TextBlock>
</StackPanel>
</Button>
<Button Command="{s:Action DeleteActiveProfile}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Trash" Margin="0 0 15 0" />
<TextBlock>Delete profile</TextBlock>
</StackPanel>
</Button>
<Separator />
<Button Command="{s:Action ExportActiveProfile}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Upload" Margin="0 0 15 0" />
<TextBlock>Export profile</TextBlock>
</StackPanel>
</Button>
<Button Command="{s:Action ImportProfile}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Download" Margin="0 0 15 0" />
<TextBlock>Import profile</TextBlock>
</StackPanel>
</Button>
</StackPanel>
</materialDesign:PopupBox>
</Grid>
<!-- Profile elements -->
@@ -182,6 +182,21 @@ namespace Artemis.UI.Screens.ProfileEditor
RemoveProfile(SelectedProfile);
}
public async Task RenameActiveProfile()
{
if (_profileEditorService.SelectedProfile == null)
return;
Profile profile = _profileEditorService.SelectedProfile;
object result = await DialogService.ShowDialog<ProfileEditViewModel>(new Dictionary<string, object> {{"profile", profile}});
if (result is string name)
{
profile.Name = name;
_profileEditorService.UpdateSelectedProfile();
SelectedProfile.Update();
}
}
public async Task ExportActiveProfile()
{
await DialogService.ShowDialog<ProfileExportViewModel>(new Dictionary<string, object>
@@ -228,7 +243,7 @@ namespace Artemis.UI.Screens.ProfileEditor
await Task.Delay(50);
focusedElement?.Focus();
});
_snackbarMessageQueue.Enqueue("Undid profile update", "REDO", Redo);
}