Esempio n. 1
0
        public override bool GlobalInvoke(CommandID commandID)
        {
            bool b = base.GlobalInvoke(commandID);

            if (commandID == StandardCommands.Copy)
            {
                Copy(commandID, EventArgs.Empty);
            }
            else if (commandID == StandardCommands.Cut)
            {
                Cut(commandID, EventArgs.Empty);
            }
            else if (commandID == StandardCommands.Paste)
            {
                Paste(commandID, EventArgs.Empty);
            }
            else if (commandID == StandardCommands.Undo)
            {
                IDesignerHost  idh        = GetService(typeof(IDesignerHost)) as IDesignerHost;
                UndoEngineImpl undoEngine = idh.GetService(typeof(UndoEngine)) as UndoEngineImpl;
                undoEngine.Undo();
            }
            else if (commandID == StandardCommands.SendToBack)
            {
                ISelectionService selection = GetService(typeof(ISelectionService)) as ISelectionService;
            }
            else if (commandID == StandardCommands.BringToFront)
            {
                ISelectionService selection = GetService(typeof(ISelectionService)) as ISelectionService;
            }
            return(b);
        }
        private void UndoUnits(object owningObject)
        {
            UndoEngineImpl undoEngineImpl = designerhost.GetService(typeof(UndoEngine)) as UndoEngineImpl;

            if (undoEngineImpl.UndoInProgress == true && undoEngineImpl.UndoUnitName != null && undoEngineImpl.UndoUnitName.IndexOf("删除") == -1 && undoEngineImpl.UndoUnitName.IndexOf("创建") == -1 && undoEngineImpl.UndoUnitName.ToLower().IndexOf("remove") == -1 && undoEngineImpl.UndoUnitName.ToLower().IndexOf("create") == -1)
            {
                for (int i = undoStockImpl.Count - 1; i >= 0; i--)
                {
                    UndoUnitImpl undoUnitImpl = undoStockImpl[i];
                    undoUnitImpl.Undo();
                    undoStockImpl.Remove(undoUnitImpl);
                    redoStockImpl.Add(undoUnitImpl);

                    if (owningObject == undoUnitImpl.OwningObject)
                    {
                        break;
                    }
                }

                ISelectionService selection = designerhost.GetService(typeof(ISelectionService)) as ISelectionService;
                selection.SetSelectedComponents(selection.GetSelectedComponents());
            }
        }