Added folder/layer renaming

Implemented profile saving
This commit is contained in:
SpoinkyNL committed 2019-11-24 23:01:11 +01:00
1 parent 1bb2d4a4f2
commit 602a0e6fee
20 files changed
+253 -62

No files matched your search

@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Artemis.UI.ViewModels.Dialogs;
using FluentValidation;
using Stylet;
namespace Artemis.UI.Screens.Module.ProfileEditor.Dialogs
@@ -27,4 +28,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Dialogs
Session.Close();
}
}
public class ProfileCreateViewModelValidator : AbstractValidator<ProfileCreateViewModel>
{
public ProfileCreateViewModelValidator()
{
RuleFor(m => m.ProfileName).NotEmpty().WithMessage("Profile name may not be empty");
}
}
}
@@ -0,0 +1,39 @@
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.Dialogs.ProfileElementRenameView"
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 MaterialDesignTitleTextBlock}">
Rename profile element
</TextBlock>
<TextBox materialDesign:HintAssist.Hint="Element name"
Margin="0 8 0 16"
Style="{StaticResource MaterialDesignFloatingHintTextBox}"
Text="{Binding ElementName, UpdateSourceTrigger=PropertyChanged}"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Style="{StaticResource MaterialDesignFlatButton}" IsCancel="True" Margin="0 8 8 0" Command="{s:Action Cancel}">
<Button.CommandParameter>
<system:Boolean xmlns:system="clr-namespace:System;assembly=mscorlib">
False
</system:Boolean>
</Button.CommandParameter>
CANCEL
</Button>
<Button Style="{StaticResource MaterialDesignFlatButton}" IsDefault="True" Margin="0 8 8 0" Command="{s:Action Accept}">
<Button.CommandParameter>
<system:Boolean xmlns:system="clr-namespace:System;assembly=mscorlib">
True
</system:Boolean>
</Button.CommandParameter>
ACCEPT
</Button>
</StackPanel>
</StackPanel>
</UserControl>
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Artemis.UI.Screens.Module.ProfileEditor.Dialogs
{
/// <summary>
/// Interaction logic for ProfileElementRenameView.xaml
/// </summary>
public partial class ProfileElementRenameView : UserControl
{
public ProfileElementRenameView()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,41 @@
using System.Threading.Tasks;
using Artemis.Core.Models.Profile.Abstract;
using Artemis.UI.ViewModels.Dialogs;
using FluentValidation;
using Stylet;
namespace Artemis.UI.Screens.Module.ProfileEditor.Dialogs
{
public class ProfileElementRenameViewModel : DialogViewModelBase
{
public ProfileElementRenameViewModel(IModelValidator<ProfileElementRenameViewModel> validator, ProfileElement profileElement) : base(validator)
{
ElementName = profileElement.Name;
}
public string ElementName { get; set; }
public async Task Accept()
{
await ValidateAsync();
if (HasErrors)
return;
Session.Close(ElementName);
}
public void Cancel()
{
Session.Close();
}
}
public class ProfileElementRenameViewModelValidator : AbstractValidator<ProfileElementRenameViewModel>
{
public ProfileElementRenameViewModelValidator()
{
RuleFor(m => m.ElementName).NotEmpty().WithMessage("Element name may not be empty");
}
}
}
@@ -1,12 +0,0 @@
using FluentValidation;
namespace Artemis.UI.Screens.Module.ProfileEditor.Dialogs
{
public class ProfileCreateViewModelValidator : AbstractValidator<ProfileCreateViewModel>
{
public ProfileCreateViewModelValidator()
{
RuleFor(m => m.ProfileName).NotEmpty().WithMessage("Profile name may not be empty");
}
}
}