Beispiel #1
0
        private void CreateMasterRibbon(UIControlledApplication uiApp, string tabName)
        {
            RibbonPanel panel = uiApp.CreateRibbonPanel(tabName, "BIM-мастер");


            SplitButtonData    sbdAddParams   = new SplitButtonData("FamilyParametersSplitButton", "Добавить параметры");
            PushButtonData     pbdClearGuids  = CreateButtonData("ClearUnusedGUIDs", "CommandClear");
            PushButtonData     pbdFixSlowFile = CreateButtonData("FixSlowFile", "Command");
            IList <RibbonItem> stacked1       = panel.AddStackedItems(sbdAddParams, pbdClearGuids, pbdFixSlowFile);

            SplitButton splitFamParam = stacked1[0] as SplitButton;

            splitFamParam.AddPushButton(CreateButtonData("ClearUnusedGUIDs", "CommandAddParameters"));
            splitFamParam.AddPushButton(CreateButtonData("ClearUnusedGUIDs", "CommandAddParamsByAnalog"));



            SplitButtonData    sbdParametrization = new SplitButtonData("ModelParametrizationSplitButton", "Параметризация");
            PushButtonData     pbdWorksets        = CreateButtonData("RevitWorksets", "Command");
            PushButtonData     pbdFamiliesLibrary = CreateButtonData("TestDockable3", "CommandShowDockableWindow");
            IList <RibbonItem> stacked2           = panel.AddStackedItems(sbdParametrization, pbdWorksets, pbdFamiliesLibrary);

            SplitButton splitParametrization = stacked2[0] as SplitButton;

            splitParametrization.AddPushButton(CreateButtonData("ParameterWriter", "Command"));
            splitParametrization.AddPushButton(CreateButtonData("RebarBDS", "Command"));
            splitParametrization.AddPushButton(CreateButtonData("WriteParametersFormElemsToParts", "CommandWriteParam"));
            splitParametrization.AddPushButton(CreateButtonData("RevitPlatesWeight", "Command"));
            splitParametrization.AddPushButton(CreateButtonData("IngradParametrisation", "Cmd"));
        }
        Result IExternalApplication.OnStartup(UIControlledApplication application)
        {
            RibbonPanel panel = application.CreateRibbonPanel("Shared parameters");

            PushButtonData data = new PushButtonData("BindSP", "Bind Shared\nParameters",
                                                     this.GetType().Assembly.Location, typeof(BindNewReadonlySharedParametersToDocument).FullName);

            panel.AddItem(data);

            panel.AddSeparator();

            PushButtonData data1 = new PushButtonData("SetIds1", "Set ids: GUID",
                                                      this.GetType().Assembly.Location, typeof(SetReadonlyId1).FullName);

            PushButtonData data2 = new PushButtonData("SetIds2", "Set ids: short",
                                                      this.GetType().Assembly.Location, typeof(SetReadonlyId2).FullName);

            panel.AddStackedItems(data1, data2);

            panel.AddSeparator();

            data1 = new PushButtonData("SetCosts1", "Set cost: random",
                                       this.GetType().Assembly.Location, typeof(SetReadonlyCost1).FullName);

            data2 = new PushButtonData("SetCosts2", "Set cost: sequence",
                                       this.GetType().Assembly.Location, typeof(SetReadonlyCost2).FullName);

            panel.AddStackedItems(data1, data2);

            return(Result.Succeeded);
        }
        /// <summary>
        /// Add buttons for the commands we define in this labs.
        /// Here we stack 2 x 2-push buttons and repeat it as we get more.
        /// TBD: still thinking which version is better ...
        /// </summary>
        public void AddUILabsCommandButtons_v2(RibbonPanel panel)
        {
            // Get the location of this dll.
            string assembly = GetType().Assembly.Location;

            // Create push buttons to stack up
            // #1
            PushButtonData pushButtonData1 = new PushButtonData("UILabsSelection", "Pick Sampler", assembly, _uiLabName + ".UISelection");

            pushButtonData1.Image = NewBitmapImage("basics.ico");

            // #2
            PushButtonData pushButtonData2 = new PushButtonData("UILabsCreateHouseUI", "Create House Pick", assembly, _uiLabName + ".CreateHouseUI");

            pushButtonData2.Image = NewBitmapImage("basics.ico");

            // #3
            PushButtonData pushButtonData3 = new PushButtonData("UILabsTaskDialog", "Dialog Sampler", assembly, _uiLabName + ".UITaskDialog");

            pushButtonData3.Image = NewBitmapImage("basics.ico");

            // #4
            PushButtonData pushButtonData4 = new PushButtonData("UILabsCreateHouseDialog", "Create House Dialog", assembly, _uiLabName + ".CreateHouseDialog");

            pushButtonData4.Image = NewBitmapImage("basics.ico");

            // Create 2 x 2-item stack.
            IList <RibbonItem> stackedItems1 = panel.AddStackedItems(pushButtonData1, pushButtonData2);

            IList <RibbonItem> stackedItems2 = panel.AddStackedItems(pushButtonData3, pushButtonData4);
        }
Beispiel #4
0
        /// <summary>
        /// Create new Stacked items at the panel
        /// </summary>
        /// <param name="action">Action where you must add items to the stacked panel</param>
        /// <returns>Panel where stacked items were created</returns>
        public Panel CreateStackedItems(Action <StackedItem> action)
        {
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            StackedItem stackedItem = new StackedItem(this);

            action.Invoke(stackedItem);

            if (stackedItem.ItemsCount < 2 ||
                stackedItem.ItemsCount > 3)
            {
                throw new InvalidOperationException("You must create 2 or three items in the StackedItems");
            }

            var item1 = stackedItem.Buttons[0].Finish();
            var item2 = stackedItem.Buttons[1].Finish();

            if (stackedItem.ItemsCount == 3)
            {
                var item3 =
                    stackedItem.Buttons[2].Finish();
                _panel.AddStackedItems(item1, item2, item3);
            }
            else
            {
                _panel.AddStackedItems(item1, item2);
            }

            return(this);
        }
Beispiel #5
0
        public static void QCPanel(UIControlledApplication uiApp, string tabname)
        {
            RibbonPanel CPanel = uiApp.CreateRibbonPanel(tabname, "Quality Control");

            PushButtonData b1Data = new PushButtonData(
                "Project Cleanup",
                "Project\r\nCleanup",
                @dllpath(),
                "CC_Plugin.ProjectCleanup");

            b1Data.ToolTip = "Remove unused View Templates, unused View Filters, and unused Elevation Markers";

            PushButton PB1 = CPanel.AddItem(b1Data) as PushButton;

            PushButtonData B2Data = new PushButtonData(
                "Update Line Styles",
                "Update Line Styles",
                @dllpath(),
                "CC_Plugin.ChangeLineStyle");

            PushButtonData B3Data = new PushButtonData(
                "List Line Styles",
                "List Line Styles",
                dllpath(),
                "CC_Plugin.ListLineStyles");

            PushButtonData B4Data = new PushButtonData(
                "Select Lines",
                "Select Lines",
                dllpath(),
                "CC_Plugin.SelectLines");

            List <RibbonItem> DBButtons2 = new List <RibbonItem>();

            DBButtons2.AddRange(CPanel.AddStackedItems(B2Data, B3Data, B4Data));

            PushButtonData B5Data = new PushButtonData(
                "Update Text Styles",
                "Update Text Styles",
                @dllpath(),
                "CC_Plugin.ChangeTextStyle");

            PushButtonData B6Data = new PushButtonData(
                "List Text Styles",
                "List Text Styles",
                dllpath(),
                "CC_Plugin.ListTextStyles");

            PushButtonData B7Data = new PushButtonData(
                "Select Notes",
                "Select Notes",
                dllpath(),
                "CC_Plugin.SelectNotes");

            List <RibbonItem> DBButtons3 = new List <RibbonItem>();

            DBButtons2.AddRange(CPanel.AddStackedItems(B5Data, B6Data, B7Data));
        }
