/// <summary>
    /// Get the default PIOTM panel
    /// </summary>
    /// <param name="application">Revit application</param>
    /// <returns></returns>
    private static RibbonPanel GetPIOTMPanel(
      UIControlledApplication application)
    {
      IList<RibbonPanel> panels = application.GetRibbonPanels();
      foreach (RibbonPanel pnl in panels)
        if (pnl.Name == PIOTM_PANEL_NAME)
          return pnl;

      return application.CreateRibbonPanel(PIOTM_PANEL_NAME);
    }
Пример #2
0
        public void RevitTo(UIControlledApplication application)
        {
            const string ribbonTag   = "ArmoApiVn";
            const string ribbonPanel = "Element";

            try
            {
                application.CreateRibbonTab(ribbonTag);
            }
            catch { }
            RibbonPanel        panel  = null;
            List <RibbonPanel> panels = application.GetRibbonPanels(ribbonTag);

            foreach (RibbonPanel pl in panels)
            {
                if (pl.Name == ribbonPanel)
                {
                    panel = pl;
                    break;
                }
            }
            if (panel == null)
            {
                panel = application.CreateRibbonPanel(ribbonTag, ribbonPanel);
            }
            Image          img     = RevitToCinima.Properties.Resources.icons8_movie_32;
            ImageSource    imgSrc  = Helper.GetImageSource(img);
            PushButtonData btnData = new PushButtonData("RevitCinima", "RevitCinima",
                                                        Assembly.GetExecutingAssembly().Location, "RevitToCinima.RevitToCinimaBinding")
            {
                ToolTip         = "Export element from revit to cinima4d",
                LongDescription = "Export element from revit to cinima4d",
                Image           = imgSrc,
                LargeImage      = imgSrc,
            };

            PushButton button = panel.AddItem(btnData) as PushButton;

            button.Enabled = true;
        }
Пример #3
0
        public Result OnStartup(UIControlledApplication application)
        {
            thisApp    = this;
            mainWindow = null;
            ctrApp     = application.ControlledApplication;

            try
            {
                application.CreateRibbonTab(tabName);
            }
            catch (Exception ex)
            {
                Log.AppendLog(LogMessageType.EXCEPTION, ex.Message);
            }

            var created = application.GetRibbonPanels(tabName).FirstOrDefault(x => x.Name == "Customizations");
            var panel   = created ?? application.CreateRibbonPanel(tabName, "Customizations");

            var currentAssembly = Assembly.GetAssembly(GetType());
            var moverImage      = ButtonUtil.LoadBitmapImage(currentAssembly, typeof(AppCommand).Namespace, "elementMover_32.png");

            var moverButton = (PushButton)panel.AddItem(new PushButtonData("ElementMoverCommand",
                                                                           "Element" + Environment.NewLine + "Mover",
                                                                           currentAssembly.Location,
                                                                           "HOK.ElementMover.MoverCommand"));

            moverButton.LargeImage = moverImage;

            const string instructionFile = @"V:\RVT-Data\HOK Program\Documentation\Element Mover_Instruction.pdf";

            if (File.Exists(instructionFile))
            {
                var contextualHelp = new ContextualHelp(ContextualHelpType.Url, instructionFile);
                moverButton.SetContextualHelp(contextualHelp);
            }

            ctrApp.DocumentChanged += CtrApp_DocumentChanged;
            return(Result.Succeeded);
        }
Пример #4
0
        public Result OnStartup(UIControlledApplication application)
        {
            try
            {
                // Path to the applicaiton
                string path = typeof(TopographyApp).Assembly.Location;

                List <RibbonPanel> panels = application.GetRibbonPanels();
                RibbonPanel        panel  = null;
                foreach (RibbonPanel rp in panels)
                {
                    if (rp.Name == "Elk DT")
                    {
                        panel = rp;
                        break;
                    }
                }
                if (panel == null)
                {
                    panel = application.CreateRibbonPanel("Elk DT");
                }

                BitmapSource   bms            = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Topo.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                PushButtonData topoButtonData = new PushButtonData(
                    "Elk Topo", "Elk\nTopo", path, "Elk.Revit.TopographyCmd")
                {
                    LargeImage = bms,
                    ToolTip    = "Generate a topo using USGS data.",
                };

                panel.AddItem(topoButtonData);

                return(Result.Succeeded);
            }
            catch
            {
                return(Result.Failed);
            }
        }
Пример #5
0
        /// <summary>
        /// Create UI on StartUp
        /// </summary>
        /// <param name="application"></param>
        /// <returns></returns>
        public Result OnStartup(UIControlledApplication application)
        {
            RibbonPanel grevitPanel = null;

            foreach (RibbonPanel rpanel in application.GetRibbonPanels())
            {
                if (rpanel.Name == "Grevit")
                {
                    grevitPanel = rpanel;
                }
            }

            if (grevitPanel == null)
            {
                grevitPanel = application.CreateRibbonPanel("Grevit");
            }

            PushButton commandButton = grevitPanel.AddItem(new PushButtonData("GrevitCommand", "Grevit", path, "Grevit.Revit.GrevitCommand")) as PushButton;

            commandButton.LargeImage = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                Properties.Resources.paper_airplane.GetHbitmap(),
                IntPtr.Zero,
                System.Windows.Int32Rect.Empty,
                BitmapSizeOptions.FromWidthAndHeight(32, 32));

            commandButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "http://grevit.net/"));

            PushButton parameterButton = grevitPanel.AddItem(new PushButtonData("ParameterNames", "Parameter names", path, "Grevit.Revit.ParameterNames")) as PushButton;

            parameterButton.LargeImage = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                Properties.Resources.tag_hash.GetHbitmap(),
                IntPtr.Zero,
                System.Windows.Int32Rect.Empty,
                BitmapSizeOptions.FromWidthAndHeight(32, 32));

            parameterButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "http://grevit.net/"));

            return(Result.Succeeded);
        }
Пример #6
0
        public RibbonPanel RibbonPanel(UIControlledApplication a)
        {
            string tab = "Template"; // Tab name
            // Empty ribbon panel
            RibbonPanel ribbonPanel = null;

            // Try to create ribbon tab.
            try
            {
                a.CreateRibbonTab(tab);
            }
            catch
            {
            }

            // Try to create ribbon panel.
            try
            {
                RibbonPanel panel = a.CreateRibbonPanel(tab, "Develop");
            }
            catch
            {
            }

            // Search existing tab for your panel.
            List <RibbonPanel> panels = a.GetRibbonPanels(tab);

            foreach (RibbonPanel p in panels)
            {
                if (p.Name == "Develop")
                {
                    ribbonPanel = p;
                }
            }

            //return panel
            return(ribbonPanel);
        }
Пример #7
0
        public Result OnStartup(UIControlledApplication application)
        {
            assemblyPath = System.Reflection.Assembly.GetExecutingAssembly().Location;

            try { application.CreateRibbonTab(tabName); } catch { }

            //создание вкладки
            string             panelName = "Обучение";
            RibbonPanel        panel     = null;
            List <RibbonPanel> tryPanels = application.GetRibbonPanels(tabName).Where(i => i.Name == panelName).ToList();

            if (tryPanels.Count == 0)
            {
                panel = application.CreateRibbonPanel(tabName, panelName);
            }
            else
            {
                panel = tryPanels.First();
            }
            //конец блока создания вкладки

            //создание кнопки
            PushButton btnConstr = panel.AddItem(new PushButtonData(
                                                     "ColumnsNumberByCoordinates",
                                                     "Нумерация\nколонн\nпо координатам",
                                                     assemblyPath,
                                                     "ColumnsNumberByCoordinates.ColumnsNumberByCoordinates")
                                                 ) as PushButton;

            //конец блока создания кнопки

            //назначения изображений кнопке
            btnConstr.LargeImage = PngImageSource("ColumnsNumberByCoordinates.Resources.ColNumCoord_32.png");
            btnConstr.Image      = PngImageSource("ColumnsNumberByCoordinates.Resources.ColNumCoord_16.png");
            //конец блок назначения изображений кнопке

            return(Result.Succeeded);
        }
Пример #8
0
        public RibbonPanel RibbonPanel(UIControlledApplication uiapp)
        {
            // Nome del Tab
            string tab = "BOLD";

            // Dichiara e inizializza un RibbonPanel vuoto
            RibbonPanel ribbonPanel = null;

            // Prova a creare un Ribbon Tab
            try
            {
                uiapp.CreateRibbonTab(tab);
            }
            catch (Exception ex)
            {
                Utils.HandleError(ex);
            }

            // Prova a creare un RibbonPanel
            try
            {
                RibbonPanel panel = uiapp.CreateRibbonPanel(tab, "Images");
            }
            catch (Exception ex)
            {
                Utils.HandleError(ex);
            }

            // Verifica se il tab del Panel esiste gia'
            List <RibbonPanel> panels = uiapp.GetRibbonPanels(tab);

            foreach (RibbonPanel p in panels.Where(x => x.Name == "Images"))
            {
                ribbonPanel = p;
            }

            return(ribbonPanel);
        }
