Ejemplo n.º 1
0
        private ExteriorConfiguration GetExteriorConfiguration()
        {
            try
            {
                var defConfig = Guid.TryParse(
                    UserConfigFile.GetValue("mprExteriorPlanDimensions", "DefaultExteriorConfiguration"), out var g)
                    ? g
                    : Guid.Empty;
                if (defConfig == Guid.Empty)
                {
                    return(null);
                }

                var exteriorConfigurations = SettingsFile.LoadExteriorConfigurations();

                foreach (var configuration in exteriorConfigurations)
                {
                    if (configuration.Id.Equals(defConfig))
                    {
                        return(configuration);
                    }
                }

                if (exteriorConfigurations.Any())
                {
                    return(exteriorConfigurations[0]);
                }
                return(null);
            }
            catch (Exception exception)
            {
                ExceptionBox.Show(exception);
                return(null);
            }
        }
        // Сохранение в файл настроек
        private void SaveToConfig()
        {
            try
            {
                // Открываем как xml
                var configFile = UserConfigFile.ConfigFileXml;

                // Проверяем есть ли группа Settings
                // Если нет, то сообщаем об ошибке
                if (configFile.Element("Settings") == null)
                {
                    ModPlusAPI.Windows.MessageBox.Show(ModPlusAPI.Language.GetItem(LangItem, "err1"), MessageBoxIcon.Close);
                    Close();
                }

                var element = configFile.Element("Settings");

                // Если есть элемент UserSurnames, то удаляем его!
                if (element?.Element("UserSurnames") != null)
                {
                    element.Element("UserSurnames")?.Remove();
                }

                // Добавляем текущий
                element?.Add(_surnamesXml);

                // Сохраняем
                UserConfigFile.SaveConfigFile();
            }
            catch (Exception ex)
            {
                ExceptionBox.Show(ex);
            }
        }
        private void ChkRibbon_OnUnchecked(object sender, RoutedEventArgs e)
        {
            UserConfigFile.SetValue("mpPlinesedit", "LoadRibbonPanel", false.ToString(), true);

            // unload ribbon
            PlinesEditRibbonBuilder.RemovePanelFromRibbon(false);
        }
        private void ChkRibbon_OnChecked(object sender, RoutedEventArgs e)
        {
            UserConfigFile.SetValue("mpPlinesedit", "LoadRibbonPanel", true.ToString(), true);

            // load ribbon
            PlinesEditRibbonBuilder.AddPanelToRibbon(false, LvFunctions.ItemsSource as List <PlinesFunction>);
        }
        /// <summary>
        /// Конструктор класса
        /// </summary>
        /// <param name="categoryModels">Лист с категориями</param>
        public MainContext(List <CategoryModel> categoryModels)
        {
            CategoryModelList = categoryModels;
            foreach (var categoryModel in CategoryModelList)
            {
                categoryModel.PropertyChanged += (sender, args) =>
                {
                    IsEnabledContinue = CategoryModelList.Any(c => c.IsChoose);
                };
            }

            var savedCategories = UserConfigFile.GetValue(ModPlusConnector.Instance.Name, "Categories");

            foreach (var s in savedCategories.Split(';'))
            {
                if (int.TryParse(s, out var i))
                {
                    var categoryModel = CategoryModelList.FirstOrDefault(c => c.ElementCategory.Id.IntegerValue == i);
                    if (categoryModel != null)
                    {
                        categoryModel.IsChoose = true;
                    }
                }
            }
        }
