// This method is called by Inventor when it loads the AddIn. The AddInSiteObject provides access
            // to the Inventor Application object. The FirstTime flag indicates if the AddIn is loaded for
            // the first time. However, with the introduction of the ribbon this argument is always true.
            public void Activate(ApplicationAddInSite addInSiteObject, bool firstTime)
            {
                try
                {
                    // Initialize AddIn members.
                    Globals.invApp = addInSiteObject.Application;

                    // Connect to the user-interface events to handle a ribbon reset.
                    m_uiEvents = Globals.invApp.UserInterfaceManager.UserInterfaceEvents;

                    // *********************************************************************************
                    // * The remaining code in this Sub is all for adding the add-in into Inventor's UI.
                    // * It can be deleted if this add-in doesn't have a UI and only runs in the
                    // * background handling events.
                    // *********************************************************************************

                    // Create the button definition using the CreateButtonDefinition function to simplify this step.
                    // ButtonName = Utilities.CreateButtonDefinition(display_text, internal_name, "", icon_path)
                    MyFirstButton  = Utilities.CreateButtonDefinition("    My First    \n    Command    ", "MyFirstCommand", "", @"ButtonResources\MyIcon1");
                    MySecondButton = Utilities.CreateButtonDefinition("    My Second    \n    Command    ", "MySecondCommand", "", @"ButtonResources\MyIcon2");
                    CloseDocButton = Utilities.CreateButtonDefinition("    Close    \n    Document    ", "CloseDocCommand", "", @"ButtonResources\MyIcon3");

                    // Add to the user interface, if it's the first time.
                    // If this add-in doesn't have a UI but runs in the background listening
                    // to events, you can delete this.
                    if (firstTime)
                    {
                        AddToUserInterface();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unexpected failure in the activation of the add-in \"My_CSharp_AddIn\"" + System.Environment.NewLine + System.Environment.NewLine + ex.Message);
                }
            }
Exemple #2
0
        protected override void CreateControl()
        {
            CommandManager commandMgr = Application.CommandManager;

            //Create IPictureDisp from Icon resources
            stdole.IPictureDisp standardIconPict =
                (StandardIcon != null ? PictureDispConverter.ToIPictureDisp(StandardIcon) : null);

            stdole.IPictureDisp largeIconPict =
                (LargeIcon != null ? PictureDispConverter.ToIPictureDisp(LargeIcon) : null);

            _controlDef = commandMgr.ControlDefinitions.AddButtonDefinition(
                DisplayName,
                InternalName,
                Classification,
                ClientId,
                Description,
                ToolTipText,
                standardIconPict,
                largeIconPict,
                ButtonDisplay);

            ControlDefinition = _controlDef as ControlDefinition;

            _controlDef.OnExecute +=
                new ButtonDefinitionSink_OnExecuteEventHandler(Handle_ButtonDefinition_OnExecute);

            _controlDef.OnHelp +=
                new ButtonDefinitionSink_OnHelpEventHandler(Handle_ButtonDefinition_OnHelp);
        }
Exemple #3
0
        public Button(string displayName,
                      string internalName,
                      CommandTypesEnum commandType,
                      string clientId,
                      string description,
                      string tooltip,
                      ButtonDisplayEnum buttonDisplayType)
        {
            try
            {
                buttonDefinition = PersistenceManager.InventorApplication.CommandManager.ControlDefinitions.AddButtonDefinition(displayName,
                                                                                                                                internalName,
                                                                                                                                commandType,
                                                                                                                                clientId,
                                                                                                                                description,
                                                                                                                                tooltip,
                                                                                                                                Type.Missing,
                                                                                                                                Type.Missing,
                                                                                                                                buttonDisplayType);

                buttonDefinition.Enabled = true;
                ButtonDefinition_OnExecuteEventDelegate = new ButtonDefinitionSink_OnExecuteEventHandler(ButtonDefinition_OnExecute);
                buttonDefinition.OnExecute += ButtonDefinition_OnExecuteEventDelegate;
            }

            catch (Exception e)
            {
                throw new ApplicationException(e.ToString());
            }
        }
Exemple #4
0
        private void ProcessTogglePopupNode(RibbonPanel panel, XmlNode node)
        {
            string commandName = node.Attributes["internalName"].Value;

            ButtonDefinition controlDef =
                _Application.CommandManager.ControlDefinitions[commandName] as ButtonDefinition;

            bool?  useLargeIcon  = XmlUtilities.GetAttributeValueAsNullable <bool>(node, "useLargeIcon");
            bool?  showText      = XmlUtilities.GetAttributeValueAsNullable <bool>(node, "showText");
            string targetControl = XmlUtilities.GetAttributeValue <string>(node, "targetControl");
            bool?  insertBefore  = XmlUtilities.GetAttributeValueAsNullable <bool>(node, "insertBefore");
            bool?  isInSlideout  = XmlUtilities.GetAttributeValueAsNullable <bool>(node, "isInSlideout");

            bool slideout = isInSlideout.HasValue ? isInSlideout.Value : false;

            CommandControls controls = (slideout ? panel.SlideoutControls : panel.CommandControls);

            ObjectCollection buttons = GetButtons(node);

            if (buttons.Count > 0)
            {
                controls.AddTogglePopup(
                    controlDef,
                    buttons,
                    useLargeIcon.HasValue ? useLargeIcon.Value : false,
                    showText.HasValue ? showText.Value : true,
                    string.IsNullOrEmpty(targetControl) ? string.Empty : targetControl,
                    insertBefore.HasValue ? insertBefore.Value : false);
            }
        }
Exemple #5
0
        static void Main(string[] args)
        {
            if (Environment.UserInteractive)
            {
                string             Title         = "Bandwidth Monitor " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " Service Manager";
                string             ServiceName   = "BandwidthMonitor";
                ButtonDefinition   btnTestRun    = new ButtonDefinition("Test-Run Service", btnTestRun_Click);
                ButtonDefinition   btnSettings   = new ButtonDefinition("Edit Service Settings", btnSettings_Click);
                ButtonDefinition[] customButtons = new ButtonDefinition[] { btnTestRun, btnSettings };

                if (Debugger.IsAttached)
                {
                    btnTestRun_Click(null, null);
                }

                System.Windows.Forms.Application.Run(new ServiceManager(Title, ServiceName, customButtons));

                svcTestRun?.DoStop();
            }
            else
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new MainSvc()
                };
                ServiceBase.Run(ServicesToRun);
            }
        }
