/// <summary> /// Called when Remove button was clicked in editor's toolbar /// </summary> /// <param name="flags">Bitmask of REMOVEKIND values, settings parameters for the action</param> /// <param name="addUndoUnit">True if undo unit should be added for the operation</param> /// <param name="undoUnit">Created undo unit (if any)</param> protected void EditorControl_RemoveRequested(REMOVEKIND flags, bool addUndoUnit, out RemoveStringsUndoUnit undoUnit) { undoUnit = null; try { if (!this.Visible) { return; } if (this.SelectedRows.Count == 0) { return; } if ((flags | REMOVEKIND.REMOVE) != REMOVEKIND.REMOVE) { throw new ArgumentException("Cannot delete or exclude strings."); } if ((flags & REMOVEKIND.REMOVE) == REMOVEKIND.REMOVE) { bool dataChanged = false; List <ResXStringGridRow> copyRows = new List <ResXStringGridRow>(SelectedRows.Count); foreach (ResXStringGridRow row in SelectedRows) { if (!row.IsNewRow) { // remove the row from the conflict resolver editorControl.conflictResolver.TryAdd(row.Key, null, row, editorControl.Editor.ProjectItem, null); row.Cells[KeyColumnName].Tag = null; row.IndexAtDeleteTime = row.Index; copyRows.Add(row); Rows.Remove(row); dataChanged = true; } } if (dataChanged) { // create and add the undo unit undoUnit = new RemoveStringsUndoUnit(editorControl, copyRows, this, editorControl.conflictResolver); if (addUndoUnit) { editorControl.Editor.AddUndoUnit(undoUnit); } NotifyItemsStateChanged(); NotifyDataChanged(); VLOutputWindow.VisualLocalizerPane.WriteLine("Removed {0} rows", copyRows.Count); } } } catch (Exception ex) { VLOutputWindow.VisualLocalizerPane.WriteException(ex); VisualLocalizer.Library.Components.MessageBox.ShowException(ex); } }
protected void EditorControl_RemoveRequested(REMOVEKIND flags) { RemoveStringsUndoUnit u; EditorControl_RemoveRequested(flags, true, out u); }