Beispiel #6
0
        private void AddStackButton(RibbonPanel ribbon, string executableLocation, ButtonInfo button)
        {
            string dllLocation = Path.Combine(executableLocation, button.Dll ?? AppLayout.DefaultDll);

            var stackButtons = button.StackedList.Select(b => GetButtonData(dllLocation, b)).ToList();

            if (stackButtons.Count == 2)
            {
                ribbon.AddStackedItems(stackButtons[0], stackButtons[1]);
            }
            else if (stackButtons.Count == 3)
            {
                ribbon.AddStackedItems(stackButtons[0], stackButtons[1], stackButtons[2]);
            }
        }
Beispiel #7
0
        public static void CreateUI(RibbonPanel ribbonPanel)
        {
            // Create a push button to trigger a command add it to the ribbon panel.
            var thisAssembly = Assembly.GetExecutingAssembly();

            var buttonData = new PushButtonData
                             (
                "cmdRhinoInsideSample4", "Sample 4",
                thisAssembly.Location,
                MethodBase.GetCurrentMethod().DeclaringType.FullName
                             );

            var comboBoxData = new ComboBoxData("Category")
            {
                ToolTip = "Category where Sample 4 will place geometry."
            };

            var items = ribbonPanel.AddStackedItems(buttonData, comboBoxData);

            if (items[0] is PushButton pushButton)
            {
                pushButton.ToolTip    = "Eval a Grasshopper definition";
                pushButton.LargeImage = ImageBuilder.BuildImage("4");
                pushButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "https://github.com/mcneel/rhino.inside/blob/master/Autodesk/Revit/README.md#sample-4"));
            }

            categoriesComboBox = items[1] as Autodesk.Revit.UI.ComboBox;
            Revit.ApplicationUI.ViewActivated += ActiveUIApplication_ViewActivated;
        }
Beispiel #8
0
        /// <summary>
        /// 当前的分特征
        /// </summary>
        /// <param name="keyValuePair1"></param>
        /// <param name="keyValuePair2"></param>
        private static void AddStackButton(RibbonPanel panel, KeyValuePair <string, List <IFangCommand> > keyValuePair1, KeyValuePair <string, List <IFangCommand> > keyValuePair2)
        {
            ButtonData b1 = null;
            ButtonData b2 = null;

            if (keyValuePair1.Value.Count > 1)
            {
                b1 = CreatePullButton(panel, keyValuePair1.Key, keyValuePair1.Value);
            }
            else
            {
                b1 = CreateButton(panel, keyValuePair1.Key, keyValuePair1.Value);
            }
            if (keyValuePair2.Value.Count > 1)
            {
                b2 = CreatePullButton(panel, keyValuePair2.Key, keyValuePair2.Value);
            }
            else
            {
                b2 = CreateButton(panel, keyValuePair2.Key, keyValuePair2.Value);
            }

            var list = panel.AddStackedItems(b1, b2);

            if (keyValuePair1.Value.Count > 1)
            {
                AppendPullButton(list[0] as PulldownButton, keyValuePair1.Value);
            }

            if (keyValuePair2.Value.Count > 1)
            {
                AppendPullButton(list[1] as PulldownButton, keyValuePair2.Value);
            }
        }
Beispiel #9
0
        public static void CreateUI(RibbonPanel ribbonPanel)
        {
            // Create a push button to trigger a command add it to the ribbon panel.
            var thisAssembly = Assembly.GetExecutingAssembly();

            var items = ribbonPanel.AddStackedItems
                        (
                new ComboBoxData("Category"),
                new PulldownButtonData("cmdRhinoInside.GrasshopperPlayer", "Grasshopper Player")
                        );

            categoriesComboBox = items[0] as Autodesk.Revit.UI.ComboBox;
            if (categoriesComboBox != null)
            {
                categoriesComboBox.ToolTip = "Category where Grasshopper Player will place geometry.";
            }

            mruPullDownButton = items[1] as Autodesk.Revit.UI.PulldownButton;
            if (mruPullDownButton != null)
            {
                mruPullDownButton.ToolTip = "Loads and evals a Grasshopper definition";
                mruPullDownButton.Image   = ImageBuilder.BuildImage("4");
                mruPullDownButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "https://github.com/mcneel/rhino.inside/blob/master/Autodesk/Revit/README.md#sample-4"));

                mruPullDownButton.AddPushButton(typeof(Browse), "Browse...", "Browse for a Grasshopper definition to evaluate");
            }

            Revit.ApplicationUI.ViewActivated += ActiveUIApplication_ViewActivated;
        }
        /// <summary>
        /// Add buttons for the commands we define in this labs.
        /// Here we stack three push buttons and repeat it as we get more.
        /// This is a template to use during the Ribbon lab exercise prior to going to following labs.
        /// </summary>
        public void AddUILabsCommandButtons_Template(RibbonPanel panel)
        {
            // Get the location of this dll.
            string assembly = GetType().Assembly.Location;

            // Create three push buttons to stack up
            // #1
            PushButtonData pushButtonData1 = new PushButtonData("UILabsCommand1", "Command1", assembly, _uiLabName + ".Command1");

            pushButtonData1.Image = NewBitmapImage("ImgHelloWorldSmall.png");

            // #2
            PushButtonData pushButtonData2 = new PushButtonData("UILabsCommand2", "Command2", assembly, _uiLabName + ".Command2");

            pushButtonData2.Image = NewBitmapImage("ImgHelloWorldSmall.png");

            // #3
            PushButtonData pushButtonData3 = new PushButtonData("UILabsCommand3", "Command3", assembly, _uiLabName + ".Command3");

            pushButtonData3.Image = NewBitmapImage("ImgHelloWorldSmall.png");

            // Put them on stack

            IList <RibbonItem> stackedButtons = panel.AddStackedItems(pushButtonData1, pushButtonData2, pushButtonData3);
        }
Beispiel #11
0
        private void CreateTableRibbon(UIControlledApplication uiApp, string tabName)
        {
            RibbonPanel panel = uiApp.CreateRibbonPanel(tabName, "Таблицы");

            PushButtonData dataRebarSketch = CreateButtonData("RebarSketch", "CommandCreatePictures3");

            dataRebarSketch.Text = "Вед-ть\nдеталей";
            panel.AddItem(dataRebarSketch);

            PushButtonData dataAutonumber = CreateButtonData("Autonumber", "CommandStart");

            panel.AddItem(dataAutonumber);

            PushButtonData dataCollapseRebarSchedule = CreateButtonData("CollapseRebarSchedule", "Command");

            dataCollapseRebarSchedule.Text = "Подчистить\nВРС";
            panel.AddItem(dataCollapseRebarSchedule);

            PushButtonData pbdRefreshSchedules = CreateButtonData("BatchPrintYay", "CommandRefreshSchedules");
            PushButtonData dataSchedulesTable  = CreateButtonData("SchedulesTable", "CommandCreateTable");
            PushButtonData dataRevisions       = CreateButtonData("RevisionClouds", "Command");

            panel.AddStackedItems(pbdRefreshSchedules, dataSchedulesTable, dataRevisions);

            panel.AddSlideOut();
            PushButtonData dataScetchConstructor = CreateButtonData("RebarSketch", "CommandFormGenerator");

            panel.AddItem(dataScetchConstructor);
        }
Beispiel #12
0
        //Create stack column
        private IList <RibbonItem> CreateStackButtons(string tabName, string panelName, RibbonPanel ribbonPanel, List <Button> buttons, string path)
        {
            PushButtonData[] buttonData  = new PushButtonData[3];
            string []        buttonNames = new string[3];

            int index = 0;

            foreach (var button in buttons)
            {
                PushButtonData data = new PushButtonData(button.Name, button.Text, path, button.Command);
                data.ToolTip = button.ToolTip;
                data.SetContextualHelp(button.ContextualHelp);

                BitmapIcons bitmapIcons = new BitmapIcons(assembly, button.Image, MyApplication);
                var         largeImage  = bitmapIcons.LargeBitmap();
                var         smallImage  = bitmapIcons.SmallBitmap();
                data.LargeImage = largeImage;
                data.Image      = smallImage;

                buttonData[index]  = data;
                buttonNames[index] = button.Name;

                index++;
            }

            IList <RibbonItem> ribbonItem = ribbonPanel.AddStackedItems(buttonData[0], buttonData[1], buttonData[2]);

            SupressStackButtonText(tabName, panelName, buttonNames);

            return(ribbonItem);
        }
