public MainWindowViewModel() { UserParties = new ReactiveCollection <PartyListElementViewModel>(); UserParties.AddRange(Database.I.UserParties.Select(x => new PartyListElementViewModel(x, OnSelectAttackRoute))); AttackParties = new ReactiveCollection <AttackRouteListElementViewModel>(); AttackRouteComment = new ReactiveProperty <string>(); CurrentRouteId = new ReactiveProperty <string>(); AddParty.Subscribe(() => { var editWindow = new EditParty(); editWindow.ShowDialog(); }); ImportParty.Subscribe(() => { var importWindow = new ImportParty(); importWindow.ShowDialog(); }); SaveRoute.Subscribe(SaveAttackRoute); NewRoute.Subscribe(CreateNewAttackRoute); OpenRoute.Subscribe(() => { var openRouteWindow = new OpenAttackRoute(OpenAttackRoute); openRouteWindow.ShowDialog(); }); MenuDatabaseUpdateDatabase.Subscribe(() => { Database.I.UpdateDatabase(); }); MenuDatabaseUpdateUnitIcons.Subscribe(() => { var window = new DownloadUnitIcon(); if (!window.IsClosed) { window.ShowDialog(); } }); MenuHelpReportBug.Subscribe(() => { System.Diagnostics.Process.Start("explorer.exe", "https://github.com/hitsub/PriconnePartyManager/issues"); }); MenuHelpCurrentVersion.Subscribe(() => { var assembly = Assembly.GetExecutingAssembly().GetName(); MessageBox.Show($"{assembly.Name}\n{assembly.Version}", "バージョン情報"); }); Database.I.OnAddUserParty += OnAddUserParty; Database.I.OnChangeUserParty += OnChangeUserParty; Database.I.OnRemoveUserParty += OnRemoveUserParty; }
public PartyListElementViewModel(UserParty party, Action <UserParty, bool> onSelect) { Id = party.Id; Party.Value = party; PartyUnits = new ReactiveCollection <UserUnitViewModel>(); Tags = new ReactiveCollection <TagViewModel>(); IsExpandComment.Subscribe(x => { if (x) { Comment.Value = party.Comment; } else { Comment.Value = party.Comment?.GetFirstLine() ?? string.Empty; } }); EditParty.Subscribe(x => { var editWindow = new EditParty((UserParty)x); editWindow.ShowDialog(); }); OnDelete.Subscribe(() => DeleteParty(party)); OnExport.Subscribe(() => ExportParty(party)); OnDuplicate.Subscribe(() => DuplicateParty(party)); OnSelect.Subscribe(() => { IsSelectedRoute.Value = !IsSelectedRoute.Value; onSelect?.Invoke(party, IsSelectedRoute.Value); }); UpdateParty(party); }