Пример #1
0
        public Result OnStartup(UIControlledApplication a)
        {
            RibbonControl Ribbon = ComponentManager.Ribbon;

            Autodesk.Windows.RibbonTab   AfryTab        = null;
            Autodesk.Windows.RibbonPanel Alignmentpanel = null;

            foreach (var Tab in Ribbon.Tabs)
            {
                if ("AFRY" == Tab.Title)
                {
                    AfryTab = Tab;
                    foreach (var item in Tab.Panels)
                    {
                        if (item.Source.Title == "Alignment Tools")
                        {
                            Alignmentpanel = item;
                        }
                    }
                }
            }
            if (Alignmentpanel == null)
            {
                if (AfryTab == null)
                {
                    try
                    {
                        a.CreateRibbonTab("AFRY");
                    }
                    catch (Exception)
                    {
                    }
                    try
                    {
                        a.CreateRibbonPanel("AFRY", "Alignment Tools");
                    }
                    catch (Exception)
                    {
                    }
                }
                else
                {
                    a.CreateRibbonPanel("AFRY", "Alignment Tools");
                }
            }


            var            Locationath = Assembly.GetExecutingAssembly().Location;
            PushButtonData Create3d    = new PushButtonData("Create", "Object Placer", Locationath, "ObjectPlacementLandXml.Command");

            Create3d.ToolTip    = "This Command creates 3D text alignments when u select a Model line"; // Can be changed to a more descriptive text.
            Create3d.Image      = new BitmapImage(new Uri(Path.GetDirectoryName(Locationath) + "\\OBjAlignment.png"));
            Create3d.LargeImage = new BitmapImage(new Uri(Path.GetDirectoryName(Locationath) + "\\OBJAlignment.png"));

            a.GetRibbonPanels("AFRY").Find(E => E.Name == "Alignment Tools").AddItem(Create3d);

            return(Result.Succeeded);
        }
Пример #2
0
        public static RibbonTab ribbontab(string Name, string id)
        {
            RibbonTab ribTab = new Autodesk.Windows.RibbonTab();

            ribTab.Title    = Name;
            ribTab.Id       = id;
            ribTab.IsActive = true;
            return(ribTab);
        }
Пример #3
0
        /// <summary>
        /// This will get the tab's name.
        /// </summary>
        /// <param name="tab">The original tab name.</param>
        /// <returns name="name">The result..</returns>
        /// <search>
        /// Ribbon.RenameTab
        /// </search>
        public static string Name(adWin.RibbonTab tab)
        {
            string result = null;

            try
            {
                result = tab.Title;
            }
            catch (Exception)
            {
                result = null;
            }

            return(result);
        }
Пример #4
0
        /// <summary>
        /// This will enable or disable the given tab.
        /// </summary>
        /// <param name="tab">The tab name to modify.</param>
        /// <param name="toggle">True or false for tab visibility.</param>
        /// <returns name="result">The result..</returns>
        /// <search>
        /// Ribbon.RenameTab
        /// </search>
        public static string SetEnabled(adWin.RibbonTab tab, bool toggle)
        {
            string result = null;

            try
            {
                tab.IsEnabled = toggle;
                result        = "Cool beans, it worked.";
            }
            catch (Exception)
            {
                result = "Yeah... that didn't work..";
            }

            return(result);
        }
Пример #5
0
        /// <summary>
        /// This will rename a tab given a new name.
        /// </summary>
        /// <param name="tab">The tab.</param>
        /// <param name="name">The new name.</param>
        /// <returns name="result">The result..</returns>
        /// <search>
        /// Ribbon.RenameTab
        /// </search>
        public static string SetName(adWin.RibbonTab tab, string name)
        {
            string result = null;

            try
            {
                tab.Title = name;
                result    = "Cool beans, it worked.";
            }
            catch (Exception)
            {
                result = "Yeah... that didn't work..";
            }

            return(result);
        }
Пример #6
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);
            }
        }
