Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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);
            }
        }