コード例 #1
0
        /// <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;
                    }
                }
            }
        }
コード例 #2
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);
            }
        }
コード例 #3
0
 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;
 }
コード例 #4
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;
 }
コード例 #5
0
 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;
 }
コード例 #6
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;
 }
コード例 #7
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;
 }
コード例 #8
0
        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;
        }
コード例 #9
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();
            }
        }
コード例 #10
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;
            }
        }
コード例 #11
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();
            }
        }
コード例 #12
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;
 }
コード例 #13
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
        }
コード例 #14
0
        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;
            }
        }
コード例 #15
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);
        }
コード例 #16
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());
             }
         }
     }
 }
コード例 #17
0
        /// <summary>
        /// Возвращает путь к папке пользовательской базы
        /// </summary>
        public static string GetCustomBaseFolder()
        {
            if (!string.IsNullOrEmpty(_customBaseFolder) && Directory.Exists(_customBaseFolder))
            {
                return(_customBaseFolder);
            }

            _customBaseFolder = UserConfigFile.GetValue(LangItem, "CustomBaseFolder");
            if (Directory.Exists(_customBaseFolder))
            {
                return(_customBaseFolder);
            }

            _customBaseFolder = Constants.DwgBaseDirectory;
            return(_customBaseFolder);
        }
コード例 #18
0
ファイル: ToolsApp.cs プロジェクト: JefftownGH/Revit_mprTools
        /// <inheritdoc />
        public Result OnStartup(UIControlledApplication application)
        {
            try
            {
                #region Coping Distance

                CopingDistanceUpdater = new CopingDistanceUpdater();

                // Значение отступа врезки из настроек. По умолчанию как в Ревите - 20 мм
                CopingDistanceCommand.DistanceInMm =
                    double.TryParse(UserConfigFile.GetValue("mprTools", "CopingDistanceValue"), out var d) ? d : 20.0;

                // Статус апдейтера
                var updaterWorkFromStartUp =
                    bool.TryParse(UserConfigFile.GetValue("mprTools", "CopingDistanceUpdaterStatus"), out var b) && b; // false

                if (updaterWorkFromStartUp)
                {
                    CopingDistanceCommand.UpdaterOn(application.ActiveAddInId, ref CopingDistanceUpdater);
                }
                else
                {
                    CopingDistanceCommand.UpdaterOff(application.ActiveAddInId, ref CopingDistanceUpdater);
                }

                #endregion

                // create ribbon tab
                CreateRibbonTab(application);

                ModPlus_Revit.App.RibbonBuilder.HideTextOfSmallButtons(
                    "ModPlus",
                    new List <string> {
                    "Grids mode", "Grids bubbles", "Rebars outside host", "Pick Annotations"
                });
            }
            catch (Exception exception)
            {
                ExceptionBox.Show(exception);
                return(Result.Failed);
            }

            // У нас всегда все хорошо
            return(Result.Succeeded);
        }
コード例 #19
0
        /* Обработчик события
         * Следит за событиями изменения окна автокада.
         * Используем его для того, чтобы "поймать" момент построения ленты,
         * учитывая, что наш плагин уже инициализировался
         */
        private void ComponentManager_ItemInitialized(object sender, RibbonItemEventArgs e)
        {
            // Проверяем, что лента загружена
            if (ComponentManager.Ribbon != null)
            {
                _loadRibbonPanel = bool.TryParse(UserConfigFile.GetValue("mpPlinesedit", "LoadRibbonPanel"), out var b) && b;

                // Строим нашу вкладку
                // Ribbon
                if (_loadRibbonPanel)
                {
                    PlinesEditRibbonBuilder.AddPanelToRibbon(true, GetListOfFunctions());
                }

                // и раз уж лента запустилась, то отключаем обработчик событий
                // ComponentManager.ItemInitialized -= ComponentManager_ItemInitialized;
            }
        }
