コード例 #1
0
        void rpt_DesignerLoaded(object sender, DesignerLoadedEventArgs e)
        {
            _DesignerHost = e.DesignerHost;
            if (_DataSource == null)
            {
                _DataSource = xrDesignPanel1.Report.DataSource;
            }
            IToolboxService ts = (IToolboxService)e.DesignerHost
                                 .GetService(typeof(IToolboxService));

            ts.AddToolboxItem(new ToolboxItem(typeof(xrFunction)));
            ts.AddToolboxItem(new ToolboxItem(typeof(xrPictureVar)));

            IMenuCommandService ms = (IMenuCommandService)e.DesignerHost
                                     .GetService(typeof(IMenuCommandService));

            MenuCommand fileOpenCommand = ms.FindCommand(UICommands.OpenFile);

            ms.RemoveCommand(fileOpenCommand);
            ms.AddCommand(new MenuCommand(new EventHandler(OnOpenFile),
                                          UICommands.OpenFile));

            MenuCommand CloseCommand = ms.FindCommand(UICommands.Closing);

            if (CloseCommand != null)
            {
                ms.RemoveCommand(CloseCommand);
            }
            ms.AddCommand(new MenuCommand(new EventHandler(OnCloseFile),
                                          UICommands.Closing));
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        private void UpdateUndoRedoMenuCommandsStatus()
        {
            IMenuCommandService menuCommandService = service.GetService(typeof(IMenuCommandService)) as IMenuCommandService;

            if (menuCommandService != null)
            {
                MenuCommand undoMenuCommand = menuCommandService.FindCommand(StandardCommands.Undo);
                MenuCommand redoMenuCommand = menuCommandService.FindCommand(StandardCommands.Redo);

                if (undoMenuCommand != null)
                {
                    undoMenuCommand.Enabled = currentPos > 0;
                }
                if (redoMenuCommand != null)
                {
                    redoMenuCommand.Enabled = currentPos < this.undoUnitList.Count;
                }
                editToolStripMenuItem.DropDownItems[redoIndex].Enabled = currentPos < this.undoUnitList.Count;
                editToolStripMenuItem.DropDownItems[undoIndex].Enabled = currentPos > 0;
                if (cassPropertyGrid != null)
                {
                    cassPropertyGrid.Refresh();
                }
            }
        }
コード例 #3
0
        private void UpdateUndoRedoMenuCommandsStatus()
        {
            // this components maybe cached.
            IMenuCommandService menuCommandService =
                this.GetService(typeof(IMenuCommandService)) as IMenuCommandService;
            MenuCommand undoMenuCommand = menuCommandService.FindCommand(StandardCommands.Undo);
            MenuCommand redoMenuCommand = menuCommandService.FindCommand(StandardCommands.Redo);

            if (undoMenuCommand != null)
            {
                undoMenuCommand.Enabled = this.currentPos > 0;
            }
            if (redoMenuCommand != null)
            {
                redoMenuCommand.Enabled = this.currentPos < this.undoUnitList.Count;
            }
        }
コード例 #4
0
        private void UpdateUndoRedoMenuCommandsStatus()
        {
            IMenuCommandService menuCommandService = base.GetService(typeof(IMenuCommandService)) as IMenuCommandService;

            if (menuCommandService != null)
            {
                MenuCommand menuCommand  = menuCommandService.FindCommand(StandardCommands.Undo);
                MenuCommand menuCommand2 = menuCommandService.FindCommand(StandardCommands.Redo);
                if (menuCommand != null)
                {
                    menuCommand.Enabled = (this.currentPos > 0 && this.undoUnitList.Count > 0);
                }
                if (menuCommand2 != null)
                {
                    menuCommand2.Enabled = (this.currentPos < this.undoUnitList.Count && this.undoUnitList.Count > 0);
                }
            }
        }
コード例 #5
0
        private static void UpdateAnalyzeCommandsState(IMenuCommandService menuCommandService, bool enabled)
        {
            var analyzeProjectCommandId  = new CommandID(Guids.SariferCommandSet, SariferPackageCommandIds.AnalyzeProject);
            var analyzeSolutionCommandId = new CommandID(Guids.SariferCommandSet, SariferPackageCommandIds.AnalyzeSolution);
            var analyzeFileCommandId     = new CommandID(Guids.SariferCommandSet, SariferPackageCommandIds.AnalyzeFile);

            MenuCommand analyzeProjectCommand = menuCommandService.FindCommand(analyzeProjectCommandId);

            analyzeProjectCommand.Enabled = enabled;

            MenuCommand analyzeSolutionCommand = menuCommandService.FindCommand(analyzeSolutionCommandId);

            analyzeSolutionCommand.Enabled = enabled;

            MenuCommand analyzeFileCommand = menuCommandService.FindCommand(analyzeFileCommandId);

            analyzeFileCommand.Enabled = enabled;
        }
コード例 #6
0
        private void SetCommandVisibility(int cmdID, bool visible)
        {
            var         newCmdID = new CommandID(CommandSet, cmdID);
            MenuCommand mc       = menuCommandService.FindCommand(newCmdID);

            if (mc != null)
            {
                mc.Visible = visible;
            }
        }
コード例 #7
0
        protected virtual void AddToMenuCommandService(Microsoft.VisualStudio.Shell.OleMenuCommand cmd)
        {
            IMenuCommandService mcs = (IMenuCommandService)Package.GetServiceAsDynamic(typeof(IMenuCommandService));
            var found = mcs.FindCommand(cmd.CommandID);

            if (found == null)
            {
                mcs.AddCommand(cmd);
            }
        }
コード例 #8
0
        /// <summary>
        /// Displsys the Add New dialog box
        /// </summary>
        /// <returns></returns>
        protected override ExecutionResult OnExecute()
        {
            IMenuCommandService menuCommandService = GetService <IMenuCommandService>();

            if (menuCommandService != null)
            {
                MenuCommand command = menuCommandService.FindCommand(this.template.Command);
                command.Invoke();
            }
            return(ExecutionResult.Finish);
        }
コード例 #9
0
        private void Report_DesignerLoaded(object sender, DesignerLoadedEventArgs e)
        {
            IMenuCommandService CommandServ = e.DesignerHost.GetService(typeof(IMenuCommandService)) as IMenuCommandService;

            MenuCommand cmd = CommandServ.FindCommand(UICommands.OpenFile);

            if (cmd != null)
            {
                CommandServ.RemoveCommand(cmd);
            }
        }
コード例 #10
0
 private void OnDelete_Clicked(object sender, EventArgs args)
 {
     if (_workspace.ActiveDocument != null)
     {
         IMenuCommandService menuCommands = _workspace.ActiveDocument.DesignSurface.GetService(typeof(IMenuCommandService)) as IMenuCommandService;
         if (menuCommands != null)
         {
             menuCommands.FindCommand(StandardCommands.Delete).Invoke();
         }
     }
 }
コード例 #11
0
ファイル: IVsTextLinesExtensions.cs プロジェクト: yaram/Eto
        public static void AddCommand(this IMenuCommandService mcs, Guid menuGroup, int cmdID, Action commandEvent, Action <OleMenuCommand> queryEvent = null)
        {
            var cmd = mcs.FindCommand(new CommandID(menuGroup, cmdID));

            if (cmd != null)
            {
                mcs.RemoveCommand(cmd);
            }
            var command = CreateCommand(menuGroup, cmdID, commandEvent, queryEvent);

            // Add the command using our IMenuCommandService instance
            mcs.AddCommand(command);
        }
コード例 #12
0
        private void OnKeyCancel(object sender, EventArgs e)
        {
            IMenuCommandService service = (IMenuCommandService)this.host.GetService(typeof(IMenuCommandService));

            if (service != null)
            {
                MenuCommand command = service.FindCommand(StandardCommands.TabOrder);
                if (command != null)
                {
                    command.Invoke();
                }
            }
        }
コード例 #13
0
 public void HideMenuCommands()
 {
     foreach (var menuCommand in _menuCommands)
     {
         var existingMenuCommand = _menuCommandService.FindCommand(menuCommand.CommandID);
         if (existingMenuCommand != null)
         {
             _menuCommandService.RemoveCommand(existingMenuCommand);
         }
         _menuCommandService.AddCommand(menuCommand);
         menuCommand.Visible = false;
     }
 }
        private void xrDesignPanel1_DesignerHostLoaded(object sender, DevExpress.XtraReports.UserDesigner.DesignerLoadedEventArgs e)
        {
            report        = e.DesignerHost.RootComponent as XtraReport;
            designerHost  = e.DesignerHost;
            selectionServ = e.DesignerHost.GetService(typeof(ISelectionService)) as ISelectionService;
            changeServ    = e.DesignerHost.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
            IMenuCommandService menuCommandService = e.DesignerHost.GetService(typeof(IMenuCommandService)) as IMenuCommandService;

            menuCommandService.RemoveCommand(menuCommandService.FindCommand(FieldListCommands.AddParameter));
            MenuCommand command = new MenuCommand(new EventHandler(AddParameter), FieldListCommands.AddParameter);

            menuCommandService.AddCommand(command);
        }
コード例 #15
0
        private MenuCommand FindCommand(Guid guid, int id, ref int hrReturn)
        {
            hrReturn = (int)Microsoft.VisualStudio.OLE.Interop.Constants.OLECMDERR_E_UNKNOWNGROUP;

            MenuCommand result = null;

            //first query the IMenuCommandService and ask it to FindCommand
            IMenuCommandService menuCommandService = GetService(typeof(IMenuCommandService)) as IMenuCommandService;

            if (menuCommandService != null)
            {
                result = menuCommandService.FindCommand(new CommandID(guid, (int)id));
            }
            //if the IMenuCommandService cames back w/o a command, then ask ourselves
            if (result == null && this != menuCommandService)
            {
                result = FindCommand(guid, (int)id);
            }

            if (result == null)
            {
                ICollection commands = GetCommandList(guid);
                if (commands != null)
                {
                    // The default error now must be "Not Supported" because the command group is known
                    hrReturn = (int)Microsoft.VisualStudio.OLE.Interop.Constants.OLECMDERR_E_NOTSUPPORTED;
                    Debug.WriteLineIf(MENUSERVICE.TraceVerbose, "\t...VSMCS Found group");
                    // Get the list of command inside this group
                    foreach (MenuCommand command in commands)
                    {
                        // we are looping again on the list of commands to check the DynamicItemMatch
                        // but this is unavoidable in this context....
                        // If the command is a OleMenuCommand, then we can try to do a dynamic match
                        OleMenuCommand vsCommand = command as OleMenuCommand;
                        if ((null != vsCommand) && (vsCommand.DynamicItemMatch(id)))
                        {
                            Debug.WriteLineIf(MENUSERVICE.TraceVerbose, "\t...VSMCS Found command2");
                            hrReturn = NativeMethods.S_OK;
                            result   = command;
                        }
                    }
                }
            }
            else
            {
                Debug.WriteLineIf(MENUSERVICE.TraceVerbose, "\t... VSMCS Found command");
                hrReturn = NativeMethods.S_OK;
            }
            return(result);
        }
コード例 #16
0
        /// <summary>
        ///  Closes the tab order UI.
        /// </summary>
        private void OnKeyCancel(object sender, EventArgs e)
        {
            IMenuCommandService mcs = (IMenuCommandService)host.GetService(typeof(IMenuCommandService));

            Debug.Assert(mcs != null, "No menu command service, can't get out of tab order UI");
            if (mcs != null)
            {
                MenuCommand mc = mcs.FindCommand(StandardCommands.TabOrder);
                Debug.Assert(mc != null, "No tab order menu command, can't get out of tab order UI");
                if (mc != null)
                {
                    mc.Invoke();
                }
            }
        }
コード例 #17
0
        private void RefreshUIState()
        {
            //Update the cursor
            WorkflowView parentView = ParentView;

            if (!CanContinueZooming)
            {
                parentView.Cursor = ZoomingMessageFilter.ZoomDisabledCursor;
            }
            else if (this.currentState == ZoomState.In)
            {
                parentView.Cursor = ZoomingMessageFilter.ZoomInCursor;
            }
            else
            {
                parentView.Cursor = ZoomingMessageFilter.ZoomOutCursor;
            }

            //Update the fast zoom
            if (this.fastZoomingMessageFilter == null && CanContinueZooming && this.currentState == ZoomState.In)
            {
                this.fastZoomingMessageFilter = new DragRectangleMessageFilter();
                this.fastZoomingMessageFilter.DragComplete += new EventHandler(OnZoomRectComplete);
                parentView.AddDesignerMessageFilter(this.fastZoomingMessageFilter);
            }
            else if (this.fastZoomingMessageFilter != null && (!CanContinueZooming || this.currentState != ZoomState.In))
            {
                this.fastZoomingMessageFilter.DragComplete -= new EventHandler(OnZoomRectComplete);
                parentView.RemoveDesignerMessageFilter(this.fastZoomingMessageFilter);
                this.fastZoomingMessageFilter = null;
            }

            //Update the menu
            IMenuCommandService menuCommandService = GetService(typeof(IMenuCommandService)) as IMenuCommandService;

            if (menuCommandService != null)
            {
                foreach (CommandID affectedCommand in CommandSet.NavigationToolCommandIds)
                {
                    MenuCommand menuCommand = menuCommandService.FindCommand(affectedCommand);
                    if (menuCommand != null && menuCommand.Enabled)
                    {
                        menuCommand.Checked = (menuCommand.CommandID == ((this.initialState == ZoomState.In) ? WorkflowMenuCommands.ZoomIn : WorkflowMenuCommands.ZoomOut));
                    }
                }
            }
        }
コード例 #18
0
        public void TryToShowMenuCommands()
        {
            if (!_shouldDisplay())
            {
                return;
            }

            foreach (var menuCommand in _menuCommands)
            {
                var existingMenuCommand = _menuCommandService.FindCommand(menuCommand.CommandID);
                if (existingMenuCommand != null)
                {
                    _menuCommandService.RemoveCommand(existingMenuCommand);
                }
                _menuCommandService.AddCommand(menuCommand);
            }
        }
コード例 #19
0
 private void OnSelectionChanged(object sender, EventArgs e)
 {
     if (this.selectionSvc.PrimarySelection == this.panel)
     {
         this.designerShortCutCommand = new MenuCommand(new EventHandler(this.OnKeyShowDesignerActions), MenuCommands.KeyInvokeSmartTag);
         IMenuCommandService service = (IMenuCommandService)this.GetService(typeof(IMenuCommandService));
         if (service != null)
         {
             this.oldShortCutCommand = service.FindCommand(MenuCommands.KeyInvokeSmartTag);
             if (this.oldShortCutCommand != null)
             {
                 service.RemoveCommand(this.oldShortCutCommand);
             }
             service.AddCommand(this.designerShortCutCommand);
         }
     }
 }
コード例 #20
0
        private void RestoreUIState()
        {
            IMenuCommandService service = base.GetService(typeof(IMenuCommandService)) as IMenuCommandService;

            if (service != null)
            {
                foreach (CommandID did in CommandSet.NavigationToolCommandIds)
                {
                    MenuCommand command = service.FindCommand(did);
                    if ((command != null) && command.Enabled)
                    {
                        command.Checked = command.CommandID == this.previousCommand;
                    }
                }
            }
            base.ParentView.Cursor = this.previousCursor;
        }
コード例 #21
0
        private void RestoreUIState()
        {
            IMenuCommandService menuCommandService = GetService(typeof(IMenuCommandService)) as IMenuCommandService;

            if (menuCommandService != null)
            {
                foreach (CommandID affectedCommand in CommandSet.NavigationToolCommandIds)
                {
                    MenuCommand menuCommand = menuCommandService.FindCommand(affectedCommand);
                    if (menuCommand != null && menuCommand.Enabled)
                    {
                        menuCommand.Checked = (menuCommand.CommandID == this.previousCommand);
                    }
                }
            }

            ParentView.Cursor = this.previousCursor;
        }
コード例 #22
0
        private void RefreshUIState()
        {
            base.ParentView.Cursor = this.panningActive ? PanBeganCursor : PanReadyCursor;
            IMenuCommandService service = base.GetService(typeof(IMenuCommandService)) as IMenuCommandService;

            if (service != null)
            {
                CommandID[] didArray = new CommandID[] { WorkflowMenuCommands.ZoomIn, WorkflowMenuCommands.ZoomOut, WorkflowMenuCommands.Pan, WorkflowMenuCommands.DefaultFilter };
                foreach (CommandID did in didArray)
                {
                    MenuCommand command = service.FindCommand(did);
                    if ((command != null) && command.Enabled)
                    {
                        command.Checked = command.CommandID == WorkflowMenuCommands.Pan;
                    }
                }
            }
        }
コード例 #23
0
 private bool IsMenuCommandEnabled(CommandID commandID)
 {
     if (this.designSurface == null)
     {
         return false;
     }
     IMenuCommandService service = (IMenuCommandService) this.designSurface.GetService(typeof(IMenuCommandService));
     if (service == null)
     {
         return false;
     }
     System.ComponentModel.Design.MenuCommand command = service.FindCommand(commandID);
     if (command == null)
     {
         return false;
     }
     return command.Enabled;
 }
コード例 #24
0
        /// <summary>
        /// Override this method to intercept the IOleCommandTarget::Exec call.
        /// </summary>
        /// <returns>Usually returns 0 if ok, or OLECMDERR_E_NOTSUPPORTED</returns>
        protected virtual int ExecCommand(ref Guid guidCmdGroup, uint cmdId, uint cmdExecOptions, IntPtr pvaIn, IntPtr pvaOut)
        {
            IServiceProvider sp = this.Site;

            if (sp != null)
            {
                // Delegate to menu command service just in case the child control registered some MenuCommands with it.
                IMenuCommandService svc = sp.GetService(typeof(IMenuCommandService)) as IMenuCommandService;
                if (svc != null)
                {
                    MenuCommand cmd = svc.FindCommand(new CommandID(guidCmdGroup, (int)cmdId));
                    if (cmd != null)
                    {
                        cmd.Invoke();
                    }
                }
            }
            return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED);
        }
