/// <summary> /// Hàm edit các method trên list /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void editMethod_Click(object sender, RoutedEventArgs e) { //int _methodId = methodCombobox.SelectedIndex; var method = methodListview.SelectedItem as Method; if (method != null) { var _methodName = method.Name; switch (_methodName) { case "Replace": { var rep = method as Replace; var _wordFrom = rep.WordFrom; var _wordTo = rep.WordTo; var _caseId = rep.CaseId; var replaceDialog = new ReplaceDialog(_wordFrom, _wordTo, _caseId); replaceDialog.ShowDialog(); if (replaceDialog.DialogResult == true) { //changed data _wordFrom = replaceDialog.wordFrom; _wordTo = replaceDialog.wordTo; _caseId = replaceDialog.caseId; var _s = ""; if (_caseId == 0) { _s = " (Name)"; } else { _s = " (Extension)"; } rep.WordFrom = _wordFrom; rep.WordTo = _wordTo; rep.CaseId = _caseId; rep.Setting = $"Replace - From \"{_wordFrom}\" to \"{_wordTo}\"{_s}"; rep.HashSetting = $"Replace{seperator}{_wordFrom}{seperator}{_wordTo}{seperator}{_caseId}"; } break; } case "NewCase": { var nc = method as NewCase; var _caseId = nc.CaseId; var newCaseDialog = new NewCaseDialog(_caseId); newCaseDialog.ShowDialog(); if (newCaseDialog.DialogResult == true) { _caseId = newCaseDialog.caseId; string _setting = "New Case - "; switch (_caseId) { case 0: { _setting += "Upper Case all characters"; break; } case 1: { _setting += "Lower Case all characters"; break; } case 2: { _setting += "Upper Case the first characters of the words"; break; } } nc.CaseId = _caseId; nc.Setting = _setting; nc.HashSetting = $"NewCase{seperator}{_caseId}"; } break; } case "FullnameNormalize": { //Show nothing break; } case "Move": { var mov = method as Move; var _start = mov.Start; var _end = mov.End; var _caseId = mov.CaseId; var moveDialog = new MoveDialog(_caseId, _start, _end); moveDialog.ShowDialog(); if (moveDialog.DialogResult == true) { //changed data _start = moveDialog.start; _end = moveDialog.end; _caseId = moveDialog.caseId; string _setting = "Move - "; switch (_caseId) { case 0: { _setting += $"Move {_start} - {_end} To begin"; break; } case 1: { _setting += $"Move {_start} - {_end} To end"; break; } } mov.CaseId = _caseId; mov.Setting = _setting; mov.Start = _start; mov.End = _end; mov.HashSetting = $"Move{seperator}{_start}{seperator}{_end}{seperator}{_caseId}"; } break; } case "UniqueName": { //Show nothing break; } } methods.ResetBindings(); } }
private void AddMethod_Click(object sender, RoutedEventArgs e) { int _methodId = methodCombobox.SelectedIndex; switch (_methodId) { case 1: { //add replace var replaceDialog = new ReplaceDialog(); replaceDialog.ShowDialog(); if (replaceDialog.DialogResult == true) { string _wordFrom = replaceDialog.wordFrom; string _wordTo = replaceDialog.wordTo; int _caseId = replaceDialog.caseId; addReplace(_wordFrom, _wordTo, _caseId); } break; } case 2: { //newcase var newCaseDialog = new NewCaseDialog(); newCaseDialog.ShowDialog(); if (newCaseDialog.DialogResult == true) { int _caseId = newCaseDialog.caseId; addNewCase(_caseId); } break; } case 3: { //fullname normalize addFullnameNornmalize(); break; } case 4: { //move var moveDialog = new MoveDialog(); moveDialog.ShowDialog(); if (moveDialog.DialogResult == true) { int _caseId = moveDialog.caseId; int _start = moveDialog.start; int _end = moveDialog.end; addMove(_caseId, _start, _end); } break; } case 5: { //unique name addUniqueName(); break; } } }