示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AddSatelliteProviderCommand"/> class.
 /// </summary>
 /// <remarks>
 /// This class is intended to be initialized by the <see cref="SectionViewModel.CreateElementCollectionAddCommands"/>.
 /// </remarks>
 /// <param name="commandAttribute">The <see cref="AddSateliteProviderCommandAttribute"/> that specifes metadata for this <see cref="AddSatelliteProviderCommand"/> to be initialized with.</param>
 /// <param name="collection"></param>
 /// <param name="commandService"></param>
 /// <param name="configurationElementType"></param>
 /// <param name="lookup"></param>
 /// <param name="uiService"></param>
 public AddSatelliteProviderCommand(AddSateliteProviderCommandAttribute commandAttribute, MenuCommandService commandService, ConfigurationElementType configurationElementType, ElementCollectionViewModel collection, ElementLookup lookup, IUIServiceWpf uiService)
     : base(commandAttribute, configurationElementType, collection, uiService)
 {
     this.commandService   = commandService;
     this.commandAttribute = commandAttribute;
     this.lookup           = lookup;
 }
示例#2
0
 public static void Register(MenuCommandService mcs)
 {
     CommandID nestId = new CommandID(GuidList.guidFileNestingCmdSet, (int)PkgCmdIDList.cmdNest);
     OleMenuCommand menuNest = new OleMenuCommand(Nest, nestId);
     mcs.AddCommand(menuNest);
     menuNest.BeforeQueryStatus += BeforeNest;
 }
示例#3
0
 public static void Register(MenuCommandService mcs)
 {
     var cmdId = new CommandID(VSCommandTable.PackageGuids.VSPackageCmdSetGuid, VSCommandTable.CommandIds.SolutionExplorerItemContextMenuItem);
     var menu = new OleMenuCommand((s, e) => { }, cmdId);
     menu.BeforeQueryStatus += BeforeQueryStatus;
     mcs.AddCommand(menu);
 }
 public static void Register(DTE2 dte, MenuCommandService mcs)
 {
     _dte = dte;
     CommandID nestAllId = new CommandID(GuidList.guidFileNestingCmdSet, (int)PkgCmdIDList.cmdRunNesting);
     OleMenuCommand menuNestAll = new OleMenuCommand(NestAll, nestAllId);
     mcs.AddCommand(menuNestAll);
 }
示例#5
0
 public static void Register(MenuCommandService mcs)
 {
     var cmdId = new CommandID(VSCommandTable.PackageGuids.VSPackageCmdSetGuid, VSCommandTable.CommandIds.CreateServiceCode);
     var menu = new OleMenuCommand(MenuItemCallbackHandler, cmdId);
     menu.BeforeQueryStatus += BeforeQueryStatus;
     mcs.AddCommand(menu);
 }
示例#6
0
        public static void Register(DTE2 dte, MenuCommandService mcs)
        {
            _dte = dte;
            CommandID      nestAllId   = new CommandID(GuidList.guidFileNestingCmdSet, (int)PkgCmdIDList.cmdRunNesting);
            OleMenuCommand menuNestAll = new OleMenuCommand(NestAll, nestAllId);

            mcs.AddCommand(menuNestAll);
        }
 public static void Register(DTE2 dte, MenuCommandService mcs)
 {
     _dte = dte;
     CommandID autoId = new CommandID(GuidList.guidFileNestingCmdSet, (int)PkgCmdIDList.cmdAutoNesting);
     OleMenuCommand menuAuto = new OleMenuCommand(AutoNest, autoId);
     mcs.AddCommand(menuAuto);
     menuAuto.BeforeQueryStatus += BeforeAutoNest;
 }
示例#8
0
        public static void Register(MenuCommandService mcs)
        {
            var cmdId = new CommandID(VSCommandTable.PackageGuids.VSPackageCmdSetGuid, VSCommandTable.CommandIds.SolutionExplorerItemContextMenuItem);
            var menu  = new OleMenuCommand((s, e) => { }, cmdId);

            menu.BeforeQueryStatus += BeforeQueryStatus;
            mcs.AddCommand(menu);
        }
示例#9
0
        public static void Register(MenuCommandService mcs)
        {
            var cmdId = new CommandID(VSCommandTable.PackageGuids.VSPackageCmdSetGuid, VSCommandTable.CommandIds.CreateContractCode);
            var menu  = new OleMenuCommand(MenuItemCallbackHandler, cmdId);

            menu.BeforeQueryStatus += BeforeQueryStatus;
            mcs.AddCommand(menu);
        }
        public static void Register(DTE2 dte, MenuCommandService mcs)
        {
            _dte = dte;
            CommandID      nestAllId   = new CommandID(PackageGuids.guidFileNestingCmdSet, PackageIds.cmdRunNesting);
            OleMenuCommand menuNestAll = new OleMenuCommand(NestAll, nestAllId);

            mcs.AddCommand(menuNestAll);
        }
        public static void Register(MenuCommandService mcs)
        {
            CommandID      unNestId   = new CommandID(PackageGuids.guidFileNestingCmdSet, PackageIds.cmdUnNest);
            OleMenuCommand menuUnNest = new OleMenuCommand(UnNest, unNestId);

            mcs.AddCommand(menuUnNest);
            menuUnNest.BeforeQueryStatus += BeforeUnNest;
        }
