private void OnDeleteAttackRoute(UserAttackRoute route) { var routeIndex = Routes.ToList().FindIndex(x => x.Id == route.Id); if (routeIndex >= 0) { Routes.RemoveAt(routeIndex); } }
public void SaveAttackRoute(UserAttackRoute route) { var index = UserAttackRoutes.FindIndex(x => x.Id == route.Id); if (index >= 0) { UserAttackRoutes[index] = route; OnChangeUserAttackRoute?.Invoke(route); FileManager.I.SaveJson(UserAttackRoutes.ToArray()); } else { AddAttackRoute(route); } }
private void SaveAttackRoute() { if (AttackParties.Count == 0) { MessageBox.Show("凸ルートを編成してください"); return; } if (m_CurrentAttackRoute == null) { m_CurrentAttackRoute = new UserAttackRoute(AttackParties.ToArray().Select(x => x.Party), AttackRouteComment.Value); CurrentRouteId.Value = m_CurrentAttackRoute.Id; } else { m_CurrentAttackRoute.Save(AttackParties.Select(x => x.Party), AttackRouteComment.Value); } Database.I.SaveAttackRoute(new UserAttackRoute(m_CurrentAttackRoute)); MessageBox.Show("保存しました"); }
private void CreateNewAttackRoute() { if (m_CurrentAttackRoute != null || AttackParties.Count > 0) { var res = MessageBox.Show("未保存の凸ルートは破棄されます。よろしいですか?", "確認", MessageBoxButton.OKCancel); if (res == MessageBoxResult.Cancel) { return; } } AttackParties.Clear(); m_CurrentAttackRoute = null; CurrentRouteId.Value = string.Empty; AttackRouteComment.Value = string.Empty; foreach (var vm in UserParties) { vm.IsSelectedRoute.Value = false; } }
public UserAttackRouteViewModel(UserAttackRoute route, Action <UserAttackRoute> onOpenRoute, Window window) { Id = route.Id; AttackParties = new ReactiveCollection <AttackRouteListElementViewModel>(); AttackParties.AddRange(route.RouteParties.Select(x => new AttackRouteListElementViewModel(x, null))); Comment = new ReactiveProperty <string>(route.Comment); OpenRoute = new ReactiveCommand(); OpenRoute.Subscribe(() => { onOpenRoute?.Invoke(route); window.Close(); }); DeleteRoute = new ReactiveCommand(); DeleteRoute.Subscribe(() => Database.I.RemoveAttackRoute(route)); Comment.AddTo(m_Disposables); }
private void OpenAttackRoute(UserAttackRoute route) { if (m_CurrentAttackRoute != null || AttackParties.Count > 0) { var res = MessageBox.Show("未保存の凸ルートは破棄されます。よろしいですか?", "確認", MessageBoxButton.OKCancel); if (res == MessageBoxResult.Cancel) { return; } } m_CurrentAttackRoute = route; CurrentRouteId.Value = route.Id; AttackRouteComment.Value = route.Comment ?? string.Empty; AttackParties.Clear(); AttackParties.AddRange(route.RouteParties.Select(x => new AttackRouteListElementViewModel(x, OnUnSelectAttackRoute))); var routeIds = route.RouteParties.Select(x => x.Id).ToArray(); foreach (var vm in UserParties) { vm.IsSelectedRoute.Value = routeIds.Contains(vm.Id); } }
public void RemoveAttackRoute(UserAttackRoute route) { UserAttackRoutes.Remove(route); OnRemoveUserAttackRoute?.Invoke(route); FileManager.I.SaveJson(UserAttackRoutes.ToArray()); }
public void AddAttackRoute(UserAttackRoute route) { UserAttackRoutes.Add(route); OnAddUserAttackRoute?.Invoke(route); FileManager.I.SaveJson(UserAttackRoutes.ToArray()); }