Beispiel #13
0
        public static void ElevationPanel(UIControlledApplication uiApp, string tabname)
        {
            RibbonPanel panel = uiApp.CreateRibbonPanel(tabname, "Elevations");

            PushButtonData b1data = new PushButtonData(
                "Generate Floor Views",
                "Generate Floor Views",
                @dllpath(),
                "CC_Events.CreateFloorViews");

            PushButtonData b2data = new PushButtonData(
                "Room Views",
                "Room Views",
                @dllpath(),
                "CC_Events.CreateRoomViews");

            PushButtonData b3data = new PushButtonData(
                "View Testing",
                "View Testing",
                @dllpath(),
                "CC_Events.CreateViews");

            List <RibbonItem> DBButtons = new List <RibbonItem>();

            DBButtons.AddRange(panel.AddStackedItems(b1data, b2data, b3data));
        }
Beispiel #14
0
        public Result OnStartup(UIControlledApplication uiApp)
        {
            try { uiApp.CreateRibbonTab(TabName); } catch {};
            RibbonPanel    Panel = uiApp.CreateRibbonPanel(TabName, PanelName);
            ComboBoxData   cb1   = new ComboBoxData("Height");
            ComboBoxData   cb2   = new ComboBoxData("Width");
            PushButtonData b1d   = new PushButtonData(
                "Create Detail Border",
                "Create Detail Border",
                @dllpath,
                "CC_ZeroPoint.CreateDetailBorder");

            b1d.ToolTip = "Create a reference border for the active detail view.";

            var items = Panel.AddStackedItems(cb1, cb2, b1d);
            var cbox1 = items[0] as ComboBox;
            var cbox2 = items[1] as ComboBox;

            cbox1.AddItem(new ComboBoxMemberData("Height - 1", "Height - 1"));
            cbox1.AddItem(new ComboBoxMemberData("Height - 2", "Height - 2"));
            cbox1.AddItem(new ComboBoxMemberData("Height - 3", "Height - 3"));
            cbox1.AddItem(new ComboBoxMemberData("Height - 4", "Height - 4"));

            cbox2.AddItem(new ComboBoxMemberData("Width - 1", "Width - 1"));
            cbox2.AddItem(new ComboBoxMemberData("Width - 1.5", "Width - 1.5"));
            cbox2.AddItem(new ComboBoxMemberData("Width - 2", "Width - 2"));
            cbox2.AddItem(new ComboBoxMemberData("Width - 3", "Width - 3"));
            cbox2.AddItem(new ComboBoxMemberData("Width - 4", "Width - 4"));
            cbox2.AddItem(new ComboBoxMemberData("Width - 5", "Width - 5"));

            return(Result.Succeeded);
        }
        public static void SchedulePanel(UIControlledApplication uiApp, string tabname)
        {
            RibbonPanel    CPanel = uiApp.CreateRibbonPanel(tabname, "Objects");
            PushButtonData pbc    = new PushButtonData(
                "Create Schedule",
                "Create Schedule",
                @dllpath(),
                "CC_Plugin.CreateSchedule");

            PushButtonData pbi = new PushButtonData(
                "Import Schedule",
                "Import Schedule",
                dllpath(),
                "CC_Plugin.ImportSchedule");

            PushButtonData pbo = new PushButtonData(
                "Import Objects",
                "Import Objects",
                dllpath(),
                "CC_Plugin.ImportObjects");

            ComboBoxData cbd = new ComboBoxData("Object Tools");

            IList <RibbonItem> Buttons = CPanel.AddStackedItems(pbc, pbi, pbo);
            ComboBox           cb      = CPanel.AddItem(cbd) as ComboBox;

            cb.AddItem(new ComboBoxMemberData("Doors", "Doors"));
            cb.AddItem(new ComboBoxMemberData("Materials", "Materials"));
        }
Beispiel #16
0
        public static void CreateUI(RibbonPanel ribbonPanel)
        {
            var items = ribbonPanel.AddStackedItems
                        (
                new ComboBoxData("Category"),
                new PulldownButtonData("cmdRhinoInside.GrasshopperPlayer", "Grasshopper Player")
                        );

            categoriesComboBox = items[0] as Autodesk.Revit.UI.ComboBox;
            if (categoriesComboBox != null)
            {
                categoriesComboBox.ToolTip = "Category where Grasshopper Player will place geometry.";
            }

            mruPullDownButton = items[1] as Autodesk.Revit.UI.PulldownButton;
            if (mruPullDownButton != null)
            {
                mruPullDownButton.ToolTip    = "Loads and evals a Grasshopper definition";
                mruPullDownButton.Image      = ImageBuilder.LoadBitmapImage("RhinoInside.Resources.GrasshopperPlayer.png", true);
                mruPullDownButton.LargeImage = ImageBuilder.LoadBitmapImage("RhinoInside.Resources.GrasshopperPlayer.png");
                mruPullDownButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "https://github.com/mcneel/rhino.inside/blob/master/Autodesk/Revit/README.md#sample-4"));

                mruPullDownButton.AddPushButton(typeof(Browse), "Browse...", "Browse for a Grasshopper definition to evaluate", typeof(Availability));
            }

            EventHandler <IdlingEventArgs> BuildDirectShapeCategoryList = null;

            Revit.ApplicationUI.Idling += BuildDirectShapeCategoryList = (sender, args) =>
            {
                var doc = (sender as UIApplication)?.ActiveUIDocument.Document;
                if (doc == null)
                {
                    return;
                }

                var directShapeCategories = Enum.GetValues(typeof(BuiltInCategory)).Cast <BuiltInCategory>().
                                            Where(categoryId => DirectShape.IsValidCategoryId(new ElementId(categoryId), doc)).
                                            Select(categoryId => Autodesk.Revit.DB.Category.GetCategory(doc, categoryId));

                foreach (var group in directShapeCategories.GroupBy(x => x.CategoryType).OrderBy(x => x.Key.ToString()))
                {
                    foreach (var category in group.OrderBy(x => x.Name))
                    {
                        var comboBoxMemberData = new ComboBoxMemberData(((BuiltInCategory)category.Id.IntegerValue).ToString(), category.Name)
                        {
                            GroupName = group.Key.ToString()
                        };
                        var item = categoriesComboBox.AddItem(comboBoxMemberData);

                        if ((BuiltInCategory)category.Id.IntegerValue == BuiltInCategory.OST_GenericModel)
                        {
                            categoriesComboBox.Current = item;
                        }
                    }
                }

                Revit.ApplicationUI.Idling -= BuildDirectShapeCategoryList;
            };
        }
Beispiel #17
0
        private void CreateSitePanel(UIControlledApplication application)
        {
            RibbonPanel    rp      = application.CreateRibbonPanel("Site");
            PushButtonData addPond = new PushButtonData("Site_Add_Pond", "Add Pond",
                                                        addAssemblyPath,
                                                        typeof(Revit.SDK.Samples.Site.CS.SiteAddRetainingPondCommand).FullName);

            SetIconsForPushButtonData(addPond, Revit.SDK.Samples.Site.CS.Properties.Resources.AddPond);
            PushButton pondPB = rp.AddItem(addPond) as PushButton;

            PushButtonData moveRegion = new PushButtonData("Site_Move_Region", "Move Region",
                                                           addAssemblyPath,
                                                           typeof(Revit.SDK.Samples.Site.CS.SiteMoveRegionAndPointsCommand).FullName);

            SetIconsForPushButtonData(moveRegion, Revit.SDK.Samples.Site.CS.Properties.Resources.MoveRegion);

            PushButtonData deleteRegion = new PushButtonData("Site_Delete_Region", "Delete Region",
                                                             addAssemblyPath,
                                                             typeof(Revit.SDK.Samples.Site.CS.SiteDeleteRegionAndPointsCommand).FullName);

            SetIconsForPushButtonData(deleteRegion, Revit.SDK.Samples.Site.CS.Properties.Resources.DeleteRegion);

            rp.AddStackedItems(moveRegion, deleteRegion);

            PushButtonData raiseTerrain = new PushButtonData("Site_Raise_Terrain", "Raise Terrain",
                                                             addAssemblyPath,
                                                             typeof(Revit.SDK.Samples.Site.CS.SiteRaiseTerrainInRegionCommand).FullName);

            SetIconsForPushButtonData(raiseTerrain, Revit.SDK.Samples.Site.CS.Properties.Resources.RaiseTerrain);

            PushButtonData lowerTerrain = new PushButtonData("Site_Lower_Terrain", "Lower Terrain",
                                                             addAssemblyPath,
                                                             typeof(Revit.SDK.Samples.Site.CS.SiteLowerTerrainInRegionCommand).FullName);

            SetIconsForPushButtonData(lowerTerrain, Revit.SDK.Samples.Site.CS.Properties.Resources.LowerTerrain);

            PushButtonData normalizeTerrain = new PushButtonData("Site_Normalize_Terrain", "Normalize Terrain",
                                                                 addAssemblyPath,
                                                                 typeof(Revit.SDK.Samples.Site.CS.SiteNormalizeTerrainInRegionCommand).FullName);

            SetIconsForPushButtonData(normalizeTerrain, Revit.SDK.Samples.Site.CS.Properties.Resources.SiteNormalize);

            rp.AddStackedItems(raiseTerrain, lowerTerrain, normalizeTerrain);
        }
