예제 #1
1
        public Result OnStartup(
            UIControlledApplication a)
        {
            _controlledApp = a;

              // Locate and load button images.

              //string AddInPath = typeof( App ).Assembly.Location;
              //string iconPath = Path.GetDirectoryName( AddInPath ).ToLower();
              //string lastDir = new DirectoryInfo( iconPath ).Name;
              //iconPath = iconPath.Replace( "\\" + lastDir, "\\icons\\" );

              //Uri uriImage = new Uri( iconPath + "image.ico" );
              //BitmapImage image = new BitmapImage( uriImage ); // PresentationCore

              BitmapSource image = GetEmbeddedImage(
            "ModifyTabButton.icon.cartoon_house_16.ico" );

              // Add modify panel

              Autodesk.Windows.RibbonControl ribbon
            = Autodesk.Windows.ComponentManager.Ribbon;

              foreach( Autodesk.Windows.RibbonTab tab
            in ribbon.Tabs )
              {
            if( tab.Id == "Modify" )
            {
              _modifyPanel = new Autodesk.Windows.RibbonPanel();
              _modifyPanel.IsVisible = false;

              Autodesk.Windows.RibbonPanelSource source
            = new Autodesk.Windows.RibbonPanelSource();

              source.Name = "mymod";
              source.Id = "mymod";
              source.Title = "My Modify";
              _modifyPanel.Source = source;
              _modifyPanel.FloatingOrientation
            = System.Windows.Controls.Orientation.Vertical;

              _button1 = CreateButton( 1, image );
              _button2 = CreateButton( 2, image );
              _button3 = CreateButton( 3, image );

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

              Autodesk.Windows.RibbonRowPanel rowPanel
            = new Autodesk.Windows.RibbonRowPanel();

              rowPanel.Items.Add( _button1 );
              rowPanel.Items.Add( new Autodesk.Windows.RibbonRowBreak() );
              rowPanel.Items.Add( _button2 );
              rowPanel.Items.Add( new Autodesk.Windows.RibbonRowBreak() );
              rowPanel.Items.Add( _button3 );

              _modifyPanel.Source.Items.Add( rowPanel );

              tab.Panels.Add( _modifyPanel );

              tab.Panels.CollectionChanged
            += new System.Collections.Specialized
              .NotifyCollectionChangedEventHandler(
                OnCollectionChanged );

              a.ViewActivated
            += new EventHandler<ViewActivatedEventArgs>(
              OnViewActivated );

              break;
            }
              }
              return Result.Succeeded;
        }
예제 #2
0
 public static void SetItem(PushButton btn)
 {
     if (ribbonButton == null)
     {
         MethodInfo method = btn.GetType().GetMethod("getRibbonButton", BindingFlags.NonPublic | BindingFlags.Instance);
         ribbonButton = method.Invoke(btn, null) as Autodesk.Windows.RibbonButton;
     }
 }
예제 #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);
        }
예제 #4
0
        /// <summary>
        /// Create a basic ribbon button with an
        /// identifying number and an image.
        /// </summary>
        static Autodesk.Windows.RibbonButton CreateButton(
            int nr,
            BitmapSource image)
        {
            string s = nr.ToString();

            Autodesk.Windows.RibbonButton b
                = new Autodesk.Windows.RibbonButton();

            b.Name             = "_Button" + s;
            b.Id               = "ID_MYBUTTON" + s;
            b.AllowInStatusBar = true;
            b.AllowInToolBar   = true;
            b.GroupLocation    = Autodesk.Private.Windows
                                 .RibbonItemGroupLocation.Middle;
            b.IsEnabled             = true;
            b.IsToolTipEnabled      = true;
            b.IsVisible             = false;
            b.LargeImage            = image;
            b.Image                 = image;
            b.ShowImage             = true; //  true;
            b.ShowText              = true;
            b.ShowToolTipOnDisabled = true;
            b.Text        = "Button " + s;
            b.ToolTip     = "Button " + s;
            b.MinHeight   = 0;
            b.MinWidth    = 0;
            b.Size        = Autodesk.Windows.RibbonItemSize.Standard;
            b.ResizeStyle = Autodesk.Windows
                            .RibbonItemResizeStyles.HideText;
            b.IsCheckable = true;
            b.Orientation = System.Windows.Controls
                            .Orientation.Horizontal; // PresentationFramework
            b.KeyTip = "Button" + s;

            return(b);
        }
