Esempio n. 1
0
        void HideTab()
        {
            Autodesk.AutoCAD.ApplicationServices.Application.Idle -= new EventHandler(OnIdle);

            if (_ctxTab != null)
            {
                Autodesk.Windows.RibbonControl ribbonCtrl = Autodesk.Windows.ComponentManager.Ribbon;

                ribbonCtrl.HideContextualTab(_ctxTab);

                _ctxTab.IsVisible = false;

                _ctxTab = null;
            }
        }
Esempio n. 2
0
        //Tab creation method

        void CreateCtxTab()
        {
            Autodesk.Windows.RibbonControl ribbonCtrl = Autodesk.Windows.ComponentManager.Ribbon;

            _ctxTab = new Autodesk.Windows.RibbonTab();

            _ctxTab.Name = "MyTab";

            _ctxTab.Id = "MY_CTX_TAB_ID";

            _ctxTab.IsVisible = true;

            _ctxTab.Title = _ctxTab.Name;

            _ctxTab.IsContextualTab = true;
            ribbonCtrl.Tabs.Add(_ctxTab);
        }
Esempio n. 3
0
        private void CreateContextButton(string tabName)
        {
            Autodesk.Windows.RibbonTab tab = Autodesk.Windows.ComponentManager.Ribbon.FindTab(tabName);

            var button = new Autodesk.Windows.RibbonButton
            {
                Id                    = "ID_DYN_BUTTON",
                Text                  = "My Button",
                Name                  = "My Name",
                ShowText              = true,
                IsEnabled             = true,
                IsVisible             = true,
                IsToolTipEnabled      = true,
                IsCheckable           = true,
                ShowToolTipOnDisabled = true,
                MinHeight             = 0,
                MinWidth              = 0,
                ToolTip               = "My dynamic command button",
                ShowImage             = true,
                LargeImage            = GetImage(),
                Size                  = Autodesk.Windows.RibbonItemSize.Large,
                Orientation           = System.Windows.Controls.Orientation.Vertical
            };

            Autodesk.Windows.ComponentManager.UIElementActivated
                += new EventHandler <Autodesk.Windows.UIElementActivatedEventArgs>(ComponentManager_UIElementActivated);

            var panelSource = new Autodesk.Windows.RibbonPanelSource
            {
                Title = "My Panel",
                Id    = "ID_PANEL"
            };

            panelSource.Items.Add(button);

            var panel = new Autodesk.Windows.RibbonPanel
            {
                Source = panelSource
            };

            tab.Panels.Add(panel);
        }
Esempio n. 4
0
 public ToolbarTab(string name, Autodesk.Windows.RibbonTab tab)
 {
     TabName   = name;
     RibbonTab = tab;
 }
Esempio n. 5
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);
        }