コード例 #25
0
        private void AddAttachCommand(IMenuCommandService mcs, int commandId, AttachDescriptor descriptor)
        {
            if (mcs == null)
            {
                return;
            }

            var commandIdentifier = new CommandID(ATAGuids.guidAnotherAttachToAnyCmdGroup, commandId);
            var existing          = mcs.FindCommand(commandIdentifier);

            if (existing != null)
            {
                ((DescriptorMenuCommand)existing).Descriptor = descriptor;
                return;
            }
            var menuItem = new DescriptorMenuCommand(MenuCommandInvokeHandler, commandId, descriptor);

            mcs.AddCommand(menuItem);
        }
コード例 #26
0
        private void RefreshUIState()
        {
            WorkflowView parentView = base.ParentView;

            if (!this.CanContinueZooming)
            {
                parentView.Cursor = ZoomDisabledCursor;
            }
            else if (this.currentState == ZoomState.In)
            {
                parentView.Cursor = ZoomInCursor;
            }
            else
            {
                parentView.Cursor = ZoomOutCursor;
            }
            if (((this.fastZoomingMessageFilter == null) && this.CanContinueZooming) && (this.currentState == ZoomState.In))
            {
                this.fastZoomingMessageFilter = new DragRectangleMessageFilter();
                this.fastZoomingMessageFilter.DragComplete += new EventHandler(this.OnZoomRectComplete);
                parentView.AddDesignerMessageFilter(this.fastZoomingMessageFilter);
            }
            else if ((this.fastZoomingMessageFilter != null) && (!this.CanContinueZooming || (this.currentState != ZoomState.In)))
            {
                this.fastZoomingMessageFilter.DragComplete -= new EventHandler(this.OnZoomRectComplete);
                parentView.RemoveDesignerMessageFilter(this.fastZoomingMessageFilter);
                this.fastZoomingMessageFilter = null;
            }
            IMenuCommandService service = base.GetService(typeof(IMenuCommandService)) as IMenuCommandService;

            if (service != null)
            {
                foreach (CommandID did in CommandSet.NavigationToolCommandIds)
                {
                    MenuCommand command = service.FindCommand(did);
                    if ((command != null) && command.Enabled)
                    {
                        command.Checked = command.CommandID == ((this.initialState == ZoomState.In) ? WorkflowMenuCommands.ZoomIn : WorkflowMenuCommands.ZoomOut);
                    }
                }
            }
        }
