Esempio n. 1
0
 /// <summary>
 /// Проверка загруженности модуля автообновления
 /// </summary>
 private static void CheckAutoUpdaterLoaded()
 {
     try
     {
         var loadWithWindows = !bool.TryParse(Regestry.GetValue("AutoUpdater", "LoadWithWindows"), out bool b) || b;
         if (loadWithWindows)
         {
             // Если "грузить с виндой", то проверяем, что модуль запущен
             // если не запущен - запускаем
             var isOpen = Process.GetProcesses().Any(t => t.ProcessName == "mpAutoUpdater");
             if (!isOpen)
             {
                 var fileToStart = Path.Combine(Constants.CurrentDirectory, "mpAutoUpdater.exe");
                 if (File.Exists(fileToStart))
                 {
                     Process.Start(fileToStart);
                 }
             }
         }
     }
     catch (System.Exception exception)
     {
         Statistic.SendException(exception);
     }
 }
        private void FillThemesAndColors()
        {
            MiTheme.ItemsSource = ModPlusStyle.ThemeManager.Themes;
            var pluginStyle          = ModPlusStyle.ThemeManager.Themes.First();
            var savedPluginStyleName = Regestry.GetValue("PluginStyle");

            if (!string.IsNullOrEmpty(savedPluginStyleName))
            {
                var theme = ModPlusStyle.ThemeManager.Themes.Single(t => t.Name == savedPluginStyleName);
                if (theme != null)
                {
                    pluginStyle = theme;
                }
            }

            _curTheme            = pluginStyle.Name;
            MiTheme.SelectedItem = pluginStyle;
        }
        /// <summary>Загрузка данных из файла конфигурации которые требуется отобразить в окне</summary>
        private void LoadSettingsFromConfigFileAndRegistry()
        {
            // Separator
            var separator = Regestry.GetValue("Separator");

            CbSeparatorSettings.SelectedIndex = string.IsNullOrEmpty(separator) ? 0 : int.Parse(separator);

            // mini functions
            ChkEntByBlock.IsChecked     = !bool.TryParse(UserConfigFile.GetValue(UserConfigFile.ConfigFileZone.Settings, "EntByBlockOCM"), out var b) || b; // true
            ChkNestedEntLayer.IsChecked = !bool.TryParse(UserConfigFile.GetValue(UserConfigFile.ConfigFileZone.Settings, "NestedEntLayerOCM"), out b) || b; // true
            ChkFastBlocks.IsChecked     = !bool.TryParse(UserConfigFile.GetValue(UserConfigFile.ConfigFileZone.Settings, "FastBlocksCM"), out b) || b;      // true
            ChkVPtoMS.IsChecked         = !bool.TryParse(UserConfigFile.GetValue(UserConfigFile.ConfigFileZone.Settings, "VPtoMS"), out b) || b;            // true
            ChkWipeoutEditOCM.IsChecked = !bool.TryParse(UserConfigFile.GetValue(UserConfigFile.ConfigFileZone.Settings, "WipeoutEditOCM"), out b) || b;    // true
            ChkDisableConnectionWithLicenseServer.IsChecked =
                bool.TryParse(UserConfigFile.GetValue(UserConfigFile.ConfigFileZone.Settings, "DisableConnectionWithLicenseServerInAutoCAD"), out b) && b;  // false
            TbLocalLicenseServerIpAddress.Text = Regestry.GetValue("LocalLicenseServerIpAddress");
            TbLocalLicenseServerPort.Value     = int.TryParse(Regestry.GetValue("LocalLicenseServerPort"), out var i) ? i : 0;
        }
        internal MpDrawings()
        {
            if (double.TryParse(Regestry.GetValue("DrawingsWinTop"), out var top))
            {
                Top = top;
            }
            else
            {
                Top = 180;
            }

            if (double.TryParse(Regestry.GetValue("DrawingsWinLeft"), out var left))
            {
                Left = left;
            }
            else
            {
                Left = 60;
            }

            InitializeComponent();
            ModPlusAPI.Windows.Helpers.WindowHelpers.ChangeStyleForResourceDictionary(Resources);
            ModPlusAPI.Language.SetLanguageProviderForResourceDictionary(Resources);

            MouseEnter          += Window_MouseEnter;
            MouseLeave          += Window_MouseLeave;
            MouseLeftButtonDown += Window_MouseLeftButtonDown;

            // Подключение обработчиков событий для создания и закрытия чертежей
            AcApp.DocumentManager.DocumentCreated   += DocumentManager_DocumentCreated;
            AcApp.DocumentManager.DocumentDestroyed += DocumentManager_DocumentDestroyed;
            AcApp.DocumentManager.DocumentActivated += DocumentManager_DocumentActivated;

            GetDocuments();

            // Обрабатываем событие покидания мышкой окна
            OnMouseLeaving();
        }
