Esempio n. 1
0
 public SettingsForm(RevitServerApp _app)
 {
     app = _app;
     InitializeComponent();
     enabledCheckBox.IsChecked = Properties.Settings.Default.enableServer;
     supressProfileCheckBox.IsChecked = Properties.Settings.Default.suppressWarning;
     defaultOnCheckBox.IsChecked = Properties.Settings.Default.defaultServerOn;
     timeOut = Properties.Settings.Default.infoTimeout;
     timeoutTextBox.Text = timeOut.ToString();
 }
Esempio n. 2
0
 public SettingsForm(RevitServerApp _app)
 {
     app = _app;
     InitializeComponent();
     enabledCheckBox.IsChecked        = Properties.Settings.Default.enableServer;
     supressProfileCheckBox.IsChecked = Properties.Settings.Default.suppressWarning;
     defaultOnCheckBox.IsChecked      = Properties.Settings.Default.defaultServerOn;
     timeOut             = Properties.Settings.Default.infoTimeout;
     timeoutTextBox.Text = timeOut.ToString();
 }
Esempio n. 3
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;
        }
Esempio n. 4
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);
        }