コード例 #27
0
        private void RefreshUIState()
        {
            //Update the cursor
            ParentView.Cursor = (this.panningActive) ? PanningMessageFilter.PanBeganCursor : PanningMessageFilter.PanReadyCursor;

            //Update the menu command
            IMenuCommandService menuCommandService = GetService(typeof(IMenuCommandService)) as IMenuCommandService;

            if (menuCommandService != null)
            {
                CommandID[] affectedCommands = new CommandID[] { WorkflowMenuCommands.ZoomIn, WorkflowMenuCommands.ZoomOut, WorkflowMenuCommands.Pan, WorkflowMenuCommands.DefaultFilter };
                foreach (CommandID affectedCommand in affectedCommands)
                {
                    MenuCommand menuCommand = menuCommandService.FindCommand(affectedCommand);
                    if (menuCommand != null && menuCommand.Enabled)
                    {
                        menuCommand.Checked = (menuCommand.CommandID == WorkflowMenuCommands.Pan);
                    }
                }
            }
        }
コード例 #28
0
        /// <summary>
        /// 判断一个命令标识符是否可用
        /// </summary>
        /// <param name="commandID"></param>
        /// <returns></returns>
        public bool IsMenuCommandEnabled(CommandID commandID)
        {
            if (_designSurface == null)
            {
                return(false);
            }

            if (_menuCommandService == null)
            {
                return(false);
            }

            System.ComponentModel.Design.MenuCommand menuCommand = _menuCommandService.FindCommand(commandID);
            if (menuCommand == null)
            {
                return(false);
            }

            //int status = menuCommand.OleStatus;
            return(menuCommand.Enabled);
        }