Exemple #6
0
        public Button(string displayName, string internalName, CommandTypesEnum commandType, string clientId, string description, string tooltip, Icon standardIcon, Icon largeIcon, ButtonDisplayEnum buttonDisplayType)
        {
            try
            {
                //get IPictureDisp for icons
                stdole.IPictureDisp standardIconIPictureDisp;
                standardIconIPictureDisp = (stdole.IPictureDisp)Support.IconToIPicture(standardIcon);

                stdole.IPictureDisp largeIconIPictureDisp;
                largeIconIPictureDisp = (stdole.IPictureDisp)Support.IconToIPicture(largeIcon);

                //create button definition
                m_buttonDefinition = m_inventorApplication.CommandManager.ControlDefinitions.AddButtonDefinition(displayName, internalName, commandType, clientId, description, tooltip, standardIconIPictureDisp , largeIconIPictureDisp, buttonDisplayType);

                //enable the button
                m_buttonDefinition.Enabled = true;

                //connect the button event sink
                ButtonDefinition_OnExecuteEventDelegate = new ButtonDefinitionSink_OnExecuteEventHandler(ButtonDefinition_OnExecute);
                m_buttonDefinition.OnExecute += ButtonDefinition_OnExecuteEventDelegate;
            }
            catch(Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Exemple #7
0
        /// <summary>
        /// This is the main entry point for the SHRD host service.
        /// </summary>
        /// <param name="args"></param>
        public static void Run(string[] args)
        {
            string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;

            Globals.InitializeProgram(exePath, "Self Hosted Remote Desktop", true);
            PrivateAccessor.SetStaticFieldValue(typeof(Globals), "errorFilePath", Globals.WritableDirectoryBase + "SHRD_Log.txt");

            FileInfo fiExe = new FileInfo(exePath);

            Environment.CurrentDirectory = fiExe.Directory.FullName;

            System.Windows.Forms.Application.ThreadException += Application_ThreadException;
            AppDomain.CurrentDomain.UnhandledException       += CurrentDomain_UnhandledException;

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            //byte[] buf = new byte[4];
            //ByteUtil.WriteFloat(5, buf, 0);
            //float f = ByteUtil.ReadFloat(buf, 0);
            //Logger.Info(f.ToString());

            if (Environment.UserInteractive)
            {
                bool cmd = args.Length > 0 && args[0] == "cmd";
                if (cmd || Debugger.IsAttached)
                {
                    BPUtil.NativeWin.WinConsole.Initialize();
                    Logger.logType = LoggingMode.Console | LoggingMode.File;
                    Logger.Info("Console environment detected. Logging to console is enabled.");
                    ServiceWrapper.Initialize();
                    ServiceWrapper.Start();
                    do
                    {
                        Console.WriteLine("Type \"exit\" to close");
                    }while (Console.ReadLine().ToLower() != "exit");
                    ServiceWrapper.Stop();
                    return;
                }
                else
                {
                    Logger.logType = LoggingMode.File;
                }

                string             Title           = "SelfHostedRemoteDesktop " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " Service Manager";
                string             ServiceName     = "SelfHostedRemoteDesktop";
                ButtonDefinition   btnStartCmdTest = new ButtonDefinition("Test w/console", btnStartCmdTest_Click);
                ButtonDefinition[] customButtons   = new ButtonDefinition[] { btnStartCmdTest };

                System.Windows.Forms.Application.Run(new ServiceManager(Title, ServiceName, customButtons));
            }
            else
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new SelfHostedRemoteDesktopSvc()
                };
                ServiceBase.Run(ServicesToRun);
            }
        }
Exemple #8
0
		public Button(string displayName, 
                      string internalName, 
                      CommandTypesEnum commandType, 
                      string clientId, 
                      string description, 
                      string tooltip, 
                      ButtonDisplayEnum buttonDisplayType)
		{
			try
			{			
                buttonDefinition = PersistenceManager.InventorApplication.CommandManager.ControlDefinitions.AddButtonDefinition(displayName, 
                                                                                                                             internalName, 
                                                                                                                             commandType, 
                                                                                                                             clientId, 
                                                                                                                             description, 
                                                                                                                             tooltip, 
                                                                                                                             Type.Missing, 
                                                                                                                             Type.Missing, 
                                                                                                                             buttonDisplayType);
								
                buttonDefinition.Enabled = true;
				ButtonDefinition_OnExecuteEventDelegate = new ButtonDefinitionSink_OnExecuteEventHandler(ButtonDefinition_OnExecute);
                buttonDefinition.OnExecute += ButtonDefinition_OnExecuteEventDelegate;
			}

			catch(Exception e)
			{
                throw new ApplicationException(e.ToString());
			}
		}
        /// <summary>
        /// Create a button from inventor using Image file as icon
        /// </summary>
        /// <param name="app"></param>
        /// <param name="displayName"></param>
        /// <param name="internalName"></param>
        /// <param name="commandType"></param>
        /// <param name="clientId"></param>
        /// <param name="description"></param>
        /// <param name="tooltip"></param>
        /// <param name="standardIcon"></param>
        /// <param name="largeIcon"></param>
        /// <param name="buttonDisplayType"></param>
        public Button(Inventor.Application app,
                      string displayName,
                      string internalName,
                      CommandTypesEnum commandType,
                      string clientId,
                      string description,
                      string tooltip,
                      object standardIcon,
                      object largeIcon,
                      ButtonDisplayEnum buttonDisplayType)
        {
            try
            {
                _buttonDefinition = app.CommandManager
                                    .ControlDefinitions
                                    .AddButtonDefinition(displayName,
                                                         internalName,
                                                         commandType,
                                                         clientId,
                                                         description,
                                                         tooltip,
                                                         standardIcon,
                                                         largeIcon,
                                                         buttonDisplayType);

                _buttonDefinition.Enabled         = true;
                _buttonDef_OnExecuteEventDelegate = new ButtonDefinitionSink_OnExecuteEventHandler(Button_OnExecute);
                _buttonDefinition.OnExecute      += _buttonDef_OnExecuteEventDelegate;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                throw new ApplicationException(ex.Message);
            }
        }
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            // This method is called by Inventor when it loads the addin.
            // The AddInSiteObject provides access to the Inventor Application object.
            // The FirstTime flag indicates if the addin is loaded for the first time.

            // Initialize AddIn members.
            m_inventorApplication = addInSiteObject.Application;

            // TODO: Add ApplicationAddInServer.Activate implementation.
            // e.g. event initialization, command creation etc.
            // Connect to the user-interface events to handle a ribbon reset.

            {
                m_uiEvents = m_inventorApplication.UserInterfaceManager.UserInterfaceEvents;
                m_uiEvents.OnResetRibbonInterface += m_uiEvents_OnResetRibbonInterface;

                stdole.IPictureDisp         largeIcon   = PictureDispConverter.ToIPictureDisp(InvAddIn.Resource1.Large);
                stdole.IPictureDisp         smallIcon   = PictureDispConverter.ToIPictureDisp(InvAddIn.Resource1.Small);
                Inventor.ControlDefinitions controlDefs = m_inventorApplication.CommandManager.ControlDefinitions;
                m_sampleButton1            = controlDefs.AddButtonDefinition("License check", "Entitlement API", CommandTypesEnum.kShapeEditCmdType, AddInClientID(), "Entitlement api", "Entitlement api", smallIcon, largeIcon);
                m_sampleButton1.OnExecute += m_sampleButton1_OnExecute;

                // Add to the user interface, if it's the first time.
                if (firstTime)
                {
                    AddToUserInterface();
                }
            }
        }
        /// <summary>
        /// The helper method for constructors to call to avoid duplicate code.
        /// </summary>
        public void Create(
            string displayName, string internalName, string description, string tooltip,
            string clientId,
            Icon standardIcon, Icon largeIcon,
            CommandTypesEnum commandType, ButtonDisplayEnum buttonDisplayType)
        {
            if (string.IsNullOrEmpty(clientId))
            {
                clientId = AddinGlobal.ClassId;
            }

            stdole.IPictureDisp standardIconIPictureDisp = null;
            stdole.IPictureDisp largeIconIPictureDisp    = null;
            if (standardIcon != null)
            {
                standardIconIPictureDisp = Support.IconToIPicture(standardIcon) as stdole.IPictureDisp;
                largeIconIPictureDisp    = (stdole.IPictureDisp)Support.IconToIPicture(largeIcon);
            }

            mButtonDef = AddinGlobal.InventorApp.CommandManager.ControlDefinitions.AddButtonDefinition(
                displayName, internalName, commandType,
                clientId, description, tooltip,
                standardIconIPictureDisp, largeIconIPictureDisp, buttonDisplayType);

            mButtonDef.Enabled    = true;
            mButtonDef.OnExecute += ButtonDefinition_OnExecute;

            DisplayText = true;

            AddinGlobal.ButtonList.Add(this);
        }