コード例 #20
0
        /// <inheritdoc />
        public void Initialize()
        {
            try
            {
                HelpGeometryColor = int.TryParse(
                    UserConfigFile.GetValue("mpPlinesedit", "HelpGeometryColor"), out var i)
                    ? i
                    : 150;

                // for ribbon
                ComponentManager.ItemInitialized  += ComponentManager_ItemInitialized;
                Application.SystemVariableChanged += AcApp_SystemVariableChanged;
            }
            catch (System.Exception exception)
            {
                ExceptionBox.Show(exception);
            }
        }
コード例 #21
0
        /// <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;
        }
コード例 #22
0
        private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            SizeToContent = SizeToContent.Manual;

            // ОБЯЗАТЕЛЬНО!
            // "Загрузка" документов баз данных
            mpMetall.Metall.LoadAllDocument();
            mpConcrete.Concrete.LoadAllDocument();
            mpWood.Wood.LoadAllDocument();
            mpMaterial.Material.LoadAllDocument();
            mpOther.Other.LoadAllDocument();

            // Марки стали - документы
            CbSteelDocument.ItemsSource   = SteelDocuments.GetSteels();
            CbSteelDocument.SelectedIndex = 0;

            // Загружаем значение из файла настроек
            var selectedDb = UserConfigFile.GetValue(LangItem, "selectedDB");

            if (!string.IsNullOrEmpty(selectedDb))
            {
                if (int.TryParse(selectedDb, out var index))
                {
                    CbDataBases.SelectedIndex = index;
                }
            }

            var selectedGroup = UserConfigFile.GetValue(LangItem, "selectedGroup");

            if (!string.IsNullOrEmpty(selectedGroup))
            {
                if (int.TryParse(selectedGroup, out var index))
                {
                    try
                    {
                        LbGroups.SelectedIndex = index;
                    }
                    catch
                    {
                        // ignored
                    }
                }
            }
        }