예제 #5
0
        public Result OnStartup(
            UIControlledApplication a)
        {
            _controlledApp = a;

            // Locate and load button images.

            //string AddInPath = typeof( App ).Assembly.Location;
            //string iconPath = Path.GetDirectoryName( AddInPath ).ToLower();
            //string lastDir = new DirectoryInfo( iconPath ).Name;
            //iconPath = iconPath.Replace( "\\" + lastDir, "\\icons\\" );

            //Uri uriImage = new Uri( iconPath + "image.ico" );
            //BitmapImage image = new BitmapImage( uriImage ); // PresentationCore

            BitmapSource image = GetEmbeddedImage(
                "ModifyTabButton.icon.cartoon_house_16.ico");

            // Add modify panel

            Autodesk.Windows.RibbonControl ribbon
                = Autodesk.Windows.ComponentManager.Ribbon;

            foreach (Autodesk.Windows.RibbonTab tab
                     in ribbon.Tabs)
            {
                if (tab.Id == "Modify")
                {
                    _modifyPanel           = new Autodesk.Windows.RibbonPanel();
                    _modifyPanel.IsVisible = false;

                    Autodesk.Windows.RibbonPanelSource source
                        = new Autodesk.Windows.RibbonPanelSource();

                    source.Name         = "mymod";
                    source.Id           = "mymod";
                    source.Title        = "My Modify";
                    _modifyPanel.Source = source;
                    _modifyPanel.FloatingOrientation
                        = System.Windows.Controls.Orientation.Vertical;

                    _button1 = CreateButton(1, image);
                    _button2 = CreateButton(2, image);
                    _button3 = CreateButton(3, image);

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

                    Autodesk.Windows.RibbonRowPanel rowPanel
                        = new Autodesk.Windows.RibbonRowPanel();

                    rowPanel.Items.Add(_button1);
                    rowPanel.Items.Add(new Autodesk.Windows.RibbonRowBreak());
                    rowPanel.Items.Add(_button2);
                    rowPanel.Items.Add(new Autodesk.Windows.RibbonRowBreak());
                    rowPanel.Items.Add(_button3);

                    _modifyPanel.Source.Items.Add(rowPanel);

                    tab.Panels.Add(_modifyPanel);

                    tab.Panels.CollectionChanged
                        += new System.Collections.Specialized
                           .NotifyCollectionChangedEventHandler(
                               OnCollectionChanged);

                    a.ViewActivated
                        += new EventHandler <ViewActivatedEventArgs>(
                               OnViewActivated);

                    break;
                }
            }
            return(Result.Succeeded);
        }
예제 #6
0
        /// <summary>
        /// Create a basic ribbon button with an 
        /// identifying number and an image.
        /// </summary>
        static Autodesk.Windows.RibbonButton CreateButton(
            int nr,
            BitmapSource image)
        {
            string s = nr.ToString();

              Autodesk.Windows.RibbonButton b
            = new Autodesk.Windows.RibbonButton();

              b.Name = "_Button" + s;
              b.Id = "ID_MYBUTTON" + s;
              b.AllowInStatusBar = true;
              b.AllowInToolBar = true;
              b.GroupLocation = Autodesk.Private.Windows
            .RibbonItemGroupLocation.Middle;
              b.IsEnabled = true;
              b.IsToolTipEnabled = true;
              b.IsVisible = false;
              b.LargeImage = image;
              b.Image = image;
              b.ShowImage = true; //  true;
              b.ShowText = true;
              b.ShowToolTipOnDisabled = true;
              b.Text = "Button " + s;
              b.ToolTip = "Button " + s;
              b.MinHeight = 0;
              b.MinWidth = 0;
              b.Size = Autodesk.Windows.RibbonItemSize.Standard;
              b.ResizeStyle = Autodesk.Windows
            .RibbonItemResizeStyles.HideText;
              b.IsCheckable = true;
              b.Orientation = System.Windows.Controls
            .Orientation.Horizontal; // PresentationFramework
              b.KeyTip = "Button" + s;

              return b;
        }