Ejemplo n.º 6
0
 private void OnClosed(object sender, EventArgs e)
 {
     UserConfigFile.SetValue(
         LevelMark.GetDescriptor().Name, ChkAlignArrowPoints.Name, ChkAlignArrowPoints.IsChecked.ToString(), true);
     UserConfigFile.SetValue(
         LevelMark.GetDescriptor().Name, ChkAlignBasePoints.Name, ChkAlignBasePoints.IsChecked.ToString(), true);
 }
 private static void GetSettings()
 {
     _layer     = bool.TryParse(UserConfigFile.GetValue(LangItem, "layer"), out bool b) && b;
     _transform = bool.TryParse(UserConfigFile.GetValue(LangItem, "transform"), out b) && b;
     _scales    = bool.TryParse(UserConfigFile.GetValue(LangItem, "scales"), out b) && b;
     _rotation  = bool.TryParse(UserConfigFile.GetValue(LangItem, "rotation"), out b) && b;
     _cleanBd   = int.TryParse(UserConfigFile.GetValue(LangItem, "cleanBD"), out int i) ? i : 0;
 }
 private void BtOk_OnClick(object sender, RoutedEventArgs e)
 {
     UserConfigFile.SetValue("PlObjectToVx", "ExcludeFirstAndLast", ChkExcludeFirstAndLastPt.IsChecked.ToString(), false);
     UserConfigFile.SetValue("PlObjectToVx", "CopyBlockBy", CbCopyBlockBy.SelectedIndex.ToString(), false);
     UserConfigFile.SetValue("PlObjectToVx", "RotateBy", CbRotateBy.SelectedIndex.ToString(), false);
     UserConfigFile.SaveConfigFile();
     DialogResult = true;
 }
Ejemplo n.º 9
0
 private void LmSettings_Loaded(object sender, RoutedEventArgs e)
 {
     ChkAutoLoad.IsChecked       = bool.TryParse(UserConfigFile.GetValue("mpLayoutManager", "AutoLoad"), out bool flag) & flag;
     ChkAddToMpPalette.IsChecked = !bool.TryParse(UserConfigFile.GetValue("mpLayoutManager", "AddToMpPalette"), out flag) | flag;
     ChkOpenNewLayout.IsChecked  = bool.TryParse(UserConfigFile.GetValue("mpLayoutManager", "OpenNewLayout"), out flag) & flag;
     ChkShowModel.IsChecked      = !bool.TryParse(UserConfigFile.GetValue("mpLayoutManager", "ShowModel"), out flag) | flag;
     ChkAskLayoutName.IsChecked  = !bool.TryParse(UserConfigFile.GetValue("mpLayoutManager", "AskLayoutName"), out flag) | flag;
 }
Ejemplo n.º 10
0
 private void CopingDistanceSettings_OnClosed(object sender, EventArgs e)
 {
     if (CopingDistanceValue.Value != null)
     {
         UserConfigFile.SetValue("mprTools", "CopingDistanceValue",
                                 CopingDistanceValue.Value.Value.ToString(CultureInfo.InvariantCulture), true);
         CopingDistanceCommand.DistanceInMm = CopingDistanceValue.Value.Value;
     }
 }
 public Settings()
 {
     InitializeComponent();
     ChkLayer.IsChecked      = bool.TryParse(UserConfigFile.GetValue(_plName, "layer"), out bool b) && b;
     ChkTransform.IsChecked  = bool.TryParse(UserConfigFile.GetValue(_plName, "transform"), out b) && b;
     ChkScales.IsChecked     = bool.TryParse(UserConfigFile.GetValue(_plName, "scales"), out b) && b;
     ChkRotation.IsChecked   = bool.TryParse(UserConfigFile.GetValue(_plName, "rotation"), out b) && b;
     CbCleanBD.SelectedIndex = int.TryParse(UserConfigFile.GetValue(_plName, "cleanBD"), out int i) ? i : 0;
 }
        private void CbCleanBD_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var cb = (ComboBox)sender;

            if (cb != null && cb.SelectedIndex != -1)
            {
                UserConfigFile.SetValue(_plName, "cleanBD", cb.SelectedIndex.ToString(), true);
            }
        }
 private void CbExteriorConfigurations_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (e.AddedItems.Count == 0)
     {
         return;
     }
     UserConfigFile.SetValue(
         LangItem, "DefaultExteriorConfiguration", ((ExteriorConfiguration)e.AddedItems[0]).Id.ToString(), true);
 }
Ejemplo n.º 14
0
#pragma warning restore SA1515 // Single-line comment should be preceded by blank line

        private void SaveStripFormatItems(IEnumerable <StripFormatItem> stripFormatItems)
        {
            foreach (var stripFormatItem in stripFormatItems)
            {
                UserConfigFile.SetValue(LangItem, stripFormatItem.Code, stripFormatItem.Selected.ToString(), false);
            }

            UserConfigFile.SaveConfigFile();
        }
 public void HideIcon()
 {
     if (ProductsDrawableOverrule.ProductsDrawableOverruleInstance != null)
     {
         UserConfigFile.SetValue("mpProductInsert", "ShowIcon", false.ToString(), true);
         Overrule.RemoveOverrule(RXObject.GetClass(typeof(Entity)), ProductsDrawableOverrule.Instance());
         ProductsDrawableOverrule.ProductsDrawableOverruleInstance = null;
         Application.DocumentManager.MdiActiveDocument.Editor.Regen();
     }
 }