コード例 #23
0
        public void Start()
        {
#if !Debug
            Statistic.SendCommandStarting(new ModPlusConnector());
#endif
            try
            {
                if (!(!bool.TryParse(UserConfigFile.GetValue("mpLayoutManager", "AddToMpPalette"), out bool b) | b))
                {
                    RemoveFromMpPalette(false);
                    if (_paletteSet != null)
                    {
                        _paletteSet.Visible = true;
                    }
                    else
                    {
                        _paletteSet       = new PaletteSet("MP:" + Language.GetItem(LangItem, "h8"), "mpLayoutManager", new Guid("CC48331E-B912-44DF-B592-D5EF66D7673E"));
                        _paletteSet.Load += _paletteSet_Load;
                        _paletteSet.Save += _paletteSet_Save;
                        LmPalette   lmPalette   = new LmPalette();
                        ElementHost elementHost = new ElementHost()
                        {
                            AutoSize = true,
                            Dock     = DockStyle.Fill,
                            Child    = lmPalette
                        };
                        _paletteSet.Add("MP:" + Language.GetItem(LangItem, "h8"), elementHost);
                        _paletteSet.Style       = PaletteSetStyles.ShowCloseButton | PaletteSetStyles.ShowPropertiesMenu | PaletteSetStyles.ShowAutoHideButton;
                        _paletteSet.MinimumSize = new Size(100, 300);
                        _paletteSet.DockEnabled = DockSides.Right | DockSides.Left;
                        _paletteSet.Visible     = true;
                    }
                }
                else
                {
                    if (_paletteSet != null)
                    {
                        _paletteSet.Visible = false;
                    }

                    AddToMpPalette(true);
                }
            }
コード例 #24
0
        /// <summary>Фильтр стен по допустимой толщине, указанной в настройках</summary>
        /// <param name="advancedWalls"></param>
        public static void FilterByWallWidth(List <AdvancedWall> advancedWalls)
        {
            var minWallWidth = int.TryParse(
                UserConfigFile.GetValue("mprExteriorPlanDimensions", "MinWallWidth"), out var m)
                ? m
                : 50;

            for (var i = advancedWalls.Count - 1; i >= 0; i--)
            {
                // Пропускаю витражи, т.к. их толщина мала, но работать с ними нужно
                if (advancedWalls[i].Wall.CurtainGrid != null)
                {
                    continue;
                }

                if (advancedWalls[i].Wall.Width * 304.8 < minWallWidth)
                {
                    advancedWalls.RemoveAt(i);
                }
            }
        }
        public ViewTemplatesCleanerViewModel(UIApplication uIApplication)
        {
            _uIApplication = uIApplication;
            var doc = uIApplication.ActiveUIDocument.Document;

            _views = new FilteredElementCollector(doc)
                     .OfClass(typeof(View))
                     .Where(e => e.Id != ElementId.InvalidElementId)
                     .Cast <View>()
                     .ToList();
            var templates = _views.Where(v => v.IsTemplate);

            _usedTemplatesIds = _views
                                .Where(v => !v.IsTemplate && v.ViewTemplateId != ElementId.InvalidElementId)
                                .Select(v => v.ViewTemplateId.IntegerValue)
                                .Distinct()
                                .ToList();

            var viewTemplates = templates
                                .Select(view => new ViewTemplate(view, _usedTemplatesIds.Contains(view.Id.IntegerValue)))
                                .ToList();

            foreach (var viewTemplate in viewTemplates)
            {
                viewTemplate.PropertyChanged += (sender, args) =>
                {
                    if (args.PropertyName == nameof(ViewTemplate.IsSelected))
                    {
                        OnPropertyChanged(nameof(CanClean));
                        OnPropertyChanged(nameof(SelectedCount));
                    }
                };
            }

            ViewTemplates =
                new ObservableCollection <ViewTemplate>(viewTemplates.OrderBy(v => v.View.Name, new ModPlusAPI.IO.OrdinalStringComparer()));

            OnUsedTemplate =
                int.TryParse(UserConfigFile.GetValue(RevitCommand.LangItem, nameof(OnUsedTemplate)), out var i) ? i : 0;
        }
        // Загрузка Конфигураций для наружных стен из файла
        private void GetExteriorConfigurations()
        {
            try
            {
                var defConfig = Guid.TryParse(
                    UserConfigFile.GetValue(LangItem, "DefaultExteriorConfiguration"), out Guid g)
                    ? g
                    : Guid.Empty;
                if (defConfig == Guid.Empty)
                {
                    BtDeleteExteriorConfiguration.IsEnabled = false;
                    BtEditExteriorConfiguration.IsEnabled   = false;
                    _exteriorConfigurations = new ObservableCollection <ExteriorConfiguration>();
                    return;
                }

                _exteriorConfigurations = SettingsFile.LoadExteriorConfigurations();
                CbExteriorConfigurations.ItemsSource = _exteriorConfigurations;
                var index = 0;
                for (var i = 0; i < _exteriorConfigurations.Count; i++)
                {
                    if (_exteriorConfigurations[i].Id.Equals(defConfig))
                    {
                        index = i;
                        break;
                    }
                }

                CbExteriorConfigurations.SelectedIndex = index;
                if (!_exteriorConfigurations.Any())
                {
                    BtDeleteExteriorConfiguration.IsEnabled = false;
                    BtEditExteriorConfiguration.IsEnabled   = false;
                }
            }
            catch (Exception exception)
            {
                ExceptionBox.Show(exception);
            }
        }
        private void SettingsWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            GetExteriorConfigurations();

            // load settings
            var minWidthSetting = int.TryParse(
                UserConfigFile.GetValue(LangItem, "ExteriorFaceMinWidthBetween"), out int m)
                ? m
                : 100;

            TbExteriorFaceMinWidthBetween.Text         = minWidthSetting.ToString();
            CbExteriorMinWidthFaceRemove.SelectedIndex = int.TryParse(
                UserConfigFile.GetValue(LangItem, "ExteriorMinWidthFaceRemove"), out m)
                ? m
                : 0;
            var minWallWidth = int.TryParse(
                UserConfigFile.GetValue(LangItem, "MinWallWidth"), out m)
                ? m
                : 50;

            TbMinWallWidth.Text = minWallWidth.ToString();
        }
