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