Beispiel #18
0
        /// <summary>
        /// Add samples of categories not in default categories
        /// </summary>
        private void AddCustomizedPulldownMenus()
        {
            int iCount = m_customizedMenus.Count;

            // Sort sample items in every category by display name
            SortSampleItemsInOneCategory(m_customizedMenus);

            int i = 0;

            while (iCount >= 3)
            {
                string             name  = m_customizedMenus.Keys[i++];
                PulldownButtonData data1 = new PulldownButtonData(name, name);
                name = m_customizedMenus.Keys[i++];
                PulldownButtonData data2 = new PulldownButtonData(name, name);
                name = m_customizedMenus.Keys[i++];
                PulldownButtonData data3   = new PulldownButtonData(name, name);
                IList <RibbonItem> buttons = m_panelRvtSamples.AddStackedItems(data1, data2, data3);
                AddSamplesToStackedButtons(buttons);

                iCount -= 3;
            }

            if (iCount == 2)
            {
                string             name  = m_customizedMenus.Keys[i++];
                PulldownButtonData data1 = new PulldownButtonData(name, name);
                name = m_customizedMenus.Keys[i++];
                PulldownButtonData data2   = new PulldownButtonData(name, name);
                IList <RibbonItem> buttons = m_panelRvtSamples.AddStackedItems(data1, data2);
                AddSamplesToStackedButtons(buttons);
            }
            else if (iCount == 1)
            {
                string             name = m_customizedMenus.Keys[i];
                PulldownButtonData pulldownButtonData = new PulldownButtonData(name, name);
                PulldownButton     button             = m_panelRvtSamples.AddItem(pulldownButtonData) as PulldownButton;
                List <SampleItem>  sampleItems        = m_customizedMenus.Values[m_customizedMenus.IndexOfKey(button.Name)];
                foreach (SampleItem item in sampleItems)
                {
                    AddSampleToPulldownMenu(button, item);
                }
            }
        }
        public static void CreateUI(RibbonPanel ribbonPanel)
        {
            var items = ribbonPanel.AddStackedItems
                        (
                new ComboBoxData("Category"),
                NewPushButtonData <CommandGrasshopperBake, NeedsActiveDocument <Availability> >("Bake Selected")
                        );

            if (items[0] is ComboBox comboBox)
            {
                categoriesComboBox = comboBox;

                EventHandler <IdlingEventArgs> BuildDirectShapeCategoryList = null;
                Revit.ApplicationUI.Idling += BuildDirectShapeCategoryList = (sender, args) =>
                {
                    var doc = (sender as UIApplication).ActiveUIDocument?.Document;
                    if (doc == null)
                    {
                        return;
                    }

                    var directShapeCategories = Enum.GetValues(typeof(DB.BuiltInCategory)).Cast <DB.BuiltInCategory>().
                                                Where(categoryId => DB.DirectShape.IsValidCategoryId(new DB.ElementId(categoryId), doc)).
                                                Select(categoryId => DB.Category.GetCategory(doc, categoryId)).
                                                Where(x => x is object);

                    foreach (var group in directShapeCategories.GroupBy(x => x.CategoryType).OrderBy(x => x.Key.ToString()))
                    {
                        foreach (var category in group.OrderBy(x => x.Name))
                        {
                            var comboBoxMemberData = new ComboBoxMemberData(((DB.BuiltInCategory)category.Id.IntegerValue).ToString(), category.Name)
                            {
                                GroupName = group.Key.ToString()
                            };
                            var item = categoriesComboBox.AddItem(comboBoxMemberData);

                            if ((DB.BuiltInCategory)category.Id.IntegerValue == DB.BuiltInCategory.OST_GenericModel)
                            {
                                categoriesComboBox.Current = item;
                            }
                        }
                    }

                    Revit.ApplicationUI.Idling -= BuildDirectShapeCategoryList;
                };
            }

            if (items[1] is PushButton bakeButton)
            {
                bakeButton.ToolTip         = "Bakes selected objects content in the active Revit document";
                bakeButton.LongDescription = "Use CTRL key to group resulting elements";
                bakeButton.Image           = ImageBuilder.LoadBitmapImage("RhinoInside.Resources.GH.Toolbar.Bake.png", true);
                bakeButton.LargeImage      = ImageBuilder.LoadBitmapImage("RhinoInside.Resources.GH.Toolbar.Bake.png");
                bakeButton.Visible         = PlugIn.PlugInExists(PluginId, out bool _, out bool _);
            }
        }
