Example #1
0
        public Result OnStartup(UIControlledApplication application)
        {
            try
            {
                appCommand = this;
                m_app      = application;
                thisAppId  = application.ActiveAddInId;
                addInGuid  = thisAppId.GetGUID(); //9C4D37B2-155D-4AC8-ACCF-383D86673F1C
                addInName  = thisAppId.GetAddInName();

                try
                {
                    m_app.CreateRibbonTab(tabName);
                }
                catch { }

                RibbonPanel setupPanel      = m_app.CreateRibbonPanel(tabName, "DTM Tool");
                string      currentAssembly = System.Reflection.Assembly.GetAssembly(this.GetType()).Location;

                Assembly   assembly   = Assembly.GetExecutingAssembly();
                PushButton pushButton = setupPanel.AddItem(new PushButtonData("Admin", "Admin", currentAssembly, "HOK.ElementWatcher.AdminCommand")) as PushButton;
                pushButton.LargeImage = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.dtm32.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());

                dtmUpdater = new DTMUpdater(thisAppId);

                application.ControlledApplication.DocumentOpened     += RegisterElementUpdaterOnOpen;
                application.ControlledApplication.FailuresProcessing += CheckElementWarning;
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                MessageBox.Show("Failed to initialize DTM Tool.\n" + ex.Message, "DTM Initialization", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            return(Result.Succeeded);
        }
Example #2
0
        public Result OnStartup(UIControlledApplication application)
        {
            try
            {
                appCommand = this;
                m_app      = application;

                AddInId appId = m_app.ActiveAddInId;
                addInGuid = appId.GetGUID();
                addInName = appId.GetAddInName();

                doorUpdater     = new DoorUpdater(appId);
                dtmUpdater      = new DTMUpdater(appId);
                revisionUpdater = new RevisionUpdater(appId);

                socketHandler = new SocketHandler(doorUpdater, dtmUpdater, revisionUpdater);
                extEvent      = ExternalEvent.Create(socketHandler);

                LogUtil.InitializeLog();
                LogUtil.AppendLog("Mission Control AddIn Started");

                m_app.ControlledApplication.DocumentOpening    += CollectConfigurationOnOpening;
                m_app.ControlledApplication.DocumentOpened     += RegisterUpdatersOnOpen;
                m_app.ControlledApplication.FailuresProcessing += FailureProcessor.CheckFailure;
                m_app.ControlledApplication.DocumentClosing    += UnregisterUpdaterOnClosing;
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                LogUtil.AppendLog("OnStartup:" + ex.Message);
            }
            return(Result.Succeeded);
        }