Пример #7
0
        public void CreateCivil3DRibbon()
        {
            Autodesk.Windows.RibbonTab rbnTab = new Autodesk.Windows.RibbonTab();
            rbnTab.Title = "Beca";
            rbnTab.Id    = "Civil3d";

            Autodesk.Windows.RibbonPanelSource panlSourceAus = new Autodesk.Windows.RibbonPanelSource();
            panlSourceAus.Title = "Australia";

            Autodesk.Windows.RibbonButton rbnSignAus = new Autodesk.Windows.RibbonButton();
            //rbnSignAus.Text = "Signs";
            rbnSignAus.ShowText         = true;
            rbnSignAus.ShowImage        = true;
            rbnSignAus.Image            = Images.getBitmap(Properties.Resources.Signs);
            rbnSignAus.LargeImage       = Images.getBitmap(Properties.Resources.Signs);
            rbnSignAus.Size             = RibbonItemSize.Large;
            rbnSignAus.CommandHandler   = new AusSignCommandHandler();
            rbnSignAus.CommandParameter = "AusSign";
            rbnSignAus.Orientation      = System.Windows.Controls.Orientation.Horizontal;
            rbnSignAus.Width            = 500;
            panlSourceAus.Items.Add(rbnSignAus);

            Autodesk.Windows.RibbonRowBreak rowBreak = new RibbonRowBreak();
            panlSourceAus.Items.Add(rowBreak);

            Autodesk.Windows.RibbonButton rbnRoadSignAus = new Autodesk.Windows.RibbonButton();
            //rbnRoadSignAus.Text = "Road Markings";
            rbnRoadSignAus.ShowText         = true;
            rbnRoadSignAus.ShowImage        = true;
            rbnRoadSignAus.Image            = Images.getBitmap(Properties.Resources.Road_Markings);
            rbnRoadSignAus.LargeImage       = Images.getBitmap(Properties.Resources.Road_Markings);
            rbnRoadSignAus.Size             = RibbonItemSize.Large;
            rbnRoadSignAus.CommandParameter = "AusRoadSign";
            rbnRoadSignAus.CommandHandler   = new AusSignCommandHandler();
            rbnRoadSignAus.Orientation      = System.Windows.Controls.Orientation.Horizontal;
            rbnRoadSignAus.Width            = 500;
            panlSourceAus.Items.Add(rbnRoadSignAus);

            Autodesk.Windows.RibbonPanel rbnPanelAus = new RibbonPanel();
            rbnPanelAus.Source = panlSourceAus;
            rbnTab.Panels.Add(rbnPanelAus);

            Autodesk.Windows.RibbonPanelSource panlSourceNZ = new Autodesk.Windows.RibbonPanelSource();
            panlSourceNZ.Title = "Newzeland";

            Autodesk.Windows.RibbonButton rbnSignNZ = new Autodesk.Windows.RibbonButton();
            //rbnSignNZ.Text = "Signs";
            rbnSignNZ.ShowText         = true;
            rbnSignNZ.ShowImage        = true;
            rbnSignNZ.Image            = Images.getBitmap(Properties.Resources.Signs);
            rbnSignNZ.LargeImage       = Images.getBitmap(Properties.Resources.Signs);
            rbnSignNZ.Size             = RibbonItemSize.Large;
            rbnSignNZ.CommandParameter = "NZSign";
            rbnSignNZ.CommandHandler   = new AusSignCommandHandler();
            rbnSignNZ.Orientation      = System.Windows.Controls.Orientation.Horizontal;
            rbnSignNZ.Width            = 500;
            panlSourceNZ.Items.Add(rbnSignNZ);

            Autodesk.Windows.RibbonRowBreak rowBreakNZ = new RibbonRowBreak();
            panlSourceNZ.Items.Add(rowBreakNZ);

            Autodesk.Windows.RibbonButton rbnRoadSignNZ = new Autodesk.Windows.RibbonButton();
            //rbnRoadSignNZ.Text = "Road Markings";
            rbnRoadSignNZ.ShowText         = true;
            rbnRoadSignNZ.ShowImage        = true;
            rbnRoadSignNZ.Image            = Images.getBitmap(Properties.Resources.Road_Markings);
            rbnRoadSignNZ.LargeImage       = Images.getBitmap(Properties.Resources.Road_Markings);
            rbnRoadSignNZ.Size             = RibbonItemSize.Large;
            rbnRoadSignNZ.CommandParameter = "NZRoadSign";
            rbnRoadSignNZ.CommandHandler   = new AusSignCommandHandler();
            rbnRoadSignNZ.Orientation      = System.Windows.Controls.Orientation.Horizontal;
            rbnRoadSignNZ.Width            = 500;
            panlSourceNZ.Items.Add(rbnRoadSignNZ);

            Autodesk.Windows.RibbonPanel rbnPanelNZ = new RibbonPanel();
            rbnPanelNZ.Source = panlSourceNZ;

            rbnTab.Panels.Add(rbnPanelNZ);

            rbnTab.IsActive = true;

            Autodesk.Windows.ComponentManager.Ribbon.Tabs.Add(rbnTab);
        }
        public void PlaceButtonOnModifyRibbon()
        {
            try
            {
                String SystemTabId   = "Modify";
                String SystemPanelId = "modify_shr";

                adWin.RibbonControl adWinRibbon = adWin.ComponentManager.Ribbon;

                adWin.RibbonTab   adWinSysTab   = null;
                adWin.RibbonPanel adWinSysPanel = null;

                adWin.RibbonTab   adWinApiTab   = null;
                adWin.RibbonPanel adWinApiPanel = null;
                adWin.RibbonItem  adWinApiItem  = null;

                foreach (adWin.RibbonTab ribbonTab in adWinRibbon.Tabs)
                {
                    // Look for the specified system tab

                    if (ribbonTab.Id == SystemTabId)
                    {
                        adWinSysTab = ribbonTab;

                        foreach (adWin.RibbonPanel ribbonPanel
                                 in ribbonTab.Panels)
                        {
                            // Look for the specified panel
                            // within the system tab

                            if (ribbonPanel.Source.Id == SystemPanelId)
                            {
                                adWinSysPanel = ribbonPanel;
                            }
                        }
                    }
                    else
                    {
                        // Look for our API tab

                        if (ribbonTab.Id == myTA.TabName)
                        {
                            adWinApiTab = ribbonTab;

                            foreach (adWin.RibbonPanel ribbonPanel in ribbonTab.Panels)
                            {
                                if (ribbonPanel.Source.Id == "CustomCtrl_%" + myTA.TabName + "%" + myTA.PanelName)
                                {
                                    foreach (adWin.RibbonItem ribbonItem in ribbonPanel.Source.Items)
                                    {
                                        if (ribbonItem.Id == "CustomCtrl_%CustomCtrl_%" + myTA.TabName + "%" + myTA.PanelName + "%" + myTA.Button_01)
                                        {
                                            adWinApiItem = ribbonItem;
                                        }
                                    }
                                }

                                if (ribbonPanel.Source.Id == "CustomCtrl_%" + myTA.TabName + "%" + myTA.PanelTransferring)
                                {
                                    adWinApiPanel = ribbonPanel;
                                }
                            }
                        }
                    }
                }


                if (adWinSysTab != null &&
                    adWinSysPanel != null &&
                    adWinApiTab != null &&
                    adWinApiPanel != null &&
                    adWinApiItem != null)
                {
                    adWinSysTab.Panels.Add(adWinApiPanel);
                    adWinApiPanel.Source.Items.Add(adWinApiItem);
                    adWinApiTab.Panels.Remove(adWinApiPanel);
                }
            }

            #region catch and finally
            catch (Exception ex)
            {
                TaskDialog.Show("me", ex.Message + Environment.NewLine + ex.InnerException);
            }
            finally
            {
            }
            #endregion
        }
