コード例 #1
0
        public static RibbonRowPanel AddNewPanel(this RibbonRow instance)
        {
            var row = new RibbonRowPanel(instance);

            instance.Items.Add(row);

            return(row);
        }
コード例 #2
0
        public static RibbonRow AddNewRibbonRow(this RibbonPanelSource instance)
        {
            var row = new RibbonRow(instance);

            instance.Items.Add(row);

            return(row);
        }
コード例 #3
0
ファイル: AddBigButton.cs プロジェクト: topcss/ACAD_DEV
        public static void AddRibbonBigButtons_Method()
        {
            Editor ed = MgdAcApplication.DocumentManager.MdiActiveDocument.Editor;

            try
            {
                CustomizationSection cs = new CustomizationSection((string)MgdAcApplication.GetSystemVariable("MENUNAME"));
                string curWorkspace     = (string)MgdAcApplication.GetSystemVariable("WSCURRENT");

                RibbonPanelSource panelSrc = AddRibbonPanelToTab(cs, "ANAW", "AcadNetAddinWizard2");
                MacroGroup        macGroup = cs.MenuGroup.MacroGroups[0];

                RibbonRow row = new RibbonRow();
                panelSrc.Items.Add((RibbonItem)row);

                RibbonCommandButton button1 = new RibbonCommandButton(row);
                button1.Text = "Button 1";
                MenuMacro menuMac1 = macGroup.CreateMenuMacro("Button1_Macro", "^C^CButton1_Command ", "Button1_Tag", "Button1_Help",
                                                              MacroType.Any, "ANAW_16x16.bmp", "ANAW_32x32.bmp", "Button1_Label_Id");
                button1.MacroID      = menuMac1.ElementID;
                button1.ButtonStyle  = RibbonButtonStyle.LargeWithText;
                button1.KeyTip       = "Button1 Key Tip";
                button1.TooltipTitle = "Button1 Tooltip Title!";
                row.Items.Add((RibbonItem)button1);

                RibbonCommandButton button2 = new RibbonCommandButton(row);
                button2.Text = "Button 2";
                MenuMacro menuMac2 = macGroup.CreateMenuMacro("Button2_Macro", "^C^CButton2_Command ", "Button2_Tag", "Button2_Help",
                                                              MacroType.Any, "ANAW_16x16.bmp", "ANAW_32x32.bmp", "Button2_Label_Id");
                button2.MacroID      = menuMac2.ElementID;
                button2.ButtonStyle  = RibbonButtonStyle.LargeWithText;
                button2.KeyTip       = "Button2 Key Tip";
                button2.TooltipTitle = "Button2 Tooltip Title!";
                row.Items.Add((RibbonItem)button2);

                RibbonCommandButton button3 = new RibbonCommandButton(row);
                button3.Text = "Button 3";
                MenuMacro menuMac3 = macGroup.CreateMenuMacro("Button3_Macro", "^C^CButton3_Command ", "Button3_Tag", "Button3_Help",
                                                              MacroType.Any, "ANAW_16x16.bmp", "ANAW_32x32.bmp", "Button3_Label_Id");
                button3.MacroID      = menuMac3.ElementID;
                button3.ButtonStyle  = RibbonButtonStyle.LargeWithText;
                button3.KeyTip       = "Button3 Key Tip";
                button3.TooltipTitle = "Button3 Tooltip Title!";
                row.Items.Add((RibbonItem)button3);

                cs.Save();
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage(Environment.NewLine + ex.Message);
            }
        }
