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));
        }
 internal static void ShowDesignerVerbs(ActivityDesigner designer, Point location, ICollection <DesignerVerb> designerVerbs)
 {
     if (!ShowingMenu && (designerVerbs.Count != 0))
     {
         IMenuCommandService service = designer.Activity.Site.GetService(typeof(IMenuCommandService)) as IMenuCommandService;
         if (service == null)
         {
             throw new Exception(SR.GetString("General_MissingService", new object[] { typeof(IMenuCommandService).FullName }));
         }
         try
         {
             foreach (DesignerVerb verb in designerVerbs)
             {
                 service.AddCommand(verb);
             }
             ShowingMenu = true;
             service.ShowContextMenu(WorkflowMenuCommands.DesignerActionsMenu, location.X - 2, location.Y + 1);
         }
         finally
         {
             ShowingMenu = false;
             foreach (DesignerVerb verb2 in designerVerbs)
             {
                 service.RemoveCommand(verb2);
             }
         }
     }
 }
示例#3
0
        /// <summary>
        ///  Called when it is time for the tab order UI to go away.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (region != null)
                {
                    region.Dispose();
                    region = null;
                }

                if (host != null)
                {
                    IOverlayService os = (IOverlayService)host.GetService(typeof(IOverlayService));
                    if (os != null)
                    {
                        os.RemoveOverlay(this);
                    }

                    IEventHandlerService ehs = (IEventHandlerService)host.GetService(typeof(IEventHandlerService));
                    if (ehs != null)
                    {
                        ehs.PopHandler(this);
                    }

                    IMenuCommandService mcs = (IMenuCommandService)host.GetService(typeof(IMenuCommandService));
                    if (mcs != null)
                    {
                        foreach (MenuCommand mc in newCommands)
                        {
                            mcs.RemoveCommand(mc);
                        }
                    }

                    // We sync add, remove and change events so we remain in sync with any nastiness that the
                    // form may pull on us.
                    //
                    IComponentChangeService cs = (IComponentChangeService)host.GetService(typeof(IComponentChangeService));
                    if (cs != null)
                    {
                        cs.ComponentAdded   -= new ComponentEventHandler(OnComponentAddRemove);
                        cs.ComponentRemoved -= new ComponentEventHandler(OnComponentAddRemove);
                        cs.ComponentChanged -= new ComponentChangedEventHandler(OnComponentChanged);
                    }

                    IHelpService hs = (IHelpService)host.GetService(typeof(IHelpService));
                    if (hs != null)
                    {
                        hs.RemoveContextAttribute("Keyword", "TabOrderView");
                    }

                    host = null;
                }
            }

            base.Dispose(disposing);
        }
        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);
            }
        }
示例#5
0
 private void DeinitializeCommands()
 {
     if (commands != null)
     {
         IMenuCommandService mcs = GetService <IMenuCommandService>(true);
         foreach (MenuCommand command in commands)
         {
             mcs.RemoveCommand(command);
         }
         commands = null;
     }
 }
示例#6
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;
     }
 }
示例#7
0
        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);
        }
示例#8
0
            private void RemoveCommands(MenuCommand[] commands)
            {
                IMenuCommandService menuService = myMenuService;

                if (menuService != null)
                {
                    int count = commands.Length;
                    for (int i = 0; i < count; ++i)
                    {
                        menuService.RemoveCommand(commands[i]);
                    }
                }
            }
        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);
        }
示例#10
0
 private void OnSelectionChanging(object sender, EventArgs e)
 {
     if (this.designerShortCutCommand != null)
     {
         IMenuCommandService service = (IMenuCommandService)this.GetService(typeof(IMenuCommandService));
         if (service != null)
         {
             service.RemoveCommand(this.designerShortCutCommand);
             if (this.oldShortCutCommand != null)
             {
                 service.AddCommand(this.oldShortCutCommand);
             }
         }
         this.designerShortCutCommand = null;
     }
 }