示例#12
0
        public static void Register(MenuCommandService mcs)
        {
            CommandID      nestId   = new CommandID(GuidList.guidFileNestingCmdSet, (int)PkgCmdIDList.cmdNest);
            OleMenuCommand menuNest = new OleMenuCommand(Nest, nestId);

            mcs.AddCommand(menuNest);
            menuNest.BeforeQueryStatus += BeforeNest;
        }
示例#13
0
        public void ShowVSExtensionManager(object parameter)
        {
            MenuCommandService menuCommandService = serviceProvider.Get <MenuCommandService>();
            CommandID          commandId          = new CommandID(VSConstants.VsStd2010, 3000);

            menuCommandService.GlobalInvoke(commandId, parameter);
            serviceProvider.Get <ITeamExplorer>().HideNotification(GuidList.UpdateNotificationId);
        }
        public static void Register(DTE2 dte, MenuCommandService mcs)
        {
            _dte = dte;
            CommandID      autoId   = new CommandID(GuidList.guidFileNestingCmdSet, (int)PkgCmdIDList.cmdAutoNesting);
            OleMenuCommand menuAuto = new OleMenuCommand(AutoNest, autoId);

            mcs.AddCommand(menuAuto);
            menuAuto.BeforeQueryStatus += BeforeAutoNest;
        }
示例#15
0
 public SelectionMenu(MenuCommandService menuCommandService)
     : base("SelectionMenu")
 {
     _getEnabled = delegate(IToolStripItemCodon codon)
     {
         DesignerContextMenuStripItemCodon contextMenuCodon = codon as DesignerContextMenuStripItemCodon;
         return(contextMenuCodon.ContextMenuCommand.Enabled);
     };
     this.Items.Add(new DesignerContextMenuStripItemCodon(new ContextMenuCommandShowEvents(menuCommandService), IconsLibrary.Event)
     {
         IsEnabled = _getEnabled
     });
     this.Items.Add(new ToolStripSeparatorCodon());
     this.Items.Add(new DesignerContextMenuStripItemCodon(new ContextMenuCommandBringToFront(menuCommandService), IconsLibrary.BringToFrontHS)
     {
         IsEnabled = _getEnabled
     });
     this.Items.Add(new DesignerContextMenuStripItemCodon(new ContextMenuCommandSendToBack(menuCommandService), IconsLibrary.SendToBackHS)
     {
         IsEnabled = _getEnabled
     });
     this.Items.Add(new ToolStripSeparatorCodon());
     this.Items.Add(new DesignerContextMenuStripItemCodon(new ContextMenuCommandLockControls(menuCommandService))
     {
         IsEnabled = _getEnabled
     });
     this.Items.Add(new ToolStripSeparatorCodon());
     foreach (DesignerVerb verb in menuCommandService.Verbs)
     {
         this.Items.Add(new DesignerContextMenuStripItemCodon(verb));
     }
     if (menuCommandService.Verbs.Count > 0)
     {
         this.Items.Add(new ToolStripSeparatorCodon());
     }
     this.Items.Add(new DesignerContextMenuStripItemCodon(new ContextMenuCommandCut(menuCommandService), IconsLibrary.Cut)
     {
         IsEnabled = _getEnabled
     });
     this.Items.Add(new DesignerContextMenuStripItemCodon(new ContextMenuCommandCopy(menuCommandService), IconsLibrary.Copy)
     {
         IsEnabled = _getEnabled
     });
     this.Items.Add(new DesignerContextMenuStripItemCodon(new ContextMenuCommandPaste(menuCommandService), IconsLibrary.Paste)
     {
         IsEnabled = _getEnabled
     });
     this.Items.Add(new DesignerContextMenuStripItemCodon(new ContextMenuCommandDelete(menuCommandService), IconsLibrary.Delete)
     {
         IsEnabled = _getEnabled
     });
     this.Items.Add(new ToolStripSeparatorCodon());
     this.Items.Add(new DesignerContextMenuStripItemCodon(new ContextMenuCommandProperties(menuCommandService), IconsLibrary.Property)
     {
         IsEnabled = _getEnabled
     });
 }
示例#16
0
        private void ChangeCommand(int commandId, bool enabled)
        {
            var command  = new CommandID(GuidList.guidthreadfix_pluginCmdSet, commandId);
            var menuItem = MenuCommandService.FindCommand(command);

            if (menuItem != null)
            {
                menuItem.Enabled = enabled;
            }
        }
示例#17
0
        public override CommandResult Invoke(Guid group, int id, object inputArg, ref object outputArg)
        {
            if (MenuCommandService != null)
            {
                POINTS[]  position    = (POINTS[])inputArg;
                CommandID menuCommand = new CommandID(_cmdSetGuid, (int)_menuId);
                MenuCommandService.ShowContextMenu(menuCommand, position[0].x, position[0].y);

                return(CommandResult.Executed);
            }
            return(CommandResult.NotSupported);
        }
