Files
@ 5e28ba3945f7
Branch filter:
Location: ATITD-Tools/Desert-Paint-Codex/ViewModels/CreateProfileViewModel.cs - annotation
5e28ba3945f7
1.7 KiB
text/x-csharp
Recipe count is now a ulong instead of an int so it can show values > 2.47 billion. Also, don't allow clearing the recipe list while the recipe generator is running.
40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 | using System.Collections.Generic;
using System.Reactive;
using System.Reactive.Linq;
using DesertPaintCodex.Services;
using ReactiveUI;
namespace DesertPaintCodex.ViewModels
{
public class CreateProfileViewModel : ViewModelBase
{
private string _profileName = string.Empty;
public string ProfileName { get => _profileName; set => this.RaiseAndSetIfChanged(ref _profileName, value); }
private readonly ObservableAsPropertyHelper<bool> _duplicateWarning;
public bool DuplicateWarning => _duplicateWarning.Value;
public CreateProfileViewModel()
{
List<string> profiles = ProfileManager.GetProfileList();
// Duplicate warning display logic.
this.WhenAnyValue(x => x.ProfileName)
.Select(profileName =>
(!string.IsNullOrWhiteSpace(profileName) &&
profiles.Contains(profileName)))
.ToProperty(this,
x => x.DuplicateWarning,
out _duplicateWarning);
// TODO: Use proper validation to decorate the TextBox, as well.
// OK button enabling logic.
var okEnabled = this.WhenAnyValue(
x => x.ProfileName,
x => !string.IsNullOrWhiteSpace(x) &&
!profiles.Contains(x));
// Button commands.
Cancel = ReactiveCommand.Create(() => { });
Ok = ReactiveCommand.Create(() => {
ProfileManager.CreateNewProfile(_profileName);
}, okEnabled);
}
public ReactiveCommand<Unit, Unit> Cancel { get; }
public ReactiveCommand<Unit, Unit> Ok { get; }
}
}
|