Пример #1
0
        //
        //
        //
        private void menuItem_Click(object sender, System.EventArgs e)
        {
            // The IMenuCommandService makes doing common commands easy.
            // It keeps track of what commands and verbs the designer supports
            // and can invoke them given members of the MenuCommands enum (CommandID's).
            IServiceContainer   sc  = host as IServiceContainer;
            IMenuCommandService mcs = sc.GetService(typeof(IMenuCommandService)) as IMenuCommandService;

            switch ((sender as MenuItem).Text)
            {
            case "Cu&t":
                mcs.GlobalInvoke(StandardCommands.Cut);
                break;

            case "&Copy":
                mcs.GlobalInvoke(StandardCommands.Copy);
                break;

            case "&Paste":
                mcs.GlobalInvoke(StandardCommands.Paste);
                break;

            case "&Delete":
                mcs.GlobalInvoke(StandardCommands.Delete);
                break;

            case "Select &All":
                mcs.GlobalInvoke(StandardCommands.SelectAll);
                break;

            case "&Service Requests":
                if (serviceRequests == null)
                {
                    serviceRequests         = new ServiceRequests();
                    serviceRequests.Closed += new EventHandler(OnServiceRequestsClosed);

                    // Our designer host looks for this service to announce the success / failure
                    // of service requests.
                    hostingServiceContainer.AddService(typeof(ServiceRequests), serviceRequests);
                    serviceRequests.Show();
                }
                serviceRequests.Activate();
                break;

            case "&Design":
                tabControl.SelectedTab = tabDesign;
                break;

            case "&C# Source":
                tabControl.SelectedTab = tabCS;
                break;

            case "&VB Source":
                tabControl.SelectedTab = tabVB;
                break;

            case "&XML":
                tabControl.SelectedTab = tabXML;
                break;

            case "&Properties":
                mcs.GlobalInvoke(MenuCommands.Properties);
                break;

            case "Show &Grid":
                mcs.GlobalInvoke(StandardCommands.ShowGrid);
                menuItemShowGrid.Checked = !menuItemShowGrid.Checked;
                break;

            case "S&nap to Grid":
                mcs.GlobalInvoke(StandardCommands.SnapToGrid);
                menuItemSnapToGrid.Checked = !menuItemSnapToGrid.Checked;
                break;

            case "&Lefts":
                mcs.GlobalInvoke(StandardCommands.AlignLeft);
                break;

            case "&Rights":
                mcs.GlobalInvoke(StandardCommands.AlignRight);
                break;

            case "&Tops":
                mcs.GlobalInvoke(StandardCommands.AlignTop);
                break;

            case "&Bottoms":
                mcs.GlobalInvoke(StandardCommands.AlignBottom);
                break;

            case "&Middles":
                mcs.GlobalInvoke(StandardCommands.AlignHorizontalCenters);
                break;

            case "&Centers":
                mcs.GlobalInvoke(StandardCommands.AlignVerticalCenters);
                break;

            case "to &Grid":
                mcs.GlobalInvoke(StandardCommands.AlignToGrid);
                break;

            case "&Horizontally":
                mcs.GlobalInvoke(StandardCommands.CenterHorizontally);
                break;

            case "&Vertically":
                mcs.GlobalInvoke(StandardCommands.CenterVertically);
                break;

            case "&Control":
                mcs.GlobalInvoke(StandardCommands.SizeToControl);
                break;

            case "Control &Width":
                mcs.GlobalInvoke(StandardCommands.SizeToControlWidth);
                break;

            case "Control &Height":
                mcs.GlobalInvoke(StandardCommands.SizeToControlHeight);
                break;

            case "&Grid":
                mcs.GlobalInvoke(StandardCommands.SizeToGrid);
                break;

            case "&Bring to Front":
                mcs.GlobalInvoke(StandardCommands.BringToFront);
                break;

            case "&Send to Back":
                mcs.GlobalInvoke(StandardCommands.SendToBack);
                break;

            case "&Tab Order":
                mcs.GlobalInvoke(StandardCommands.TabOrder);
                break;
            }
        }
Пример #2
0
 //
 private void OnServiceRequestsClosed(object sender, EventArgs e)
 {
     serviceRequests = null;
     hostingServiceContainer.RemoveService(typeof(ServiceRequests));
 }