示例#18
0
        public Control GetControl()
        {
            ServiceContainer serviceContainer = new ServiceContainer();

            serviceContainer.AddService(typeof(System.ComponentModel.Design.IDesignerEventService), new DesignerEventService());
            serviceContainer.AddService(typeof(System.ComponentModel.Design.Serialization.INameCreationService), new NameCreationService());
            _toolboxService = new CustomToolboxService();
            serviceContainer.AddService(typeof(IToolboxService), _toolboxService);

            DesignSurface surface = new DesignSurface(serviceContainer);

            _host = (IDesignerHost)surface.GetService(typeof(IDesignerHost));

            serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), new Services.EventBindingService(surface));

            _menuCommandService = new MenuCommandService(surface);
            serviceContainer.AddService(typeof(IMenuCommandService), _menuCommandService);

            //surface.BeginLoad(typeof(Form));
            _CodeDomHostLoader = new Loader.CodeDomHostLoader();
            surface.BeginLoad(_CodeDomHostLoader);

            Control designerContorl = (Control)surface.View;


            designerContorl.BackColor = Color.Aqua;
            designerContorl.Dock      = DockStyle.Fill;
            //获取root组件
            var designerHost = (IDesignerHost)this._host;

            if (designerHost != null)
            {
                rootComponent = (Form)designerHost.RootComponent;
            }

            rootComponent.FormBorderStyle = FormBorderStyle.None;

            #region 初始化窗体大小

            //- set the Size
            PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(designerContorl);
            //- Sets a PropertyDescriptor to the specific property.
            PropertyDescriptor pdS = pdc.Find("Size", false);
            if (null != pdS)
            {
                pdS.SetValue(_host.RootComponent, new Size(800, 480));
            }
            #endregion

            return(designerContorl);
        }
示例#19
0
        private void UpdateUndoRedoMenuCommandsStatus()
        {
            MenuCommandService menuCommandService = GetService(typeof(MenuCommandService)) as MenuCommandService;
            var undoMenuCommand = menuCommandService.FindCommand(StandardCommands.Undo);
            var redoMenuCommand = menuCommandService.FindCommand(StandardCommands.Redo);

            if (undoMenuCommand is object)
            {
                undoMenuCommand.Enabled = currentPos > 0;
            }
            if (redoMenuCommand is object)
            {
                redoMenuCommand.Enabled = currentPos < undoUnitList.Count;
            }
        }
示例#20
0
        public StationMapForm()
        {
            InitializeComponent();
            persistState = new PersistWindowState(registryPath, this);
            DesignSurface     surface   = new DesignSurface();
            IServiceContainer container = surface.GetService(typeof(IServiceContainer)) as IServiceContainer;

            _menuCommandService = new MenuCommandService(surface);
            if (container != null)
            {
                container.AddService(typeof(IMenuCommandService), _menuCommandService);
            }
            DrawForm();
            //InitStationDeviceType();
        }
示例#21
0
        private void UpdateUndoRedoMenuCommandsStatus()
        {
            // this components maybe cached.
            MenuCommandService menuCommandService = GetService(typeof(MenuCommandService)) as MenuCommandService;
            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;
            }
        }
示例#22
0
 private void OnShowContextMenu(object sender, ShowContextMenuEventArgs e)
 {
     if (MenuCommandService != null)
     {
         OnBeforeShowContextMenu();
         var explorerContextMenu = GetContextMenuCommandID();
         var p = _elementHost.PointToScreen(new Point((int)e.Point.X, (int)e.Point.Y));
         try
         {
             MenuCommandService.ShowContextMenu(explorerContextMenu, p.X, p.Y);
         }
         catch (COMException ex)
         {
             // do not rethrow exception as this causes VS crash
             Debug.Fail("Caught exception of type " + ex.GetType().FullName +
                        " with message " + ex.Message + ". Stack Trace: " + ex.StackTrace);
         }
     }
 }
示例#23
0
        /// <summary>
        /// Initializes a new instance of <see cref="ApplicationViewModel"/>.
        /// </summary>
        /// <param name="uiService">The <see cref="IUIServiceWpf"/> that should be used to interact with the user.</param>
        /// <param name="sourceModel">The <see cref="ConfigurationSourceModel"/> that should be used to interact with the configuration schema.</param>
        /// <param name="lookup">The <see cref="ElementLookup"/> that should be used to look up <see cref="ElementViewModel"/> instances.</param>
        /// <param name="builder">The <see cref="IUnityContainer"/> instance that should be used to create view model instances with.</param>
        /// <param name="menuCommandService">The <see cref="MenuCommandService"/> that should be used to look up top-level <see cref="CommandModel"/> instances.</param>
        /// <param name="validationModel">The <see cref="ValidationModel"/> that should be used to add validation errors and warnings to.</param>
        public ApplicationViewModel(IUIServiceWpf uiService, ConfigurationSourceModel sourceModel, ElementLookup lookup,
                                    IUnityContainer builder, MenuCommandService menuCommandService,
                                    ValidationModel validationModel)
        {
            ValidationModel  = validationModel;
            this.uiService   = uiService;
            this.sourceModel = sourceModel;

            this.lookup             = lookup;
            this.builder            = builder;
            this.menuCommandService = menuCommandService;

            NewConfigurationCommand    = new DelegateCommand(x => New());
            SaveConfigurationCommand   = new DelegateCommand(x => Save());
            SaveAsConfigurationCommand = new DelegateCommand(x => SaveAs());
            OpenConfigurationCommand   = new DelegateCommand(x => OpenConfigurationSource());
            ExitCommand = new DelegateCommand(x => Close());

            OpenEnvironmentCommand = new OpenEnvironmentConfigurationDeltaCommand(uiService, this);
            NewEnvironmentCommand  = new DelegateCommand(x => NewEnvironment());
        }
