public OperationBaseForm Create(FileRenameCommand command, int indexId) { if (command.GetType() == typeof(RemoveSearchTextCommand)) { return(new RemoveStringForm((RemoveSearchTextCommand)command, indexId)); } if (command.GetType() == typeof(RemovePositionTextCommand)) { return(new RemovePositionTextForm((RemovePositionTextCommand)command, indexId)); } if (command.GetType() == typeof(InsertStringCommand)) { return(new InsertStringForm((InsertStringCommand)command, indexId)); } if (command.GetType() == typeof(ReplaceStringCommand)) { return(new CustomReplaceForm((ReplaceStringCommand)command, indexId)); } if (command.GetType() == typeof(CutCopyPasteCommand)) { return(new CopyPasteForm((CutCopyPasteCommand)command, indexId)); } throw new InvalidOperationException(string.Format("No form exists for command: {0}", command.GetType().Name)); }
private void AddCommand(FileRenameCommand command) { if (command.GetType() == typeof(RemoveSearchTextCommand)) { ShowNewOperationForm(new RemoveStringForm()); } else if (command.GetType() == typeof(RemovePositionTextCommand)) { ShowNewOperationForm(new RemovePositionTextForm()); } else if (command.GetType() == typeof(ReplaceStringCommand)) { ShowNewOperationForm(new CustomReplaceForm()); } else if (command.GetType() == typeof(InsertStringCommand)) { ShowNewOperationForm(new InsertStringForm()); } else if (command.GetType() == typeof(CutCopyPasteCommand)) { ShowNewOperationForm(new CopyPasteForm()); } else { opsToDoListBox.Add(command); } opsToDoListBox.SetLastSelected(); }
private void ShowEditOperationForm(FileRenameCommand command) { var form = _operationFormFactory.Create(command, opsToDoListBox.SelectedIndex); form.EditOperationFormEvent += editOperationDoneEventHandler; form.Show(); }
public static bool HasForm(FileRenameCommand command) { return((command.GetType() == typeof(RemoveSearchTextCommand)) || (command.GetType() == typeof(RemovePositionTextCommand)) || (command.GetType() == typeof(InsertStringCommand)) || (command.GetType() == typeof(ReplaceStringCommand)) || (command.GetType() == typeof(CutCopyPasteCommand))); }
protected void InvokeEditOperationFormEvent(FileRenameCommand command, int id) { EditOperationDelegate handler = EditOperationFormEvent; if (handler != null) { handler(command, id); } }
protected void InvokeNewOperationFormEvent(FileRenameCommand command) { NewOperationDelegate handler = NewOperationFormEvent; if (handler != null) { handler(command); } }
private void EditCommand(FileRenameCommand command) { if (OperationFormFactory.HasForm(command)) { ShowEditOperationForm(command); } else { MessageBox.Show("Operation is not editable", "Not editable", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public void Initialize() { _testee = new FileRenameCommand(new FileSystemProxy(), new ImageProcessor(), new FileNameFormatter(), new DirectoryNameFormatter()); }
private void editOperationDoneEventHandler(FileRenameCommand command, int id) { opsToDoListBox.SetSelected(id); opsToDoListBox.Update(command, id); PreviewRenameFilesIfEnabled(); }
private void newOperationDoneEventHandler(FileRenameCommand command) { opsToDoListBox.Add(command); PreviewRenameFilesIfEnabled(); }
/// <summary> /// Add operation to end of list /// </summary> public void Add(FileRenameCommand command) { Items.Add(command); SetLastSelected(); }
/// <summary> /// Update the operation at the specified index position /// </summary> public void Update(FileRenameCommand command, int index) { Items[index] = command; }