Files
@ 5e28ba3945f7
Branch filter:
Location: ATITD-Tools/Desert-Paint-Codex/ViewModels/SelectProfileViewModel.cs - annotation
5e28ba3945f7
1.4 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 7117d2e703c8 40eaee10ae56 7117d2e703c8 40eaee10ae56 7117d2e703c8 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 7117d2e703c8 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 7117d2e703c8 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.Reactive;
using ReactiveUI;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using DesertPaintCodex.Models;
using DesertPaintCodex.Services;
using DynamicData;
namespace DesertPaintCodex.ViewModels
{
public class SelectProfileViewModel : ViewModelBase
{
public ObservableCollection<string> Profiles { get; } = new();
private string? _selectedItem;
public string? SelectedItem { get => _selectedItem; set => this.RaiseAndSetIfChanged(ref _selectedItem, value); }
public SelectProfileViewModel()
{
Profiles.AddRange(ProfileManager.GetProfileList());
var okEnabled = this.WhenAnyValue(
x => x.SelectedItem,
x => !string.IsNullOrWhiteSpace(x));
NewProfile = ReactiveCommand.Create(() => { });
Ok = ReactiveCommand.Create(() =>
{
Debug.Assert(_selectedItem != null);
ProfileManager.LoadProfile(_selectedItem);
}, okEnabled);
Cancel = ReactiveCommand.Create(() => { });
if (Profiles.Count > 0)
{
SelectedItem = Profiles[0];
}
}
public ReactiveCommand<Unit, Unit> NewProfile { get; }
public ReactiveCommand<Unit, Unit> Ok { get; }
public ReactiveCommand<Unit, Unit> Cancel { get; }
}
}
|