示例#24
0
        private void UpdateUndoRedoMenuCommandsStatus()
        {
            // this components maybe cached.
            try
            {
                MenuCommandService menuCommandService = GetService(typeof(MenuCommandService)) as MenuCommandService;
                menuCommandService = new Host.MenuCommandServiceImpl(IUGConceptor._hostSurfaceManager);
                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;
                }
            }
            catch
            {
            }
        }
示例#25
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param>
        /// <param name="progress">A provider for progress updates.</param>
        /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            // When initialized asynchronously, the current thread may be a background thread at this point.
            // Do any initialization that requires the UI thread after switching to the UI thread.

            var commandService = await GetServiceAsync(typeof(System.ComponentModel.Design.IMenuCommandService)) as OleMenuCommandService;



            if (commandService is MenuCommandService)
            {
                _menuCommandService = commandService;
            }
            await cmdCommandWindow.InitializeAsync(this);

            await cmdCloudDeploy.InitializeAsync(this);

            await cmdCloudCompress.InitializeAsync(this);

            await cmdConfigureSSH.InitializeAsync(this);

//            await cmdDeployWindow.InitializeAsync(this);
        }
示例#26
0
 public ContainerMenu(MenuCommandService menuCommandService)
     : base("ContainerMenu")
 {
     _getEnabled = delegate(IToolStripItemCodon codon)
     {
         DesignerContextMenuStripItemCodon contextMenuCodon = codon as DesignerContextMenuStripItemCodon;
         return(contextMenuCodon.ContextMenuCommand.Enabled);
     };
     this.Items.Add(new DesignerContextMenuStripItemCodon(new ContextMenuCommandShowEvents(menuCommandService), IconsLibrary.Event)
     {
         IsEnabled = _getEnabled
     });
     this.Items.Add(new ToolStripSeparatorCodon());
     this.Items.Add(new DesignerContextMenuStripItemCodon(new ContextMenuCommandTabOrder(menuCommandService), IconsLibrary.TabOrder)
     {
         IsEnabled = _getEnabled
     });
     this.Items.Add(new DesignerContextMenuStripItemCodon(new ContextMenuCommandLockControls(menuCommandService))
     {
         IsEnabled = _getEnabled
     });
     this.Items.Add(new ToolStripSeparatorCodon());
     this.Items.Add(new DesignerContextMenuStripItemCodon(new ContextMenuCommandPaste(menuCommandService), IconsLibrary.Paste)
     {
         IsEnabled = delegate(IToolStripItemCodon codon)
         {
             DesignerContextMenuStripItemCodon contextMenuCodon = codon as DesignerContextMenuStripItemCodon;
             return(contextMenuCodon.ContextMenuCommand.Enabled);
         }
     });
     this.Items.Add(new ToolStripSeparatorCodon());
     this.Items.Add(new DesignerContextMenuStripItemCodon(new ContextMenuCommandProperties(menuCommandService), IconsLibrary.Property)
     {
         IsEnabled = _getEnabled
     });
 }
        /// <summary>
        /// Initializes a new instance of <see cref="ApplicationViewModel"/>.
        /// </summary>
        /// <param name="uiService">The <see cref="IUIServiceWpf"/> that should be used to interact with the user.</param>
        /// <param name="sourceModel">The <see cref="ConfigurationSourceModel"/> that should be used to interact with the configuration schema.</param>
        /// <param name="lookup">The <see cref="ElementLookup"/> that should be used to look up <see cref="ElementViewModel"/> instances.</param>
        /// <param name="builder">The <see cref="IUnityContainer"/> instance that should be used to create view model instances with.</param>
        /// <param name="menuCommandService">The <see cref="MenuCommandService"/> that should be used to look up top-level <see cref="CommandModel"/> instances.</param>
        /// <param name="validationModel">The <see cref="ValidationModel"/> that should be used to add validation errors and warnings to.</param>
        /// <param name="profile">The <see cref="Profile"/> that should be used to filter UI elements based on the platform.</param>
        public ApplicationViewModel(IUIServiceWpf uiService, ConfigurationSourceModel sourceModel, ElementLookup lookup,
                                    IUnityContainer builder, MenuCommandService menuCommandService,
                                    ValidationModel validationModel, Profile profile)
        {
            ValidationModel  = validationModel;
            this.uiService   = uiService;
            this.sourceModel = sourceModel;

            this.lookup             = lookup;
            this.builder            = builder;
            this.menuCommandService = menuCommandService;
            this.profile            = profile;

            NewConfigurationCommand    = new DelegateCommand(x => New());
            SaveConfigurationCommand   = new DelegateCommand(x => Save());
            SaveAsConfigurationCommand = new DelegateCommand(x => SaveAs());
            OpenConfigurationCommand   = new DelegateCommand(x => OpenConfigurationSource());
            ExitCommand = new DelegateCommand(x => Close());

            var environmentCommandsEnabled = this.profile == null ? true : profile.EnvironmentCommandsEnabled;

            OpenEnvironmentCommand = new OpenEnvironmentConfigurationDeltaCommand(uiService, this, environmentCommandsEnabled);
            NewEnvironmentCommand  = new DelegateCommand(x => NewEnvironment(), _ => environmentCommandsEnabled);
        }
		public override void Initialize(IComponent component)
		{
			base.Initialize(component);
			sections = new List<BaseSection>();
			
			// We need to listen to change events.  If a shape changes,
			// we need to invalidate our view.
			//
		
			this.componentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
			if (this.componentChangeService != null)
			{
				this.componentChangeService.ComponentAdded += new ComponentEventHandler(OnComponentAdded);
//				this.componentChangeService.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving);
//				this.componentChangeService.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved);
				this.componentChangeService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged);
//				this.componentChangeService.ComponentChanging += new ComponentChangingEventHandler(OnComponentChanging);
			}
	
	
			// Add the menu commands we support.  We must be a member of the VSIP program to
			// define new menu items, but we can handle any item located within the StandardCommands
			// class because Visual Studio already defines them.
			//
			
			menuCommandService = (MenuCommandService)GetService(typeof(MenuCommandService));
			/*
			if (menuCommandService != null)
			{
				/*
				m_menuCommands = new MenuCommand[]
					{
						new MenuCommand(new EventHandler(OnMenuCut), StandardCommands.Cut),
						new MenuCommand(new EventHandler(OnMenuCopy), StandardCommands.Copy),
//						new ImmediateMenuCommand(new EventHandler(OnMenuPasteStatus), new EventHandler(OnMenuPaste), StandardCommands.Paste),
						new MenuCommand(new EventHandler(OnMenuDelete), StandardCommands.Delete)
					};

				foreach(MenuCommand mc in m_menuCommands)
				{
					m_menuCommandService.AddCommand(mc);
				}
			
				System.Console.WriteLine("RootDesigner menuService set");
			}
		*/
			// Select our base shape.  By default there is nothing selected but that looks
			// strange (the property grid is empty).
			//
		
			this.selectionService = (ISelectionService)GetService(typeof(ISelectionService));
			if (this.selectionService != null)
			{
				this.selectionService.SetSelectedComponents(new object[] {component}, SelectionTypes.Replace);
				this.selectionService.SelectionChanged += new EventHandler(OnSelectionChanged);
			}
		
			this.host = (IDesignerHost)GetService(typeof(IDesignerHost));
			
			this.menuCommandService = (MenuCommandService)host.GetService(typeof(MenuCommandService));
			if (host != null)
			{
				host.LoadComplete += new EventHandler(OnLoadComplete);
			}
			//Dragdropp only allowed in Section
			this.Control.AllowDrop = false;
		}
 public MenuCommandServiceExt(IServiceProvider serviceProvider)
 {
     this._serviceProvider = serviceProvider;
     _menuCommandService   = new MenuCommandService(serviceProvider);
 }
 public AbstractContextMenuCommand(MenuCommandService menuCommandService)
 {
     _menuCommandService = menuCommandService;
 }
