コード例 #1
0
        /// <inheritdoc />
        public Result OnStartup(UIControlledApplication application)
        {
            try
            {
                // init lang
                if (!Language.Initialize())
                {
                    return(Result.Cancelled);
                }

                // statistic
                Statistic.SendModuleLoaded("Revit", VersionData.CurrentRevitVersion);

                // Принудительная загрузка сборок
                LoadAssemblies();
                UserConfigFile.InitConfigFile();
                LoadPlugins();

                // check adaptation
                CheckAdaptation();

                // Load ribbon
                App.RibbonBuilder.CreateRibbon(application);

                // проверка загруженности модуля автообновления
                CheckAutoUpdaterLoaded();

                var disableConnectionWithLicenseServer = Variables.DisableConnectionWithLicenseServerInRevit;

                // license server
                if (Variables.IsLocalLicenseServerEnable && !disableConnectionWithLicenseServer)
                {
                    ClientStarter.StartConnection(SupportedProduct.Revit);
                }

                if (Variables.IsWebLicenseServerEnable && !disableConnectionWithLicenseServer)
                {
                    WebLicenseServerClient.Instance.Start(SupportedProduct.Revit);
                }

                // user info
                AuthorizationOnStartup();

                return(Result.Succeeded);
            }
            catch (Exception exception)
            {
                // Тут отображение ошибки должно быть в обычном окне, т.к. сборки могли еще не загрузился
                TaskDialog.Show("ModPlus", exception.Message + Environment.NewLine + exception.StackTrace,
                                TaskDialogCommonButtons.Ok);
                return(Result.Failed);
            }
        }
コード例 #2
0
        /// <inheritdoc/>
        public bool Initialize(string pluginFolder)
        {
            RengaApplication   = new Renga.Application();
            ActionEventSources = new List <Renga.ActionEventSource>();
            try
            {
                // init lang
                if (!Language.Initialize())
                {
                    return(false);
                }

                // statistic
                Statistic.SendPluginStarting("Renga", "4.0");

                // Принудительная загрузка сборок
                LoadAssemblies();
                UserConfigFile.InitConfigFile();
                LoadFunctions();

                MenuBuilder.Build(RengaApplication, ActionEventSources);

                // проверка загруженности модуля автообновления
                CheckAutoUpdaterLoaded();

                var disableConnectionWithLicenseServer = Variables.DisableConnectionWithLicenseServerInRenga;

                // license server
                if (Variables.IsLocalLicenseServerEnable && !disableConnectionWithLicenseServer)
                {
                    ClientStarter.StartConnection(SupportedProduct.Renga);
                }

                if (Variables.IsWebLicenseServerEnable && !disableConnectionWithLicenseServer)
                {
                    WebLicenseServerClient.Instance.Start(SupportedProduct.Renga);
                }

                // user info
                AuthorizationOnStartup();

                return(true);
            }
            catch (Exception exception)
            {
                RengaApplication.UI.ShowMessageBox(Renga.MessageIcon.MessageIcon_Error, "ModPlus", exception.Message);
                return(false);
            }
        }
コード例 #3
0
        /// <inheritdoc />
        public void Initialize()
        {
            try
            {
                var sw = new Stopwatch();
                sw.Start();

                // init lang
                if (!Language.Initialize())
                {
                    return;
                }

                // Получим значение переменной "Тихая загрузка" в первую очередь
                _quiteLoad = ModPlusAPI.Variables.QuietLoading;

                // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                // Файла конфигурации может не существовать при загрузке плагина!
                // Поэтому все, что связанно с работой с файлом конфигурации должно это учитывать!
                // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                var ed = AcApp.DocumentManager.MdiActiveDocument.Editor;
                if (!CheckCadVersion())
                {
                    ed.WriteMessage("\n***************************");
                    ed.WriteMessage($"\n{Language.GetItem(LangItem, "p1")}");
                    ed.WriteMessage($"\n{Language.GetItem(LangItem, "p2")}");
                    ed.WriteMessage($"\n{Language.GetItem(LangItem, "p3")}");
                    ed.WriteMessage("\n***************************");
                    return;
                }

                Statistic.SendPluginStarting("AutoCAD", VersionData.CurrentCadVersion);
                ed.WriteMessage("\n***************************");
                ed.WriteMessage($"\n{Language.GetItem(LangItem, "p4")}");
                if (!_quiteLoad)
                {
                    ed.WriteMessage($"\n{Language.GetItem(LangItem, "p5")}");
                }

                // Принудительная загрузка сборок
                LoadAssemblies(ed);
                if (!_quiteLoad)
                {
                    ed.WriteMessage($"\n{Language.GetItem(LangItem, "p6")}");
                }
                LoadBaseAssemblies(ed);
                if (!_quiteLoad)
                {
                    ed.WriteMessage($"\n{Language.GetItem(LangItem, "p7")}");
                }
                UserConfigFile.InitConfigFile();
                if (!_quiteLoad)
                {
                    ed.WriteMessage($"\n{Language.GetItem(LangItem, "p8")}");
                }
                LoadFunctions(ed);

                // check adaptation
                CheckAdaptation();

                // Строим: ленту, меню, плавающее меню
                // Загрузка ленты
                Autodesk.Windows.ComponentManager.ItemInitialized += ComponentManager_ItemInitialized;
                if (ModPlusAPI.Variables.Palette)
                {
                    MpPalette.CreatePalette(false);
                }

                // Загрузка основного меню (с проверкой значения из файла настроек)
                FloatMenuCommand.LoadMainMenu();

                // Загрузка окна Чертежи
                MpDrawingsFunction.LoadMainMenu();

                // Загрузка контекстных меню для мини-функций
                MiniFunctions.LoadUnloadContextMenu();

                // проверка загруженности модуля автообновления
                CheckAutoUpdaterLoaded();

                // Включение иконок для продуктов
                var showProductsIcon =
                    bool.TryParse(UserConfigFile.GetValue("mpProductInsert", "ShowIcon"), out var b) && b; // false
                if (showProductsIcon)
                {
                    ProductIconFunctions.ShowIcon();
                }

                // license server
                var disableConnectionWithLicenseServerInAutoCad =
                    ModPlusAPI.Variables.DisableConnectionWithLicenseServerInAutoCAD;

                if (ModPlusAPI.Variables.IsLocalLicenseServerEnable &&
                    !disableConnectionWithLicenseServerInAutoCad)
                {
                    ClientStarter.StartConnection(SupportedProduct.AutoCAD);
                }

                if (ModPlusAPI.Variables.IsWebLicenseServerEnable &&
                    !disableConnectionWithLicenseServerInAutoCad)
                {
                    WebLicenseServerClient.Instance.Start(SupportedProduct.AutoCAD);
                }

                // user info
                AuthorizationOnStartup();

                // tooltip hook
                AcApp.PreTranslateMessage += AutoCadMessageHandler;
                Autodesk.Windows.ComponentManager.ToolTipOpened += ComponentManager_ToolTipOpened;
                Autodesk.Windows.ComponentManager.ToolTipClosed += ComponentManager_ToolTipClosed;

                sw.Stop();
                ed.WriteMessage($"\n{Language.GetItem(LangItem, "p9")} {sw.ElapsedMilliseconds}");
                ed.WriteMessage($"\n{Language.GetItem(LangItem, "p10")}");
                ed.WriteMessage("\n***************************");
            }
            catch (System.Exception exception)
            {
                ExceptionBox.Show(exception);
            }
        }