コード例 #28
0
        // Окно загрузилось
        private void MpDocTemplate_OnLoaded(object sender, RoutedEventArgs e)
        {
            try
            {
                _textBoxes = new List <TextBox>
                {
                    TbController,
                    TbDescription,
                    TbEmployer,
                    TbEngineer,
                    TbGIP,
                    TbNumProj,
                    TbOrganization,
                    TbResolution,
                    TbCustomer
                };

                // Данные из файла настроек
                foreach (var tb in _textBoxes)
                {
                    tb.Text = UserConfigFile.GetValue(LangItem, tb.Name);
                }

                // Создаем новые коллекции, заполняем и биндим их
                _kapDocs = new ObservableCollection <TemplateItem>();
                TemplateData.FillKapItems(_kapDocs);
                LbKap.ItemsSource = _kapDocs;
                _linDocs          = new ObservableCollection <TemplateItem>();
                TemplateData.FillLinItems(_linDocs);
                LbLin.ItemsSource = _linDocs;
            }
            catch (System.Exception exception)
            {
                ExceptionBox.Show(exception);
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="uiApplication"><see cref="UIApplication"/></param>
        /// <param name="mainWindow">Ссылка на главное окно</param>
        public FamiliesFixContext(UIApplication uiApplication, MainWindow mainWindow)
            : base(mainWindow)
        {
            _langItem            = ModPlusConnector.Instance.Name;
            _uiApplication       = uiApplication;
            _mainWindow          = mainWindow;
            FamiliesByCategories = new ObservableCollection <ExtCategory>();

            if (bool.TryParse(UserConfigFile.GetValue(_langItem, nameof(CopyFamilySymbols)), out var b))
            {
                CopyFamilySymbols = b;
            }
            if (bool.TryParse(UserConfigFile.GetValue(_langItem, nameof(CopyFamilySymbolParameters)), out b))
            {
                CopyFamilySymbolParameters = b;
            }
            if (bool.TryParse(UserConfigFile.GetValue(_langItem, nameof(ChangeFamilyInstancesSymbol)), out b))
            {
                ChangeFamilyInstancesSymbol = b;
            }
            if (ChangeFamilyInstancesSymbol)
            {
                if (bool.TryParse(UserConfigFile.GetValue(_langItem, nameof(SetFamilyInstanceSymbolFromSourceFamily)), out b))
                {
                    SetFamilyInstanceSymbolFromSourceFamily = b;
                }
                if (bool.TryParse(UserConfigFile.GetValue(_langItem, nameof(CopyFamilyInstanceParameters)), out b))
                {
                    CopyFamilyInstanceParameters = b;
                }
                if (bool.TryParse(UserConfigFile.GetValue(_langItem, nameof(DeleteDuplicateFamilies)), out b))
                {
                    DeleteDuplicateFamilies = b;
                }
            }
        }
        /// <summary>Фильтрация face'ов по условиям</summary>
        private IEnumerable <AdvancedPlanarFace> FilterFaces(
            ExtremeWallVariant extremeWallVariant,
            List <AdvancedWall> sideWalls,
            IEnumerable <AdvancedPlanarFace> selectedFaces)
        {
            var tolerance = 0.0001;

            // Нужно два списка так как разные фильтрации
            var faces = new List <AdvancedPlanarFace>();

            // Удаляю фейсы, не пересекаемые секущей плоскостью
            foreach (var face in selectedFaces)
            {
                if (face.MinZ <= _cutPlanZ && face.MaxZ >= _cutPlanZ)
                {
                    faces.Add(face);
                }
            }

            // Нужно удалить фейсы, которые совпадают по направлению
            var returnedFaces = new List <AdvancedPlanarFace>();

            bool hasFaces;

            do
            {
                hasFaces = faces.Any(f => f != null);
                for (var i = 0; i < faces.Count; i++)
                {
                    var face = faces[i];
                    if (face != null)
                    {
                        returnedFaces.Add(face);
                        for (var j = 0; j < faces.Count; j++)
                        {
                            if (i == j)
                            {
                                continue;
                            }
                            if (faces[j] == null)
                            {
                                continue;
                            }

                            if (extremeWallVariant == ExtremeWallVariant.Left ||
                                extremeWallVariant == ExtremeWallVariant.Right)
                            {
                                // same Y
                                if (Math.Abs(face.PlanarFace.Origin.Y - faces[j].PlanarFace.Origin.Y) < tolerance)
                                {
                                    faces[j] = null;
                                }
                            }
                            else if (extremeWallVariant == ExtremeWallVariant.Top ||
                                     extremeWallVariant == ExtremeWallVariant.Bottom)
                            {
                                // same X
                                if (Math.Abs(face.PlanarFace.Origin.X - faces[j].PlanarFace.Origin.X) < tolerance)
                                {
                                    faces[j] = null;
                                }
                            }
                        }

                        faces[i] = null;
                    }
                }
            }while (hasFaces);

            // Удаление по глубине проецирования
            // Глубину проецирования беру по наибольшей толщине стен в списке
            var depth = AdvancedHelpers.GetMaxWallWidthFromList(sideWalls) * 2;

            if (extremeWallVariant == ExtremeWallVariant.Bottom)
            {
                foreach (var wall in sideWalls.Where(w => w.Orientation == ElementOrientation.Horizontal))
                {
                    for (var i = returnedFaces.Count - 1; i >= 0; i--)
                    {
                        var face = returnedFaces[i];
                        if (face.MinX > wall.GetMinX() - wall.Wall.Width &&
                            face.MinX < wall.GetMaxX() + wall.Wall.Width)
                        {
                            if (face.MinY > wall.GetMinY() + depth)
                            {
                                returnedFaces.RemoveAt(i);
                            }
                        }
                    }
                }
            }

            if (extremeWallVariant == ExtremeWallVariant.Top)
            {
                foreach (var wall in sideWalls.Where(w => w.Orientation == ElementOrientation.Horizontal))
                {
                    for (var i = returnedFaces.Count - 1; i >= 0; i--)
                    {
                        var face = returnedFaces[i];
                        if (face.MinX > wall.GetMinX() - wall.Wall.Width &&
                            face.MinX < wall.GetMaxX() + wall.Wall.Width)
                        {
                            if (face.MaxY < wall.GetMaxY() - depth)
                            {
                                returnedFaces.RemoveAt(i);
                            }
                        }
                    }
                }
            }

            if (extremeWallVariant == ExtremeWallVariant.Left)
            {
                foreach (var wall in sideWalls.Where(w => w.Orientation == ElementOrientation.Vertical))
                {
                    for (var i = returnedFaces.Count - 1; i >= 0; i--)
                    {
                        var face = returnedFaces[i];
                        if (face.MinY > wall.GetMinY() - wall.Wall.Width &&
                            face.MinY < wall.GetMaxY() + wall.Wall.Width)
                        {
                            if (face.MinX > wall.GetMinX() + depth)
                            {
                                returnedFaces.RemoveAt(i);
                            }
                        }
                    }
                }
            }

            if (extremeWallVariant == ExtremeWallVariant.Right)
            {
                foreach (var wall in sideWalls.Where(w => w.Orientation == ElementOrientation.Vertical))
                {
                    for (var i = returnedFaces.Count - 1; i >= 0; i--)
                    {
                        var face = returnedFaces[i];
                        if (face.MinY > wall.GetMinY() - wall.Wall.Width &&
                            face.MinY < wall.GetMaxY() + wall.Wall.Width)
                        {
                            if (face.MaxX < wall.GetMaxX() - depth)
                            {
                                returnedFaces.RemoveAt(i);
                            }
                        }
                    }
                }
            }

            // Фильтрация ближайших граней: если расстояние между гранями меньше заданного в настройка,
            // то удалять из этой пары ту грань, которая указана в настройках (по длине грани)
            var minWidthSetting = int.TryParse(
                UserConfigFile.GetValue(LangItem, "ExteriorFaceMinWidthBetween"), out var m)
                ? m
                : 100;
            var minWidthBetween = minWidthSetting.MmToFt();

            // Вариант удаления: 0 - наименьший, 1 - наибольший
            var removeVariant = int.TryParse(
                UserConfigFile.GetValue(LangItem, "ExteriorMinWidthFaceRemove"), out m)
                ? m
                : 0;

            if (extremeWallVariant == ExtremeWallVariant.Bottom || extremeWallVariant == ExtremeWallVariant.Top)
            {
                // Сначала нужно отсортировать
                returnedFaces.Sort((f1, f2) => f1.MinX.CompareTo(f2.MinX));
                var wasRemoved = false;
                do
                {
                    for (var i = 0; i < returnedFaces.Count - 1; i++)
                    {
                        var face1    = returnedFaces[i];
                        var face2    = returnedFaces[i + 1];
                        var distance = Math.Abs(face1.MinX - face2.MinX);
                        if (distance < minWidthBetween)
                        {
                            wasRemoved = true;
                            var face1Length = Math.Abs(face1.MaxY - face1.MinY);
                            var face2Length = Math.Abs(face2.MaxY - face2.MinY);
                            if (removeVariant == 0)
                            {
                                if (face1Length < face2Length)
                                {
                                    returnedFaces.RemoveAt(i);
                                }
                                else
                                {
                                    returnedFaces.RemoveAt(i + 1);
                                }
                            }
                            else
                            {
                                if (face1Length > face2Length)
                                {
                                    returnedFaces.RemoveAt(i);
                                }
                                else
                                {
                                    returnedFaces.RemoveAt(i + 1);
                                }
                            }

                            break;
                        }

                        wasRemoved = false;
                    }
                }while (wasRemoved);
            }

            if (extremeWallVariant == ExtremeWallVariant.Left || extremeWallVariant == ExtremeWallVariant.Right)
            {
                // Сначала нужно отсортировать
                returnedFaces.Sort((f1, f2) => f1.MinY.CompareTo(f2.MinY));
                var wasRemoved = false;
                do
                {
                    for (var i = 0; i < returnedFaces.Count - 1; i++)
                    {
                        var face1    = returnedFaces[i];
                        var face2    = returnedFaces[i + 1];
                        var distance = Math.Abs(face1.MinY - face2.MinY);
                        if (distance < minWidthBetween)
                        {
                            wasRemoved = true;
                            var face1Lenght = Math.Abs(face1.MaxX - face1.MinX);
                            var face2Lenght = Math.Abs(face2.MaxX - face2.MinX);
                            if (removeVariant == 0)
                            {
                                if (face1Lenght < face2Lenght)
                                {
                                    returnedFaces.RemoveAt(i);
                                }
                                else
                                {
                                    returnedFaces.RemoveAt(i + 1);
                                }
                            }
                            else
                            {
                                if (face1Lenght > face2Lenght)
                                {
                                    returnedFaces.RemoveAt(i);
                                }
                                else
                                {
                                    returnedFaces.RemoveAt(i + 1);
                                }
                            }

                            break;
                        }

                        wasRemoved = false;
                    }
                }while (wasRemoved);
            }

            return(returnedFaces);
        }