private void CloneGameItemClick(object sender, RoutedEventArgs e) { NewGameItem = EnglishGameHelper.CloneItem(SelectedGameItem); ViewDetailItem.DataContext = NewGameItem; _currentAction = ActionState.Add; EditorTitle.Text = "Add new item"; CanCloneAndDeleteVisibility = GetCloneAndDeleteVisibility(); _isRaseSelectionChange = false; DataGridGameItem.SelectedItem = null; _isRaseSelectionChange = true; }
private void ListItemSelectionChange(object sender, SelectionChangedEventArgs e) { if (!_isRaseSelectionChange) { return; } UpdateGameItem = EnglishGameHelper.CloneItem(SelectedGameItem); ViewDetailItem.DataContext = UpdateGameItem; _currentAction = ActionState.Update; EditorTitle.Text = "Selected item detail"; CanCloneAndDeleteVisibility = GetCloneAndDeleteVisibility(); }
private void LoadData() { //Backup update item var backup = new GameItem(); if (_currentAction == ActionState.Update) { backup = EnglishGameHelper.CloneItem(UpdateGameItem); } //Get new list items GameItems = FileManagement.GetListGameData(); IntializeGroupData(); DataGridGameItem.UpdateLayout(); //Show data if (GameItems.Count > 0) { switch (_currentAction) { case ActionState.Add: SelectedGameItem = GameItems.First(x => x.Title == NewGameItem.Title && x.GameName == NewGameItem.GameName); break; case ActionState.Update: SelectedGameItem = GameItems.First(x => x.Title == backup.Title && x.GameName == backup.GameName); break; default: SelectedGameItem = GameItems[0]; break; } _currentAction = ActionState.Update; EditorTitle.Text = "Selected item detail"; ViewDetailItem.DataContext = UpdateGameItem; } else { AddNewGameItemClick(null, null); } CanCloneAndDeleteVisibility = GetCloneAndDeleteVisibility(); }