示例#31
0
 protected SingleCommand(int commandId, VisualStudioPackage package) : base(commandId, package)
 {
     _command = new OleMenuCommand(InvokeHandler, new CommandID(CommandSet.Guid, commandId));
     _command.BeforeQueryStatus += CommandOnBeforeQueryStatus;
     MenuCommandService.AddCommand(_command);
 }
示例#32
0
        private void Initialize()
        {
            IDesignerHost host;
            Form form;
            IRootDesigner rootDesigner;
            Control view;

            // Initialise service container and designer host
            serviceContainer = new ServiceContainer();
            serviceContainer.AddService(typeof(INameCreationService), new NameCreationService());
            serviceContainer.AddService(typeof(IUIService), new UIService(this));
            host = new DesignerHost(serviceContainer);

            // Add toolbox service
            serviceContainer.AddService(typeof(IToolboxService), lstToolbox);
            lstToolbox.designPanel = pnlViewHost;
            PopulateToolbox(lstToolbox);

            // Add menu command service
            menuService = new MenuCommandService();
            serviceContainer.AddService(typeof(IMenuCommandService), menuService);

            // Start the designer host off with a Form to design
            form = (Form)host.CreateComponent(typeof(Form));
            form.TopLevel = false;
            form.Text = "Form1";

            // Get the root designer for the form and add its design view to this form
            rootDesigner = (IRootDesigner)host.GetDesigner(form);
            view = (Control)rootDesigner.GetView(ViewTechnology.WindowsForms);
            view.Dock = DockStyle.Fill;
            pnlViewHost.Controls.Add(view);

            // Subscribe to the selectionchanged event and activate the designer
            ISelectionService s = (ISelectionService)serviceContainer.GetService(typeof(ISelectionService));
            s.SelectionChanged += new EventHandler(OnSelectionChanged);
            host.Activate();
        }