Exemple #12
0
        public static void MainMethod()
        {
            string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;

            Globals.Initialize(exePath);
            PrivateAccessor.SetStaticFieldValue(typeof(Globals), "errorFilePath", Globals.WritableDirectoryBase + "MJpegCameraErrors.txt");

            if (Environment.UserInteractive)
            {
                string             Title         = "CameraProxy " + CameraProxyGlobals.Version + " Service Manager";
                string             ServiceName   = "MJpegCameraProxy";
                ButtonDefinition   btnCmd        = new ButtonDefinition("Command Line Test", btnCmd_Click);
                ButtonDefinition[] customButtons = new ButtonDefinition[] { btnCmd };

                Application.Run(new ServiceManager(Title, ServiceName, customButtons));
            }
            else
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new CameraProxyService()
                };
                ServiceBase.Run(ServicesToRun);
            }
        }
Exemple #13
0
        public McMasterButton(StandardAddInServer s)
        {
            _stAddIn = s;
            mv       = new MainWindowViewModel();
            Stream myStream = System.Reflection.Assembly.
                              GetExecutingAssembly().GetManifestResourceStream(
                "McMasterAddin.Resources.mcmaster.ico");

            stdole.IPictureDisp largeImage =
                PictureDispConverter.ToIPictureDisp(new Icon(myStream));

            //Button definition
            m_buttonDefinition = _stAddIn.m_invApp.CommandManager.
                                 ControlDefinitions.AddButtonDefinition("Browse",
                                                                        "BrowseButton",
                                                                        CommandTypesEnum.kQueryOnlyCmdType, StandardAddInServer.m_ClientIDstr,
                                                                        "Browse McMaster-Carr Inventory", "Use this to find " +
                                                                        "hardware and other products available on McMaster.com",
                                                                        largeImage, largeImage, ButtonDisplayEnum.kAlwaysDisplayText);

            m_button_Definition_OnExecute_Delegate = new
                                                     ButtonDefinitionSink_OnExecuteEventHandler(
                m_button_OnExecute);
            m_buttonDefinition.OnExecute +=
                m_button_Definition_OnExecute_Delegate;
            m_buttonDefinition.Enabled = true;
        }
        protected ButtonBase()
        {
            var typeName = GetType().Name;

            Name = "Autodesk:PowerTools:" + typeName;

            try
            {
                var standardIcon = ImageConvert.FromIconToIPictureDisp(
                    icon: new Icon(typeof(ButtonBase), typeName + ".ico")
                    );

                _buttonDefinition =
                    AddIn.Inventor.CommandManager.ControlDefinitions.AddButtonDefinition(
                        DisplayName: DisplayName,
                        InternalName: Name,
                        Classification: CommandType,
                        ClientId: AddIn.ClientId,
                        DescriptionText: Description,
                        ToolTipText: ToolTip,
                        StandardIcon: standardIcon,
                        LargeIcon: standardIcon,
                        ButtonDisplay: DisplayType
                        );

                _buttonDefinition.OnExecute += OnExecute;

                IsEnabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemple #15
0
        public void Activate(ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            // This method is called by Inventor when it loads the addin.
            // The AddInSiteObject provides access to the Inventor Application object.
            // The FirstTime flag indicates if the addin is loaded for the first time.

            // Initialize AddIn members.
            _inventorApplication = addInSiteObject.Application;

            ControlDefinitions controlDefs   = _inventorApplication.CommandManager.ControlDefinitions;
            IPictureDisp       smallPicture2 = AxHostConverter.ImageToPictureDisp(Resources.CreateMasterM.ToBitmap());
            IPictureDisp       largePicture2 = AxHostConverter.ImageToPictureDisp(Resources.CreateMasterM.ToBitmap());

            _dockableWindow            = controlDefs.AddButtonDefinition("Dockable Window", "DockableWindow:Show", CommandTypesEnum.kNonShapeEditCmdType, "{" + ClientId + "}", null, null, smallPicture2, largePicture2);
            _dockableWindow.OnExecute += m_dockableWindow_OnExecute;

            // Get the initial ribbon.
            Ribbon ribbon = _inventorApplication.UserInterfaceManager.Ribbons["ZeroDoc"];
            // Get "Extras" tab.
            RibbonTab extrasTab = ribbon.RibbonTabs["id_TabTools"];

            const string chatPanelInternalName = "DockableWindow:ChatPanel";
            RibbonPanel  panel = extrasTab.RibbonPanels.OfType <RibbonPanel>().SingleOrDefault(rp => rp.InternalName == chatPanelInternalName);

            if (panel == null)
            {
                panel = extrasTab.RibbonPanels.Add("Chat", chatPanelInternalName, "{" + ClientId + "}");
            }

            panel.CommandControls.AddButton(_dockableWindow, true);
        }
Exemple #16
0
        /// <summary>
        /// modifies Drawing ribbon by adding two buttons used by the add-in
        /// </summary>
        private void modifyRibbon()
        {
            //get Command manager
            cmdMan = m_inventorApplication.CommandManager;

            //get control definitions
            ctrlDefs = cmdMan.ControlDefinitions;

            //define command category for add-in's buttons
            cmdCat = cmdMan.CommandCategories.Add("Auto-Breaker", "Autodesk:CmdCategory:AutoBreaker", addInGuid);

            //get 'Drawing' ribbon
            drawingRibbon = m_inventorApplication.UserInterfaceManager.Ribbons["Drawing"];

            //get 'Place Views' tab from 'Drawing' ribbon
            placeTab = drawingRibbon.RibbonTabs["id_TabPlaceViews"];

            //define 'Apply break' button
            applyButton            = ctrlDefs.AddButtonDefinition("Apply!", "Autodesk:AutoBreaker:ApplyButton", CommandTypesEnum.kQueryOnlyCmdType, addInGuid, "auto-break description", "auto-break tooltip", plus16obj, plus128obj, ButtonDisplayEnum.kAlwaysDisplayText);
            applyButton.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(customAction);
            cmdCat.Add(applyButton);

            //define 'Settings' button
            settingsButton            = ctrlDefs.AddButtonDefinition("Settings", "Autodesk:AutoBreaker:SettingsButton", CommandTypesEnum.kQueryOnlyCmdType, addInGuid, "auto-breaker settings description", "auto-break settings tool-tip", gear16obj, gear128obj, ButtonDisplayEnum.kAlwaysDisplayText);
            settingsButton.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(settingsClick);
            cmdCat.Add(settingsButton);

            //define panel in 'Place Views' tab
            panel                = placeTab.RibbonPanels.Add("Auto-Breaker", "Autodesk:AutoBreaker:AutoBreakerPanel", addInGuid);
            controlApplyBreak    = panel.CommandControls.AddButton(applyButton, true, true);
            controlSettingsBreak = panel.CommandControls.AddButton(settingsButton, true, true);
        }
Exemple #17
0
        private void AddMainButtonToRibbon()
        {
            ControlDefinitions ctrlDefs = InventorApp.CommandManager.ControlDefinitions;
            var  currAssembly           = System.Reflection.Assembly.GetExecutingAssembly();
            Icon icon32        = Resources.shaft_32x32;
            Icon icon16        = Resources.shaft_16x16;
            var  pictureDisp32 = PictureDispConverter.ToIPictureDisp(icon32);
            var  pictureDisp16 = PictureDispConverter.ToIPictureDisp(icon16);

            this.mainButtonDefinition = ctrlDefs.AddButtonDefinition(
                DisplayName: "Shaft",
                InternalName: "Autodesk:InventorShaftGenerator:MainCtrl",
                Classification: CommandTypesEnum.kEditMaskCmdType,
                ClientId: AdnInventorUtilities.AddInGuid,
                ToolTipText: "Shaft Component Generator",
                StandardIcon: pictureDisp16,
                LargeIcon: pictureDisp32
                );
            this.mainButtonDefinition.OnExecute += OnMainButtonExecute;

            Ribbon    assebmlyRibbon = InventorApp.UserInterfaceManager.Ribbons["Assembly"];
            RibbonTab asmDesingTab   = assebmlyRibbon.RibbonTabs["id_TabDesign"];

            var panel3 = asmDesingTab.RibbonPanels.Add(
                DisplayName: "Tools Panel",
                InternalName: "Autodesk:InventorShaftGenerator:PartToolsPanel",
                ClientId: AdnInventorUtilities.AddInGuid);

            panel3.CommandControls.AddButton(
                ButtonDefinition: this.mainButtonDefinition,
                UseLargeIcon: true
                );
        }
Exemple #18
0
        public void Deactivate()
        {
            // Release objects.
            if (_activeProjectType == MultiUserModeEnum.kVaultMode)
            {
                UnSubscribeEvents();
            }

            _applicationEvents.OnActiveProjectChanged -= ApplicationEvents_OnActiveProjectChanged;

            _userInputEvents       = null;
            _dockableWindowsEvents = null;
            _applicationEvents     = null;

            _vaultAddin = null;

            _myVaultBrowserButton = null;
            _myVaultBrowser       = null;

            _hwndDic = null;
            Hook.Clear();

            Marshal.ReleaseComObject(_inventorApplication);
            _inventorApplication = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Exemple #19
0
        public Button(string displayName, string internalName, CommandTypesEnum commandType, string clientId, string description, string tooltip, Icon standardIcon, Icon largeIcon, ButtonDisplayEnum buttonDisplayType)
        {
            try
            {
                //get IPictureDisp for icons
                stdole.IPictureDisp standardIconIPictureDisp;
                standardIconIPictureDisp = (stdole.IPictureDisp)Support.IconToIPicture(standardIcon);

                stdole.IPictureDisp largeIconIPictureDisp;
                largeIconIPictureDisp = (stdole.IPictureDisp)Support.IconToIPicture(largeIcon);

                //create button definition
                m_buttonDefinition = m_inventorApplication.CommandManager.ControlDefinitions.AddButtonDefinition(displayName, internalName, commandType, clientId, description, tooltip, standardIconIPictureDisp, largeIconIPictureDisp, buttonDisplayType);

                //enable the button
                m_buttonDefinition.Enabled = true;

                //connect the button event sink
                ButtonDefinition_OnExecuteEventDelegate = new ButtonDefinitionSink_OnExecuteEventHandler(ButtonDefinition_OnExecute);
                m_buttonDefinition.OnExecute           += ButtonDefinition_OnExecuteEventDelegate;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
        /// <summary>
        /// Loads graphics content for this screen. The background texture is quite
        /// big, so we use our own local ContentManager to load it. This allows us
        /// to unload before going from the menus into the game itself, wheras if we
        /// used the shared ContentManager provided by the Game class, the content
        /// would remain loaded forever.
        /// </summary>
        public override void LoadContent()
        {
            title      = ScreenManager.Game.Content.Load <Texture2D>("title");
            background = ScreenManager.Game.Content.Load <Texture2D>("background");
            // Setup virtual gamepad
            gamepadTexture = ScreenManager.Game.Content.Load <Texture2D>("gamepad");
            ButtonDefinition BButton = new ButtonDefinition();

            BButton.Texture     = gamepadTexture;
            BButton.Position    = new Vector2(270, 240);
            BButton.Type        = Buttons.Back;
            BButton.TextureRect = new Rectangle(72, 77, 36, 36);

            ButtonDefinition AButton = new ButtonDefinition();

            AButton.Texture     = gamepadTexture;
            AButton.Position    = new Vector2(30, 420);
            AButton.Type        = Buttons.A;
            AButton.TextureRect = new Rectangle(73, 114, 36, 36);

            GamePad.ButtonsDefinitions.Add(BButton);
            GamePad.ButtonsDefinitions.Add(AButton);

            ThumbStickDefinition thumbStick = new ThumbStickDefinition();

            thumbStick.Position    = new Vector2(220, 400);
            thumbStick.Texture     = gamepadTexture;
            thumbStick.TextureRect = new Rectangle(2, 2, 68, 68);

            GamePad.LeftThumbStickDefinition = thumbStick;
        }
Exemple #21
0
        /*
         * public addInButtonDefinition(string Name, string ToolTip, Icon large_Ico, CommandTypesEnum cmd_Type)
         * {
         *
         *  assemble(var_es._ClientId, Name, "id_" + Name, ToolTip, "", null, large_Ico, cmd_Type, ButtonDisplayEnum.kDisplayTextInLearningMode);
         *
         * }
         *
         */

        #endregion

        private void assemble(string ClientId, string Name, string internalName, string Tooltip, string Description, Icon small_Ico, Icon large_Ico, CommandTypesEnum cmd_type, ButtonDisplayEnum btn_type)
        {
            if (String.IsNullOrEmpty(ClientId))
            {
                ClientId = var_es._ClientId;
            }

            stdole.IPictureDisp common = null;

            if (small_Ico != null)
            {
                common = ImgTypeConv.Ico_to_Picture(small_Ico);
            }

            stdole.IPictureDisp large = null;

            if (large_Ico != null)
            {
                large = ImgTypeConv.Ico_to_Picture(large_Ico);
            }

            Button = var_es.InventorApp.CommandManager.ControlDefinitions.AddButtonDefinition(Name, internalName, cmd_type, ClientId, Description, Tooltip, common, large, btn_type);

            Button.Enabled = true;

            Button.OnExecute += BTN_OnExecute;
        }
Exemple #22
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;

            Globals.Initialize(exePath);
            Directory.SetCurrentDirectory(Globals.ApplicationDirectoryBase);

            Application.ThreadException += Application_ThreadException;
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;

            if (Environment.UserInteractive)
            {
                string Title = "DahuaSunriseSunset " + Assembly.GetEntryAssembly().GetName().Version.ToString() + " Service Manager";
                Logger.Info(Title + " Startup");
                string             ServiceName        = "DahuaSunriseSunset";
                ButtonDefinition   btnConfigure       = new ButtonDefinition("Configure Service", btnConfigure_Click);
                ButtonDefinition   btnSimulateSunrise = new ButtonDefinition("Simulate Sunrise", btnSimulateSunrise_Click);
                ButtonDefinition   btnViewNextTimes   = new ButtonDefinition("View rise/set", btnViewNextTimes_Click);
                ButtonDefinition   btnSimulateSunset  = new ButtonDefinition("Simulate Sunset", btnSimulateSunset_Click);
                ButtonDefinition[] customButtons      = new ButtonDefinition[] { btnConfigure, btnSimulateSunrise, btnViewNextTimes, btnSimulateSunset };

                Application.Run(sm = new ServiceManager(Title, ServiceName, customButtons));
            }
            else
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new DahuaSunriseSunsetService()
                };
                ServiceBase.Run(ServicesToRun);
            }
        }
Exemple #23
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            if (Environment.UserInteractive)
            {
                if (Debugger.IsAttached || (args.Length == 1 && args[0] == "cmd"))
                {
                    BPUtil.NativeWin.WinConsole.Initialize();
                    TimelapseWrapper server = new TimelapseWrapper(false);
                    server.SocketBound += Server_SocketBound;
                    server.Start();

                    do
                    {
                        Console.WriteLine("Type \"exit\" to close.");
                    }while (Console.ReadLine().ToLower() != "exit");

                    server.Stop();
                    return;
                }
                string           Title       = "Timelapse " + TimelapseGlobals.Version + " Service Manager";
                string           ServiceName = "Timelapse";
                ButtonDefinition btnCmd      = new ButtonDefinition("Run Command Line", btnCmd_Click);

                Application.Run(new ServiceManager(Title, ServiceName, new ButtonDefinition[] { btnCmd }));
            }
            else
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new TimelapseWebService()
                };
                ServiceBase.Run(ServicesToRun);
            }
        }