Beispiel #20
0
        static void AddRibbonPanel(UIControlledApplication application)
        {
            // Create a custom ribbon tab
            String tabName = "Grimshaw";

            application.CreateRibbonTab(tabName);

            // Add a new ribbon panel
            RibbonPanel ribbonPanel = application.CreateRibbonPanel(tabName, "Grimshaw Architects");

            // Get dll assembly path
            string thisAssemblyPath = Assembly.GetExecutingAssembly().Location;

            #region Curve Total Length Button
            PushButtonData buttonData = new PushButtonData("cmdCurveTotalLength",
                                                           "Total Length", thisAssemblyPath, "GrimshawRibbon.CurveTotalLength");
            PushButton pushButton = ribbonPanel.AddItem(buttonData) as PushButton;
            pushButton.ToolTip = "Select Multiple Lines to Obtain Total Length";
            // Add image icon to
            Uri         uriImage   = new Uri(@"D:\Stuff\RevitVisualStudio\CurveTotalLength\CurveTotalLength\bin\Debug\CurveTotalLength.png");
            BitmapImage largeImage = new BitmapImage(uriImage);
            pushButton.LargeImage = largeImage;
            #endregion // Curve Total Length Button

            #region Workset 3d View, Upper Case Views on Sheet and Delete Reference Planes Buttons
            // Create two push buttons
            // Project Management Commands
            PushButtonData pushButton1 = new PushButtonData("cmdWorkset3dView", "Make 3D View/Workset", thisAssemblyPath, "GrimshawRibbon.Workset3dView");
            pushButton1.Image   = new BitmapImage(new Uri(@"D:\Stuff\RevitVisualStudio\Workset3dView\Workset3dView\bin\Debug\favicon.png"));
            pushButton1.ToolTip = "Create one 3D View per workset with all elemets on that workset isolated.";

            PushButtonData pushButton2 = new PushButtonData("cmdUpperCaseViewsOnSheets", "UpperCase Sheet Views", thisAssemblyPath, "GrimshawRibbon.UpperCaseViewsOnSheets");
            pushButton2.Image   = new BitmapImage(new Uri(@"D:\Stuff\RevitVisualStudio\UpperCaseViewsOnSheets\UpperCaseViewsOnSheets\bin\Debug\UpperCaseViewsOnSheets.png"));
            pushButton2.ToolTip = "Rename all Views in the Project to 'uppercase' if its on a Sheet and 'lowercase' if its not on a Sheet.";

            PushButtonData pushButton3 = new PushButtonData("cmdDeleteReferencePlanes", "Delete Reference Planes", thisAssemblyPath, "GrimshawRibbon.DeleteReferencePlanes");
            pushButton3.Image   = new BitmapImage(new Uri(@"D:\Stuff\RevitVisualStudio\DeleteReferencePlanes\DeleteReferencePlanes\bin\Debug\deleteReferencePlanes.png"));
            pushButton3.ToolTip = "Delete all unnamed reference planes in the project.";

            // Add the buttons to the panel
            List <RibbonItem> projectButtons = new List <RibbonItem>();
            projectButtons.AddRange(ribbonPanel.AddStackedItems(pushButton1, pushButton2, pushButton3));
            #endregion // Workset 3d View, Upper Case Views on Sheet and Delete Reference Planes Buttons

            #region Prevent Deletion Button
            PushButtonData preventDelButtonData = new PushButtonData("cmdPreventDeletion",
                                                                     "Prevent Deletion", thisAssemblyPath, "GrimshawRibbon.PreventDeletion");
            PushButton preventDelButton = ribbonPanel.AddItem(preventDelButtonData) as PushButton;
            preventDelButton.ToolTip = "Prevent elements from being deleted.";
            // Add image icon to
            Uri         preventDelImage      = new Uri(@"D:\Stuff\RevitVisualStudio\PreventDeletion\PreventDeletion\bin\Debug\preventDeletion.png");
            BitmapImage preventDellargeImage = new BitmapImage(preventDelImage);
            preventDelButton.LargeImage = preventDellargeImage;
            #endregion // Prevent Deletion Button
        }
        /// <summary>
        /// Stacked Buttons - combination of: push button, dropdown button, combo box and text box.
        /// (no radio button group, split buttons).
        /// Here we define 6 buttons, make grouping of 1, 3, 2 items, and stack them in three layer:
        /// (1) simple push button with "Hello World"
        /// (2) pull down with 3 items: "Command Data", "DB Element" and "Element Filtering".
        /// (3) pull down with 2 items: "Element Modification" and "Model Creation"
        /// </summary>
        public void AddStackedButtons_Complex(RibbonPanel panel)
        {
            // Create six push buttons to group for pull down and stack up

            // #0
            PushButtonData pushButtonData0 = new PushButtonData("StackComplexHelloWorld", "Hello World", _introLabPath, _introLabName + ".HelloWorld");

            pushButtonData0.Image = NewBitmapImage("Basics.ico");

            // #1
            PushButtonData pushButtonData1 = new PushButtonData("StackComplexCommandData", "Command Data", _introLabPath, _introLabName + ".CommandData");

            pushButtonData1.Image = NewBitmapImage("Basics.ico");

            // #2
            PushButtonData pushButtonData2 = new PushButtonData("StackComplexDbElement", "DB Element", _introLabPath, _introLabName + ".DBElement");

            // #3
            PushButtonData pushButtonData3 = new PushButtonData("StackComplexElementFiltering", "Filtering", _introLabPath, _introLabName + ".ElementFiltering");

            // #4
            PushButtonData pushButtonData4 = new PushButtonData("StackComplexElementModification", "Modify", _introLabPath, _introLabName + ".ElementModification");

            // #5
            PushButtonData pushButtonData5 = new PushButtonData("StackComplexModelCreation", "Create", _introLabPath, _introLabName + ".ModelCreation");

            // Make two sets of pull down

            PulldownButtonData pulldownBtnData1 = new PulldownButtonData("StackComplePulldownButton1", "DB Basics");
            PulldownButtonData pulldownBtnData2 = new PulldownButtonData("StackComplePulldownButton2", "Modeling");

            // Create three item stack.
            IList <RibbonItem> stackedItems = panel.AddStackedItems(pushButtonData0, pulldownBtnData1, pulldownBtnData2);
            PulldownButton     pulldownBtn2 = stackedItems[1] as PulldownButton;
            PulldownButton     pulldownBtn3 = stackedItems[2] as PulldownButton;

            pulldownBtn2.Image = NewBitmapImage("Basics.ico");
            pulldownBtn3.Image = NewBitmapImage("House.ico");

            // Add each sub items
            PushButton button1 = pulldownBtn2.AddPushButton(pushButtonData1);
            PushButton button2 = pulldownBtn2.AddPushButton(pushButtonData2);
            PushButton button3 = pulldownBtn2.AddPushButton(pushButtonData3);
            PushButton button4 = pulldownBtn3.AddPushButton(pushButtonData4);
            PushButton button5 = pulldownBtn3.AddPushButton(pushButtonData5);

            // Note: we need to set the image later. if we do in button data, it won't show in the Ribbon.
            button1.Image = NewBitmapImage("Basics.ico");
            button2.Image = NewBitmapImage("Basics.ico");
            button3.Image = NewBitmapImage("Basics.ico");
            button4.Image = NewBitmapImage("Basics.ico");

            button5.Image = NewBitmapImage("Basics.ico");
        }
Beispiel #22
0
        private static void AddRibbonPanel(UIControlledApplication application)
        {
            string tab_name = "DotNetRevit";

            application.CreateRibbonTab(tab_name);

            RibbonPanel projectRibbonPanel = application.CreateRibbonPanel(tab_name, "Project");

            projectRibbonPanel.AddStackedItems(Scripts.MainTab.Project.ProjectTools2_Stack.B_GetCentralPath.buttonData,
                                               Scripts.MainTab.Project.ProjectTools2_Stack.b_GetRvtInfo.buttonData,
                                               Scripts.MainTab.Project.ProjectTools2_Stack.b_LoadMoreTypes.buttonData);
        }
        /// <summary>
        /// Add buttons for the commands we define in this labs.
        /// Here we stack three push buttons and repeat it as we get more.
        /// </summary>
        public void AddUILabsCommandButtons(RibbonPanel panel)
        {
            // Get the location of this dll.
            string assembly = GetType().Assembly.Location;

            // Create three push buttons to stack up
            // #1
            PushButtonData pushButtonData1 = new PushButtonData("UILabsSelection", "Pick Sampler", assembly, _uiLabName + ".UISelection");

            pushButtonData1.Image = NewBitmapImage("basics.ico");

            // #2
            PushButtonData pushButtonData2 = new PushButtonData("UILabsCreateHouse", "Create House Pick", assembly, _uiLabName + ".UICreateHouse");

            pushButtonData2.Image = NewBitmapImage("House.ico");

            // #3
            PushButtonData pushButtonData3 = new PushButtonData("UILabsTaskDialog", "Dialog Sampler", assembly, _uiLabName + ".UITaskDialog");

            pushButtonData3.Image = NewBitmapImage("basics.ico");

            // #4
            PushButtonData pushButtonData4 = new PushButtonData("UILabsCreateHouseDialog", "Create House Dialog", assembly, _uiLabName + ".UICreateHouseDialog");

            pushButtonData4.Image = NewBitmapImage("House.ico");

            // #5
            // Make three sets of pull down
            PulldownButtonData pulldownBtnData1 = new PulldownButtonData("UILabsPulldownButton1", "Selection");
            PulldownButtonData pulldownBtnData2 = new PulldownButtonData("UILabsPulldownButton2", "Task Dialog");

            // Create three item stack.
            IList <RibbonItem> stackedItems = panel.AddStackedItems(pulldownBtnData1, pulldownBtnData2);
            PulldownButton     pulldownBtn1 = stackedItems[0] as PulldownButton;
            PulldownButton     pulldownBtn2 = stackedItems[1] as PulldownButton;

            pulldownBtn1.Image = NewBitmapImage("Basics.ico");
            pulldownBtn2.Image = NewBitmapImage("Basics.ico");

            // Add each sub items
            PushButton button1 = pulldownBtn1.AddPushButton(pushButtonData1);
            PushButton button2 = pulldownBtn1.AddPushButton(pushButtonData2);
            PushButton button3 = pulldownBtn2.AddPushButton(pushButtonData3);
            PushButton button4 = pulldownBtn2.AddPushButton(pushButtonData4);

            // Note: we need to set the image later. if we do in button data, it won't show in the Ribbon.
            button1.Image = NewBitmapImage("Basics.ico");
            button2.Image = NewBitmapImage("Basics.ico");
            button3.Image = NewBitmapImage("Basics.ico");
            button4.Image = NewBitmapImage("Basics.ico");
        }