示例#11
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);
         }
     }
 }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.region != null)
         {
             this.region.Dispose();
             this.region = null;
         }
         if (this.host != null)
         {
             IOverlayService service = (IOverlayService)this.host.GetService(typeof(IOverlayService));
             if (service != null)
             {
                 service.RemoveOverlay(this);
             }
             IEventHandlerService service2 = (IEventHandlerService)this.host.GetService(typeof(IEventHandlerService));
             if (service2 != null)
             {
                 service2.PopHandler(this);
             }
             IMenuCommandService service3 = (IMenuCommandService)this.host.GetService(typeof(IMenuCommandService));
             if (service3 != null)
             {
                 foreach (MenuCommand command in this.newCommands)
                 {
                     service3.RemoveCommand(command);
                 }
             }
             IComponentChangeService service4 = (IComponentChangeService)this.host.GetService(typeof(IComponentChangeService));
             if (service4 != null)
             {
                 service4.ComponentAdded   -= new ComponentEventHandler(this.OnComponentAddRemove);
                 service4.ComponentRemoved -= new ComponentEventHandler(this.OnComponentAddRemove);
                 service4.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged);
             }
             IHelpService service5 = (IHelpService)this.host.GetService(typeof(IHelpService));
             if (service5 != null)
             {
                 service5.RemoveContextAttribute("Keyword", "TabOrderView");
             }
             this.host = null;
         }
     }
     base.Dispose(disposing);
 }
示例#13
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);
            }
        }
 public void Dispose()
 {
     if (this.marshalingControl != null)
     {
         this.marshalingControl.Dispose();
         this.marshalingControl = null;
     }
     if (this.serviceProvider != null)
     {
         IComponentChangeService service = (IComponentChangeService)this.serviceProvider.GetService(typeof(IComponentChangeService));
         if (service != null)
         {
             service.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged);
         }
         if (this.cmdShowDesignerActions != null)
         {
             IMenuCommandService service2 = (IMenuCommandService)this.serviceProvider.GetService(typeof(IMenuCommandService));
             if (service2 != null)
             {
                 service2.RemoveCommand(this.cmdShowDesignerActions);
             }
         }
     }
     this.serviceProvider = null;
     this.behaviorService = null;
     this.selSvc          = null;
     if (this.designerActionService != null)
     {
         this.designerActionService.DesignerActionListsChanged -= new DesignerActionListsChangedEventHandler(this.OnDesignerActionsChanged);
         if (this.disposeActionService)
         {
             this.designerActionService.Dispose();
         }
     }
     this.designerActionService = null;
     if (this.designerActionUIService != null)
     {
         this.designerActionUIService.DesignerActionUIStateChange -= new DesignerActionUIStateChangeEventHandler(this.OnDesignerActionUIStateChange);
         if (this.disposeActionUIService)
         {
             this.designerActionUIService.Dispose();
         }
     }
     this.designerActionUIService = null;
     this.designerActionAdorner   = null;
 }
        public override void Initialize(IComponent component)
        {
            base.Initialize(component);
            mcs = (IMenuCommandService)component.Site.GetService(typeof(IMenuCommandService));

            dv = new DesignerVerb("Global menu",
                                  new EventHandler(OnClickGlobalMenu));
            dv.Enabled   = true;
            dv.Visible   = true;
            dv.Supported = true;
            mcs.RemoveVerb(dv);
            mcs.AddVerb(dv);

            ms = new MenuCommand(new EventHandler(OnKeyHome),
                                 MenuCommands.KeyHome);
            ms.Enabled   = true;
            ms.Visible   = true;
            ms.Supported = true;
            mcs.RemoveCommand(ms);
            mcs.AddCommand(ms);
        }
示例#16
0
        protected virtual void Dispose(bool disposing)
        {
            Debug.Assert(disposing, "Finalizing CustomCommand without disposing.");

            if (disposing)
            {
                if (m_serviceProvider != null)
                {
                    IMenuCommandService menuService = m_serviceProvider.GetService <IMenuCommandService>();
                    if (menuService != null)
                    {
                        menuService.RemoveCommand(this);
                    }
                    m_serviceProvider = null;
                }
            }

            m_metaCommand = null;
            m_selection   = null;

            Debug.WriteLine("Unloaded and disposed command " + m_metaCommand);
        }
 public void RemoveCommand(MenuCommand command)
 {
     _menuCommandService.RemoveCommand(command);
 }
示例#18
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;
			}
		}