示例#33
0
        internal Guid pageGuid;//与model的编号对应



        public DesignWorkbench(string pageName)
        {
            InitializeComponent();
            AutoScaleMode = AutoScaleMode.Dpi;

            PageMoel pm = new PageMoel();

            _propertyGrid = new PropertyGrid {
                Dock = DockStyle.Fill
            };
            pm.propertyGrid = _propertyGrid;
            pm.PageName     = pageName;

            ServiceContainer serviceContainer = new ServiceContainer();

            serviceContainer.AddService(typeof(System.ComponentModel.Design.IDesignerEventService), new DesignerEventService());
            serviceContainer.AddService(typeof(System.ComponentModel.Design.Serialization.INameCreationService), new NameCreationService());
            _toolboxService = new CustomToolboxService();
            serviceContainer.AddService(typeof(IToolboxService), _toolboxService);

            surface = new DesignSurface(serviceContainer);
            _host   = (IDesignerHost)surface.GetService(typeof(IDesignerHost));

            serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), new Services.EventBindingService(surface));

            _menuCommandService = new MenuCommandService(surface);
            serviceContainer.AddService(typeof(IMenuCommandService), _menuCommandService);

            //surface.BeginLoad(typeof(Form));
            _CodeDomHostLoader = new Loader.CodeDomHostLoader();
            surface.BeginLoad(_CodeDomHostLoader);

            Control designerContorl = (Control)surface.View;


            designerContorl.BackColor = Color.Aqua;
            designerContorl.Dock      = DockStyle.Fill;
            //获取root组件
            var designerHost = (IDesignerHost)this._host;

            if (designerHost != null)
            {
                rootComponent = (Form)designerHost.RootComponent;
            }

            rootComponent.FormBorderStyle = FormBorderStyle.None;

            #region 初始化窗体大小

            //- set the Size
            PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(designerContorl);
            //- Sets a PropertyDescriptor to the specific property.
            PropertyDescriptor pdS = pdc.Find("Size", false);
            if (null != pdS)
            {
                pdS.SetValue(_host.RootComponent, new Size(800, 480));
            }
            #endregion
            tpDesign.Controls.Add(designerContorl);//窗体

            _textEditor = new TextEditorControl
            {
                IsReadOnly = true,
                Dock       = DockStyle.Fill,
                Document   = { HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy("C#") }
            }; //代码编辑器
            tpCode.Controls.Add(_textEditor);

            _propertyGrid.SelectedObject = surface.ComponentContainer.Components[0];
            _propertyGrid.Site           = (new IDEContainer(_host)).CreateSite(_propertyGrid);
            _propertyGrid.PropertyTabs.AddTabType(typeof(System.Windows.Forms.Design.EventsTab), PropertyTabScope.Document);


            pm.serviceContainer = serviceContainer;
            pm.surFace          = surface;
            pageGuid            = Guid.NewGuid();
            pm.PageGuid         = pageGuid;
            List <PageMoel> pages = GolableInstance.PageList();
            pages.Add(pm);


            //if (ChangeSur != null) ChangeSur();
        }