Ejemplo n.º 16
0
 public CopingDistanceSettings(UIApplication uiApplication)
 {
     InitializeComponent();
     Title                     = ModPlusAPI.Language.GetItem(LangItem, "h1");
     _uiApplication            = uiApplication;
     ChkUpdaterState.IsChecked =
         bool.TryParse(UserConfigFile.GetValue("mprTools", "CopingDistanceUpdaterStatus"), out var b) && b; // false
     CopingDistanceValue.Value =
         double.TryParse(UserConfigFile.GetValue("mprTools", "CopingDistanceValue"), out var d) ? d : 20.0;
 }
 public PlinesEdit()
 {
     InitializeComponent();
     Title = ModPlusAPI.Language.GetItem("mpPlinesEdit", "h1");
     BtColor.Background   = new SolidColorBrush(ColorIndexToMediaColor(PlinesEditFunction.HelpGeometryColor));
     ChkRibbon.Checked   -= ChkRibbon_OnChecked;
     ChkRibbon.Unchecked -= ChkRibbon_OnUnchecked;
     ChkRibbon.IsChecked  = bool.TryParse(UserConfigFile.GetValue("mpPlinesedit", "LoadRibbonPanel"), out var b) && b;
     ChkRibbon.Checked   += ChkRibbon_OnChecked;
     ChkRibbon.Unchecked += ChkRibbon_OnUnchecked;
 }
 private void SettingsWindow_OnClosed(object sender, EventArgs e)
 {
     // save settings
     UserConfigFile.SetValue(
         LangItem, "ExteriorFaceMinWidthBetween", TbExteriorFaceMinWidthBetween.Text, false);
     UserConfigFile.SetValue(
         LangItem, "MinWallWidth", TbMinWallWidth.Text, false);
     UserConfigFile.SetValue(
         LangItem, "ExteriorMinWidthFaceRemove", CbExteriorMinWidthFaceRemove.SelectedIndex.ToString(), false);
     UserConfigFile.SaveConfigFile();
 }
Ejemplo n.º 19
0
 public static void ShowIcon()
 {
     if (MpProductsDrawableOverrule.MpProductsDrawableOverruleInstance == null)
     {
         UserConfigFile.SetValue(UserConfigFile.ConfigFileZone.Settings, "mpProductInsert", "ShowIcon",
                                 true.ToString(), true);
         Overrule.AddOverrule(RXObject.GetClass(typeof(Entity)), MpProductsDrawableOverrule.Instance(), true);
         Overrule.Overruling = true;
         AcApp.DocumentManager.MdiActiveDocument.Editor.Regen();
     }
 }
        public ObjectToVxSettings()
        {
            InitializeComponent();

            ChkExcludeFirstAndLastPt.IsChecked =
                bool.TryParse(UserConfigFile.GetValue("PlObjectToVx", "ExcludeFirstAndLast"), out var b) && b;
            CbCopyBlockBy.SelectedIndex =
                int.TryParse(UserConfigFile.GetValue("PlObjectToVx", "CopyBlockBy"), out var i) ? i : 0;
            CbRotateBy.SelectedIndex =
                int.TryParse(UserConfigFile.GetValue("PlObjectToVx", "RotateBy"), out i) ? i : 0;
        }
        private static void FastBlocksSettings_Closed(object sender, EventArgs e)
        {
            // off/on menu
            var fastBlocksContextMenu = !bool.TryParse(UserConfigFile.GetValue("FastBlocksCM"), out var b) || b;

            if (fastBlocksContextMenu)
            {
                global::ModPlus.MiniPlugins.MiniFunctionsContextMenuExtensions.FastBlockContextMenu.Detach();
                global::ModPlus.MiniPlugins.MiniFunctionsContextMenuExtensions.FastBlockContextMenu.Attach();
            }
        }