Пример #9
0
        public RibbonPanel RibbonPanel(UIControlledApplication a)
        {
            string tab = "GraphQL"; // Tab name

            // Empty ribbon panel
            RibbonPanel ribbonPanel = null;

            // Try to create ribbon tab.
            try
            {
                a.CreateRibbonTab(tab);
            }
            catch (Exception ex)
            {
                Util.HandleError(ex);
            }

            // Try to create ribbon panel.
            try
            {
                RibbonPanel panel = a.CreateRibbonPanel(tab, "Remote");
            }
            catch (Exception ex)
            {
                Util.HandleError(ex);
            }

            // Search existing tab for your panel.
            List <RibbonPanel> panels = a.GetRibbonPanels(tab);

            foreach (RibbonPanel p in panels.Where(p => p.Name == "Remote"))
            {
                ribbonPanel = p;
            }

            //return panel
            return(ribbonPanel);
        }
Пример #10
0
        /// <summary>
        /// Selects or Creates a Ribbon Panel in a specified Ribbon Tab
        /// </summary>
        /// <param name="application"></param>
        /// <param name="tabName"></param>
        /// <param name="panelName"></param>
        /// <returns></returns>
        private RibbonPanel GetSetRibbonPanel(UIControlledApplication application, string tabName, string panelName)
        {
            List <RibbonPanel> tabList = new List <RibbonPanel>();

            tabList = application.GetRibbonPanels(tabName);

            RibbonPanel tab = null;

            foreach (RibbonPanel r in tabList)
            {
                if (r.Name.ToUpper() == panelName.ToUpper())
                {
                    tab = r;
                }
            }

            if (tab is null)
            {
                tab = application.CreateRibbonPanel(tabName, panelName);
            }

            return(tab);
        }
Пример #11
0
 public static RibbonPanel RibbonPanel(this UIControlledApplication uiCa, string tabName, string panelName)
 {
     if (WriteEmptyComment(uiCa, tabName, "Tab name is empty") ||
         WriteEmptyComment(uiCa, panelName, "Panel name is empty"))
     {
         return(null);
     }
     // if no tab create it
     if (tabName.ToLower() == "addins")
     {
         return(RibbonPanel(uiCa, Tab.AddIns, panelName));
     }
     if (tabName.ToLower() == "analyze")
     {
         return(RibbonPanel(uiCa, Tab.Analyze, panelName));
     }
     AddRibbonTab(uiCa, tabName);
     foreach (var panel in uiCa.GetRibbonPanels(tabName).Where(panel => panel.Name == panelName))
     {
         return(panel);
     }
     return(uiCa.CreateRibbonPanel(tabName, panelName));
 }
Пример #12
0
        private RibbonPanel GetRibbonPanel(UIControlledApplication a)
        {
            string tabName   = "Architectural Tools";
            string panelName = "Architectural";

            try
            {
                a.CreateRibbonTab(tabName);
            }
            catch (Exception)
            { }

            try
            {
                a.CreateRibbonPanel(tabName, panelName);
            }
            catch (Exception)
            { }

            IEnumerable <RibbonPanel> ribbonPanels = a.GetRibbonPanels(tabName);

            return(ribbonPanels.FirstOrDefault(p => p.Name == panelName));
        }
Пример #13
0
        public static RibbonPanel ribbonPanel(UIControlledApplication uIControlledApplication, string panelName)
        {
            RibbonPanel   ribbonPanel = null;
            string        tapName     = "RevitHandyTools";
            List <string> panelList   = new List <string>()
            {
                "Coordination", "Detail", "Shared Parameters"
            };

            //string panelAnnotationName = "Shared Parameters";
            try
            {
                uIControlledApplication.CreateRibbonTab(tapName);
            }
            catch { }
            try
            {
                foreach (string p_name in panelList)
                {
                    //RibbonPanel panel = a.CreateRibbonPanel(tapName, panelAnnotationName);
                    RibbonPanel panel = uIControlledApplication.CreateRibbonPanel(tapName, p_name);
                }
            }
            catch { }

            List <RibbonPanel> panels = uIControlledApplication.GetRibbonPanels(tapName);

            foreach (RibbonPanel p in panels)
            {
                if (p.Name == panelName)
                {
                    ribbonPanel = p;
                }
            }
            return(ribbonPanel);
        }
Пример #14
0
        }         // end OnShutdown

        private RibbonPanel AddRibbonPanel(string panelName, string m_tabName)
        {
            string m_panelName = panelName;

            RibbonPanel ribbonPanel = null;

            // check to see if the panel alrady exists
            // get the Panel within the tab by name
            List <RibbonPanel> m_RP = new List <RibbonPanel>();

            m_RP = _uiCtrlApp.GetRibbonPanels(m_tabName);

            foreach (RibbonPanel xRP in m_RP)
            {
                if (xRP.Name.ToUpper().Equals(m_panelName.ToUpper()))
                {
                    ribbonPanel = xRP;
                    break;
                }
            }

            // add the panel if it does not exist
            if (ribbonPanel == null)
            {
                // create the ribbon panel on the tab given the tab's name
                // FYI - leave off the ribbon panel's name to put onto the "add-in" tab
                ribbonPanel = _uiCtrlApp.CreateRibbonPanel(m_tabName, m_panelName);
            }

            // if (!AddSplitButtons(ribbonPanel))
            // {
            //  return Result.Failed;
            // }

            return(ribbonPanel);
        }
Пример #15
0
        /// <summary>
        /// Возвращает ссылку на панель <see cref="RibbonPanel"/>, находящуюся в указанной вкладке и имеющую указанное имя.
        /// Если панель не существует, то она создается
        /// </summary>
        /// <remarks>Метод также создает вкладку, если её не существует</remarks>
        /// <param name="application"><see cref="UIControlledApplication"/></param>
        /// <param name="tabName">Имя вкладки</param>
        /// <param name="panelName">Имя панели</param>
        public static RibbonPanel GetOrCreateRibbonPanel(
            UIControlledApplication application, string tabName, string panelName)
        {
            RibbonPanel panel = null;

            CreateModPlusTabIfNoExist(application);
            var rPanels = application.GetRibbonPanels(tabName);

            foreach (var rPanel in rPanels)
            {
                if (rPanel.Name.Equals(panelName))
                {
                    panel = rPanel;
                    break;
                }
            }

            if (panel == null)
            {
                panel = application.CreateRibbonPanel(tabName, panelName);
            }

            return(panel);
        }