Beispiel #24
0
        /// <summary>
        /// Adds a group of text fields for accepting user input for the various parameters
        /// of the sine curve (cycles, period, amplitude).
        /// </summary>
        /// <param name="panel">the RibbonPanel where the UI element is added</param>
        private void AddCurvePropertiesTextFields(RibbonPanel panel)
        {
            //Inactive textfields that just display information about the active input fields
            TextBoxData periodLabelData    = new TextBoxData("curve period field");
            TextBoxData cyclesLabelData    = new TextBoxData("curve cycles field");
            TextBoxData amplitudeLabelData = new TextBoxData("curve amplitude field");
            //Stack them horizontally
            IList <RibbonItem> textFieldList = panel.AddStackedItems(periodLabelData, cyclesLabelData, amplitudeLabelData);
            //Call method to customize the text boxes and make them inactive
            String periodToolTip = "A double value denoting the period of the curve, i.e. how often the curve goes a full repition around the unit circle.";

            CustomizeTextBox(panel, (TextBox)textFieldList[0], periodToolTip, "curve period:", 0, false, 130);
            String cyclesToolTip = "A double value denoting the number of circles the curve makes.";

            CustomizeTextBox(panel, (TextBox)textFieldList[1], cyclesToolTip, "curve cycles:", 0, false, 130);
            String amplitudeToolTip = "A double value denoting how far the curve gets away from the x-axis.";

            CustomizeTextBox(panel, (TextBox)textFieldList[2], amplitudeToolTip, "curve amplitude:", 0, false, 130);

            //Active text fields for user input
            TextBoxData periodBoxData    = new TextBoxData("curve period");
            TextBoxData cyclesBoxData    = new TextBoxData("curve cycles");
            TextBoxData amplitudeBoxData = new TextBoxData("curve amplitude");
            //Stack them horizontally
            IList <RibbonItem> textBoxList = panel.AddStackedItems(periodBoxData, cyclesBoxData, amplitudeBoxData);

            periodBox    = (TextBox)textBoxList[0];
            cyclesBox    = (TextBox)textBoxList[1];
            amplitudeBox = (TextBox)textBoxList[2];

            //Call method to customize the text boxes and make them active
            CustomizeTextBox(panel, periodBox,
                             "Define the period of the sine curve", "" + periodVal, periodVal, true, 50);
            CustomizeTextBox(panel, cyclesBox,
                             "Define the number of cycles of the sine curve", "" + cyclesVal, cyclesVal, true, 50);
            CustomizeTextBox(panel, amplitudeBox,
                             "Define the amplitude of the sine curve", "" + amplitudeVal, amplitudeVal, true, 50);
        }
Beispiel #25
0
        public Result OnStartup(
            UIControlledApplication a)
        {
            string path = System.Reflection.Assembly
                          .GetExecutingAssembly().Location;

            // Create ribbon panel

            RibbonPanel p = a.CreateRibbonPanel(Caption);

            // Create buttons

            //PushButtonData d = new PushButtonData(
            //  _cmd1, _cmd1, path,
            //  _class_name_prefix + "GeomVertices" );

            //d.ToolTip = "Place a setout point marker "
            //  + "on every concrete corner.";

            //p.AddItem( d );

            //d = new PushButtonData( _cmd2, _cmd2, path,
            //  _class_name_prefix + _cmd2 );

            //d.ToolTip = "Renumber major setout points";

            //p.AddItem( d );

            List <PushButtonData> buttonData
                = new List <PushButtonData>(
                      data.Length);

            foreach (CmdData cd in data)
            {
                PushButtonData pbd = new PushButtonData(
                    cd.Name, cd.Text, path,
                    _class_name_prefix + cd.Name);

                pbd.ToolTip = cd.Tip;

                //p.AddItem( pbd );

                buttonData.Add(pbd);
            }

            p.AddStackedItems(buttonData[0],
                              buttonData[1]);

            return(Result.Succeeded);
        }