コード例 #29
0
        private bool IsMenuCommandEnabled(CommandID commandID)
        {
            if (designSurface == null)
            {
                return(false);
            }

            IMenuCommandService menuCommandService = (IMenuCommandService)designSurface.GetService(typeof(IMenuCommandService));

            if (menuCommandService == null)
            {
                return(false);
            }

            System.ComponentModel.Design.MenuCommand menuCommand = menuCommandService.FindCommand(commandID);
            if (menuCommand == null)
            {
                return(false);
            }
            return(menuCommand.Enabled);
        }
コード例 #30
0
 private MenuCommand FindCommand(CommandID commandID, IMenuCommandService menuService)
 {
     System.Windows.Forms.Design.Behavior.Behavior appropriateBehavior = this.GetAppropriateBehavior(this.hitTestedGlyph);
     if (appropriateBehavior != null)
     {
         if (appropriateBehavior.DisableAllCommands)
         {
             MenuCommand command = menuService.FindCommand(commandID);
             if (command != null)
             {
                 command.Enabled = false;
             }
             return command;
         }
         MenuCommand command2 = appropriateBehavior.FindCommand(commandID);
         if (command2 != null)
         {
             return command2;
         }
     }
     return menuService.FindCommand(commandID);
 }
コード例 #31
0
		/// <summary>
		/// Called by the framework when the designer is being initialized with the designed control
		/// </summary>
		/// <param name="component"></param>
		public override void Initialize(IComponent component)
		{
			base.Initialize(component);

			if (Control is TreeView)
			{
				try
				{
					m_oSelectionService = (ISelectionService) GetService(typeof (ISelectionService));
				}
				catch
				{
				}
				try
				{
					m_oSelectionService.SelectionChanged += new EventHandler(this.OnSelectionServiceChanged);
				}
				catch
				{
				}
				try
				{
					m_oDesignerHost = (IDesignerHost) GetService(typeof (IDesignerHost));
				}
				catch
				{
				}
				try
				{
					m_oMenuService = (IMenuCommandService) GetService(typeof (IMenuCommandService));
				}
				catch
				{
				}
				try
				{
					m_oDesignerSerializationService = (IDesignerSerializationService) GetService(typeof (IDesignerSerializationService));
				}
				catch
				{
				}
				try
				{
					m_oToolboxService = (IToolboxService) GetService(typeof (IToolboxService));
				}
				catch
				{
				}
				try
				{
					m_oUIService = (IUIService) GetService(typeof (IUIService));
				}
				catch
				{
				}
				try
				{
					m_oComponentChangeService = (IComponentChangeService) GetService(typeof (IComponentChangeService));
				}
				catch
				{
				}

				m_oTreeView = (TreeView) Control;
				m_oTreeView.m_bFocus = true;
				m_oTreeView.ClearAllSelection();
				m_oTreeView.DesignerHost = m_oDesignerHost;
				m_oTreeView.IsDesignMode = true;

				if (m_bFirstTime == true)
				{
					OnComponentCreated(m_oTreeView);
					m_bFirstTime = false;
				}

				try
				{
					m_oComponentAddedHandler = new ComponentEventHandler(this.OnComponentAdded);
				}
				catch
				{
				}
				try
				{
					m_oComponentRemovingHandler = new ComponentEventHandler(this.OnComponentRemoving);
				}
				catch
				{
				}
				try
				{
					m_oComponentChangeService.ComponentAdded += m_oComponentAddedHandler;
				}
				catch
				{
				}
				try
				{
					m_oComponentChangeService.ComponentRemoving += m_oComponentRemovingHandler;
				}
				catch
				{
				}
				try
				{
					m_oNodeParentChanged = new EventHandler(this.OnNodeParentChanged);
				}
				catch
				{
				}

				try
				{
					m_oOldCmdCopy = m_oMenuService.FindCommand(StandardCommands.Copy);
				}
				catch
				{
				}
				try
				{
					m_oOldCmdPaste = m_oMenuService.FindCommand(StandardCommands.Paste);
				}
				catch
				{
				}
				try
				{
					m_oOldCmdCut = m_oMenuService.FindCommand(StandardCommands.Cut);
				}
				catch
				{
				}
				try
				{
					m_oOldBringFront = m_oMenuService.FindCommand(StandardCommands.BringToFront);
				}
				catch
				{
				}
				try
				{
					m_oOldSendBack = m_oMenuService.FindCommand(StandardCommands.SendToBack);
				}
				catch
				{
				}
				try
				{
					m_oOldAlignGrid = m_oMenuService.FindCommand(StandardCommands.AlignToGrid);
				}
				catch
				{
				}
				try
				{
					m_oOldLockControls = m_oMenuService.FindCommand(StandardCommands.LockControls);
				}
				catch
				{
				}
				try
				{
					m_oOldDelete = m_oMenuService.FindCommand(StandardCommands.Delete);
				}
				catch
				{
				}

				try
				{
					m_oNewCmdCopy = new MenuCommand(new EventHandler(this.OnMenuCopy), StandardCommands.Copy);
				}
				catch
				{
				}
				try
				{
					m_oNewCmdPaste = new MenuCommand(new EventHandler(this.OnMenuPaste), StandardCommands.Paste);
				}
				catch
				{
				}

				if (TreeViewDesigner.MenuAdded == false)
				{
					try
					{
						m_oMenuService.RemoveCommand(m_oOldCmdCopy);
					}
					catch
					{
					}
					try
					{
						m_oMenuService.RemoveCommand(m_oOldCmdPaste);
					}
					catch
					{
					}
					try
					{
						m_oMenuService.AddCommand(m_oNewCmdCopy);
					}
					catch
					{
					}
					try
					{
						m_oMenuService.AddCommand(m_oNewCmdPaste);
					}
					catch
					{
					}

					TreeViewDesigner.MenuAdded = true;
				}

				m_oTreeView.Invalidate();

				#region action menus

				#region node menu

				m_oActionMenuNode = new ActionMenuNative();
				m_oActionMenuNode.Width = 170;
				m_oActionMenuNode.Title = "Node Action Menu";

				ActionMenuGroup oMenuGroup = m_oActionMenuNode.AddMenuGroup("Editing");
				oMenuGroup.Expanded = true;
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Add Node");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Delete Node");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Add Panel");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "-");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Clear Content");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Delete TreeView");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "-");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Copy");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Paste");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "-");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Properties");
				oMenuGroup = m_oActionMenuNode.AddMenuGroup("Arranging");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Expand");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Collapse");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Top");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Bottom");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Up");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Down");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Left");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Right");
				oMenuGroup = m_oActionMenuNode.AddMenuGroup("Color Schemes");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Default");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Forest");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Gold");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Ocean");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Rose");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Silver");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Sky");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Sunset");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Wood");

				m_oActionMenuNode.ItemClick += new ActionMenuNative.ItemClickEventHandler(this.OnActionMenuNodeItemClicked);

				#endregion			

				#region TreeView menu

				m_oActionMenuTreeView = new ActionMenuNative();
				m_oActionMenuTreeView.Width = 170;
				m_oActionMenuTreeView.Title = "TreeView Action Menu";

				oMenuGroup = m_oActionMenuTreeView.AddMenuGroup("Editing");
				oMenuGroup.Expanded = true;
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Add Node");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Color Scheme Picker...");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "-");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Clear Content");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Delete TreeView");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "-");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Copy");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Paste");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "-");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Properties");
				oMenuGroup = m_oActionMenuTreeView.AddMenuGroup("Arranging");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Expand All");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Collapse All");
				oMenuGroup = m_oActionMenuTreeView.AddMenuGroup("Layout");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Bring to Front");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Send to Back");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Align to Grid");
				m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Lock Controls");

				m_oActionMenuTreeView.ItemClick += new ActionMenuNative.ItemClickEventHandler(this.OnActionMenuTreeViewItemClicked);

				#endregion

				#endregion

				// enable the drag drop operations
				m_oTreeView.AllowDrop = true;
				this.EnableDragDrop(true);

				m_oTreeView.CollapseAll();
				m_oSelector.SelectionService = m_oSelectionService;
				m_oSelector.TreeView = m_oTreeView;
			}
		}
コード例 #32
0
 public MenuCommand FindCommand(CommandID commandId)
 {
     return(_menuCommandService.FindCommand(commandId));
 }