コード例 #4
0
        public static RibbonCommandButton AddNewButton(
            this RibbonRow instance,
            string text,
            string commandFriendlyName,
            string command,
            string commandDescription,
            string smallImagePath,
            string largeImagePath,
            RibbonButtonStyle style)
        {
            var customizationSection = instance.CustomizationSection;
            var macroGroups          = customizationSection.MenuGroup.MacroGroups;

            MacroGroup macroGroup;

            if (macroGroups.Count == 0)
            {
                macroGroup = new MacroGroup("MacroGroup", customizationSection.MenuGroup);
            }
            else
            {
                macroGroup = macroGroups[0];
            }

            var button = new RibbonCommandButton(instance);

            button.Text = text;

            var commandMacro = "^C^C_" + command;
            var commandId    = "ID_" + command;
            var buttonId     = "btn" + command;
            var labelId      = "lbl" + command;

            var menuMacro = macroGroup.CreateMenuMacro(commandFriendlyName,
                                                       commandMacro,
                                                       commandId,
                                                       commandDescription,
                                                       MacroType.Any,
                                                       smallImagePath,
                                                       largeImagePath,
                                                       labelId);
            var macro = menuMacro.macro;

            /*Associate custom command to ribbonbutton macro*/
            macro.CLICommand = command;

            button.MacroID     = menuMacro.ElementID;
            button.ButtonStyle = style;
            instance.Items.Add(button);

            return(button);
        }
コード例 #5
0
        public static RibbonSplitButton AddSplitButtonToRibbonPanel(RibbonPanelSource panelSource)
        {
            var ribbonRow = new RibbonRow();

            panelSource.Items.Add(ribbonRow);

            var splitButton = new RibbonSplitButton(ribbonRow);

            splitButton.ButtonStyle = RibbonButtonStyle.LargeWithText;
            ribbonRow.Items.Add(splitButton);

            return(splitButton);
        }
コード例 #6
0
        public static void CreateRibbonTabAndPanel(CustomizationSection cs, string toWorkspace, string tabName, string panelName)
        {
            RibbonRoot root = cs.MenuGroup.RibbonRoot;
            RibbonPanelSourceCollection panels = root.RibbonPanelSources;

            //Create The Ribbon Button
            MacroGroup macroGroup = new MacroGroup("MM19macroGroup", cs.MenuGroup);
            MenuMacro  macroLine  = macroGroup.CreateMenuMacro("TestLine",
                                                               "^C^C_Line",
                                                               "ID_MyLineCmd",
                                                               "My Line help",
                                                               MacroType.Any,
                                                               "RCDATA_16_LINE",
                                                               "RCDATA_32_LINE",
                                                               "My Test Line");

            //Create the ribbon panel source and add it to the ribbon panel source collection
            RibbonPanelSource panelSrc = new RibbonPanelSource(root);

            panelSrc.Text      = panelSrc.Name = panelName;
            panelSrc.ElementID = panelSrc.Id = panelName + "_PanelSourceID";
            panels.Add(panelSrc);



            //Create the ribbon tab source and add it to the ribbon tab source collection
            RibbonTabSource tabSrc = new RibbonTabSource(root);

            tabSrc.Name      = tabSrc.Text = tabName;
            tabSrc.ElementID = tabSrc.Id = tabName + "_TabSourceID";
            root.RibbonTabSources.Add(tabSrc);

            //Create the ribbon panel source reference and add it to the ribbon panel source reference collection
            RibbonPanelSourceReference ribPanelSourceRef = new RibbonPanelSourceReference(tabSrc)
            {
                PanelId = panelSrc.ElementID
            };

            tabSrc.Items.Add(ribPanelSourceRef);

            // Create a ribbon row
            RibbonRow ribRow = new RibbonRow(ribPanelSourceRef);

            panelSrc.Items.Add(ribRow);


            //Create a Ribbon Command Button
            RibbonCommandButton ribCommandButton = new RibbonCommandButton(ribRow)
            {
                Text    = "MyTestLineButton",
                MacroID = macroLine.ElementID,
            };

            ribCommandButton.ButtonStyle = RibbonButtonStyle.LargeWithText;
            ribRow.Items.Add(ribCommandButton);
            //Create the workspace ribbon tab source reference
            WSRibbonTabSourceReference tabSrcRef = WSRibbonTabSourceReference.Create(tabSrc);

            //Get the ribbon root of the workspace
            int          curWsIndex   = cs.Workspaces.IndexOfWorkspaceName(toWorkspace);
            WSRibbonRoot wsRibbonRoot = cs.Workspaces[curWsIndex].WorkspaceRibbonRoot;

            //Set the owner of the ribbon tab source reference and add it to the workspace ribbon tab collection
            tabSrcRef.SetParent(wsRibbonRoot);
            wsRibbonRoot.WorkspaceTabs.Add(tabSrcRef);
        }