Beispiel #26
0
        /// <summary>
        /// Add min 2 or max 3 buttons to a stacked button.
        /// </summary>
        private bool AddStackedButton(RibbonPanel panel, IList <PushButtonData> stackedButtonsGroup, string stackedButtonName, string stackedButtonText)
        {
            try
            {
                List <RibbonItem> projectButtons = new List <RibbonItem>();
                projectButtons.AddRange(panel.AddStackedItems(stackedButtonsGroup[0], stackedButtonsGroup[1], stackedButtonsGroup[2]));

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Beispiel #27
0
        private void CreateViewRibbon(UIControlledApplication uiApp, string tabName)
        {
            RibbonPanel panel = uiApp.CreateRibbonPanel(tabName, "Виды и листы");

            PushButtonData pbdPrint = CreateButtonData("BatchPrintYay", "CommandBatchPrint");

            panel.AddItem(pbdPrint);

            PushButtonData pbdColorize = CreateButtonData("RevitViewFilters", "CommandViewColoring");

            panel.AddItem(pbdColorize);


            PushButtonData pbdWallHatch = CreateButtonData("RevitViewFilters", "CommandWallHatch");
            PushButtonData pbdOverrides = CreateButtonData("RevitGraphicsOverride", "Command");

            SplitButtonData sbdFilters = new SplitButtonData("SplitButtonViewFilters", "Фильтры графики");



            IList <RibbonItem> filterItems = panel.AddStackedItems(pbdOverrides, pbdWallHatch, sbdFilters);

            SplitButton    sbFilters        = filterItems[2] as SplitButton;
            PushButtonData pbdCreateFilters = CreateButtonData("RevitViewFilters", "CommandCreate");

            sbFilters.AddPushButton(pbdCreateFilters);
            PushButtonData pbdDeleteFilters = CreateButtonData("RevitViewFilters", "CommandBatchDelete");

            sbFilters.AddPushButton(pbdDeleteFilters);

            PushButtonData pbdOpenSheets  = CreateButtonData("OpenSheets", "Command");
            PushButtonData pbdViewNumbers = CreateButtonData("ViewportNumbers", "CommandViewportNumbers");
            PushButtonData pbdTemplates   = CreateButtonData("ViewTemplateUtils", "CommandCopyTemplate");

            panel.AddStackedItems(pbdOpenSheets, pbdViewNumbers, pbdTemplates);
        }
Beispiel #28
0
        private bool AddStackedPullDownhButtons(RibbonPanel rp)
        {
            SplitButton sb0;
            SplitButton sb1;


            SplitButtonData sbData0 = new SplitButtonData("pullDownButton0", "function select");

            sbData0.Image = RibbonUtil.GetBitmapImage(SMALLICON);

            SplitButtonData sbData1 = new SplitButtonData("pullDownButton1", "auto activate");

            sbData1.Image = RibbonUtil.GetBitmapImage(SMALLICON);

            PushButtonData pbData0 = createButton("pushButton0", "Auto Update: On - Turn Off", "ToggAutoActivate",
                                                  "Revit Windows Settings", SMALLICON, LARGEICON);

            PushButtonData pbData1 = createButton("pushButton1", "Settings", "SettingsFormShow",
                                                  "Revit Windows Settings", SMALLICON, LARGEICON);

            IList <RibbonItem> ris = rp.AddStackedItems(sbData0, pbData0, pbData1);

            sb0 = ris[0] as SplitButton;
//			sb1 = ris[1] as SplitButton;
            pb01 = ris[1] as PushButton;

            PushButtonData pbd;

            // pull down button 0
            pbd = createButton("button00", "Side Views Larger ", "IncreaseSideViewSize",
                               "Make the Active View Larger", SMALLICON, LARGEICON);
            sb0.AddPushButton(pbd);

            pbd = createButton("button01", "Side Views Smaller", "DecreaseSideViewSize",
                               "Make the Active View Smaller", SMALLICON, LARGEICON);
            sb0.AddPushButton(pbd);

//			// pull down button 1
//			pbd = createButton("button10", "Activate Auto On", "AutoActivateOn",
//				"Turn on AutoActivate", SMALLICON, LARGEICON);
//			sb1.AddPushButton(pbd);
//
//			pbd = createButton("button11", "Activate Auto Off", "AutoActivateOff",
//				"Turn off AutoActivate", SMALLICON, LARGEICON);
//			sb1.AddPushButton(pbd);
//
            return(true);
        }
Beispiel #29
0
        static void AddToolbar(UIControlledApplication application)
        {
            application.CreateRibbonTab("SAC");

            RibbonPanel ribbonPanel = application.CreateRibbonPanel("SAC", "Tools");

            String thisAssemblyPath = Assembly.GetExecutingAssembly().Location;

            PushButtonData b1Data = new PushButtonData("cmdRotateClockwise", "Rotate Clockwise", thisAssemblyPath, "SACToolbar.RotateClockwise");
            PushButtonData b2Data = new PushButtonData("cmdRotateCounterClockwise", "Rotate Counter Clockwise", thisAssemblyPath, "SACToolbar.RotateCounterClockwise");
            PushButtonData b3Data = new PushButtonData("cmdCircuitEditor", "Circuit Editor", thisAssemblyPath, "SACToolbar.CircuitEditor");

            List <RibbonItem> projectbuttons = new List <RibbonItem>();

            projectbuttons.AddRange(ribbonPanel.AddStackedItems(b1Data, b2Data, b3Data));
        }
Beispiel #30
0
        /// <summary>
        /// Create a stack of 3 buttons in the Revit UI.
        /// </summary>
        /// <param name="revApp">Revit's UIControlledApplication for adding the button</param>
        /// <param name="tabName">Name of the tab you want to add the button to.</param>
        /// <param name="panelName">Name of the panel on the tab you want to add the button</param>
        /// <param name="button0">Top button in the stack</param>
        /// <param name="button1">Middle button in the stack</param>
        /// <param name="button2">Bottom button in the stack</param>
        public static bool AddToRibbon(UIControlledApplication revApp, string tabName, string panelName, PushButtonData button0, PushButtonData button1, PushButtonData button2)
        {
            RibbonPanel panel = GetRibbonPanel(revApp, tabName, panelName);

            // Add the button to the panel
            if (panel != null)
            {
                panel.AddStackedItems(button0, button1, button2);
            }
            else
            {
                TaskDialog.Show("Error", "Could not create stacked buttons for:\n" + button0.Text + "\n" + button1.Text + "\n" + button2.Text);
            }

            return(true);
        }
    /// <summary>
    /// Add buttons for the commands we define in this labs. 
    /// Here we stack three push buttons and repeat it as we get more. 
    /// This is a template to use during the Ribbon lab exercise prior to going to following labs. 
    /// </summary>
    public void AddUILabsCommandButtons_Template(RibbonPanel panel)
    {
      // Get the location of this dll. 
      string assembly = GetType().Assembly.Location;

      // Create three push buttons to stack up 
      // #1 
      PushButtonData pushButtonData1 = new PushButtonData("UILabsCommand1", "Command1", assembly, _uiLabName + ".Command1");
      pushButtonData1.Image = NewBitmapImage("ImgHelloWorldSmall.png");

      // #2 
      PushButtonData pushButtonData2 = new PushButtonData("UILabsCommand2", "Command2", assembly, _uiLabName + ".Command2");
      pushButtonData2.Image = NewBitmapImage("ImgHelloWorldSmall.png");

      // #3 
      PushButtonData pushButtonData3 = new PushButtonData("UILabsCommand3", "Command3", assembly, _uiLabName + ".Command3");
      pushButtonData3.Image = NewBitmapImage("ImgHelloWorldSmall.png");

      // Put them on stack 

      IList<RibbonItem> stackedButtons = panel.AddStackedItems(pushButtonData1, pushButtonData2, pushButtonData3);
    }
        private static void AddUngroupedCommands(string dllfullpath, RibbonPanel ribbonPanel, List<Command> commands)
        {
            // add canned commands as stacked pushbuttons (try to pack 3 commands per pushbutton, then 2)
            while (commands.Count > 4 || commands.Count == 3)
            {
                // remove first three commands from the list
                var command0 = commands[0];
                var command1 = commands[1];
                var command2 = commands[2];
                commands.RemoveAt(0);
                commands.RemoveAt(0);
                commands.RemoveAt(0);

                PushButtonData pbdA = new PushButtonData(command0.Name, command0.Name, dllfullpath, "Command" + command0.Index);
                pbdA.Image = command0.SmallImage;
                pbdA.LargeImage = command0.LargeImage;

                PushButtonData pbdB = new PushButtonData(command1.Name, command1.Name, dllfullpath, "Command" + command1.Index);
                pbdB.Image = command1.SmallImage;
                pbdB.LargeImage = command1.LargeImage;

                PushButtonData pbdC = new PushButtonData(command2.Name, command2.Name, dllfullpath, "Command" + command2.Index);
                pbdC.Image = command2.SmallImage;
                pbdC.LargeImage = command2.LargeImage;

                ribbonPanel.AddStackedItems(pbdA, pbdB, pbdC);
            }
            if (commands.Count == 4)
            {
                // remove first two commands from the list
                var command0 = commands[0];
                var command1 = commands[1];
                commands.RemoveAt(0);
                commands.RemoveAt(0);

                PushButtonData pbdA = new PushButtonData(command0.Name, command0.Name, dllfullpath, "Command" + command0.Index);
                pbdA.Image = command0.SmallImage;
                pbdA.LargeImage = command0.LargeImage;

                PushButtonData pbdB = new PushButtonData(command1.Name, command1.Name, dllfullpath, "Command" + command1.Index);
                pbdB.Image = command0.SmallImage;
                pbdB.LargeImage = command0.LargeImage;

                ribbonPanel.AddStackedItems(pbdA, pbdB);
            }
            if (commands.Count == 2)
            {
                // remove first two commands from the list
                var command0 = commands[0];
                var command1 = commands[1];
                commands.RemoveAt(0);
                commands.RemoveAt(0);
                PushButtonData pbdA = new PushButtonData(command0.Name, command0.Name, dllfullpath, "Command" + command0.Index);
                pbdA.Image = command0.SmallImage;
                pbdA.LargeImage = command0.LargeImage;

                PushButtonData pbdB = new PushButtonData(command1.Name, command1.Name, dllfullpath, "Command" + command1.Index);
                pbdB.Image = command1.SmallImage;
                pbdB.LargeImage = command1.LargeImage;

                ribbonPanel.AddStackedItems(pbdA, pbdB);
            }
            if (commands.Count == 1)
            {
                // only one command defined, show as a big button...
                var command = commands[0];
                PushButtonData pbd = new PushButtonData(command.Name, command.Name, dllfullpath, "Command" + command.Index);
                pbd.Image = command.SmallImage;
                pbd.LargeImage = command.LargeImage;
                ribbonPanel.AddItem(pbd);
            }
        }
    /// <summary>
    /// Stacked Buttons - combination of: push button, dropdown button, combo box and text box. 
    /// (no radio button group, split buttons). 
    /// Here we stack three push buttons for "Command Data", "DB Element" and "Element Filtering". 
    /// </summary>
    public void AddStackedButtons_Simple(RibbonPanel panel)
    {
      // Create three push buttons to stack up 
      // #1 
      PushButtonData pushButtonData1 = new PushButtonData("StackSimpleCommandData", "Command Data", _introLabPath, _introLabName + ".CommandData");
      pushButtonData1.Image = NewBitmapImage("ImgHelloWorldSmall.png");

      // #2 
      PushButtonData pushButtonData2 = new PushButtonData("StackSimpleDbElement", "DB Element", _introLabPath, _introLabName + ".DBElement");
      pushButtonData2.Image = NewBitmapImage("ImgHelloWorldSmall.png");

      // #3 
      PushButtonData pushButtonData3 = new PushButtonData("StackSimpleElementFiltering", "Element Filtering", _introLabPath, _introLabName + ".ElementFiltering");
      pushButtonData3.Image = NewBitmapImage("ImgHelloWorldSmall.png");

      // Put them on stack 
      IList<RibbonItem> stackedButtons = panel.AddStackedItems(pushButtonData1, pushButtonData2, pushButtonData3);
    }
    /// <summary>
    /// Stacked Buttons - combination of: push button, dropdown button, combo box and text box. 
    /// (no radio button group, split buttons). 
    /// Here we define 6 buttons, make grouping of 1, 3, 2 items, and stack them in three layer: 
    /// (1) simple push button with "Hello World" 
    /// (2) pull down with 3 items: "Command Data", "DB Element" and "Element Filtering". 
    /// (3) pull down with 2 items: "Element Modification" and "Model Creation" 
    /// </summary>
    public void AddStackedButtons_Complex(RibbonPanel panel)
    {
      // Create six push buttons to group for pull down and stack up 

      // #0 
      PushButtonData pushButtonData0 = new PushButtonData("StackComplexHelloWorld", "Hello World", _introLabPath, _introLabName + ".HelloWorld");
      pushButtonData0.Image = NewBitmapImage("Basics.ico");

      // #1 
      PushButtonData pushButtonData1 = new PushButtonData("StackComplexCommandData", "Command Data", _introLabPath, _introLabName + ".CommandData");
      pushButtonData1.Image = NewBitmapImage("Basics.ico");

      // #2 
      PushButtonData pushButtonData2 = new PushButtonData("StackComplexDbElement", "DB Element", _introLabPath, _introLabName + ".DBElement");

      // #3 
      PushButtonData pushButtonData3 = new PushButtonData("StackComplexElementFiltering", "Filtering", _introLabPath, _introLabName + ".ElementFiltering");

      // #4 
      PushButtonData pushButtonData4 = new PushButtonData("StackComplexElementModification", "Modify", _introLabPath, _introLabName + ".ElementModification");

      // #5 
      PushButtonData pushButtonData5 = new PushButtonData("StackComplexModelCreation", "Create", _introLabPath, _introLabName + ".ModelCreation");

      // Make two sets of pull down 

      PulldownButtonData pulldownBtnData1 = new PulldownButtonData("StackComplePulldownButton1", "DB Basics");
      PulldownButtonData pulldownBtnData2 = new PulldownButtonData("StackComplePulldownButton2", "Modeling");

      // Create three item stack. 
      IList<RibbonItem> stackedItems = panel.AddStackedItems(pushButtonData0, pulldownBtnData1, pulldownBtnData2);
      PulldownButton pulldownBtn2 = stackedItems[1] as PulldownButton;
      PulldownButton pulldownBtn3 = stackedItems[2] as PulldownButton;

      pulldownBtn2.Image = NewBitmapImage("Basics.ico");
      pulldownBtn3.Image = NewBitmapImage("House.ico");

      // Add each sub items 
      PushButton button1 = pulldownBtn2.AddPushButton(pushButtonData1);
      PushButton button2 = pulldownBtn2.AddPushButton(pushButtonData2);
      PushButton button3 = pulldownBtn2.AddPushButton(pushButtonData3);
      PushButton button4 = pulldownBtn3.AddPushButton(pushButtonData4);
      PushButton button5 = pulldownBtn3.AddPushButton(pushButtonData5);

      // Note: we need to set the image later. if we do in button data, it won't show in the Ribbon. 
      button1.Image = NewBitmapImage("Basics.ico");
      button2.Image = NewBitmapImage("Basics.ico");
      button3.Image = NewBitmapImage("Basics.ico");
      button4.Image = NewBitmapImage("Basics.ico");

      button5.Image = NewBitmapImage("Basics.ico");
    }
    /// <summary>
    /// Add buttons for the commands we define in this labs. 
    /// Here we stack three push buttons and repeat it as we get more. 
    /// </summary>
    public void AddUILabsCommandButtons(RibbonPanel panel)
    {
      // Get the location of this dll. 
      string assembly = GetType().Assembly.Location;

      // Create three push buttons to stack up 
      // #1 
      PushButtonData pushButtonData1 = new PushButtonData("UILabsSelection", "Pick Sampler", assembly, _uiLabName + ".UISelection");
      pushButtonData1.Image = NewBitmapImage("basics.ico");

      // #2 
      PushButtonData pushButtonData2 = new PushButtonData("UILabsCreateHouse", "Create House Pick", assembly, _uiLabName + ".UICreateHouse");
      pushButtonData2.Image = NewBitmapImage("House.ico");

      // #3 
      PushButtonData pushButtonData3 = new PushButtonData("UILabsTaskDialog", "Dialog Sampler", assembly, _uiLabName + ".UITaskDialog");
      pushButtonData3.Image = NewBitmapImage("basics.ico");

      // #4 
      PushButtonData pushButtonData4 = new PushButtonData("UILabsCreateHouseDialog", "Create House Dialog", assembly, _uiLabName + ".UICreateHouseDialog");
      pushButtonData4.Image = NewBitmapImage("House.ico");

      // #5 
      // Make three sets of pull down 
      PulldownButtonData pulldownBtnData1 = new PulldownButtonData("UILabsPulldownButton1", "Selection");
      PulldownButtonData pulldownBtnData2 = new PulldownButtonData("UILabsPulldownButton2", "Task Dialog");

      // Create three item stack. 
      IList<RibbonItem> stackedItems = panel.AddStackedItems(pulldownBtnData1, pulldownBtnData2);
      PulldownButton pulldownBtn1 = stackedItems[0] as PulldownButton;
      PulldownButton pulldownBtn2 = stackedItems[1] as PulldownButton;

      pulldownBtn1.Image = NewBitmapImage("Basics.ico");
      pulldownBtn2.Image = NewBitmapImage("Basics.ico");

      // Add each sub items 
      PushButton button1 = pulldownBtn1.AddPushButton(pushButtonData1);
      PushButton button2 = pulldownBtn1.AddPushButton(pushButtonData2);
      PushButton button3 = pulldownBtn2.AddPushButton(pushButtonData3);
      PushButton button4 = pulldownBtn2.AddPushButton(pushButtonData4);

      // Note: we need to set the image later. if we do in button data, it won't show in the Ribbon. 
      button1.Image = NewBitmapImage("Basics.ico");
      button2.Image = NewBitmapImage("Basics.ico");
      button3.Image = NewBitmapImage("Basics.ico");
      button4.Image = NewBitmapImage("Basics.ico");
    }
    /// <summary>
    /// Add buttons for the commands we define in this labs. 
    /// Here we stack 2 x 2-push buttons and repeat it as we get more. 
    /// TBD: still thinking which version is better ... 
    /// </summary>
    public void AddUILabsCommandButtons_v2(RibbonPanel panel)
    {
      // Get the location of this dll. 
      string assembly = GetType().Assembly.Location;

      // Create push buttons to stack up 
      // #1 
      PushButtonData pushButtonData1 = new PushButtonData("UILabsSelection", "Pick Sampler", assembly, _uiLabName + ".UISelection");
      pushButtonData1.Image = NewBitmapImage("basics.ico");

      // #2 
      PushButtonData pushButtonData2 = new PushButtonData("UILabsCreateHouseUI", "Create House Pick", assembly, _uiLabName + ".CreateHouseUI");
      pushButtonData2.Image = NewBitmapImage("basics.ico");

      // #3 
      PushButtonData pushButtonData3 = new PushButtonData("UILabsTaskDialog", "Dialog Sampler", assembly, _uiLabName + ".UITaskDialog");
      pushButtonData3.Image = NewBitmapImage("basics.ico");

      // #4 
      PushButtonData pushButtonData4 = new PushButtonData("UILabsCreateHouseDialog", "Create House Dialog", assembly, _uiLabName + ".CreateHouseDialog");
      pushButtonData4.Image = NewBitmapImage("basics.ico");

      // Create 2 x 2-item stack. 
      IList<RibbonItem> stackedItems1 = panel.AddStackedItems(pushButtonData1, pushButtonData2);

      IList<RibbonItem> stackedItems2 = panel.AddStackedItems(pushButtonData3, pushButtonData4);
    }