Exemple #1
0
        /// <summary>
        /// Implements the OnStartup event
        /// </summary>
        /// <param name="uiConApp"></param>
        /// <returns></returns>
        public Result OnStartup(UIControlledApplication uiConApp)
        {
            thisApp = this;  // static access to this application instance

            string thisAssemblyPath = Assembly.GetExecutingAssembly().Location;
            string bitmapFolder     = Path.GetDirectoryName(thisAssemblyPath) + "\\icons";

            // Create New Ribbon Tab - SOM
            // If exists, throw Exception
            try
            {
                uiConApp.CreateRibbonTab(SystemPanelId);
            }
            catch
            {
                //MessageBox.Show(e.ToString());
            }

            try
            {
                Autodesk.Revit.UI.RibbonPanel Edit_RibbonPanel = uiConApp.CreateRibbonPanel(SystemPanelId, "Edit");
                // Create Buttons for Ribbon Panel
                PushButtonData IntersectButtonData = new PushButtonData("Intersect", "Intersect\n Elements ", thisAssemblyPath, "EditElements.IntersectDialog");

                // Bind Buttons to Ribbon Panel
                PushButton IntersectButton = Edit_RibbonPanel.AddItem(IntersectButtonData) as PushButton;

                IntersectButton.ToolTip      = "Intersect Elements.";
                IntersectButton.Image        = new BitmapImage(new Uri(Path.Combine(bitmapFolder, "EasyRevit_Intersect_24_new.png"), UriKind.Absolute));
                IntersectButton.LargeImage   = new BitmapImage(new Uri(Path.Combine(bitmapFolder, "EasyRevit_Intersect_24_new.png"), UriKind.Absolute));
                IntersectButton.ToolTipImage = new BitmapImage(new Uri(Path.Combine(bitmapFolder, "EasyRevit_Intersect_24_new.png"), UriKind.Absolute));

                Edit_RibbonPanel.AddSeparator();

                // Create Buttons for Ribbon Panel
                PushButtonData SplitButtonData = new PushButtonData("Split", "Split\n Elements ", thisAssemblyPath, "EditElements.SplitDialog");

                // Bind Buttons to Ribbon Panel
                PushButton SplitButton = Edit_RibbonPanel.AddItem(SplitButtonData) as PushButton;
                SplitButton.ToolTip      = "Split Elements by cutting elements.";
                SplitButton.Image        = new BitmapImage(new Uri(Path.Combine(bitmapFolder, "EasyRevit_Split_24_new.png"), UriKind.Absolute));
                SplitButton.LargeImage   = new BitmapImage(new Uri(Path.Combine(bitmapFolder, "EasyRevit_Split_24_new.png"), UriKind.Absolute));
                SplitButton.ToolTipImage = new BitmapImage(new Uri(Path.Combine(bitmapFolder, "EasyRevit_Split_24_new.png"), UriKind.Absolute));

                // Subscribe to the "ApplicationInitialized" event
                // then continue from there once it is fired.
                // This is to ensure that the ribbon is fully
                // populated before we mess with it.
                uiConApp.ControlledApplication.ApplicationInitialized += OnApplicationInitialized;

                return(Result.Succeeded);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            return(Result.Succeeded);
        }
Exemple #2
0
 public CustomPanel CreateSeparator()
 {
     _panel.AddSeparator();
     return(this);
 }
Exemple #3
0
        // <summary>
        // Adds a set of PushbuttonData to the ribbon on a specified panel as stacked and/or buttons
        // </summary>
        // <param name = "tabname" ></ param >
        // <param name = "panelName" ></ param >
        // <param name = "buttons" ></ param >
        // <remarks></remarks>
        private void AddAsStackedAndButtons(string tabname, string panelName, Dictionary <string, List <PushButtonData> > buttons)//, buttons As Dictionary(Of String, List(Of PushButtonData))
        {
            Autodesk.Revit.UI.RibbonPanel m_panelSubsc = GetRibbonPanelByTabName(tabname, panelName);
            int m_iCnt = 0;

            foreach (var kvp in buttons)
            {
                if (kvp.Value.Count > 0)
                {
                    if (m_iCnt > 0)
                    {
                        m_panelSubsc.AddSeparator();
                        m_iCnt += 1;
                    }

                    switch (kvp.Value.Count)
                    {
                    case 12:
                        m_panelSubsc.AddStackedItems(kvp.Value[0], kvp.Value[1], kvp.Value[2]);
                        m_panelSubsc.AddStackedItems(kvp.Value[3], kvp.Value[4], kvp.Value[5]);
                        m_panelSubsc.AddStackedItems(kvp.Value[6], kvp.Value[7], kvp.Value[8]);
                        m_panelSubsc.AddStackedItems(kvp.Value[9], kvp.Value[10], kvp.Value[11]);
                        break;

                    case 11:
                        m_panelSubsc.AddStackedItems(kvp.Value[9], kvp.Value[10]);
                        m_panelSubsc.AddStackedItems(kvp.Value[0], kvp.Value[1], kvp.Value[2]);
                        m_panelSubsc.AddStackedItems(kvp.Value[3], kvp.Value[4], kvp.Value[5]);
                        m_panelSubsc.AddStackedItems(kvp.Value[6], kvp.Value[7], kvp.Value[8]);
                        break;

                    case 10:
                        m_panelSubsc.AddItem(kvp.Value[9]);
                        m_panelSubsc.AddStackedItems(kvp.Value[0], kvp.Value[1], kvp.Value[2]);
                        m_panelSubsc.AddStackedItems(kvp.Value[3], kvp.Value[4], kvp.Value[5]);
                        m_panelSubsc.AddStackedItems(kvp.Value[6], kvp.Value[7], kvp.Value[8]);
                        break;

                    case 9:
                        m_panelSubsc.AddStackedItems(kvp.Value[0], kvp.Value[1], kvp.Value[2]);
                        m_panelSubsc.AddStackedItems(kvp.Value[3], kvp.Value[4], kvp.Value[5]);
                        m_panelSubsc.AddStackedItems(kvp.Value[6], kvp.Value[7], kvp.Value[8]);
                        break;

                    case 8:
                        m_panelSubsc.AddItem(kvp.Value[0]);
                        m_panelSubsc.AddItem(kvp.Value[1]);
                        m_panelSubsc.AddStackedItems(kvp.Value[2], kvp.Value[3], kvp.Value[4]);
                        m_panelSubsc.AddStackedItems(kvp.Value[5], kvp.Value[6], kvp.Value[7]);
                        break;

                    case 7:
                        m_panelSubsc.AddItem(kvp.Value[0]);
                        m_panelSubsc.AddStackedItems(kvp.Value[1], kvp.Value[2], kvp.Value[3]);
                        m_panelSubsc.AddStackedItems(kvp.Value[4], kvp.Value[5], kvp.Value[6]);
                        break;

                    case 6:
                        m_panelSubsc.AddStackedItems(kvp.Value[0], kvp.Value[1], kvp.Value[2]);
                        m_panelSubsc.AddStackedItems(kvp.Value[3], kvp.Value[4], kvp.Value[5]);
                        break;

                    case 5:
                        m_panelSubsc.AddItem(kvp.Value[0]);
                        m_panelSubsc.AddItem(kvp.Value[1]);
                        m_panelSubsc.AddStackedItems(kvp.Value[2], kvp.Value[3], kvp.Value[4]);
                        break;

                    case 4:
                        m_panelSubsc.AddItem(kvp.Value[0]);
                        m_panelSubsc.AddStackedItems(kvp.Value[1], kvp.Value[2], kvp.Value[3]);
                        break;

                    case 3:
                        m_panelSubsc.AddStackedItems(kvp.Value[0], kvp.Value[1], kvp.Value[2]);
                        break;

                    case 2:
                        m_panelSubsc.AddStackedItems(kvp.Value[0], kvp.Value[1]);
                        break;

                    case 1:
                        m_panelSubsc.AddItem(kvp.Value[0]);
                        break;

                    default:
                        m_panelSubsc.AddItem(kvp.Value[0]);
                        break;
                    }
                }
            }
        }