Exemple #24
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            if (Environment.UserInteractive)
            {
                string Title       = "Windows Server Monitor " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " Service Manager";
                string ServiceName = "WindowsServerMonitor";

                MonitorSvc svcTestRun = null;
                if (Debugger.IsAttached)
                {
                    svcTestRun = new MonitorSvc();
                    svcTestRun.DoStart();
                }

                ButtonDefinition   btnLaunch = new ButtonDefinition("Launch in Browser", btnLaunch_Click);
                ButtonDefinition   btnLoadDefaultSettings = new ButtonDefinition("Default Settings", btnLoadDefaultSettings_Click);
                ButtonDefinition[] customButtons          = new ButtonDefinition[] { btnLaunch, btnLoadDefaultSettings };

                System.Windows.Forms.Application.Run(new ServiceManager(Title, ServiceName, customButtons));

                svcTestRun?.DoStop();
            }
            else
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new MonitorSvc()
                };
                ServiceBase.Run(ServicesToRun);
            }
        }
Exemple #25
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            Globals.Initialize(Application.ExecutablePath);
            PrivateAccessor.SetStaticFieldValue(typeof(Globals), "configFilePath", Globals.WritableDirectoryBase + "IpCameraSpeedometerSettings.xml");

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.ThreadException += Application_ThreadException;
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            if (Environment.UserInteractive)
            {
                ServiceWrapper.settings.SaveIfNoExist(Globals.ConfigFilePath);
                string           Title            = "IpCameraSpeedometer " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " Service Manager";
                ButtonDefinition btnConfiguration = new ButtonDefinition("Configuration", btnConfiguration_Click);
                ServiceManager   serviceManager   = new ServiceManager(Title, ServiceWrapper.settings.ServiceName, new ButtonDefinition[] { btnConfiguration }, new ServiceName(ServiceWrapper.settings.ServiceName, ServiceNameChange));
                Application.Run(serviceManager);
                while (ServiceWrapper.restartServiceManager)
                {
                    ServiceWrapper.restartServiceManager = false;
                    serviceManager = new ServiceManager(Title, ServiceWrapper.settings.ServiceName, new ButtonDefinition[] { btnConfiguration }, new ServiceName(ServiceWrapper.settings.ServiceName, ServiceNameChange));
                    Application.Run(serviceManager);
                }
            }
            else
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new IpCameraSpeedometer()
                };
                ServiceBase.Run(ServicesToRun);
            }
        }