Ejemplo n.º 22
0
        private static void FastBlocksSettings_Closed(object sender, EventArgs e)
        {
            // off/on menu
            bool b;
            var  fastBlocksContextMenu = !bool.TryParse(UserConfigFile.GetValue(UserConfigFile.ConfigFileZone.Settings, "FastBlocksCM"), out b) || b;

            if (fastBlocksContextMenu)
            {
                MiniFunctions.MiniFunctionsContextMenuExtensions.FastBlockContextMenu.Detach();
                MiniFunctions.MiniFunctionsContextMenuExtensions.FastBlockContextMenu.Attach();
            }
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LevelMarkAlignSetup"/> class.
 /// </summary>
 public LevelMarkAlignSetup()
 {
     InitializeComponent();
     Title   = ModPlusAPI.Language.GetItem("h110");
     Closed += OnClosed;
     ChkAlignArrowPoints.IsChecked =
         !bool.TryParse(
             UserConfigFile.GetValue(LevelMark.GetDescriptor().Name, ChkAlignArrowPoints.Name), out var b) || b;
     ChkAlignBasePoints.IsChecked =
         !bool.TryParse(
             UserConfigFile.GetValue(LevelMark.GetDescriptor().Name, ChkAlignBasePoints.Name), out b) || b;
 }
Ejemplo n.º 24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SymbolsFixContext"/> class.
        /// </summary>
        /// <param name="uiApplication"><see cref="UIApplication"/></param>
        /// <param name="mainWindow">Ссылка на главное окно</param>
        public SymbolsFixContext(UIApplication uiApplication, MainWindow mainWindow)
            : base(mainWindow)
        {
            _uiApplication = uiApplication;
            _mainWindow    = mainWindow;
            Categories     = new ObservableCollection <ExtCategory>();

            if (bool.TryParse(UserConfigFile.GetValue(ModPlusConnector.Instance.Name, nameof(RemoveReplacedFamilySymbols)), out var b))
            {
                RemoveReplacedFamilySymbols = b;
            }
        }
Ejemplo n.º 25
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);
            }
        }
Ejemplo n.º 26
0
        public GeneralWipeViewModel(UIApplication uiApplication)
        {
            _uiApplication = uiApplication;

            WipeOptions = new ObservableCollection <WipeOption>(new WipeOptionFactory().GetWipeOptions(uiApplication));
            foreach (var wipeOption in WipeOptions)
            {
                wipeOption.LoadStateStatusFromSettings();
            }

            SkipFailures = bool.TryParse(
                UserConfigFile.GetValue(RevitCommand.LangItem, nameof(SkipFailures)), out var b) && b; // false
        }
Ejemplo n.º 27
0
        private static string CurrentStyleGuid(string functionName)
        {
            var savedStyleGuid = UserConfigFile.GetValue(functionName, "CurrentStyleGuid");

            if (!string.IsNullOrEmpty(savedStyleGuid))
            {
                return(savedStyleGuid);
            }

            const string firstSystemGuid = "00000000-0000-0000-0000-000000000000";

            UserConfigFile.SetValue(functionName, "CurrentStyleGuid", firstSystemGuid, true);
            return(firstSystemGuid);
        }
        public void Initialize()
        {
            var loadLayoutManager           = bool.TryParse(UserConfigFile.GetValue("mpLayoutManager", "AutoLoad"), out bool b) & b;
            var addLayoutManagerToMpPalette = bool.TryParse(UserConfigFile.GetValue("mpLayoutManager", "AddToMpPalette"), out b) & b;

            if (loadLayoutManager & !addLayoutManagerToMpPalette)
            {
                Start();
            }
            else if (loadLayoutManager & addLayoutManagerToMpPalette)
            {
                AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
            }
        }
Ejemplo n.º 29
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);
            }
        }
Ejemplo n.º 30
0
 private void AcApp_SystemVariableChanged(object sender, Autodesk.AutoCAD.ApplicationServices.SystemVariableChangedEventArgs e)
 {
     if (e.Name.Equals("COLORTHEME"))
     {
         if (ComponentManager.Ribbon != null)
         {
             _loadRibbonPanel = bool.TryParse(UserConfigFile.GetValue("mpPlinesedit", "LoadRibbonPanel"), out var b) && b;
             if (_loadRibbonPanel)
             {
                 PlinesEditRibbonBuilder.RemovePanelFromRibbon(false);
                 PlinesEditRibbonBuilder.AddPanelToRibbon(false, GetListOfFunctions());
             }
         }
     }
 }