Пример #16
0
        public Result OnStartup(UIControlledApplication app)
        {
            try
            {
                // create the ribbon tab first - this is the top level
                // UI item, below this will be the panel that is "on" the tab
                // and below this will be a button that is "on" the panel
                // give the tab a name
                string m_tabName = TAB_NAME;

                // first create the tab
                try
                {
                    // try to create the ribbon panel
                    app.CreateRibbonTab(m_tabName);
                }
                catch (Exception)
                {
                    // might already exist - do nothing
                }

                // got the tab now

                // create the ribbon panel if needed
                // give the panel a name
                string m_panelName = PANEL_NAME;

                RibbonPanel m_RibbonPanel = null;

                // check to see if the panel alrady exists
                // get the Panel within the tab by name
                List <RibbonPanel> m_RP = new List <RibbonPanel>();

                m_RP = app.GetRibbonPanels(m_tabName);

                foreach (RibbonPanel xRP in m_RP)
                {
                    if (xRP.Name.ToUpper().Equals(m_panelName.ToUpper()))
                    {
                        m_RibbonPanel = xRP;
                        break;
                    }
                }

                // if
                // add the panel if it does not exist
                if (m_RibbonPanel == null)
                {
                    // create the ribbon panel on the tab given the tab's name
                    // FYI - leave off the ribbon panel's name to put onto the "add-in" tab
                    m_RibbonPanel = app.CreateRibbonPanel(m_tabName, m_panelName);
                }


                // create a button for the 'copy sheet' command
                if (!AddPushButton(m_RibbonPanel, "CreateSheets", BUTTON_NAME,
                                   "CreateSheets_16.png",
                                   "CreateSheets_32.png",
                                   Assembly.GetExecutingAssembly().Location, "CreateSheets.Command", "Duplicate Existing Sheet"))

                {
                    // creating the pushbutton failed
                    MessageBox.Show("Failed to Add Button!", "Duplicate Sheet Warning",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    return(Result.Failed);
                }

                return(Result.Succeeded);
            }
            catch
            {
                return(Result.Failed);
            }
        }         // end OnStartup
Пример #17
0
        public Result OnStartup(UIControlledApplication application)
        {
            // Revit2015+ has disabled hardware acceleration for WPF to
            // avoid issues with rendering certain elements in the Revit UI.
            // Here we get it back, by setting the ProcessRenderMode to Default,
            // signifying that we want to use hardware rendering if it's
            // available.

            RenderOptions.ProcessRenderMode = RenderMode.Default;

            try
            {
                if (false == TryResolveDynamoCore())
                {
                    return(Result.Failed);
                }

                UIControlledApplication = application;
                ControlledApplication   = application.ControlledApplication;

                SubscribeAssemblyResolvingEvent();
                SubscribeApplicationEvents();

                TransactionManager.SetupManager(new AutomaticTransactionStrategy());
                ElementBinder.IsEnabled = true;

                // Create new ribbon panel
                var panels      = application.GetRibbonPanels();
                var ribbonPanel = panels.FirstOrDefault(p => p.Name.Contains(Resources.App_Description));
                if (null == ribbonPanel)
                {
                    ribbonPanel = application.CreateRibbonPanel(Resources.App_Description);
                }

                var fvi        = FileVersionInfo.GetVersionInfo(assemblyName);
                var dynVersion = String.Format(Resources.App_Name, fvi.FileMajorPart, fvi.FileMinorPart);

                DynamoButton =
                    (PushButton)
                    ribbonPanel.AddItem(
                        new PushButtonData(
                            dynVersion,
                            dynVersion,
                            assemblyName,
                            "Dynamo.Applications.DynamoRevit"));

                Bitmap dynamoIcon = Resources.logo_square_32x32;

                BitmapSource bitmapSource =
                    Imaging.CreateBitmapSourceFromHBitmap(
                        dynamoIcon.GetHbitmap(),
                        IntPtr.Zero,
                        Int32Rect.Empty,
                        BitmapSizeOptions.FromEmptyOptions());

                DynamoButton.LargeImage = bitmapSource;
                DynamoButton.Image      = bitmapSource;

                RegisterAdditionalUpdaters(application);

                return(Result.Succeeded);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(Result.Failed);
            }
        }
Пример #18
0
        /// <summary>
        /// This method will be executed when Autodesk Revit
        /// will be started.
        ///
        /// WARNING
        /// Don't use the RevitDevTools.dll features directly
        /// in this method. You are to call other methods which
        /// do it instead of.
        /// </summary>
        /// <param name="uic_app">A handle to the application
        /// being started.</param>
        /// <returns>Indicates if the external application
        /// completes its work successfully.</returns>
        Result IExternalApplication.OnStartup(
            UIControlledApplication uic_app)
        {
            Result result                = Result.Succeeded;
            string tabName               = "Filter Lab";
            string panelName             = "Filter Tools";
            string panelName2            = "Settings";
            string buttonfiltername      = "Selection Filter";
            string buttonfilternametype  = "Selection" + Environment.NewLine + "Filter";
            string buttonfilternamehelp  = "This tool is used to Filter selected elements.";
            string buttonfiltername2     = "Pre-Selection Filter";
            string buttonfiltername2type = "Pre-Selection" + Environment.NewLine + "Filter";
            string buttonfilternamehelp2 = "This tool is used to Filter elements before selecting.";
            string button2Name           = "Sheets";
            string button3Name           = "Strand";
            string buttonsplitName       = "Extra Tools";

            try
            {
                List <RibbonPanel> panels = uic_app.GetRibbonPanels(
                    tabName);
            }
            catch
            {
                uic_app.CreateRibbonTab(tabName);
            }

            RibbonPanel panelViewExport = uic_app.CreateRibbonPanel(
                tabName, panelName);

            panelViewExport.Name  = panelName;
            panelViewExport.Title = panelName;

            PushButtonData buttonfilter = new PushButtonData(
                buttonfiltername, buttonfilternametype,
                Assembly.GetExecutingAssembly().Location,
                typeof(SelectedCommand).FullName);

            buttonfilter.ToolTip = buttonfilternamehelp;
            ImageSource iconfilter = GetIconSource(Resources.Button_image_17);

            buttonfilter.LargeImage = iconfilter;
            buttonfilter.Image      = Thumbnail(iconfilter);
            panelViewExport.AddItem(buttonfilter);

            panelViewExport.AddSeparator();

            PushButtonData buttonfilter2 = new PushButtonData(
                buttonfiltername2, buttonfiltername2type,
                Assembly.GetExecutingAssembly().Location,
                typeof(PreSelectionCommand).FullName);

            buttonfilter2.ToolTip = buttonfilternamehelp2;
            ImageSource iconfilter2 = GetIconSource(Resources.Button_image_24);

            buttonfilter2.LargeImage = iconfilter2;
            buttonfilter2.Image      = Thumbnail(iconfilter2);
            panelViewExport.AddItem(buttonfilter2);

            panelViewExport.AddSeparator();

            PushButtonData button2 = new PushButtonData(
                button2Name, button2Name,
                Assembly.GetExecutingAssembly().Location,
                typeof(FilterCommand).FullName);

            button2.ToolTip = button2Name;
            ImageSource icon2 = GetIconSource(Resources.Button_image_20);

            button2.LargeImage = icon2;
            button2.Image      = Thumbnail(icon2);



            PushButtonData button3 = new PushButtonData(
                button3Name, button3Name,
                Assembly.GetExecutingAssembly().Location,
                typeof(FilterCommand).FullName);

            button3.ToolTip = button3Name;
            ImageSource icon3 = GetIconSource(Resources.Button_image_18);

            button3.LargeImage = icon3;
            button3.Image      = Thumbnail(icon3);


            SplitButtonData sb1 = new SplitButtonData(buttonsplitName, buttonsplitName);
            SplitButton     sb  = panelViewExport.AddItem(sb1) as SplitButton;

            sb.AddPushButton(button2);
            sb.AddPushButton(button3);



            RibbonPanel panelViewExport2 = uic_app.CreateRibbonPanel(
                tabName, panelName2);

            panelViewExport2.Name  = panelName2;
            panelViewExport2.Title = panelName2;

            PushButtonData buttonsettings = new PushButtonData(
                "Settings", "Settings",
                Assembly.GetExecutingAssembly().Location,
                typeof(SettingsCommand).FullName);

            buttonsettings.ToolTip = "To change settings for Filters.";
            ImageSource iconsettings = GetIconSource(Resources.Button_image_13);

            buttonsettings.LargeImage = iconsettings;
            buttonsettings.Image      = Thumbnail(iconsettings);
            panelViewExport2.AddItem(buttonsettings);

            panelViewExport2.AddSeparator();

            PushButtonData buttonweb = new PushButtonData(
                "Web Help", "Web Help",
                Assembly.GetExecutingAssembly().Location,
                typeof(WebHelp).FullName);

            buttonweb.ToolTip = "Why not Google It!!!!";
            ImageSource iconweb = GetIconSource(Resources.Button_image_21);

            buttonweb.LargeImage = iconweb;
            buttonweb.Image      = Thumbnail(iconweb);
            panelViewExport2.AddItem(buttonweb);

            panelViewExport2.AddSeparator();

            PushButtonData buttonabout = new PushButtonData(
                "About", "About",
                Assembly.GetExecutingAssembly().Location,
                typeof(AboutCommand).FullName);

            buttonabout.ToolTip = "Learn About Filter Labs";
            ImageSource iconabout = GetIconSource(Resources.Button_image_23);

            buttonabout.LargeImage = iconabout;
            buttonabout.Image      = Thumbnail(iconabout);
            panelViewExport2.AddItem(buttonabout);

            return(result);
        }
Пример #19
0
        //		internal static PushButtonData pbData0;

        public Result OnStartup(UIControlledApplication app)
        {
            _uiCtrlApp = app;

            try
            {
                _uiCtrlApp.Idling += OnIdling;


                // create the ribbon tab first - this is the top level
                // ui item.  below this will be the panel that is "on" the tab
                // and below this will be a pull down or split button that is "on" the panel;

                // give the tab a name;
                string tabName = TAB_NAME;
                // give the panel a name
                string panelName = PANEL_NAME;

                // first try to create the tab
                try
                {
                    _uiCtrlApp.CreateRibbonTab(tabName);
                }
                catch (Exception)
                {
                    // might already exist - do nothing
                }

                // tab created or exists

                // create the ribbon panel if needed
                RibbonPanel ribbonPanel = null;

                // check to see if the panel already exists
                // get the Panel within the tab name
                List <RibbonPanel> rp = new List <RibbonPanel>();

                rp = _uiCtrlApp.GetRibbonPanels(tabName);

                foreach (RibbonPanel rpx in rp)
                {
                    if (rpx.Name.ToUpper().Equals(panelName.ToUpper()))
                    {
                        ribbonPanel = rpx;
                        break;
                    }
                }

                // if panel not found
                // add the panel if it does not exist
                if (ribbonPanel == null)
                {
                    // create the ribbon panel on the tab given the tab's name
                    // FYI - leave off the ribbon panel's name to put onto the "add-in" tab
                    ribbonPanel = _uiCtrlApp.CreateRibbonPanel(tabName, panelName);
                }

                //add a split button to the panel
                if (!AddSplitButton(ribbonPanel))
                {
                    // create the stacked split button failed
                    MessageBox.Show("Failed to Add the Split Buttons!", "Information",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    return(Result.Failed);
                }


                //add a stacked pair of stacked pull down buttons to the panel
                if (!AddStackedPullDownhButtons(ribbonPanel))
                {
                    // create the stacked split button failed
                    MessageBox.Show("Failed to Add the Stacked Push Buttons!", "Information",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    return(Result.Failed);
                }

//				RegisterDocEvents();

                /*
                 * examples of how to add various buttons goes here
                 *
                 */
            }
            catch (Exception e)
            {
                Debug.WriteLine("exception " + e.Message);

                TaskDialog td = new TaskDialog("Revit Windows");
                td.TitleAutoPrefix = false;
                td.MainInstruction = "Failed to Add to Ribbon";
                td.MainIcon        = TaskDialogIcon.TaskDialogIconWarning;
                td.CommonButtons   = TaskDialogCommonButtons.Ok;

                return(Result.Failed);
            }


            return(Result.Succeeded);
        }
Пример #20
0
        public Result OnStartup(UIControlledApplication app)
        {
            _uiCtrlApp = app;

            clearConsole();

            try
            {
                _uiCtrlApp.Idling += OnIdling;

                // create the ribbon tab first - this is the top level
                // UI item, below this will be the panel that is "on" the tab
                // and below this will be a button that is "on" the panel
                // give the tab a name
                string m_tabName = TAB_NAME;

                // first create the tab
                try
                {
                    // try to create the ribbon panel
                    app.CreateRibbonTab(m_tabName);
                }
                catch (Exception)
                {
                    // might already exist - do nothing
                }

                // got the tab now

                // create the ribbon panel if needed
                // give the panel a name
                string m_panelName = PANEL_NAME;

                RibbonPanel m_RibbonPanel = null;

                // check to see if the panel alrady exists
                // get the Panel within the tab by name
                List <RibbonPanel> m_RP = new List <RibbonPanel>();

                m_RP = app.GetRibbonPanels(m_tabName);

                foreach (RibbonPanel xRP in m_RP)
                {
                    if (xRP.Name.ToUpper().Equals(m_panelName.ToUpper()))
                    {
                        m_RibbonPanel = xRP;
                        break;
                    }
                }

                // if
                // add the panel if it does not exist
                if (m_RibbonPanel == null)
                {
                    // create the ribbon panel on the tab given the tab's name
                    // FYI - leave off the ribbon panel's name to put onto the "add-in" tab
                    m_RibbonPanel = app.CreateRibbonPanel(m_tabName, m_panelName);
                }

                // create a button for the 'delux measure command
                if (!UiUtil.AddPushButton(m_RibbonPanel, "Delux Measure", BUTTON_NAME1,
                                          "information16.png",
                                          "information32.png",
                                          Assembly.GetExecutingAssembly().Location, "AOTools.DxMeasure",
                                          "Create and Modify Unit Styles"))

                {
                    // creating the pushbutton failed
                    TaskDialog td = new TaskDialog("AO Tools");
                    td.MainIcon    = TaskDialogIcon.TaskDialogIconWarning;
                    td.MainContent = String.Format(Properties.Resources.ButtonCreateFail,
                                                   Properties.Resources.UnitStyleButtonText);
                    td.Show();

                    return(Result.Failed);
                }

                return(Result.Succeeded);
            }
            catch
            {
                return(Result.Failed);
            }
        }         // end OnStartup
Пример #21
0
        public Result OnStartup(UIControlledApplication a)
        {
            try
            {
                a.CreateRibbonTab(RibbonTab);
            }
            catch (Exception)
            {
                // ignored
            }

            // Get o create the panel
            List <RibbonPanel> panels = a.GetRibbonPanels(RibbonTab);
            RibbonPanel        panel  = panels.FirstOrDefault(ribbonPanel => ribbonPanel.Name == RibbonPanel) ?? a.CreateRibbonPanel(RibbonTab, RibbonPanel);

            // ----------------------------
            // ---Button Add shared parameters---
            // ----------------------------
            // get the image for the button
            Image       img         = Properties.Resources.icons8_add_property_32;
            ImageSource imageSource = GetImageSource(img);

            // create the button data
            var addSharedBtnData = new PushButtonData("Add shared parameters", "Добавить параметры", this.path + "\\CreateParams.dll", "CreateParams.Command")
            {
                ToolTip         = "Пакетное добавление параметров в проект или в семейства по excel файлу",
                LongDescription = "Разработчик: Кожевников Андрей",
                Image           = imageSource,
                LargeImage      = imageSource
            };

            // add the button to the ribbon
            if (panel.AddItem(addSharedBtnData) is PushButton addSharedButton)
            {
                addSharedButton.Enabled = true;
            }

            panel.AddSeparator();

            // ----------------------------
            // ---Button get parameters---
            // ----------------------------
            img         = Properties.Resources.icons8_export_csv_32;
            imageSource = GetImageSource(img);

            var exportParametersBtnData = new PushButtonData("Export model", "Выгрузить модель", this.path + "\\FindParameters.dll", "FindParameters.Command")
            {
                ToolTip         = "Выгрузить модель в excel",
                LongDescription = "Разработчик: Кожевников Андрей",
                Image           = imageSource,
                LargeImage      = imageSource
            };

            if (panel.AddItem(exportParametersBtnData) is PushButton exportParametersButton)
            {
                exportParametersButton.Enabled = true;
            }

            panel.AddSeparator();

            // ----------------------------
            // ---Button Gladkoe---
            // ----------------------------
            img         = Properties.Resources.icons8_administrative_tools_32;
            imageSource = GetImageSource(img);

            PulldownButtonData pullDownDataGladkoe = new PulldownButtonData("Gladkoe", "НБ_Гладкое")
            {
                Image = imageSource, LargeImage = imageSource, ToolTip = "Утилиты для проекта НБ_Гладкое"
            };
            PulldownButton pullDownButtonGladkoe = panel.AddItem(pullDownDataGladkoe) as PulldownButton;

            img         = Properties.Resources.icons8_paint_palette_32;
            imageSource = GetImageSource(img);

            var colorConnectorsBtnData = new PushButtonData("Color Connectors", "Окраска коннекторов", this.path + "\\Gladkoe.dll", "Gladkoe.ConnectorsRecolor")
            {
                ToolTip         = "Окраска коннекторов в проекте НБ_Гладкое",
                LongDescription = "Разработчик: Кожевников Андрей,\n Климович Александр",
                Image           = imageSource,
                LargeImage      = imageSource
            };

            pullDownButtonGladkoe.AddPushButton(colorConnectorsBtnData);

            img         = Properties.Resources.icons8_doctors_folder_32;
            imageSource = GetImageSource(img);

            var fillParametersBtnData = new PushButtonData("Fill parameters", "Заполнить \"Концевое условие\"", this.path + "\\Gladkoe.dll", "Gladkoe.FillingParameters")
            {
                ToolTip         = "Заполнение параметров \"Концевое условие\" (сварной шов / фланец) в проекте НБ_Гладкое",
                LongDescription = "Разработчик: Кожевников Андрей",
                Image           = imageSource,
                LargeImage      = imageSource
            };

            pullDownButtonGladkoe.AddPushButton(fillParametersBtnData);

            return(Result.Succeeded);
        }
Пример #22
0
        public Result OnStartup(UIControlledApplication a)
        {
            //Get ribbon tab
            try
            {
                a.CreateRibbonTab(ribbonTab);
            }
            catch (Exception) { }

            //create ribbon panel
            RibbonPanel        panel  = null;
            List <RibbonPanel> panels = a.GetRibbonPanels(ribbonTab);

            foreach (RibbonPanel pnl in panels)
            {
                if (pnl.Name == ribbonPanel)
                {
                    panel = pnl;
                    break;
                }
            }

            //couldnt find the panel
            if (panel == null)
            {
                panel = a.CreateRibbonPanel(ribbonTab, ribbonPanel);
            }

            //load image
            Image       img    = Properties.Resources.ExteriorBrick;
            ImageSource imgSrc = GetImageSrc(img);

            //create button data
            PushButtonData btnData = new PushButtonData(
                "MyButton",
                "My Ribbon Button",
                Assembly.GetExecutingAssembly().Location,
                "MyRevitCommands.ProjectRay"
                )
            {
                ToolTip         = "Aligns all diffusers and lights to nearest ceiling",
                LongDescription = "All Air Terminal and Lighting Fixture families are evaluated and moved to the correct celing height. All wall mounted lighting and " +
                                  "sidewall diffusers including louvers are ignored.",
                Image      = imgSrc,
                LargeImage = imgSrc
            };

            //add button to ribbon
            PushButton button = panel.AddItem(btnData) as PushButton;

            button.Enabled = true;

            //RibbonPanel panel = ribbonPanel(a);
            //string thisAssemblyPath = Assembly.GetExecutingAssembly().Location;
            //PushButton button = panel.AddItem(new PushButtonData("Button", "test button", thisAssemblyPath,"ProjectRay")) as PushButton;
            //button.ToolTip = "This is a sample tooltip";
            //var globePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "ExteriorBrick.png");

            //Uri uriImage = new Uri(globePath);
            //BitmapImage largeImage = new BitmapImage();
            //button.LargeImage = largeImage;

            return(Result.Succeeded);
        }
Пример #23
0
        public Result OnStartup(UIControlledApplication a)
        {
            #region Tab
            try
            {
                a.CreateRibbonTab(AR_RIBBON_TAB);
            }
            catch (Exception) { }
            List <RibbonPanel> panels = a.GetRibbonPanels(AR_RIBBON_TAB);
            #endregion
            #region Panel Системы
            //Создание панели
            RibbonPanel panelSys = null;
            foreach (RibbonPanel pnl in panels)
            {
                if (pnl.Name == AR_RIBBON_PANEL_SYSTEMS)
                {
                    panelSys = pnl;
                    break;
                }
            }
            if (panelSys == null)
            {
                panelSys = a.CreateRibbonPanel(AR_RIBBON_TAB, AR_RIBBON_PANEL_SYSTEMS);
            }

            //Кнопка "Назначение параметра СЭ_Имя системы"
            {
                PushButtonData btnCommandSetSENameSysData = new PushButtonData(
                    "СЭ_Имя системы",
                    "СЭ_Имя системы",
                    Assembly.GetExecutingAssembly().Location,
                    "StroyExp.CommandSetSENameSys"
                    )
                {
                    ToolTip         = "Назначение параметра СЭ_Имя системы",
                    LongDescription = @"Задает значение для параметра ""СЭ_Имя системы"" в соответствии с параметром ""Описание"" типа инженерной системы",
                };
                PushButton btnCommandSetSENameSys    = panelSys.AddItem(btnCommandSetSENameSysData) as PushButton;
                Image      btnCommandSetSENameSysImg = Properties.Resources.SetParam;
                btnCommandSetSENameSys.LargeImage = Convert(btnCommandSetSENameSysImg); //new BitmapImage(new Uri(@"/Resources/Icons/SetParam.png"));
                btnCommandSetSENameSys.Enabled    = true;
            }
            #endregion
            #region Panel Архитектура
            RibbonPanel panelArch = null;
            foreach (RibbonPanel pnl in panels)
            {
                if (pnl.Name == AR_RIBBON_PANEL_ARCHITECTURE)
                {
                    panelArch = pnl;
                    break;
                }
            }
            if (panelArch == null)
            {
                panelArch = a.CreateRibbonPanel(AR_RIBBON_PANEL_ARCHITECTURE);
            }

            //Кнопка "Отделка"
            {
                PushButtonData btnDataSetWallFinishRoomParams = new PushButtonData(
                    "Отделка",
                    "Отделка",
                    Assembly.GetExecutingAssembly().Location,
                    "SetWallFinishRoomParams.Command"
                    )
                {
                    ToolTip         = "Назначение параметров отделки",
                    LongDescription = @"",
                };
                PushButton btnSetWallFinishRoomParams    = panelArch.AddItem(btnDataSetWallFinishRoomParams) as PushButton;
                Image      btnSetWallFinishRoomParamsImg = Properties.Resources.SetParam;
                btnCommandSetSENameSys.LargeImage = Convert(btnCommandSetSENameSysImg); //new BitmapImage(new Uri(@"/Resources/Icons/SetParam.png"));
                btnCommandSetSENameSys.Enabled    = true;
            }
            #endregion
            return(Result.Succeeded);
        }
Пример #24
0
        public Result OnStartup(UIControlledApplication app)
        {
            _uiCtrlApp = app;

//			clearConsole();

            try
            {
                _uiCtrlApp.Idling += OnIdling;

                // create the ribbon tab first - this is the top level
                // UI item, below this will be the panel that is "on" the tab
                // and below this will be a button that is "on" the panel
                // give the tab a name
                string m_tabName = TAB_NAME;

                // first create the tab
                try
                {
                    // try to create the ribbon panel
                    app.CreateRibbonTab(m_tabName);
                }
                catch (Exception)
                {
                    // might already exist - do nothing
                }

                // got the tab now

                // create the ribbon panel if needed
                // give the panel a name
                string m_panelName = UNITS_PANEL_NAME;

                RibbonPanel ribbonPanel = null;

                // check to see if the panel alrady exists
                // get the Panel within the tab by name
                List <RibbonPanel> m_RP = new List <RibbonPanel>();

                m_RP = app.GetRibbonPanels(m_tabName);

                foreach (RibbonPanel xRP in m_RP)
                {
                    if (xRP.Name.ToUpper().Equals(m_panelName.ToUpper()))
                    {
                        ribbonPanel = xRP;
                        break;
                    }
                }

                // add the panel if it does not exist
                if (ribbonPanel == null)
                {
                    // create the ribbon panel on the tab given the tab's name
                    // FYI - leave off the ribbon panel's name to put onto the "add-in" tab
                    ribbonPanel = app.CreateRibbonPanel(m_tabName, m_panelName);
                }

                if (!AddSplitButtons(ribbonPanel))
                {
                    return(Result.Failed);
                }

                SmUsrInit();

                return(Result.Succeeded);
            }
            catch
            {
                return(Result.Failed);
            }
        }         // end OnStartup
Пример #25
0
        public Result OnStartup(UIControlledApplication application)
        {
            #region Пример интересной реализации

            /*
             * // метод который позволяет размстить кнопку на системной панели.. но метод на нее не привязать
             *
             * adWin.RibbonControl ribbon = adWin.ComponentManager.Ribbon;
             *
             * adWin.RibbonTab modifyTab = ribbon.Tabs.Where(xxx => xxx.Id == "Modify").FirstOrDefault();
             * adWin.RibbonPanel geometryPanel = modifyTab.Panels.Where(xxx => xxx.Source.Id == "geometry_shr").FirstOrDefault();
             *
             * adWin.RibbonButton button = new adWin.RibbonButton();
             * button.Name = "VSumButton";
             * button.Image = new BitmapImage(new Uri(@"C:\Users\Sidorin\Source\Repos\KSP-VolumesSum\KSP-VolumesSum\res\sum-16.png"));
             * button.LargeImage = new BitmapImage(new Uri(@"C:\Users\Sidorin\Source\Repos\KSP-VolumesSum\KSP-VolumesSum\res\sum-32.png"));
             * button.Id = "ID_VSumButton";
             * button.AllowInStatusBar = true;
             * button.AllowInToolBar = true;
             * button.GroupLocation = Autodesk.Private.Windows.RibbonItemGroupLocation.Last;
             * button.IsEnabled = true;
             * button.IsToolTipEnabled = true;
             * button.IsVisible = true;
             * button.ShowImage = true; //  true;
             * button.ShowText = false;
             * button.ShowToolTipOnDisabled = true;
             * button.Text = "Подсчет объемов";
             * button.ToolTip = "Считает объемы выделенных элементов";
             * //                button.MinHeight = 0;
             * //                button.MinWidth = 0;
             * button.Size = adWin.RibbonItemSize.Standard;
             * button.ResizeStyle = adWin.RibbonItemResizeStyles.HideText;
             * button.IsCheckable = true;
             * button.KeyTip = "KEYVSUM";
             *
             * geometryPanel.Source.Items.Add(button);
             * adWin.ComponentManager.UIElementActivated +=
             *  new EventHandler<adWin.UIElementActivatedEventArgs>(CommandForButton);
             *
             * adWin.RibbonControl ribbon = adWin.ComponentManager.Ribbon;
             * foreach (adWin.RibbonTab tab in ribbon.Tabs)
             * {
             *  foreach (adWin.RibbonPanel panel in tab.Panels)
             *  {
             *      foreach (adWin.RibbonItem ribbonItem in panel.Source.Items)
             *      {
             *          str += tab.Id + " : " + panel.Source.Id + " : " + ribbonItem.Id + Environment.NewLine;
             *      }
             *
             *  }
             *  str += tab.Id + Environment.NewLine;
             * }
             * TaskDialog.Show("123", str);
             *
             * //str += " -----> " + modifyTab.Id + geometryPanel.Source.Id;
             *
             * //TaskDialog.Show("123", str);
             *
             */
            #endregion

            List <RibbonPanel> panels = application.GetRibbonPanels();
            string             str    = "";

            application.CreateRibbonTab(TabName);
            RibbonPanel panelVS = application.CreateRibbonPanel(TabName, PanelName);

            string path = Assembly.GetExecutingAssembly().Location;

            PushButtonData SumBtnData = new PushButtonData(ButtonName, ButtonText, path, "KSP_VolumesSum.VSum")
            {
                ToolTipImage = new BitmapImage(new Uri(Path.GetDirectoryName(path) + "\\res\\sum-32.png", UriKind.Absolute)),
                ToolTip      = "Суммирует объемы элементов модели, если они есть"
            };
            PushButton SumBtn = panelVS.AddItem(SumBtnData) as PushButton;
            SumBtn.LargeImage = new BitmapImage(new Uri(Path.GetDirectoryName(path) + "\\res\\sum-32.png", UriKind.Absolute));

            PlaceButtonOnModifyRibbon();



            return(Result.Succeeded);
        }
        /// <summary>
        /// Add the button to Revit UI for an external command.
        /// </summary>
        /// <param name="uic_app">A handle to the application
        /// being started.</param>
        /// <param name="cmd_type">The command type. It must to
        /// implement the IExternalCommand interface.</param>
        /// <param name="default_resources_type">The type which
        /// contains the default values of necessary resources.
        /// </param>
        public static void AddButton(
            UIControlledApplication uic_app, Type cmd_type,
            Type default_resources_type)
        {
            if (uic_app == null)
            {
                throw new ArgumentNullException(nameof(uic_app)
                                                );
            }

            if (cmd_type == null)
            {
                throw new ArgumentNullException(nameof(
                                                    cmd_type));
            }

            if (cmd_type.GetInterface(typeof(IExternalCommand)
                                      .FullName) == null)
            {
                throw new ArgumentException(nameof(cmd_type));
            }

            if (default_resources_type == null)
            {
                throw new ArgumentNullException(nameof(
                                                    default_resources_type));
            }

            // The target ribbon tab name.
            string tab_name = GetResourceString(cmd_type,
                                                default_resources_type, ResourceKeyNames
                                                .RibbonTabName);

            try {
                /* Through the using of the tabs_dict
                 * dictionary I try to minimize the exceptions
                 * count. */
                if (!tabs_dict.ContainsKey(tab_name))
                {
                    uic_app.CreateRibbonTab(tab_name);
                    tabs_dict.Add(tab_name, tab_name);
                }
            }
            catch { }

            // The target ribbon panel name
            string panel_name = GetResourceString(cmd_type,
                                                  default_resources_type, ResourceKeyNames
                                                  .RibbonPanelName);

            RibbonPanel panel = uic_app.GetRibbonPanels(
                tab_name).FirstOrDefault(
                n => n.Name.Equals(panel_name, StringComparison
                                   .InvariantCulture));

            if (panel == null)
            {
                panel = uic_app.CreateRibbonPanel(tab_name,
                                                  panel_name);
            }

            string this_assembly_path = Assembly
                                        .GetExecutingAssembly().Location;

            // Get localized help file name
            string help_file = Path.Combine(Path
                                            .GetDirectoryName(this_assembly_path),
                                            GetResourceString(cmd_type,
                                                              default_resources_type, ResourceKeyNames
                                                              .HelpFileName));

            ContextualHelp help = new ContextualHelp(
                ContextualHelpType.ChmFile, help_file);

            // Help topic id (inside of help file).
            help.HelpTopicUrl = GetResourceString(cmd_type,
                                                  default_resources_type, ResourceKeyNames
                                                  .HelpTopicId);

            string cmd_name = cmd_type.Name;

            string cmd_text = GetResourceString(cmd_type,
                                                default_resources_type, ResourceKeyNames
                                                .ButtonCaption);

            string cmd_tooltip = GetResourceString(cmd_type,
                                                   default_resources_type, ResourceKeyNames
                                                   .ButtonTooltipText);

            string long_description = GetResourceString(
                cmd_type, default_resources_type,
                ResourceKeyNames.ButtonLongDescription);

            PushButtonData button_data = new PushButtonData(
                cmd_name, cmd_text,
                this_assembly_path, cmd_type.FullName);

            // Get corresponding class name which implements
            // the IExternalCommandAvailability interface
            var aviability_type = GetResourceString(cmd_type,
                                                    default_resources_type, ResourceKeyNames
                                                    .CommandAvailabilityType);

            var av_type = Type.GetType(aviability_type);

            if (av_type != null && av_type.GetInterface(typeof(
                                                            IExternalCommandAvailability).FullName)
                != null)
            {
                button_data.AvailabilityClassName = av_type
                                                    .FullName;
            }

            PushButton push_button = panel.AddItem(
                button_data) as PushButton;

            push_button.ToolTip = cmd_tooltip;

            BitmapSource btn_src_img = GetResourceImage(
                cmd_type, default_resources_type,
                ResourceKeyNames.ButtonImage);

            push_button.LargeImage = btn_src_img;

            BitmapSource ttp_bitmap_src = GetResourceImage(
                cmd_type, default_resources_type,
                ResourceKeyNames.ButtonTooltipImage);

            push_button.ToolTipImage    = ttp_bitmap_src;
            push_button.LongDescription = long_description;
            push_button.SetContextualHelp(help);
        }
Пример #27
0
        /// <summary>
        /// Implement this method to implement the external application which should be called when 
        /// Revit is about to exit, Any documents must have been closed before this method is called.
        /// </summary>
        /// <param name="application">An object that is passed to the external application 
        /// which contains the controlled application.</param>
        /// <returns>Return the status of the external application. 
        /// A result of Succeeded means that the external application successfully shutdown. 
        /// Cancelled can be used to signify that the user cancelled the external operation at 
        /// some point.
        /// If Failed is returned then the Revit user should be warned of the failure of the external 
        /// application to shut down correctly.</returns>
        public Autodesk.Revit.UI.Result OnShutdown(UIControlledApplication application)
        {
            //remove events
            List<RibbonPanel> myPanels = application.GetRibbonPanels();
            Autodesk.Revit.UI.ComboBox comboboxLevel = (Autodesk.Revit.UI.ComboBox)(myPanels[0].GetItems()[2]);
            application.ControlledApplication.DocumentCreated -= new EventHandler<
               Autodesk.Revit.DB.Events.DocumentCreatedEventArgs>(DocumentCreated);
            Autodesk.Revit.UI.TextBox textBox = myPanels[0].GetItems()[5] as Autodesk.Revit.UI.TextBox;
            textBox.EnterPressed -= new EventHandler<
               Autodesk.Revit.UI.Events.TextBoxEnterPressedEventArgs>(SetTextBoxValue);

            return Autodesk.Revit.UI.Result.Succeeded;
        }
Пример #28
0
        public Result OnStartup(UIControlledApplication a)
        {
            //declare variables
            PulldownButton     pulldownButton;
            PulldownButtonData pulldownData;

            //create Ribbon panel
            List <RibbonPanel> panels    = a.GetRibbonPanels();
            RibbonPanel        krspPanel = null;

            foreach (RibbonPanel pnl in panels)
            {
                if (pnl.Name == PANEL_NAME)
                {
                    krspPanel = pnl;
                }
            }
            if (krspPanel == null)
            {
                krspPanel = a.CreateRibbonPanel(PANEL_NAME);
            }

            //Create contextual help
            ContextualHelp help = new ContextualHelp(ContextualHelpType.Url, @"http://krispcad.blogspot.com.au/2013/07/revit-exchange-app-store.html");

            //create pulldown data
            System.Drawing.Image image = Properties.Resources.KRSP_TextUtilities;
            ImageSource          img   = Utils.ImageUtils.GetSource(image);

            pulldownData = new PulldownButtonData("TextUtils", "Text\nUtilities")
            {
                LargeImage = img,
                Image      = img
            };
            pulldownButton = krspPanel.AddItem(pulldownData) as PulldownButton;
            pulldownButton.SetContextualHelp(help);

            image = Properties.Resources.TextCase;
            AddPushButton("KRSP.Revit.TextChangeCase.Format2015.dll",
                          "ChangeTextCase",
                          "Change Case",
                          "KRSP.Revit.TextChangeCase.Format2015.Command",
                          "Change the case of the specified text notes in the project.",
                          "",
                          Utils.ImageUtils.GetSource(image),
                          pulldownButton);

            image = Properties.Resources.TextAlign;
            AddPushButton("KRSP.Revit.TextAlign.Format2015.dll",
                          "TextAlign",
                          "Text Align",
                          "KRSP.Revit.TextAlign.Format2015.Command",
                          "Align selected text notes to the selected text note.",
                          "",
                          Utils.ImageUtils.GetSource(image),
                          pulldownButton);


            //AddPushButton("KRSP.Revit.TextCreateStyles.Format_2013.dll",
            //    "CreateTextStyles",
            //    "KrispCAD Create Text Styles",
            //    "KRSP.Revit.TextCreateStyles.Format_2013.Command",
            //    "Create text styles based on predefined settings.",
            //    "",
            //    img,
            //    pulldownButton);

            return(Result.Succeeded);
        }
Пример #29
0
        public RibbonPanel ribbonPanel(UIControlledApplication a)
        {
            RibbonPanel ribbonPanel = null;

            //Create add-in to the SOM tool ribbon tab
            try
            {
                a.CreateRibbonTab("SOM Tools");
            }
            catch (Exception)
            { }
            //Create Ribbon Panel
            try
            {
                RibbonPanel alignViewsPanel = a.CreateRibbonPanel("SOM Tools", "Sheet Layout");

            }

            catch (Exception)
            { }

            List<RibbonPanel> alignViewpanels = a.GetRibbonPanels("SOM Tools");
            foreach (RibbonPanel panel in alignViewpanels)
            {
                if (panel.Name == "Sheet Layout")
                {
                    ribbonPanel = panel;
                }
            }
            return ribbonPanel;
        }
Пример #30
0
        public Result OnStartup(UIControlledApplication application)
        {
            address = new Uri(addr + application.ControlledApplication.VersionNumber);
            uicApp  = application;


            _app         = this;
            serverActive = Properties.Settings.Default.defaultServerOn;
            // Create the button
            try
            {
                BitmapSource   bms;
                PushButtonData lyrebirdButton;
                //StartServer();
                if (disableButton)
                {
                    bms            = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_On.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                    lyrebirdButton = new PushButtonData("Lyrebird Server", "Lyrebird Server\nDisabled", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.ServerToggle")
                    {
                        LargeImage = bms,
                        ToolTip    = "The Lyrebird Server is currently disabled in this session of Revit.  This is most likely because you have more than one session of Revit and the server can only run in one.",
                    };
                    Properties.Settings.Default.enableServer = false;
                    Properties.Settings.Default.Save();
                }
                else
                {
                    if (serverActive)
                    {
                        bms            = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_On.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                        lyrebirdButton = new PushButtonData("Lyrebird Server", "Lyrebird\nServer On", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.ServerToggle")
                        {
                            LargeImage = bms,
                            ToolTip    = "The Lyrebird Server currently on and will accept requests for data and can create objects.  Push button to toggle the server off.",
                        };
                        StartServer();
                        //ServiceOn();
                    }
                    else
                    {
                        bms            = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_Off.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                        lyrebirdButton = new PushButtonData("Lyrebird Server", "Lyrebird\nServer Off", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.ServerToggle")
                        {
                            LargeImage = bms,
                            ToolTip    = "The Lyrebird Server is currently off and will not accept requests for data or create objects.  Push button to toggle the server on.",
                        };
                    }
                    Properties.Settings.Default.enableServer = true;
                    Properties.Settings.Default.Save();
                }

                // Settings button
                BitmapSource   setBMS             = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_Settings.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                PushButtonData settingsButtonData = new PushButtonData("Lyrebird Settings", "Lyrebird Settings", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.SettingsCmd")
                {
                    LargeImage = setBMS,
                    ToolTip    = "Lyrebird Server settings.",
                };

                // Selection button
                BitmapSource   selBMS = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_Select.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                PushButtonData selectionButtonData = new PushButtonData("Select Run", "Select Run", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.SelectRunElementsCmd")
                {
                    LargeImage = selBMS,
                    ToolTip    = "Select elements created from Lyrebird",
                };

                // Selection button
                BitmapSource   delBMS           = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_RemoveData.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                PushButtonData removeButtonData = new PushButtonData("Remove Data", "Remove Data", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.RemoveDataCmd")
                {
                    LargeImage = delBMS,
                    ToolTip    = "Remove Lyrebird data from selected elements",
                };

                // Create the tab if necessary
                const string tabName = "LMN";
                Autodesk.Windows.RibbonControl ribbon = Autodesk.Windows.ComponentManager.Ribbon;
                Autodesk.Windows.RibbonTab     tab    = null;
                foreach (Autodesk.Windows.RibbonTab t in ribbon.Tabs)
                {
                    if (t.Id == tabName)
                    {
                        tab = t;
                    }
                }
                if (tab == null)
                {
                    application.CreateRibbonTab(tabName);
                }

                bool found = false;
                List <RibbonPanel> panels = application.GetRibbonPanels(tabName);
                RibbonPanel        panel  = null;
                foreach (RibbonPanel rp in panels)
                {
                    if (rp.Name == "Utilities")
                    {
                        panel = rp;
                        found = true;
                    }
                }

                SplitButtonData sbd = new SplitButtonData("Lyrebird", "Lyrebird");

                if (!found)
                {
                    // Create the panel
                    RibbonPanel utilitiesPanel = application.CreateRibbonPanel(tabName, "Utilities");

                    // Split button
                    SplitButton sb = utilitiesPanel.AddItem(sbd) as SplitButton;
                    serverButton = sb.AddPushButton(lyrebirdButton) as PushButton;
                    PushButton settingsButton = sb.AddPushButton(settingsButtonData) as PushButton;
                    PushButton selButton      = sb.AddPushButton(selectionButtonData) as PushButton;
                    PushButton removeButton   = sb.AddPushButton(removeButtonData) as PushButton;
                    sb.IsSynchronizedWithCurrentItem = false;
                }
                else
                {
                    SplitButton sb = panel.AddItem(sbd) as SplitButton;
                    serverButton = sb.AddPushButton(lyrebirdButton) as PushButton;
                    PushButton settingsButton = sb.AddPushButton(settingsButtonData) as PushButton;
                    PushButton selButton      = sb.AddPushButton(selectionButtonData) as PushButton;
                    PushButton removeButton   = sb.AddPushButton(removeButtonData) as PushButton;
                    sb.IsSynchronizedWithCurrentItem = false;
                }

                if (disableButton)
                {
                    serverButton.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                TaskDialog.Show("Error", ex.ToString());
            }

            return(Result.Succeeded);
        }
Пример #31
0
        public Result OnStartup(UIControlledApplication application)
        {
            address = new Uri(addr + application.ControlledApplication.VersionNumber);
            uicApp = application;


            _app = this;
            serverActive = Properties.Settings.Default.defaultServerOn;
            // Create the button
            try
            {
                BitmapSource bms;
                PushButtonData lyrebirdButton;
                //StartServer();
                if (disableButton)
                {
                    bms = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_On.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                    lyrebirdButton = new PushButtonData("Lyrebird Server", "Lyrebird Server\nDisabled", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.ServerToggle")
                    {
                        LargeImage = bms,
                        ToolTip = "The Lyrebird Server is currently disabled in this session of Revit.  This is most likely because you have more than one session of Revit and the server can only run in one.",
                    };
                    Properties.Settings.Default.enableServer = false;
                    Properties.Settings.Default.Save();
                }
                else
                {
                    if (serverActive)
                    {
                        bms = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_On.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                        lyrebirdButton = new PushButtonData("Lyrebird Server", "Lyrebird\nServer On", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.ServerToggle")
                        {
                            LargeImage = bms,
                            ToolTip = "The Lyrebird Server currently on and will accept requests for data and can create objects.  Push button to toggle the server off.",
                        };
                        StartServer();
                        //ServiceOn();
                    }
                    else
                    {
                        bms = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_Off.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                        lyrebirdButton = new PushButtonData("Lyrebird Server", "Lyrebird\nServer Off", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.ServerToggle")
                        {
                            LargeImage = bms,
                            ToolTip = "The Lyrebird Server is currently off and will not accept requests for data or create objects.  Push button to toggle the server on.",
                        };
                    }
                    Properties.Settings.Default.enableServer = true;
                    Properties.Settings.Default.Save();
                }

                // Settings button
                BitmapSource setBMS = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_Settings.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                PushButtonData settingsButtonData = new PushButtonData("Lyrebird Settings", "Lyrebird Settings", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.SettingsCmd")
                {
                    LargeImage = setBMS,
                    ToolTip = "Lyrebird Server settings.",
                };

                // Selection button
                BitmapSource selBMS = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_Select.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                PushButtonData selectionButtonData = new PushButtonData("Select Run", "Select Run", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.SelectRunElementsCmd")
                {
                    LargeImage = selBMS,
                    ToolTip = "Select elements created from Lyrebird",
                };

                // Selection button
                BitmapSource delBMS = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lyrebird_RemoveData.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                PushButtonData removeButtonData = new PushButtonData("Remove Data", "Remove Data", typeof(RevitServerApp).Assembly.Location, "LMNA.Lyrebird.RemoveDataCmd")
                {
                    LargeImage = delBMS,
                    ToolTip = "Remove Lyrebird data from selected elements",
                };

                // Create the tab if necessary
                const string tabName = "LMN";
                Autodesk.Windows.RibbonControl ribbon = Autodesk.Windows.ComponentManager.Ribbon;
                Autodesk.Windows.RibbonTab tab = null;
                foreach (Autodesk.Windows.RibbonTab t in ribbon.Tabs)
                {
                    if (t.Id == tabName)
                    {
                        tab = t;
                    }
                }
                if (tab == null)
                {
                    application.CreateRibbonTab(tabName);
                }

                bool found = false;
                List<RibbonPanel> panels = application.GetRibbonPanels(tabName);
                RibbonPanel panel = null;
                foreach (RibbonPanel rp in panels)
                {
                    if (rp.Name == "Utilities")
                    {
                        panel = rp;
                        found = true;
                    }
                }

                SplitButtonData sbd = new SplitButtonData("Lyrebird", "Lyrebird");

                if (!found)
                {
                    // Create the panel
                    RibbonPanel utilitiesPanel = application.CreateRibbonPanel(tabName, "Utilities");

                    // Split button
                    SplitButton sb = utilitiesPanel.AddItem(sbd) as SplitButton;
                    serverButton = sb.AddPushButton(lyrebirdButton) as PushButton;
                    PushButton settingsButton = sb.AddPushButton(settingsButtonData) as PushButton;
                    PushButton selButton = sb.AddPushButton(selectionButtonData) as PushButton;
                    PushButton removeButton = sb.AddPushButton(removeButtonData) as PushButton;
                    sb.IsSynchronizedWithCurrentItem = false;
                }
                else
                {
                    SplitButton sb = panel.AddItem(sbd) as SplitButton;
                    serverButton = sb.AddPushButton(lyrebirdButton) as PushButton;
                    PushButton settingsButton = sb.AddPushButton(settingsButtonData) as PushButton;
                    PushButton selButton = sb.AddPushButton(selectionButtonData) as PushButton;
                    PushButton removeButton = sb.AddPushButton(removeButtonData) as PushButton;
                    sb.IsSynchronizedWithCurrentItem = false;
                }

                if (disableButton)
                {
                    serverButton.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                TaskDialog.Show("Error", ex.ToString());
            }

            return Result.Succeeded;
        }
Пример #32
0
        public Result OnStartup(UIControlledApplication a)
        {
            string tabName          = "LineTools";
            string panelName        = "LineTools";
            string buttonThinName   = "Thin";
            string buttonThickName  = "Thick";
            string buttonToggleName = "Toggle";

            try
            {
                List <RibbonPanel> panels = a.GetRibbonPanels(
                    tabName);
            }
            catch
            {
                a.CreateRibbonTab(tabName);
            }

            RibbonPanel panelViewExport = a.CreateRibbonPanel(
                tabName, panelName);

            panelViewExport.Name  = panelName;
            panelViewExport.Title = panelName;

            PushButtonData buttonThin = new PushButtonData(
                buttonThinName, buttonThinName,
                System.Reflection.Assembly.GetExecutingAssembly().Location,
                typeof(Command_ThinLines).FullName);

            buttonThin.ToolTip = buttonThinName;
            ImageSource iconThin = GetIconSource(Images.Thin);

            buttonThin.LargeImage = iconThin;
            buttonThin.Image      = Thumbnail(iconThin);
            panelViewExport.AddItem(buttonThin);

            PushButtonData buttonThick = new PushButtonData(
                buttonThickName, buttonThickName,
                System.Reflection.Assembly.GetExecutingAssembly().Location,
                typeof(Command_ThickLines).FullName);

            buttonThick.ToolTip = buttonThickName;
            ImageSource iconThick = GetIconSource(Images.Thick);

            buttonThick.LargeImage = iconThick;
            buttonThick.Image      = Thumbnail(iconThick);
            panelViewExport.AddItem(buttonThick);

            PushButtonData buttonToggle = new PushButtonData(
                buttonToggleName, buttonToggleName,
                System.Reflection.Assembly.GetExecutingAssembly().Location,
                typeof(Command_ToggleLineThickness).FullName);

            buttonToggle.ToolTip = buttonToggleName;
            ImageSource iconToggle = GetIconSource(Images.ToggleLineThickness);

            buttonToggle.LargeImage = iconToggle;
            buttonToggle.Image      = Thumbnail(iconToggle);
            panelViewExport.AddItem(buttonToggle);

            return(Result.Succeeded);
        }
Пример #33
0
        private static RibbonPanel GetRibbonPanel(UIControlledApplication revApp, string tabName, string panelName)
        {
            try
            {
                // Verify if the tab exists, create it if ncessary
                adWin.RibbonControl ribbon = adWin.ComponentManager.Ribbon;
                adWin.RibbonTab     tab    = null;
                bool defaultTab            = false;

                foreach (adWin.RibbonTab t in ribbon.Tabs)
                {
                    if (t.Id == tabName)
                    {
                        if (t.Id != t.Name)
                        {
                            defaultTab = true;
                        }
                        tab = t;
                        break;
                    }
                }

                if (!defaultTab && tab == null)
                {
                    revApp.CreateRibbonTab(tabName);
                }
                if (defaultTab)
                {
                    tab = null;
                }

                // Verify if the panel exists
                List <RibbonPanel> panels;
                if (defaultTab)
                {
                    panels = revApp.GetRibbonPanels();
                }
                else
                {
                    panels = revApp.GetRibbonPanels(tabName);
                }

                RibbonPanel panel = null;
                foreach (RibbonPanel rp in panels)
                {
                    if (rp.Name == panelName)
                    {
                        panel = rp;
                        break;
                    }
                }

                if (panel == null && !defaultTab)
                {
                    panel = revApp.CreateRibbonPanel(tabName, panelName);
                }
                else if (panel == null && defaultTab)
                {
                    panel = revApp.CreateRibbonPanel(panelName);
                }

                return(panel);
            }
            catch
            {
                return(null);
            }
        }
Пример #34
0
        public Result OnStartup(UIControlledApplication application)
        {
            Instance = this;
            m_app    = application;
            var versionNumber = m_app.ControlledApplication.VersionNumber;

            Tasks = new Queue <Action <UIApplication> >();

            application.Idling += OnIdling;

            try
            {
                m_app.CreateRibbonTab(tabName);
            }
            catch
            {
                Log.AppendLog(LogMessageType.WARNING, "Ribbon tab was not created. It might already exist.");
            }

            var panelsVisibility = new Dictionary <string, bool>();

            ViewModel = new AddinInstallerModel(versionNumber);
            foreach (var addin in ViewModel.Addins)
            {
                // (Konrad) Currently the only way to distinguish between ExternalCommands and ExternalApplications
                // is via "ButtonText" attribute. It should be empty for ExternalApplications.
                if (string.IsNullOrEmpty(addin.ButtonText))
                {
                    if (addin.IsInstalled)
                    {
                        if (File.Exists(ViewModel.InstallDirectory + Path.GetFileName(addin.AddinFilePath)))
                        {
                            try
                            {
                                File.Delete(ViewModel.InstallDirectory + Path.GetFileName(addin.AddinFilePath));
                            }
                            catch
                            {
                                Log.AppendLog(LogMessageType.ERROR, "Could not delete existing Addin Manifest.");
                            }
                        }
                        File.Copy(ViewModel.TempDirectory + Path.GetFileName(addin.AddinFilePath), ViewModel.InstallDirectory + Path.GetFileName(addin.AddinFilePath));

                        if (addin.AdditionalButtonNames != null)
                        {
                            if (panelsVisibility.ContainsKey(addin.Panel))
                            {
                                panelsVisibility.Remove(addin.Panel);
                            }

                            panelsVisibility.Add(addin.Panel, true);
                        }
                    }
                    continue;
                }

                // (Konrad) Temp path dll, to file moved from install location
                // Keeps install location free from being locked by Revit.
                // If addin hasn't been installed yet, we create a button for it,
                // but assign it a Temp.dll reference so that we can re-assign it later.
                var relativePath = addin.DllRelativePath.Replace("Temp\\", "");
                var dllPath      = addin.IsInstalled ? ViewModel.InstallDirectory + relativePath : ViewModel.TempDirectory + "Temp.dll";

                var panel = m_app.GetRibbonPanels("  HOK - Beta").FirstOrDefault(x => x.Name == addin.Panel)
                            ?? m_app.CreateRibbonPanel(tabName, addin.Panel);

                var button = (PushButton)panel.AddItem(new PushButtonData(addin.Name + "_Command", addin.ButtonText, dllPath, addin.CommandNamespace));
                button.LargeImage = addin.Image;
                button.ToolTip    = addin.Description;

                button.Visible = addin.IsInstalled;

                if (panelsVisibility.ContainsKey(addin.Panel))
                {
                    if (panelsVisibility[addin.Panel])
                    {
                        panel.Visible = true;
                    }
                }
                else
                {
                    panel.Visible = panel.GetItems().Any(x => x.Visible);
                }
            }

            currentAssembly = Assembly.GetAssembly(GetType()).Location;
            CreateInstallerPanel();

            return(Result.Succeeded);
        }