Exemple #26
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;

            Globals.Initialize(exePath);

            if (Environment.UserInteractive)
            {
                string             Title         = "LetsEncryptManager " + LEGlobals.Version + " Service Manager";
                string             ServiceName   = "LetsEncryptManager";
                ButtonDefinition   btnConfigure  = new ButtonDefinition("Configure Service", btnConfigure_Click);
                ButtonDefinition   btnExportKey  = new ButtonDefinition("Pfx2crt&key", btnExportKey_Click);
                ButtonDefinition[] customButtons = new ButtonDefinition[] { btnConfigure, btnExportKey };

                Application.Run(sm = new ServiceManager(Title, ServiceName, customButtons));
            }
            else
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new MainService()
                };
                ServiceBase.Run(ServicesToRun);
            }
        }
Exemple #27
0
        public Panel(Inventor.Application invApp, ButtonDefinition btnDef, string ribbonName, string ribbonTabName, string displayName, string intName, string m_guid)
        {
            UserInterfaceManager userInterfaceManager;

            userInterfaceManager = invApp.UserInterfaceManager;
            Ribbons ribbons;

            ribbons = userInterfaceManager.Ribbons;
            Ribbon ribbon;

            ribbon = ribbons[ribbonName];
            RibbonTabs ribbonTabs;

            ribbonTabs = ribbon.RibbonTabs;
            RibbonTab ribbonTab;

            ribbonTab = ribbonTabs[ribbonTabName];
            RibbonPanels ribbonPanels;

            ribbonPanels = ribbonTab.RibbonPanels;
            RibbonPanel ribbonPanel;

            ribbonPanel = ribbonPanels.Add(displayName, intName, m_guid, "", false);
            //CommandControls commandControls;
            m_commandControls = ribbonPanel.CommandControls;
            m_commandControl  = m_commandControls.AddButton(btnDef);
        }
Exemple #28
0
        public void CreateButtonNoIcon(Application application, string displayName, string internalName, CommandTypesEnum commandType, object clientId, string description, string toolTip, object standardIcon, object largeIcon, ButtonDisplayEnum buttonType, bool autoAddToGUI)
        {
            //store the Inventor application object
            m_inventorApplication = application;

            //create the button definition
            m_buttonDefinition = m_inventorApplication.CommandManager.ControlDefinitions.AddButtonDefinition(
                displayName,
                internalName,
                commandType,
                clientId,
                description,
                toolTip,
                standardIcon,
                largeIcon,
                buttonType);

            //connect the button events sink
            m_buttonDefinition_OnExecute_Delegate = new ButtonDefinitionSink_OnExecuteEventHandler(ButtonDefinition_OnExecute);
            m_buttonDefinition.OnExecute         += m_buttonDefinition_OnExecute_Delegate;

            //display button by default if specified
            if (autoAddToGUI)
            {
                m_buttonDefinition.AutoAddToGUI();
            }
        }
