Exemplo n.º 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;
        }
Exemplo n.º 2
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);
        }