示例#34
0
        protected override void OnBeforeShowContextMenu()
        {
            // Creating commands for adding scalar and complex properties to complex types (one for each complex type from the model).
            // Since the scalar types can change dependent on the schemaVersion and since complex types can be added or deleted
            // we need to compute these commands each time a context menu is requested

            // only need to do this if selected is ExplorerComplexType
            var selectedElement = CurrentExplorerInfo._explorerFrame.GetSelectedExplorerEFElement();

            if (selectedElement is ExplorerComplexType)
            {
                var service = EditingContext.GetEFArtifactService();
                Debug.Assert(service != null && service.Artifact != null, "service and service.Artifact must both be non-null");
                if (service != null &&
                    service.Artifact != null)
                {
                    // Creating commands for adding scalar properties to complex types (one for each primitive type)
                    var i = 0;
                    foreach (var type in ModelHelper.AllPrimitiveTypesSorted(service.Artifact.SchemaVersion))
                    {
                        var cmdId = new CommandID(
                            PackageConstants.guidEscherCmdSet, PackageConstants.cmdIdExplorerAddScalarPropertyBase + i);
                        var cmd = MenuCommandService.FindCommand(cmdId);
                        if (cmd == null)
                        {
                            cmd = new DynamicStatusMenuCommand(OnStatusAddComplexTypeProperty, OnMenuAddComplexTypeProperty, cmdId);
                            cmd.Properties[PackageConstants.guidEscherCmdSet] = type;
                            MenuCommandService.AddCommand(cmd);
                        }
                        else
                        {
                            cmd.Properties[PackageConstants.guidEscherCmdSet] = type;
                        }
                        i++;
                    }

                    // set up commands for complex types
                    var conceptualModel = service.Artifact.ConceptualModel();
                    Debug.Assert(conceptualModel != null, "service.Artifact.ConceptualModel() should not be null");
                    if (conceptualModel != null)
                    {
                        var complexTypes = new List <ComplexType>(conceptualModel.ComplexTypes());
                        complexTypes.Sort(EFElement.EFElementDisplayNameComparison);

                        i = 0;
                        foreach (var complexType in complexTypes)
                        {
                            // don't add an item for a ComplexType that is same as currently selected one
                            if (selectedElement.ModelItem == complexType)
                            {
                                continue;
                            }

                            // if we find an old command with the same cmdId remove it and replace
                            // with the new one to force VS to refresh the text
                            var cmdId = new CommandID(
                                PackageConstants.guidEscherCmdSet, PackageConstants.cmdIdExplorerAddComplexPropertyBase + i);
                            var cmd = MenuCommandService.FindCommand(cmdId);
                            if (cmd != null)
                            {
                                MenuCommandService.RemoveCommand(cmd);
                            }
                            cmd = new DynamicStatusMenuCommand(OnStatusAddComplexTypeProperty, OnMenuAddComplexTypeProperty, cmdId);
                            cmd.Properties[PackageConstants.guidEscherCmdSet] = complexType;
                            MenuCommandService.AddCommand(cmd);

                            i++;
                            if (i >= AddComplexPropertyCommandMaxCount)
                            {
                                // break after adding 10 ComplexTypes
                                break;
                            }
                        }

                        // if some of the complex types were removed, we need to remove unnecessary commands
                        var cmd2 =
                            MenuCommandService.FindCommand(
                                new CommandID(PackageConstants.guidEscherCmdSet, PackageConstants.cmdIdExplorerAddComplexPropertyBase + i));
                        while (i < AddComplexPropertyCommandMaxCount &&
                               cmd2 != null)
                        {
                            MenuCommandService.RemoveCommand(cmd2);
                            i++;
                            cmd2 =
                                MenuCommandService.FindCommand(
                                    new CommandID(
                                        PackageConstants.guidEscherCmdSet, PackageConstants.cmdIdExplorerAddComplexPropertyBase + i));
                        }
                    }
                }
            }
        }
        public override void Initialize(IComponent component)
        {
            base.Initialize(component);
            sections = new List <BaseSection>();

            // We need to listen to change events.  If a shape changes,
            // we need to invalidate our view.
            //

            this.componentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
            if (this.componentChangeService != null)
            {
                this.componentChangeService.ComponentAdded += new ComponentEventHandler(OnComponentAdded);
//				this.componentChangeService.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving);
//				this.componentChangeService.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved);
                this.componentChangeService.ComponentChanged  += new ComponentChangedEventHandler(OnComponentChanged);
                this.componentChangeService.ComponentChanging += new ComponentChangingEventHandler(OnComponentChanging);
            }


            // Add the menu commands we support.  We must be a member of the VSIP program to
            // define new menu items, but we can handle any item located within the StandardCommands
            // class because Visual Studio already defines them.
            //

            menuCommandService = (MenuCommandService)GetService(typeof(MenuCommandService));

            /*
             * if (menuCommandService != null)
             * {
             *      /*
             *      m_menuCommands = new MenuCommand[]
             *              {
             *                      new MenuCommand(new EventHandler(OnMenuCut), StandardCommands.Cut),
             *                      new MenuCommand(new EventHandler(OnMenuCopy), StandardCommands.Copy),
             * //						new ImmediateMenuCommand(new EventHandler(OnMenuPasteStatus), new EventHandler(OnMenuPaste), StandardCommands.Paste),
             *                      new MenuCommand(new EventHandler(OnMenuDelete), StandardCommands.Delete)
             *              };
             *
             *      foreach(MenuCommand mc in m_menuCommands)
             *      {
             *              m_menuCommandService.AddCommand(mc);
             *      }
             *
             *      System.Console.WriteLine("RootDesigner menuService set");
             * }
             */
            // Select our base shape.  By default there is nothing selected but that looks
            // strange (the property grid is empty).
            //

            selectionService = (ISelectionService)GetService(typeof(ISelectionService));
            if (this.selectionService != null)
            {
                this.selectionService.SetSelectedComponents(new object[] { component }, SelectionTypes.Replace);
                this.selectionService.SelectionChanged += new EventHandler(OnSelectionChanged);
            }

            host = (IDesignerHost)GetService(typeof(IDesignerHost));

            menuCommandService = (MenuCommandService)host.GetService(typeof(MenuCommandService));
            if (host != null)
            {
                host.LoadComplete += OnLoadComplete;
            }
            //Dragdropp only allowed in Section
            this.Control.AllowDrop = false;
        }