Esempio n. 5
0
        public MpFloatMenu()
        {
            if (double.TryParse(Regestry.GetValue("FloatingMenuTop"), out var top))
            {
                Top = top;
            }
            else
            {
                Top = 180;
            }

            if (double.TryParse(Regestry.GetValue("FloatingMenuLeft"), out var left))
            {
                Left = left;
            }
            else
            {
                Left = 60;
            }

            InitializeComponent();

            Closed += MpFloatMenu_OnClosed;

            ModPlusAPI.Windows.Helpers.WindowHelpers.ChangeStyleForResourceDictionary(Resources);
            ModPlusAPI.Language.SetLanguageProviderForResourceDictionary(Resources);

            MouseEnter          += Window_MouseEnter;
            MouseLeave          += Window_MouseLeave;
            MouseLeftButtonDown += Window_MouseLeftButtonDown;
            FillFieldsFunction();

            // Заполняем функции
            FillFunctions();

            if (Variables.DrawingsInFloatMenu)
            {
                // Подключение обработчиков событий для создания и закрытия чертежей
                Application.DocumentManager.DocumentCreated   += DocumentManager_DocumentCreated;
                Application.DocumentManager.DocumentDestroyed += DocumentManager_DocumentDestroyed;
                try
                {
                    Drawings.Items.Clear();
                    foreach (Document doc in _docs)
                    {
                        var lbi      = new ListBoxItem();
                        var filename = Path.GetFileName(doc.Name);
                        lbi.Content = filename;
                        lbi.ToolTip = doc.Name;
                        Drawings.Items.Add(lbi);
                        Drawings.SelectedItem = lbi;
                    }
                }
                catch
                {
                    // ignored
                }
            }
            else
            {
                // Подключение и отключение (чтобы не было ошибки) обработчиков событий для создания и закрытия чертежей
                Application.DocumentManager.DocumentCreated   += DocumentManager_DocumentCreated;
                Application.DocumentManager.DocumentDestroyed += DocumentManager_DocumentDestroyed;
                ///////////////////////////
                Application.DocumentManager.DocumentCreated   -= DocumentManager_DocumentCreated;
                Application.DocumentManager.DocumentDestroyed -= DocumentManager_DocumentDestroyed;
            }

            // Обрабатываем событие покидания мышкой окна
            OnMouseLeaving();
        }
        private void MpMainSettings_OnClosed(object sender, EventArgs e)
        {
            try
            {
                var isDifferentLanguage = IsDifferentLanguage();

                // Если отключили плавающее меню
                if (!ChkMpFloatMenu.IsChecked.Value)
                {
                    // Закрываем плавающее меню
                    if (MpMenuFunction.MpMainMenuWin != null)
                    {
                        MpMenuFunction.MpMainMenuWin.Close();
                    }
                }
                else // Если включили плавающее меню
                {
                    // Если плавающее меню было включено
                    if (MpMenuFunction.MpMainMenuWin != null)
                    {
                        // Перегружаем плавающее меню, если изменилась тема, вкл/выкл открытые чертежи, сворачивать в
                        if (!Regestry.GetValue("PluginStyle").Equals(_curTheme) ||
                            !Regestry.GetValue("FloatMenuCollapseTo").Equals(_curFloatMenuCollapseTo.ToString()) ||
                            !ChkMpChkDrwsOnMnu.IsChecked.Value.Equals(_curDrawingsOnMenu) ||
                            isDifferentLanguage)
                        {
                            MpMenuFunction.MpMainMenuWin.Close();
                            MpMenuFunction.LoadMainMenu();
                        }
                    }
                    else
                    {
                        MpMenuFunction.LoadMainMenu();
                    }
                }

                // если отключили палитру
                if (!ChkMpPalette.IsChecked.Value)
                {
                    if (MpPalette.MpPaletteSet != null)
                    {
                        MpPalette.MpPaletteSet.Visible = false;
                    }
                }
                else // если включили палитру
                {
                    MpPalette.CreatePalette();
                }

                // Если отключили плавающее меню Чертежи
                if (!ChkMpDrawingsAlone.IsChecked.Value)
                {
                    if (MpDrawingsFunction.MpDrawingsWin != null)
                    {
                        MpDrawingsFunction.MpDrawingsWin.Close();
                    }
                }
                else
                {
                    if (MpDrawingsFunction.MpDrawingsWin != null)
                    {
                        // Перегружаем плавающее меню, если изменилась тема, вкл/выкл открытые чертежи, границы, сворачивать в
                        if (!Regestry.GetValue("PluginStyle").Equals(_curTheme) ||
                            !Regestry.GetValue("DrawingsCollapseTo").Equals(_curDrawingsCollapseTo.ToString()) ||
                            !ChkMpDrawingsAlone.IsChecked.Value.Equals(_curDrawingsAlone) ||
                            isDifferentLanguage)
                        {
                            MpDrawingsFunction.MpDrawingsWin.Close();
                            MpDrawingsFunction.LoadMainMenu();
                        }
                    }
                    else
                    {
                        MpDrawingsFunction.LoadMainMenu();
                    }
                }

                // Ribbon
                // Если включили и была выключена
                if (ChkMpRibbon.IsChecked.Value && !_curRibbon)
                {
                    RibbonBuilder.BuildRibbon();
                }

                // Если включили и была включена, но сменился язык
                if (ChkMpRibbon.IsChecked.Value && _curRibbon && isDifferentLanguage)
                {
                    RibbonBuilder.RemoveRibbon();
                    RibbonBuilder.BuildRibbon(true);
                }

                // Если выключили и была включена
                if (!ChkMpRibbon.IsChecked.Value && _curRibbon)
                {
                    RibbonBuilder.RemoveRibbon();
                }

                // context menu
                // если сменился язык, то все выгружаю
                if (isDifferentLanguage)
                {
                    MiniFunctions.UnloadAll();
                }

                MiniFunctions.LoadUnloadContextMenu();

                // License server
                UserConfigFile.SetValue(UserConfigFile.ConfigFileZone.Settings, "DisableConnectionWithLicenseServerInAutoCAD",
                                        ChkDisableConnectionWithLicenseServer.IsChecked.Value.ToString(), true);
                Regestry.SetValue("LocalLicenseServerIpAddress", TbLocalLicenseServerIpAddress.Text);
                Regestry.SetValue("LocalLicenseServerPort", TbLocalLicenseServerPort.Value.ToString());

                if (_restartClientOnClose)
                {
                    // reload server
                    ClientStarter.StopConnection();
                    ClientStarter.StartConnection(ProductLicenseType.AutoCAD);
                }

                // перевод фокуса на автокад
                Utils.SetFocusToDwgView();
            }
            catch (Exception ex)
            {
                ExceptionBox.Show(ex);
            }
        }