Пример #9
0
        void OnApplicationInitialized(object sender, Autodesk.Revit.DB.Events.ApplicationInitializedEventArgs e)
        {
            // Find a system ribbon tab and panel to house
            // our API items
            // Also find our API tab, panel and button within
            // the Autodesk.Windows.RibbonControl context

            adWin.RibbonControl adWinRibbon = adWin.ComponentManager.Ribbon;

            adWin.RibbonTab   adWinSysTab   = null;
            adWin.RibbonPanel adWinSysPanel = null;

            adWin.RibbonTab   adWinApiTab   = null;
            adWin.RibbonPanel adWinApiPanel = null;
            adWin.RibbonItem  adWinApiItem  = null;

            foreach (adWin.RibbonTab ribbonTab in adWinRibbon.Tabs)
            {
                // Look for the specified system tab

                if (ribbonTab.Id == SystemTabId)
                {
                    adWinSysTab = ribbonTab;

                    foreach (adWin.RibbonPanel ribbonPanel in ribbonTab.Panels)
                    {
                        // Look for the specified panel
                        // within the system tab

                        if (ribbonPanel.Source.Id == SystemPanelId)
                        {
                            adWinSysPanel = ribbonPanel;
                        }
                    }
                }
                else
                {
                    // Look for our API tab

                    if (ribbonTab.Id == ApiTabName)
                    {
                        adWinApiTab = ribbonTab;

                        foreach (adWin.RibbonPanel ribbonPanel in ribbonTab.Panels)
                        {
                            // Look for our API panel.

                            // The Source.Id property of an API created
                            // ribbon panel has the following format:
                            // CustomCtrl_%[TabName]%[PanelName]
                            // Where PanelName correlates with the string
                            // entered as the name of the panel at creation
                            // The Source.AutomationName property can also
                            // be used as it is also a direct correlation
                            // of the panel name, but without all the cruft
                            // Be sure to include any new line characters
                            // (\n) used for the panel name at creation as
                            // they still form part of the Id & AutomationName

                            //if(ribbonPanel.Source.AutomationName
                            //  == ApiPanelName) // Alternative method

                            if (ribbonPanel.Source.Id == "CustomCtrl_%" + ApiTabName + "%" + ApiPanelName)
                            {
                                adWinApiPanel = ribbonPanel;

                                foreach (adWin.RibbonItem ribbonItem in ribbonPanel.Source.Items)
                                {
                                    // Look for our command button

                                    // The Id property of an API created ribbon
                                    // item has the following format:
                                    // CustomCtrl_%CustomCtrl_%[TabName]%[PanelName]%[ItemName]
                                    // Where ItemName correlates with the string
                                    // entered as the first parameter (name)
                                    // of the PushButtonData() constructor
                                    // While AutomationName correlates with
                                    // the string entered as the second
                                    // parameter (text) of the PushButtonData()
                                    // constructor
                                    // Be sure to include any new line
                                    // characters (\n) used for the button
                                    // name and text at creation as they
                                    // still form part of the ItemName
                                    // & AutomationName

                                    //if(ribbonItem.AutomationName
                                    //  == ApiButtonText) // alternative method

                                    if (ribbonItem.Id == "CustomCtrl_%CustomCtrl_%" + ApiTabName + "%" + ApiPanelName + "%" + ApiButtonName)
                                    {
                                        adWinApiItem = ribbonItem;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // Make sure we got everything we need

            if (adWinSysTab != null &&
                adWinSysPanel != null &&
                adWinApiTab != null &&
                adWinApiPanel != null &&
                adWinApiItem != null)
            {
                // First we'll add the whole panel including
                // the button to the system tab

                adWinSysTab.Panels.Add(adWinApiPanel);

                // now lets also add the button itself
                // to a system panel

                adWinSysPanel.Source.Items.Add(adWinApiItem);

                // Remove panel from original API tab
                // It can also be left there if needed,
                // there doesn't seem to be any problems with
                // duplicate panels / buttons on seperate tabs
                // / panels respectively

                adWinApiTab.Panels.Remove(adWinApiPanel);

                // Remove our original API tab from the ribbon

                adWinRibbon.Tabs.Remove(adWinApiTab);
            }

            // A new panel should now be added to the
            // specified system tab. Its command buttons
            // will behave as they normally would, including
            // API access and ExternalCommandAvailability tests.
            // There will also be a second copy of the command
            // button from the panel added to the specified
            // system panel.
        }
Пример #10
0
        //convert revit ribbon to adwin for extra control over graphics
        //set buttons to no text
        public static void setButtonNoText()
        {
            Debug.Print("test");
            adwin.RibbonControl ribbon        = adwin.ComponentManager.Ribbon;
            adwin.RibbonTab     my_tab        = null;
            adwin.RibbonPanel   my_panel      = null;
            adwin.RibbonButton  my_buttonStop = null;
            adwin.RibbonButton  my_buttonPlay = null;

            ribbon.FontSize   = 6;                        //needs a total restart to apply
            ribbon.FontFamily = new FontFamily("Impact"); //needs a total restart to apply
            ribbon.FontWeight = System.Windows.FontWeights.DemiBold;
            ribbon.Foreground = Brushes.Gray;             //doesn't do anything



            Autodesk.Internal.Windows.TabTheme myTheme = new Autodesk.Internal.Windows.TabTheme();
            myTheme.PanelBackground      = Brushes.White; //this sits behind and is hidden by our tabs
            myTheme.PanelTitleForeground = Brushes.White; //this is the tab text colour
            //myTheme.PanelTitleBackground = Brushes.White;
            //myTheme.TabHeaderBackground = Brushes.LimeGreen;
            myTheme.TabHeaderForeground = Brushes.White;
            myTheme.PanelBorder         = Brushes.Black;   //doesn't do anything
            myTheme.PanelSeparatorBrush = Brushes.HotPink; //doesn't do anything
            myTheme.InnerBorder         = Brushes.Black;   //tab border
            myTheme.OuterBorder         = Brushes.Red;     //doesn't do anything
            myTheme.PanelSeparatorBrush = Brushes.Black;   //doesn't do anything
            //myTheme.RolloverTabHeaderBackground = Brushes.HotPink;

            foreach (var tab in ribbon.Tabs)
            {
                Debug.Print(tab.Id);
                if (tab.Id == "BrickDims")
                {
                    my_tab       = tab;
                    my_tab.Theme = myTheme;
                    break;
                }
            }
            if (my_tab == null)
            {
                return;
            }
            foreach (var panel in my_tab.Panels)
            {
                Debug.Print(panel.Source.Id);
                if (panel.Source.Id == "CustomCtrl_%BrickDims%Brick Dims")
                {
                    my_panel = panel;
                    my_panel.CustomPanelTitleBarBackground = Brushes.Black;  //this is the tab colour at the bottom when it's activated
                    my_panel.CustomPanelBackground         = Brushes.White;
                    break;
                }
            }
            if (my_panel == null)
            {
                return;
            }
            foreach (var item in my_panel.Source.Items)
            {
                Debug.Print(item.Id);
                // The Id property of an API created ribbon
                // item has the following format:
                // CustomCtrl_%CustomCtrl_%[TabName]%[PanelName]%[ItemName]
                if (item.Id.Contains("Stop"))
                {
                    Debug.Print("stop");
                    my_buttonStop = item as adwin.RibbonButton;
                    //my_buttonStop.ShowText = false;
                }
                if (item.Id.Contains("Play"))
                {
                    Debug.Print("play");
                    my_buttonPlay             = item as adwin.RibbonButton;
                    my_buttonPlay.Orientation = System.Windows.Controls.Orientation.Vertical;
                    //my_buttonPlay.ShowText = false;
                    break;
                }
            }
            if (my_buttonStop == null)
            {
                return;
            }
            if (my_buttonPlay == null)
            {
                return;
            }
            //string filepath = Path.Combine(@"K:\", "ArkUser", "basis.ico");
            //my_button.LargeImage = new System.Windows.Media.Imaging.BitmapImage(new Uri(filepath, UriKind.Absolute));
        }
Пример #11
0
        public void CreateRibbon()
        {
            AcadWindows.RibbonControl ribbon = AcadWindows.ComponentManager.Ribbon;
            AcadWindows.RibbonTab     tab    = new AcadWindows.RibbonTab();
            tab.Name  = "MyTab";
            tab.Title = "My Tab";
            tab.Id    = "MyTabId";
            ribbon.Tabs.Add(tab);

            AcadWindows.RibbonPanelSource panelSrc = new AcadWindows.RibbonPanelSource();
            panelSrc.Name  = "MyPanel";
            panelSrc.Title = "My Panel";
            panelSrc.Id    = "MyPanelId";

            AcadWindows.RibbonCheckBox cb = new Autodesk.Windows.RibbonCheckBox();
            cb.Text      = "Testing";
            cb.IsChecked = true;
            cb.Size      = AcadWindows.RibbonItemSize.Large;

            AcadWindows.RibbonButton button1 = new AcadWindows.RibbonButton();
            button1.Name = "MyButton";
            button1.Text = "My Button";
            button1.Id   = "MyButtonId";

            AcadWindows.RibbonButton button2 = new AcadWindows.RibbonButton();
            button2.Name           = "MyOtherButton";
            button2.Text           = "My Other Button";
            button2.Id             = "MyOtherButtonId";
            button2.Size           = AcadWindows.RibbonItemSize.Large;
            button2.ShowText       = true;
            button2.LargeImage     = GetBitmap(new Bitmap(@"C:\Users\nguye\OneDrive\Desktop\Untitled.png"), 64, 64);
            button2.CommandHandler = new MyButtonCmd();

            AcadWindows.RibbonButton button3 = new AcadWindows.RibbonButton();
            button3.Name           = "MyOtherButton";
            button3.Text           = "My Other Button";
            button3.Id             = "MyOtherButtonId";
            button3.Size           = AcadWindows.RibbonItemSize.Large;
            button3.ShowText       = true;
            button3.Orientation    = System.Windows.Controls.Orientation.Vertical;
            button3.LargeImage     = GetBitmap(new Bitmap(@"C:\Users\nguye\OneDrive\Desktop\Untitled.png"), 64, 64);
            button3.CommandHandler = new MyButtonCmd();

            panelSrc.Items.Add(button1);
            panelSrc.Items.Add(button2);
            panelSrc.Items.Add(button3);
            panelSrc.Items.Add(cb);

            AcadWindows.RibbonPanel panel = new AcadWindows.RibbonPanel();
            panel.Source      = panelSrc;
            panel.ResizeStyle = AcadWindows.RibbonResizeStyles.NeverChangeImageSize;
            tab.Panels.Add(panel);

            if (ps == null)
            {
                ps = new PaletteSet("My Palette 1",
                                    new Guid("229E43DB-E76F-48F9-849A-CC8D726DF257"));
                ps.SetLocation(new System.Drawing.Point(312, 763));
                ps.SetSize(new System.Drawing.Size(909, 40));
                /*For the first time we 'll enable on Bottom*/
                ps.DockEnabled = DockSides.Right;

                UserControl user_control = new UserControl();

                Button btn = new Button();
                btn.Width  = 100;
                btn.Height = 100;
                btn.Text   = "abc";
                user_control.Controls.Add(btn);
                ps.Add("1", user_control);
            }

            ps.Visible = true;

            /*Add Handler*/

            ps.PaletteSetMoved += ps_PaletteSetMoved;
        }
Пример #12
0
        //Ribbon hinzufügen
        public void addRessourceTab()
        {
            RibbonSeparator separator = new RibbonSeparator();

            separator.SeparatorStyle = RibbonSeparatorStyle.Spacer;

            //**************
            //PanelSource IO
            RibbonPanelSource panelSrcIO = new RibbonPanelSource();

            panelSrcIO.Title = "Punkte Import/Export";

            //Pt Import
            RibbonButton bt_PtImport = new RibbonButton();

            bt_PtImport.Id                    = "PtImport";
            bt_PtImport.Text                  = "Punkte importieren";
            bt_PtImport.Image                 = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.IN_small);
            bt_PtImport.LargeImage            = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.IN_small);
            bt_PtImport.Orientation           = System.Windows.Controls.Orientation.Horizontal;
            bt_PtImport.Size                  = RibbonItemSize.Standard;
            bt_PtImport.ShowText              = false;
            bt_PtImport.ShowImage             = true;
            bt_PtImport.CommandHandler        = new RibbonCommandHandler();
            bt_PtImport.ShowToolTipOnDisabled = true;
            bt_PtImport.Description           = "Punkte importieren";

            //Import 3d?
            RibbonCheckBox ribchkBoxImport3d = new RibbonCheckBox();

            ribchkBoxImport3d.Id               = "PtImport3d";
            ribchkBoxImport3d.Text             = "3d";
            ribchkBoxImport3d.Initialized     += new EventHandler(ribchkBoxImport3d_Initialized);
            ribchkBoxImport3d.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(ribchkBoxImport3d_PropertyChanged);
            ribchkBoxImport3d.CommandHandler   = new RibbonCommandHandler();

            //Pt Export
            RibbonButton bt_PtExport = new RibbonButton();

            bt_PtExport.Id                    = "PtExport";
            bt_PtExport.Text                  = "Punkte exportieren";
            bt_PtExport.Image                 = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.Out_small);
            bt_PtExport.LargeImage            = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.Out);
            bt_PtExport.Orientation           = System.Windows.Controls.Orientation.Horizontal;
            bt_PtExport.Size                  = RibbonItemSize.Standard;
            bt_PtExport.ShowText              = false;
            bt_PtExport.ShowImage             = true;
            bt_PtExport.CommandHandler        = new RibbonCommandHandler();
            bt_PtExport.ShowToolTipOnDisabled = true;
            bt_PtExport.Description           = "Punkte exportieren";

            //ComboBox für aktuellen Punktlayer
            RibbonCombo ribCB_Basislayer = new RibbonCombo();

            ribCB_Basislayer.Text            = "Basislayer:";
            ribCB_Basislayer.ShowText        = true;
            ribCB_Basislayer.MinWidth        = 100;
            ribCB_Basislayer.DropDownWidth   = 150;
            ribCB_Basislayer.Initialized    += new EventHandler(ribCB_Basislayer_Initialized);
            ribCB_Basislayer.CurrentChanged += new EventHandler <RibbonPropertyChangedEventArgs>(ribCB_Basislayer_CurrentChanged);
            ribCB_Basislayer.DropDownOpened += new EventHandler <EventArgs>(ribCB_Basislayer_DropDownOpened);

            RibbonRowPanel rowPanel_IO = new RibbonRowPanel();

            rowPanel_IO.Items.Add(bt_PtImport);
            rowPanel_IO.Items.Add(ribchkBoxImport3d);
            rowPanel_IO.Items.Add(new RibbonRowBreak());
            rowPanel_IO.Items.Add(bt_PtExport);
            rowPanel_IO.Items.Add(separator);
            rowPanel_IO.Items.Add(ribCB_Basislayer);
            panelSrcIO.Items.Add(rowPanel_IO);


            //**************
            //PanelSource Tools
            Autodesk.Windows.RibbonPanelSource panelSrcTools = new Autodesk.Windows.RibbonPanelSource();
            panelSrcTools.Title = "Tools";

            //Punkte einfügen
            Autodesk.Windows.RibbonButton bt_PtIns = new Autodesk.Windows.RibbonButton();
            bt_PtIns.Id                    = "PtIns";
            bt_PtIns.Text                  = "Punkte einfügen";
            bt_PtIns.Image                 = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.BlockManipulation);
            bt_PtIns.LargeImage            = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.BlockManipulation);
            bt_PtIns.Orientation           = System.Windows.Controls.Orientation.Horizontal;
            bt_PtIns.Size                  = Autodesk.Windows.RibbonItemSize.Standard;
            bt_PtIns.ShowText              = false;
            bt_PtIns.ShowImage             = true;
            bt_PtIns.CommandHandler        = new RibbonCommandHandler();
            bt_PtIns.ShowToolTipOnDisabled = true;
            bt_PtIns.Description           = "Punkte einfügen";

            //Blockattribute Pre-/Suffix
            Autodesk.Windows.RibbonButton bt_attPreSuf = new Autodesk.Windows.RibbonButton();
            bt_attPreSuf.Id                    = "BlockManipulator";
            bt_attPreSuf.Text                  = "Block Operationen";
            bt_attPreSuf.Image                 = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.BlockManipulation);
            bt_attPreSuf.LargeImage            = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.BlockManipulation);
            bt_attPreSuf.Orientation           = System.Windows.Controls.Orientation.Horizontal;
            bt_attPreSuf.Size                  = Autodesk.Windows.RibbonItemSize.Standard;
            bt_attPreSuf.ShowText              = false;
            bt_attPreSuf.ShowImage             = true;
            bt_attPreSuf.CommandHandler        = new RibbonCommandHandler();
            bt_attPreSuf.ShowToolTipOnDisabled = true;
            bt_attPreSuf.Description           = "Blöcke manipulieren";

            //Layer exportieren
            Autodesk.Windows.RibbonButton bt_layExport = new Autodesk.Windows.RibbonButton();
            bt_layExport.Id                    = "layExport";
            bt_layExport.Text                  = "Layer exportieren";
            bt_layExport.Image                 = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.LayerEport);
            bt_layExport.LargeImage            = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.LayerEport);
            bt_layExport.Orientation           = System.Windows.Controls.Orientation.Horizontal;
            bt_layExport.Size                  = Autodesk.Windows.RibbonItemSize.Large;
            bt_layExport.ShowText              = false;
            bt_layExport.ShowImage             = true;
            bt_layExport.CommandHandler        = new RibbonCommandHandler();
            bt_layExport.ShowToolTipOnDisabled = true;
            bt_layExport.Description           = "Layer exportieren";

            //Objekte auf 3d heben
            Autodesk.Windows.RibbonButton bt_Obj3d = new Autodesk.Windows.RibbonButton();
            bt_layExport.Id                    = "Obj3d";
            bt_layExport.Text                  = "Objekte auf 3d heben";
            bt_layExport.Image                 = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.ObjTo3d);
            bt_layExport.LargeImage            = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.ObjTo3d);
            bt_layExport.Orientation           = System.Windows.Controls.Orientation.Horizontal;
            bt_layExport.Size                  = Autodesk.Windows.RibbonItemSize.Standard;
            bt_layExport.ShowText              = false;
            bt_layExport.ShowImage             = true;
            bt_layExport.CommandHandler        = new RibbonCommandHandler();
            bt_layExport.ShowToolTipOnDisabled = true;
            bt_layExport.Description           = "Objekte auf 3d heben";

            panelSrcTools.Items.Add(bt_PtIns);
            panelSrcTools.Items.Add(bt_attPreSuf);
            panelSrcTools.Items.Add(bt_layExport);
            panelSrcTools.Items.Add(new RibbonRowBreak());
            panelSrcTools.Items.Add(bt_Obj3d);

            //**************
            //PanelSource Attribute
            Autodesk.Windows.RibbonPanelSource panelSrcAtt = new Autodesk.Windows.RibbonPanelSource();
            panelSrcAtt.Title = "Blockattribute";

            Autodesk.Windows.RibbonSubPanelSource panelSubSrcAtt = new Autodesk.Windows.RibbonSubPanelSource();

            //Att Pon
            Autodesk.Windows.RibbonButton bt_AttPon = new Autodesk.Windows.RibbonButton();
            bt_AttPon.Id                    = "AttPon";
            bt_AttPon.Image                 = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.AttPon);
            bt_AttPon.LargeImage            = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.AttPon);
            bt_AttPon.Orientation           = System.Windows.Controls.Orientation.Vertical;
            bt_AttPon.Size                  = Autodesk.Windows.RibbonItemSize.Standard;
            bt_AttPon.ShowText              = false;
            bt_AttPon.ShowImage             = true;
            bt_AttPon.CommandHandler        = new RibbonCommandHandler();
            bt_AttPon.ShowToolTipOnDisabled = true;
            bt_AttPon.Description           = "PNr einschalten";

            //Att Poff
            Autodesk.Windows.RibbonButton bt_AttPoff = new Autodesk.Windows.RibbonButton();
            bt_AttPoff.Id                    = "AttPoff";
            bt_AttPoff.Image                 = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.AttPoff_small);
            bt_AttPoff.LargeImage            = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.AttPoff);
            bt_AttPoff.Orientation           = System.Windows.Controls.Orientation.Horizontal;
            bt_AttPoff.Size                  = Autodesk.Windows.RibbonItemSize.Standard;
            bt_AttPoff.ShowText              = false;
            bt_AttPoff.ShowImage             = true;
            bt_AttPoff.CommandHandler        = new RibbonCommandHandler();
            bt_AttPoff.ShowToolTipOnDisabled = true;
            bt_AttPoff.Description           = "PNr ausschalten";

            //Att Hon
            Autodesk.Windows.RibbonButton bt_AttHon = new Autodesk.Windows.RibbonButton();
            bt_AttHon.Id                    = "AttHon";
            bt_AttHon.Image                 = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.AttHon_small);
            bt_AttHon.LargeImage            = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.AttHon_small1);
            bt_AttHon.Orientation           = System.Windows.Controls.Orientation.Horizontal;
            bt_AttHon.Size                  = Autodesk.Windows.RibbonItemSize.Standard;
            bt_AttHon.ShowText              = false;
            bt_AttHon.ShowImage             = true;
            bt_AttHon.CommandHandler        = new RibbonCommandHandler();
            bt_AttHon.ShowToolTipOnDisabled = true;
            bt_AttHon.Description           = "Höhe einschalten";

            //Att Hoff
            Autodesk.Windows.RibbonButton bt_AttHoff = new Autodesk.Windows.RibbonButton();
            bt_AttHoff.Id                    = "AttHoff";
            bt_AttHoff.Image                 = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.AttHoff);
            bt_AttHoff.LargeImage            = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.AttHoff);
            bt_AttHoff.Orientation           = System.Windows.Controls.Orientation.Horizontal;
            bt_AttHoff.Size                  = Autodesk.Windows.RibbonItemSize.Standard;
            bt_AttHoff.ShowText              = false;
            bt_AttHoff.ShowImage             = true;
            bt_AttHoff.CommandHandler        = new RibbonCommandHandler();
            bt_AttHoff.ShowToolTipOnDisabled = true;
            bt_AttHoff.Description           = "Höhe ausschalten";

            Autodesk.Windows.RibbonRowPanel rowPanel_Att = new Autodesk.Windows.RibbonRowPanel();
            rowPanel_Att.Items.Add(bt_AttPon);
            rowPanel_Att.Items.Add(bt_AttPoff);
            rowPanel_Att.Items.Add(new RibbonRowBreak());
            rowPanel_Att.Items.Add(bt_AttHon);
            rowPanel_Att.Items.Add(bt_AttHoff);

            panelSrcAtt.Items.Add(rowPanel_Att);

            //**************
            //PanelSource Zeichnen
            Autodesk.Windows.RibbonPanelSource panelSrcZeichnen = new Autodesk.Windows.RibbonPanelSource();
            panelSrcZeichnen.Title = "Zeichnen";
            //Settings
            Autodesk.Windows.RibbonButton bt_Block3P = new Autodesk.Windows.RibbonButton();
            bt_Block3P.Id                    = "Block3P";
            bt_Block3P.Text                  = "Einstellungen";
            bt_Block3P.Image                 = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.Block3P);
            bt_Block3P.LargeImage            = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.Block3P);
            bt_Block3P.Orientation           = System.Windows.Controls.Orientation.Horizontal;
            bt_Block3P.Size                  = Autodesk.Windows.RibbonItemSize.Standard;
            bt_Block3P.ShowText              = false;
            bt_Block3P.ShowImage             = true;
            bt_Block3P.CommandHandler        = new RibbonCommandHandler();
            bt_Block3P.ShowToolTipOnDisabled = true;
            bt_Block3P.Description           = "Block mit 3 Punkten einfügen";

            panelSrcZeichnen.Items.Add(bt_Block3P);

            //**************
            //PanelSource Settings
            Autodesk.Windows.RibbonPanelSource panelSrcSettings = new Autodesk.Windows.RibbonPanelSource();
            panelSrcSettings.Title = "Settings";
            //Settings
            Autodesk.Windows.RibbonButton bt_Settings = new Autodesk.Windows.RibbonButton();
            bt_Settings.Id                    = "Settings";
            bt_Settings.Text                  = "Einstellungen";
            bt_Settings.Image                 = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.settings_16x16);
            bt_Settings.LargeImage            = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.Settings);
            bt_Settings.Orientation           = System.Windows.Controls.Orientation.Horizontal;
            bt_Settings.Size                  = Autodesk.Windows.RibbonItemSize.Large;
            bt_Settings.ShowText              = false;
            bt_Settings.ShowImage             = true;
            bt_Settings.CommandHandler        = new RibbonCommandHandler();
            bt_Settings.ShowToolTipOnDisabled = true;
            bt_Settings.Description           = "Einstellungen ";

            panelSrcSettings.Items.Add(bt_Settings);

            //**************
            //PanelSource Help
            Autodesk.Windows.RibbonPanelSource panelSrcHelp = new Autodesk.Windows.RibbonPanelSource();
            panelSrcHelp.Title = "Hilfe";

            //AboutBox
            Autodesk.Windows.RibbonButton bt_About = new Autodesk.Windows.RibbonButton();
            bt_About.Id                    = "AboutBox";
            bt_About.Text                  = "Info zu CAS2018";
            bt_About.Image                 = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.helpdoc);
            bt_About.LargeImage            = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.helpdoc);
            bt_About.Orientation           = System.Windows.Controls.Orientation.Horizontal;
            bt_About.Size                  = Autodesk.Windows.RibbonItemSize.Large;
            bt_About.ShowText              = false;
            bt_About.ShowImage             = true;
            bt_About.CommandHandler        = new RibbonCommandHandler();
            bt_About.ShowToolTipOnDisabled = true;
            bt_About.Description           = "Info über CAS2018";

            panelSrcHelp.Items.Add(bt_About);

            // Row Panel
            Autodesk.Windows.RibbonRowPanel rowPanel1 = new Autodesk.Windows.RibbonRowPanel();
            rowPanel1.Items.Add(bt_About);
            rowPanel1.Items.Add(bt_attPreSuf);

            //rowPanel.Items.Add( panelSubSrcAtt);
            rowPanel1.Items.Add(bt_Settings);
            rowPanel1.ResizeStyle = Autodesk.Windows.RibbonItemResizeStyles.ChangeSize;
            rowPanel1.Size        = Autodesk.Windows.RibbonItemSize.Standard;

            // Create a panel for holding the panel
            // source content
            Autodesk.Windows.RibbonPanel panelCAS = new Autodesk.Windows.RibbonPanel();

            panelCAS.Source = panelSrcIO;
            Autodesk.Windows.RibbonControl control = panelCAS.RibbonControl;

            //Tabs
            Autodesk.Windows.RibbonPanel panel_IO = new Autodesk.Windows.RibbonPanel();

            panel_IO.Source = panelSrcIO;

            Autodesk.Windows.RibbonPanel panel_Tools = new Autodesk.Windows.RibbonPanel();
            panel_Tools.Source = panelSrcTools;

            Autodesk.Windows.RibbonPanel panel_Att = new Autodesk.Windows.RibbonPanel();
            panel_Att.Source = panelSrcAtt;

            Autodesk.Windows.RibbonPanel panel_Zeichnen = new RibbonPanel();
            panel_Zeichnen.Source = panelSrcZeichnen;

            Autodesk.Windows.RibbonPanel panel_Settings = new Autodesk.Windows.RibbonPanel();
            panel_Settings.Source = panelSrcSettings;

            Autodesk.Windows.RibbonPanel panel_Help = new Autodesk.Windows.RibbonPanel();
            panel_Help.Source = panelSrcHelp;

            Autodesk.Windows.RibbonTab tabCAS2018 = new Autodesk.Windows.RibbonTab();
            tabCAS2018.Title           = "CAS2018";
            tabCAS2018.Id              = "CAS2018";
            tabCAS2018.IsContextualTab = false;

            tabCAS2018.Panels.Add(panel_IO);
            tabCAS2018.Panels.Add(panel_Tools);
            tabCAS2018.Panels.Add(panel_Att);
            tabCAS2018.Panels.Add(panel_Zeichnen);
            tabCAS2018.Panels.Add(panel_Settings);
            tabCAS2018.Panels.Add(panel_Help);

            // Now add the tab to AutoCAD Ribbon bar...
            try
            {
                Autodesk.Windows.RibbonControl ribbonControl = RibbonServices.RibbonPaletteSet.RibbonControl;
                Autodesk.Windows.RibbonTab     ribTab        = new Autodesk.Windows.RibbonTab();
                ribbonControl.Tabs.Add(tabCAS2018);
            }
            catch { }
        }
