mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Added dialog system
Added surface delete
This commit is contained in:
1 parent
c7790c1d82
commit
89bd76387b
24 files changed
+470
-96
No files matched your search
@@ -0,0 +1,28 @@
|
||||
namespace Artemis.UI.ViewModels.Dialogs
|
||||
{
|
||||
public class ConfirmDialogViewModel : DialogViewModelBase
|
||||
{
|
||||
public ConfirmDialogViewModel(string header, string text, string confirmText, string cancelText)
|
||||
{
|
||||
Header = header;
|
||||
Text = text;
|
||||
ConfirmText = confirmText;
|
||||
CancelText = cancelText;
|
||||
}
|
||||
|
||||
public string Header { get; }
|
||||
public string Text { get; }
|
||||
public string ConfirmText { get; }
|
||||
public string CancelText { get; }
|
||||
|
||||
public void Confirm()
|
||||
{
|
||||
Session.Close(true);
|
||||
}
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
Session.Close(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Artemis.UI.ViewModels.Utilities;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.ViewModels.Dialogs
|
||||
{
|
||||
public abstract class DialogViewModelBase : ValidatingModelBase
|
||||
{
|
||||
protected DialogViewModelBase(IModelValidator validator) : base(validator)
|
||||
{
|
||||
}
|
||||
|
||||
protected DialogViewModelBase()
|
||||
{
|
||||
}
|
||||
|
||||
public DialogViewModelHost DialogViewModelHost { get; set; }
|
||||
public DialogSession Session { get; private set; }
|
||||
|
||||
public void OnDialogOpened(object sender, DialogOpenedEventArgs e)
|
||||
{
|
||||
Session = e.Session;
|
||||
}
|
||||
|
||||
public virtual void OnDialogClosed(object sender, DialogClosingEventArgs e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Threading.Tasks;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.ViewModels.Dialogs
|
||||
{
|
||||
public class SurfaceCreateViewModel : DialogViewModelBase
|
||||
{
|
||||
public SurfaceCreateViewModel(IModelValidator<SurfaceCreateViewModel> validator) : base(validator)
|
||||
{
|
||||
}
|
||||
|
||||
public string SurfaceName { get; set; }
|
||||
|
||||
public async Task Accept()
|
||||
{
|
||||
await ValidateAsync();
|
||||
|
||||
if (HasErrors)
|
||||
return;
|
||||
|
||||
Session.Close(SurfaceName);
|
||||
}
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
Session.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using FluentValidation;
|
||||
|
||||
namespace Artemis.UI.ViewModels.Dialogs
|
||||
{
|
||||
public class SurfaceCreateViewModelValidator : AbstractValidator<SurfaceCreateViewModel>
|
||||
{
|
||||
public SurfaceCreateViewModelValidator()
|
||||
{
|
||||
RuleFor(m => m.SurfaceName).NotEmpty().WithMessage("Layout name may not be empty");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user