private void ButtonClearAll_Click(ProcedureUI.Button sender) { if (EditorMessageBox.ShowQuestion(Translate("Delete all objects and child components?"), MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } var undoMultiAction = new UndoMultiAction(); foreach (var groupOfObjects in GetObjects <Component_GroupOfObjects>()) { var indexes = groupOfObjects.ObjectsGetAll(); if (indexes.Count != 0) { var action = new Component_GroupOfObjects_Editor.UndoActionCreateDelete(groupOfObjects, indexes.ToArray(), false, true); undoMultiAction.AddAction(action); } var components = groupOfObjects.GetComponents(); undoMultiAction.AddAction(new UndoActionComponentCreateDelete(Provider.DocumentWindow.Document, components, false)); } if (undoMultiAction.Actions.Count != 0) { Provider.DocumentWindow.Document.CommitUndoAction(undoMultiAction); } }
private void ButtonClearObjects_Click(ProcedureUI.Button obj) { if (EditorMessageBox.ShowQuestion(Translate("Delete all objects of the element?"), MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } var undoMultiAction = new UndoMultiAction(); foreach (var element in GetObjects <Component_GroupOfObjectsElement>()) { var groupOfObjects = element.Parent as Component_GroupOfObjects; if (groupOfObjects != null) { var indexes = element.GetObjectsOfElement(); if (indexes.Count != 0) { var action = new Component_GroupOfObjects_Editor.UndoActionCreateDelete(groupOfObjects, indexes.ToArray(), false, true); undoMultiAction.AddAction(action); } } } if (undoMultiAction.Actions.Count != 0) { Provider.DocumentWindow.Document.CommitUndoAction(undoMultiAction); } }
private void ButtonResizeMasks_Click(ProcedureUI.Button sender) { var terrain = GetTerrain(); if (terrain == null) { return; } var layers = GetLayersToResizeMask(terrain); if (layers.Count == 0) { return; } var text = string.Format(EditorLocalization.Translate("Terrain", "Resize masks of selected layers to {0}x{0}?"), terrain.GetPaintMaskSizeInteger()); if (EditorMessageBox.ShowQuestion(text, EMessageBoxButtons.OKCancel) == EDialogResult.OK) { var undoMultiAction = new UndoMultiAction(); foreach (var layer in layers) { var oldValue = layer.Mask; layer.Mask = Component_PaintLayer.ResizeMask(layer.Mask, terrain.GetPaintMaskSizeInteger()); var property = (Metadata.Property)layer.MetadataGetMemberBySignature("property:Mask"); var undoItem = new UndoActionPropertiesChange.Item(layer, property, oldValue); undoMultiAction.AddAction(new UndoActionPropertiesChange(undoItem)); } if (undoMultiAction.Actions.Count != 0) { Provider.DocumentWindow.Document.CommitUndoAction(undoMultiAction); } } }
private void ButtonBakeIntoMesh_Click(ProcedureUI.Button sender) { var document = Provider.DocumentWindow.Document; var undoMultiAction = new UndoMultiAction(); var modifiers = GetMeshModifiers(); if (modifiers.Length != 0) { string text; if (modifiers.Length > 1) { text = Translate("Bake selected geometries into the mesh?"); } else { text = Translate("Bake selected geometry into the mesh?"); } if (EditorMessageBox.ShowQuestion(text, System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) { //bake foreach (var modifier in modifiers) { modifier.BakeIntoMesh(document, undoMultiAction); } //delete and add to undo undoMultiAction.AddAction(new UndoActionComponentCreateDelete(document, modifiers, false)); if (undoMultiAction.Actions.Count != 0) { document.CommitUndoAction(undoMultiAction); } } } }
protected virtual void StopToolModify(bool cancel) { //update rendering data foreach (var item in needUpdateRectangle) { item.Terrain.UpdateRenderingData(item.Rectangle, true, true, true); } //update collision if (!cancel) { foreach (var item in needUpdateRectangle) { item.Terrain.UpdateCollisionData(item.Rectangle); ////update MapObject's alignment //{ // const int border = 2; // Vec2I indexMin = item.needUpdateCollisionRectangle.Minimum - new Vec2I( border, border ); // Vec2I indexMax = item.needUpdateCollisionRectangle.Maximum + new Vec2I( border, border ); // item.terrain.ClampCellIndex( ref indexMin ); // item.terrain.ClampCellIndex( ref indexMax ); // Rect rectangle = new Rect( item.terrain.GetPositionXY( indexMin ), // item.terrain.GetPositionXY( indexMax ) ); // if( EntitiesEditManager.Instance != null ) // EntitiesEditManager.Instance.UpdateObjectsVerticalAlignment( rectangle ); //} } } needUpdateRectangle.Clear(); //add to undo if (geometryChangeUndoActions.Count != 0) { if (cancel) { foreach (var action in geometryChangeUndoActions) { action.RestoreOldValues(); } } else { var multiAction = new UndoMultiAction(); foreach (var action in geometryChangeUndoActions) { multiAction.AddAction(action); } DocumentWindow.Document.CommitUndoAction(multiAction); } geometryChangeUndoActions.Clear(); } if (paintSetPropertyUndoActions.Count != 0) { if (cancel) { foreach (var action in paintSetPropertyUndoActions) { action.PerformUndo(); } } else { var multiAction = new UndoMultiAction(); foreach (var action in paintSetPropertyUndoActions) { multiAction.AddAction(action); } DocumentWindow.Document.CommitUndoAction(multiAction); } paintSetPropertyUndoActions.Clear(); } if (paintChangeUndoActions.Count != 0) { if (cancel) { foreach (var action in paintChangeUndoActions) { action.PerformUndo(); } } else { var multiAction = new UndoMultiAction(); foreach (var action in paintChangeUndoActions) { multiAction.AddAction(action); } DocumentWindow.Document.CommitUndoAction(multiAction); } paintChangeUndoActions.Clear(); } //if( holeChangeUndoActions.Count != 0 ) //{ // UndoMultiAction multiAction = new UndoMultiAction(); // foreach( UndoSystem.Action action in holeChangeUndoActions ) // multiAction.AddAction( action ); // UndoSystem.Instance.CommitAction( multiAction ); // holeChangeUndoActions.Clear(); //} toolModify = false; }
//bool CanPaste( out Component destinationParent ) //{ // if( ClipboardManager.CheckAvailableInClipboard<ObjectCutCopyPasteData>() ) // { // destinationParent = ObjectOfWindow as Component; // if( destinationParent != null ) // return true; // } // destinationParent = null; // return false; //} public virtual bool Paste() { if (!CanPaste(out var destinationParent)) { return(false); } var data = ClipboardManager.GetFromClipboard <ObjectCutCopyPasteData>(); if (data != null) { var components = new List <Component>(); foreach (var obj in data.objects) { var c = obj as Component; if (c != null) { components.Add(c); } } //create new objects var newObjects = new List <Component>(); Vector3 addToPosition = Vector3.Zero; for (int n = 0; n < components.Count; n++) { var c = components[n]; var cloned = c.Clone(); if (destinationParent.GetComponent(c.Name) == null) { cloned.Name = c.Name; } else { cloned.Name = destinationParent.Components.GetUniqueName(c.Name, true, 2); } destinationParent.AddComponent(cloned); newObjects.Add(cloned); } if (data.cut) { //cut if (data.documentWindow.Document != Document) { //another document { var action = new UndoActionComponentCreateDelete(data.documentWindow.Document, components, false); data.documentWindow.Document.UndoSystem.CommitAction(action); data.documentWindow.Document.Modified = true; } { var action = new UndoActionComponentCreateDelete(Document, newObjects, true); Document.UndoSystem.CommitAction(action); Document.Modified = true; } } else { //same document var multiAction = new UndoMultiAction(); multiAction.AddAction(new UndoActionComponentCreateDelete(Document, components, false)); multiAction.AddAction(new UndoActionComponentCreateDelete(Document, newObjects, true)); Document.UndoSystem.CommitAction(multiAction); Document.Modified = true; } } else { //copy var action = new UndoActionComponentCreateDelete(Document, newObjects, true); Document.UndoSystem.CommitAction(action); Document.Modified = true; } } return(true); }