示例#36
0
        /// <summary>
        ///  Called to do control-specific processing for this window.
        /// </summary>
        void IWindowTarget.OnMessage(ref Message m)
        {
            // Get the Designer for the currently selected item on the Designer...
            // SET STATE ..
            ignoreMessages = false;

            // Here lets query for the ISupportInSituService.
            // If we find the service then ask if it has a designer which is interested
            // in getting the keychars by querying the IgnoreMessages.
            if ((m.Msg >= (int)User32.WM.KEYFIRST && m.Msg <= (int)User32.WM.KEYLAST) ||
                (m.Msg >= (int)User32.WM.IME_STARTCOMPOSITION && m.Msg <= (int)User32.WM.IME_COMPOSITION))
            {
                if (InSituSupportService != null)
                {
                    ignoreMessages = InSituSupportService.IgnoreMessages;
                }
            }

            switch (m.Msg)
            {
            case WM_PRIVATE_POSTCHAR:

                if (bufferedChars == null)
                {
                    return;
                }

                // recreate the keystroke to the newly activated window
                IntPtr hWnd;
                if (!ignoreMessages)
                {
                    hWnd = User32.GetFocus();
                }
                else
                {
                    if (InSituSupportService != null)
                    {
                        hWnd = InSituSupportService.GetEditWindow();
                    }
                    else
                    {
                        hWnd = User32.GetFocus();
                    }
                }

                if (hWnd != m.HWnd)
                {
                    foreach (BufferedKey bk in bufferedChars)
                    {
                        if (bk.KeyChar.MsgInternal == User32.WM.CHAR)
                        {
                            if (bk.KeyDown.MsgInternal != 0)
                            {
                                User32.SendMessageW(hWnd, User32.WM.KEYDOWN, bk.KeyDown.WParamInternal, bk.KeyDown.LParamInternal);
                            }

                            User32.SendMessageW(hWnd, User32.WM.CHAR, bk.KeyChar.WParamInternal, bk.KeyChar.LParamInternal);
                            if (bk.KeyUp.MsgInternal != 0)
                            {
                                User32.SendMessageW(hWnd, User32.WM.KEYUP, bk.KeyUp.WParamInternal, bk.KeyUp.LParamInternal);
                            }
                        }
                        else
                        {
                            User32.SendMessageW(hWnd, bk.KeyChar.MsgInternal, bk.KeyChar.WParamInternal, bk.KeyChar.LParamInternal);
                        }
                    }
                }

                bufferedChars.Clear();
                return;

            case (int)User32.WM.KEYDOWN:
                lastKeyDown = m;
                break;

            case (int)User32.WM.IME_ENDCOMPOSITION:
            case (int)User32.WM.KEYUP:
                lastKeyDown.Msg = 0;
                break;

            case (int)User32.WM.CHAR:
            case (int)User32.WM.IME_STARTCOMPOSITION:
            case (int)User32.WM.IME_COMPOSITION:
                if ((Control.ModifierKeys & (Keys.Control | Keys.Alt)) != 0)
                {
                    break;
                }

                if (bufferedChars == null)
                {
                    bufferedChars = new ArrayList();
                }

                bufferedChars.Add(new BufferedKey(lastKeyDown, m, lastKeyDown));

                if (!ignoreMessages && MenuCommandService != null)
                {
                    // throw the properties window command, we will redo the keystroke when we actually
                    // lose focus
                    postCharMessage = true;
                    MenuCommandService.GlobalInvoke(StandardCommands.PropertiesWindow);
                }
                else if (ignoreMessages && m.Msg != (int)User32.WM.IME_COMPOSITION)
                {
                    if (InSituSupportService != null)
                    {
                        postCharMessage = true;
                        InSituSupportService.HandleKeyChar();
                    }
                }

                if (postCharMessage)
                {
                    // If copy of message has been buffered for forwarding, eat the original now
                    return;
                }

                break;

            case (int)User32.WM.KILLFOCUS:
                if (postCharMessage)
                {
                    // see ASURT 45313
                    // now that we've actually lost focus, post this message to the queue.  This allows
                    // any activity that's in the queue to settle down before our characters are posted.
                    // to the queue.
                    //
                    // we post because we need to allow the focus to actually happen before we send
                    // our strokes so we know where to send them
                    //
                    // we can't use the wParam here because it may not be the actual window that needs
                    // to pick up the strokes.
                    //
                    User32.PostMessageW(target.Handle, (User32.WM)WM_PRIVATE_POSTCHAR, IntPtr.Zero, IntPtr.Zero);
                    postCharMessage = false;
                }

                break;
            }

            if (oldTarget != null)
            {
                oldTarget.OnMessage(ref m);
            }
        }
示例#37
0
 public SEUndoUnitZOrder(EnumSendTo sendTo, MenuCommandService menuCommandService, CommandID commandID)
 {
     _sendTo             = sendTo;
     _menuCommandService = menuCommandService;
     _commandId          = commandID;
 }