Пример #13
0
 public CustomTab(CustomRibbon ribbon, Autodesk.Windows.RibbonTab ribbonTab)
     : this(ribbon)
 {
     this._ribbonTab = ribbonTab;
 }
Пример #14
0
        public adWin.RibbonItem AdwinButton(string tabName, string panelName, string btnName, bool isSystemTab = false)
        {
            adWin.RibbonControl adWinRibbon   = adWin.ComponentManager.Ribbon;
            adWin.RibbonTab     adWinSysTab   = null;
            adWin.RibbonPanel   adWinSysPanel = null;
            adWin.RibbonTab     adWinApiTab   = null;
            adWin.RibbonPanel   adWinApiPanel = null;
            adWin.RibbonItem    adWinApiItem  = null;

            //If input tab is system tab
            if (isSystemTab)
            {
                foreach (adWin.RibbonTab ribbonTab in adWinRibbon.Tabs)
                {
                    if (ribbonTab.Id != tabName)
                    {
                        continue;
                    }
                    adWinSysTab = ribbonTab;
                    break;
                }
                if (adWinSysTab != null)
                {
                    foreach (adWin.RibbonPanel ribbonPanel in adWinApiTab.Panels)
                    {
                        if (ribbonPanel.Source.Id != tabName)
                        {
                            continue;
                        }
                        adWinSysPanel = ribbonPanel;
                        break;;
                    }
                }

                return(null);
            }


            //If input tab is not a system tab
            foreach (adWin.RibbonTab ribbonTab in adWinRibbon.Tabs)
            {
                if (!ribbonTab.Title.Equals(tabName))
                {
                    continue;
                }
                adWinApiTab           = ribbonTab;
                adWinApiTab.IsVisible = false;
                break;
            }

            // Problem: Autodesk.Windows.RibbonTab.Panels = {0}  ???
            // I don't understand here
            if (adWinApiTab != null)
            {
                foreach (adWin.RibbonPanel ribbonPanel in adWinApiTab.Panels)
                {
                    // Look for our API panel.
                    // The ConvertToPushButton.Id property of an API created
                    // ribbon panel has the following format:
                    // CustomCtrl_%[TabName]%[PanelName]
                    if (ribbonPanel.Source.Id != "CustomCtrl_%" + tabName + "%" + panelName)
                    {
                        continue;
                    }
                    adWinApiPanel = ribbonPanel;
                    break;;
                }
            }
            if (adWinApiPanel != null)
            {
                foreach (adWin.RibbonItem ribbonItem
                         in adWinApiPanel.Source.Items)
                {
                    // Look for our command button
                    // The Id property of an API created ribbon
                    // item has the following format:
                    // CustomCtrl_%CustomCtrl_%[TabName]%[PanelName]%[ItemName]

                    //if(ribbonItem.AutomationName
                    //  == ApiButtonText) // alternative method

                    if (ribbonItem.Id != "CustomCtrl_%CustomCtrl_%"
                        + tabName + "%" + panelName
                        + "%" + btnName)
                    {
                        continue;
                    }
                    adWinApiItem = ribbonItem;
                    break;
                }
            }

            if (adWinApiItem != null)
            {
                adWinApiItem.ToolTip = "This button is found by api.";
                TaskDialog.Show("Existing Button", $"Button {btnName} founded");
                // Do something

                return(adWinApiItem);
            }

            TaskDialog.Show("Existing Button", $"Button {btnName} is not founded");
            return(null);
        }