Exemple #29
0
        private void ProcessGalleryNode(RibbonPanel panel, XmlNode node)
        {
            string commandName = node.Attributes["internalName"].Value;

            ButtonDefinition controlDef =
                _Application.CommandManager.ControlDefinitions[commandName] as ButtonDefinition;

            bool?  displayAsCombo = XmlUtilities.GetAttributeValueAsNullable <bool>(node, "displayAsCombo");
            int?   width          = XmlUtilities.GetAttributeValueAsNullable <int>(node, "width");
            string targetControl  = XmlUtilities.GetAttributeValue <string>(node, "targetControl");
            bool?  insertBefore   = XmlUtilities.GetAttributeValueAsNullable <bool>(node, "insertBefore");
            bool?  isInSlideout   = XmlUtilities.GetAttributeValueAsNullable <bool>(node, "isInSlideout");

            bool slideout = isInSlideout.HasValue ? isInSlideout.Value : false;

            CommandControls controls = (slideout ? panel.SlideoutControls : panel.CommandControls);

            ObjectCollection buttons = GetButtons(node);

            if (buttons.Count > 0)
            {
                controls.AddGallery(
                    buttons,
                    displayAsCombo.HasValue ? displayAsCombo.Value : false,
                    width.HasValue ? width.Value : 15,
                    string.IsNullOrEmpty(targetControl) ? string.Empty : targetControl,
                    insertBefore.HasValue ? insertBefore.Value : false);
            }
        }
 public Button(string DisplayName, string internalName, string clientId, string description, string tooltip, Icon standarticon, Icon largeIcon, string catName = "CSharp")
 {
     try
     {
         stdole.IPictureDisp standartIconIPictureDisp;
         standartIconIPictureDisp = OleCreateConverter.ImageToPictureDisp(standarticon.ToBitmap());
         stdole.IPictureDisp largeIconIPictureDisp;
         largeIconIPictureDisp = OleCreateConverter.ImageToPictureDisp(largeIcon.ToBitmap());
         m_buttonDefinition    = m_inventorApplication.CommandManager.ControlDefinitions.AddButtonDefinition(DisplayName,
                                                                                                             "Autodesk:Macros:" + internalName, CommandTypesEnum.kNonShapeEditCmdType, clientId, description, tooltip, standartIconIPictureDisp,
                                                                                                             largeIconIPictureDisp, ButtonDisplayEnum.kDisplayTextInLearningMode);
         m_buttonDefinition.Enabled = true;
         ButtonDefinition_OnExecuteEventDelegate = new ButtonDefinitionSink_OnExecuteEventHandler(ButtonDefinition_OnExecute);
         m_buttonDefinition.OnExecute           += ButtonDefinition_OnExecuteEventDelegate;
         if (catName != "")
         {
             CommandCategory cat = u.get <CommandCategory>(m_inventorApplication.CommandManager.CommandCategories, c => c.DisplayName == catName) ??
                                   m_inventorApplication.CommandManager.CommandCategories.Add(catName, "Autodesk:Macros:" + catName);
             cat.Add(m_buttonDefinition);
         }
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Exemple #31
0
 private void RenderButton(ButtonDefinition theButton, SpriteBatch batch)
 {
     if (batch == null)
     {
         throw new InvalidOperationException("SpriteBatch not set.");
     }
     batch.Draw(theButton.Texture, theButton.Position, theButton.TextureRect, _alphaColor);
 }
Exemple #32
0
        public void TestConstructor_InitalizesButtons()
        {
            ButtonDefinition button = _objectUnderTest.Buttons.Single();

            Assert.AreEqual(CloudExplorerViewModel.s_refreshIcon.Value, button.Icon);
            Assert.AreEqual(Resources.CloudExplorerRefreshButtonToolTip, button.ToolTip);
            Assert.AreEqual(_objectUnderTest.RefreshCommand, button.Command);
        }
Exemple #33
0
        public Button(string displayName, string internalName, CommandTypesEnum commandType, string clientId, string description, string tooltip, ButtonDisplayEnum buttonDisplayType)
        {
            try
            {
                //create button definition
                m_buttonDefinition = m_inventorApplication.CommandManager.ControlDefinitions.AddButtonDefinition(displayName, internalName, commandType, clientId, description, tooltip, Type.Missing, Type.Missing, buttonDisplayType);

                //enable the button
                m_buttonDefinition.Enabled = true;

                //connect the button event sink
                ButtonDefinition_OnExecuteEventDelegate = new ButtonDefinitionSink_OnExecuteEventHandler(ButtonDefinition_OnExecute);
                m_buttonDefinition.OnExecute += ButtonDefinition_OnExecuteEventDelegate;
            }
            catch(Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Exemple #34
0
		public Button(string displayName, 
                      string internalName, 
                      CommandTypesEnum commandType, 
                      string clientId, 
                      string description, 
                      string tooltip, 
                      Icon standardIcon, 
                      Icon largeIcon, 
                      ButtonDisplayEnum buttonDisplayType)
		{
			try
			{
				stdole.IPictureDisp standardIconIPictureDisp;				
				standardIconIPictureDisp = PictureDispConverter.ToIPictureDisp(standardIcon);			
				stdole.IPictureDisp largeIconIPictureDisp;
		        largeIconIPictureDisp = PictureDispConverter.ToIPictureDisp(largeIcon);   
				buttonDefinition = PersistenceManager.InventorApplication.CommandManager.ControlDefinitions.AddButtonDefinition(displayName, 
                                                                                                                             internalName, 
                                                                                                                             commandType, 
                                                                                                                             clientId, 
                                                                                                                             description, 
                                                                                                                             tooltip, 
                                                                                                                             standardIconIPictureDisp , 
                                                                                                                             largeIconIPictureDisp, 
                                                                                                                             buttonDisplayType);
												
                buttonDefinition.Enabled = true;			
                ButtonDefinition_OnExecuteEventDelegate = new ButtonDefinitionSink_OnExecuteEventHandler(ButtonDefinition_OnExecute);
                buttonDefinition.OnExecute += ButtonDefinition_OnExecuteEventDelegate;
			}

			catch(Exception e)
			{
                throw new ApplicationException(e.ToString());
			}
		}
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            // This method is called by Inventor when it loads the addin.
            // The AddInSiteObject provides access to the Inventor Application object.
            // The FirstTime flag indicates if the addin is loaded for the first time.

            // Initialize AddIn members.
            m_inventorApplication = addInSiteObject.Application;

            // TODO: Add ApplicationAddInServer.Activate implementation.
            // e.g. event initialization, command creation etc.
            ControlDefinitions oCtrlDefs = m_inventorApplication.CommandManager.ControlDefinitions;

            System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();

            string[] resources = assembly.GetManifestResourceNames();

            System.IO.Stream oStream32 = assembly.GetManifestResourceStream("RibbonDemoAddin.resources.button 32x32.ico");
            System.IO.Stream oStream16 = assembly.GetManifestResourceStream("RibbonDemoAddin.resources.button 16x16.ico");

            System.Drawing.Icon oIcon32 = new System.Drawing.Icon(oStream32);
            System.Drawing.Icon oIcon16 = new System.Drawing.Icon(oStream16);

            object oIPictureDisp32 = AxHostConverter.ImageToPictureDisp(oIcon32.ToBitmap());
            object oIPictureDisp16 = AxHostConverter.ImageToPictureDisp(oIcon16.ToBitmap());

            try
            {
                _buttonDef1 = oCtrlDefs["Autodesk:BrowserDemo:ButtonDef1"] as ButtonDefinition;
            }
            catch (Exception ex)
            {
                _buttonDef1 = oCtrlDefs.AddButtonDefinition("Ribbon Demo1",
                                                          "Autodesk:RibbonDemoC#:ButtonDef1",
                                                          CommandTypesEnum.kEditMaskCmdType,
                                                          addInGuid,
                                                          "Ribbon Demo",
                                                          "Ribbon Demo Description",
                                                          oIPictureDisp16,
                                                          oIPictureDisp32,
                                                          ButtonDisplayEnum.kDisplayTextInLearningMode);

                CommandCategory cmdCat = m_inventorApplication.CommandManager.CommandCategories.Add("RibbonDemo C#", "Autodesk:CmdCategory:RibbonDemoC#", addInGuid);

                cmdCat.Add(_buttonDef1);
            }

            if (firstTime)
            {
                try
                {
                    if (m_inventorApplication.UserInterfaceManager.InterfaceStyle == InterfaceStyleEnum.kRibbonInterface)
                    {
                        Ribbon ribbon = m_inventorApplication.UserInterfaceManager.Ribbons["Part"];

                        RibbonTab tab = ribbon.RibbonTabs["id_TabModel"];

                        try
                        {
                            RibbonPanel panel = tab.RibbonPanels.Add("Ribbon Demo", "Autodesk:RibbonDemoC#:Panel1", addInGuid, "", false);

                            CommandControl control1 = panel.CommandControls.AddButton(_buttonDef1, true, true, "", false);
                        }
                        catch (Exception ex)
                        {

                        }
                    }
                    else
                    {
                        CommandBar oCommandBar = m_inventorApplication.UserInterfaceManager.CommandBars["PMxPartFeatureCmdBar"];
                        oCommandBar.Controls.AddButton(_buttonDef1, 0);
                    }
                }
                catch
                {
                    CommandBar oCommandBar = m_inventorApplication.UserInterfaceManager.CommandBars["PMxPartFeatureCmdBar"];
                    oCommandBar.Controls.AddButton(_buttonDef1, 0);
                }
            }

            _buttonDef1.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(_buttonDef1_OnExecute);
        }
 /// <summary>
 /// This method changes the button that is being displayed on the rectangle control panel.
 /// </summary>
 /// <param name="buttonDefinition"></param>
 public void ChangeDisplayedControl(ButtonDefinition buttonDefinition)
 {
     if (StandardAddInServer.InventorApplication.ActiveDocumentType == DocumentTypeEnum.kPartDocumentObject)
     {
         partRectangleSplitButton.DisplayedControl = buttonDefinition as ControlDefinition;
     }
     else if (StandardAddInServer.InventorApplication.ActiveDocumentType == DocumentTypeEnum.kDrawingDocumentObject)
     {
         drawingRectangleSplitButton.DisplayedControl = buttonDefinition as ControlDefinition;
     }
     else if (StandardAddInServer.InventorApplication.ActiveDocumentType == DocumentTypeEnum.kAssemblyDocumentObject)
     {
         assemblyRectangleSplitButton.DisplayedControl = buttonDefinition as ControlDefinition;
     }
 }
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            // This method is called by Inventor when it loads the addin.
            // The AddInSiteObject provides access to the Inventor Application object.
            // The FirstTime flag indicates if the addin is loaded for the first time.

            // Initialize AddIn members.
            m_inventorApplication = addInSiteObject.Application;

            // TODO: Add ApplicationAddInServer.Activate implementation.
            // e.g. event initialization, command creation etc.

            ControlDefinitions oCtrlDefs = m_inventorApplication.CommandManager.ControlDefinitions;

            System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();

            string[] resources = assembly.GetManifestResourceNames();

            System.IO.Stream oStream1 = assembly.GetManifestResourceStream("ZeroRibbon.resources.Icon1.ico");
            System.IO.Stream oStream2 = assembly.GetManifestResourceStream("ZeroRibbon.resources.Icon2.ico");

            System.Drawing.Icon oIcon1 = new System.Drawing.Icon(oStream1);
            System.Drawing.Icon oIcon2 = new System.Drawing.Icon(oStream2);

            object oIPictureDisp1 = AxHostConverter.ImageToPictureDisp(oIcon1.ToBitmap());
            object oIPictureDisp2 = AxHostConverter.ImageToPictureDisp(oIcon2.ToBitmap());

            try
            {
                Zero_GetStarted_LaunchPanel_ButtonDef = oCtrlDefs["Autodesk:ZeroRibbon:ButtonDef1"] as ButtonDefinition;
                Zero_GetStarted_NewPanel_ButtonDef = oCtrlDefs["Autodesk:ZeroRibbon:ButtonDef2"] as ButtonDefinition;
            }
            catch (Exception ex)
            {
                Zero_GetStarted_LaunchPanel_ButtonDef = oCtrlDefs.AddButtonDefinition("Ribbon Demo1",
                                                          "Autodesk:ZeroRibbon:ButtonDef1",
                                                          CommandTypesEnum.kEditMaskCmdType,
                                                          addInGuid,
                                                          "Ribbon Demo",
                                                          "Ribbon Demo Description",
                                                          oIPictureDisp1,
                                                          oIPictureDisp1,
                                                          ButtonDisplayEnum.kDisplayTextInLearningMode);

                Zero_GetStarted_NewPanel_ButtonDef = oCtrlDefs.AddButtonDefinition("Ribbon Demo2",
                                                        "Autodesk:ZeroRibbon:ButtonDef2",
                                                        CommandTypesEnum.kEditMaskCmdType,
                                                        addInGuid,
                                                        "Ribbon Demo",
                                                        "Ribbon Demo Description",
                                                        oIPictureDisp2,
                                                        oIPictureDisp2,
                                                        ButtonDisplayEnum.kDisplayTextInLearningMode);

                CommandCategory cmdCat = m_inventorApplication.CommandManager.CommandCategories.Add("RibbonDemo C#", "Autodesk:CmdCategory:RibbonDemoC#", addInGuid);


                cmdCat.Add(Zero_GetStarted_LaunchPanel_ButtonDef);
                cmdCat.Add(Zero_GetStarted_NewPanel_ButtonDef);
            }



            Ribbon ribbon = m_inventorApplication.UserInterfaceManager.Ribbons["ZeroDoc"];
            RibbonTab tab = ribbon.RibbonTabs["id_GetStarted"];
            RibbonPanel built_panel = tab.RibbonPanels["id_Panel_Launch"];
            built_panel.CommandControls.AddButton(Zero_GetStarted_LaunchPanel_ButtonDef, true);

            RibbonPanel panel1 = tab.RibbonPanels.Add("Ribbon Demo", "Autodesk:RibbonDemoC#:Panel1", addInGuid, "", false);
            panel1.CommandControls.AddButton(Zero_GetStarted_NewPanel_ButtonDef, true);


            Zero_GetStarted_LaunchPanel_ButtonDef.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(Zero_GetStarted_LaunchPanel_ButtonDef_OnExecute);
            Zero_GetStarted_NewPanel_ButtonDef.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(Zero_GetStarted_NewPanel_ButtonDef_OnExecute);
        }
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            // This method is called by Inventor when it loads the addin.
            // The AddInSiteObject provides access to the Inventor Application object.
            // The FirstTime flag indicates if the addin is loaded for the first time.

            // Initialize AddIn members.
            m_inventorApplication = addInSiteObject.Application;

            // TODO: Add ApplicationAddInServer.Activate implementation.
            // e.g. event initialization, command creation etc.
            // Connect to the user-interface events to handle a ribbon reset.

            {
                m_uiEvents = m_inventorApplication.UserInterfaceManager.UserInterfaceEvents;
                m_uiEvents.OnResetRibbonInterface +=m_uiEvents_OnResetRibbonInterface;

                stdole.IPictureDisp largeIcon = PictureDispConverter.ToIPictureDisp(InvAddIn.Resource1.Large);
                stdole.IPictureDisp smallIcon = PictureDispConverter.ToIPictureDisp(InvAddIn.Resource1.Small);
                Inventor.ControlDefinitions controlDefs = m_inventorApplication.CommandManager.ControlDefinitions;
                m_sampleButton1 = controlDefs.AddButtonDefinition("License check", "Entitlement API", CommandTypesEnum.kShapeEditCmdType, AddInClientID(), "Entitlement api", "Entitlement api", smallIcon, largeIcon);
                m_sampleButton1.OnExecute +=m_sampleButton1_OnExecute;

                // Add to the user interface, if it's the first time.
                if (firstTime)
                {
                    AddToUserInterface();
                }
            }
        }
        protected ButtonBase()
        {
            var typeName = GetType().Name;
            Name = "Autodesk:PowerTools:" + typeName;

            try
            {
                var standardIcon = ImageConvert.FromIconToIPictureDisp(
                    icon: new Icon(typeof(ButtonBase), typeName + ".ico")
                );

                _buttonDefinition =
                    AddIn.Inventor.CommandManager.ControlDefinitions.AddButtonDefinition(
                        DisplayName: DisplayName,
                        InternalName: Name,
                        Classification: CommandType,
                        ClientId: AddIn.ClientId,
                        DescriptionText: Description,
                        ToolTipText: ToolTip,
                        StandardIcon: standardIcon,
                        LargeIcon: standardIcon,
                        ButtonDisplay: DisplayType
                    );

                _buttonDefinition.OnExecute += OnExecute;

                IsEnabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemple #40
0
        public void Deactivate()
        {
            // This method is called by Inventor when the AddIn is unloaded.
            // The AddIn will be unloaded either manually by the user or
            // when the Inventor session is terminated

            // TODO: Add ApplicationAddInServer.Deactivate implementation

            // Release objects.
            Marshal.ReleaseComObject(buttonDefinition);
            buttonDefinition = null;

            Marshal.ReleaseComObject(m_inventorApplication);
            m_inventorApplication = null;

            GC.WaitForPendingFinalizers();
            GC.Collect();
        }
Exemple #41
0
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            // This method is called by Inventor when it loads the addin.
            // The AddInSiteObject provides access to the Inventor Application object.
            // The FirstTime flag indicates if the addin is loaded for the first time.

            // Initialize AddIn members.
            m_inventorApplication = addInSiteObject.Application;

            // TODO: Add ApplicationAddInServer.Activate implementation.
            // e.g. event initialization, command creation etc.
            String strAddInGUID = "{" + ((GuidAttribute)System.Attribute.GetCustomAttribute(typeof(StandardAddInServer), typeof(GuidAttribute))).Value + "}";

            buttonDefinition = m_inventorApplication.CommandManager.ControlDefinitions.AddButtonDefinition(
              "Chapter1AddInBD",
              "Chapter1AddInBD_Internal",
              Inventor.CommandTypesEnum.kShapeEditCmdType,
              strAddInGUID,
              "Chapter1AddInBD_Description",
              "Chapter1AddInBD_Tooltip",
              System.Type.Missing,
              System.Type.Missing,
              Inventor.ButtonDisplayEnum.kAlwaysDisplayText);
            buttonDefinition.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(ButtonDefinition_OnExecute);

            if (firstTime)
            {
                Inventor.CommandBar commandBar = m_inventorApplication.UserInterfaceManager.CommandBars.Add(
                  "Chapter1AddInCB",
                  "Chapter1AddInCB_Internal",
                  Inventor.CommandBarTypeEnum.kRegularCommandBar,
                  strAddInGUID);
                commandBar.Controls.AddButton(buttonDefinition, 0);
                commandBar.Visible = true;
            }
        }
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            _addInSiteObject = addInSiteObject;

            // This method is called by Inventor when it loads the addin.
            // The AddInSiteObject provides access to the Inventor Application object.
            // The FirstTime flag indicates if the addin is loaded for the first time.
            
            // Initialize AddIn members.
            _Application = addInSiteObject.Application;

            AdnInventorUtilities.Initialize(_Application, this.GetType());

            ControlDefinitions ctrlDefs =
               _Application.CommandManager.ControlDefinitions;

            System.Drawing.Icon Icon32 = Resources.CGAUDemo_32x32;
            System.Drawing.Icon Icon16 = Resources.CGAUDemo_16x16;

            object IPictureDisp32 = PictureDispConverter.ToIPictureDisp(Icon32);
            object IPictureDisp16 = PictureDispConverter.ToIPictureDisp(Icon16);

            try
            {
                _MainControlButtonDef = 
                    ctrlDefs["Autodesk:AdskCGAUDemo:MainCtrl"] as ButtonDefinition;
            }
            catch
            {
                _MainControlButtonDef =
                    ctrlDefs.AddButtonDefinition(
                        "   Demo   \n   Control   ",
                        "Autodesk:AdskCGAUDemo:MainCtrl",
                        CommandTypesEnum.kEditMaskCmdType,
                        AdnInventorUtilities.AddInGuid,
                        "Client Graphics Demo AU",
                        "Client Graphics Demo AU",
                        IPictureDisp16,
                        IPictureDisp32,
                        ButtonDisplayEnum.kDisplayTextInLearningMode);
            }

            _MainControlButtonDef.OnExecute += 
                new ButtonDefinitionSink_OnExecuteEventHandler(MainControlButtonDef_OnExecute);

            if (firstTime)
            {
                Ribbon partRibbon = _Application.UserInterfaceManager.Ribbons["Part"];
                Ribbon asmRibbon = _Application.UserInterfaceManager.Ribbons["Assembly"];
                Ribbon dwgRibbon = _Application.UserInterfaceManager.Ribbons["Drawing"];

                AddToRibbon(partRibbon, AdnInventorUtilities.AddInGuid);
                AddToRibbon(asmRibbon, AdnInventorUtilities.AddInGuid);
                AddToRibbon(dwgRibbon, AdnInventorUtilities.AddInGuid);
            } 
        }