public void Init(FreeHierarchyTree parent, FreeHierarchyTreeDescriptor descriptor)
        {
            _parent     = parent;
            _descriptor = descriptor;

            Dispatcher.BeginInvoke((Action)(() =>
            {
                FoundedGrid.DataSource = null;

                cbTypeHierarchy.ItemsSource = EnumsHelper.TypesDict;

                #region Прятать или нет поиск по серийному номеру

                if (_parent != null)
                {
                    var im = _parent.FindParent <IModule>();
                    if (im != null)
                    {
                        switch (im.ModuleType)
                        {
                        case ModuleType.DataTIElectricity:
                        case ModuleType.DeviceManage:
                        case ModuleType.JuridicalPersons:
                        case ModuleType.MonitoringAutoSbor:
                        case ModuleType.Monitoring61968:
                        case ModuleType.MonitoringConcentratorSbor:
                        case ModuleType.MonitoringUSPDSbor:
                            spFindTypeLayout.Visibility = System.Windows.Visibility.Visible;
                            break;
                        }
                    }
                }

                #endregion

                if (LoginPage.IsShowPik)
                {
                    byPik.Visibility = Visibility.Visible;
                }
                else
                {
                    byPik.Visibility = Visibility.Collapsed;
                }
            }));

            Dispatcher.BeginInvoke((System.Action)(() => Keyboard.Focus(textFind)), DispatcherPriority.Background);
        }
        internal static void OpenFreeHierarchyTreeFindBar(FreeHierarchyTree parent, FreeHierarchyTreeDescriptor descriptor)
        {
            FreeHierarchyTreeFindBar findBar;

            //Сначала закрываем предыдущее окно
            if (parent.TreeFindBar != null)
            {
                findBar = parent.TreeFindBar;
                findBar.Init(parent, descriptor);
                var previousPopup = findBar.FindParent <System.Windows.Controls.Primitives.Popup>();
                if (previousPopup != null && !previousPopup.IsOpen)
                {
                    previousPopup.IsOpen = true;
                }
                return;
            }

            findBar            = new FreeHierarchyTreeFindBar(parent, descriptor);
            parent.TreeFindBar = findBar;

            findBar.MakeResizable();
            var tvPlace = new Rect(parent.tree.PointToScreen(new Point(0, 0)),
                                   parent.tree.PointToScreen(new Point(parent.tree.ActualWidth, parent.tree.ActualHeight)));
            var wa = SystemParameters.WorkArea;

            var popup = new System.Windows.Controls.Primitives.Popup
            {
                Child     = findBar,
                StaysOpen = false,
            };

            var isShowNearest = true;
            var ch            = parent.FindParent <ILocalChildren>();

            isShowNearest = ch == null;

            popup.PlacementTarget = parent.tree;

            if (isShowNearest)
            {
                if ((tvPlace.Right + findBar.ActualHeight) < wa.Right)
                {
                    popup.Placement = PlacementMode.Right;
                }
                else if (tvPlace.Left - findBar.ActualWidth > wa.Left)
                {
                    popup.Placement = PlacementMode.Left;
                }
                else if (tvPlace.Bottom + findBar.ActualHeight < wa.Bottom)
                {
                    popup.Placement        = PlacementMode.Relative;
                    popup.HorizontalOffset = tvPlace.Width - findBar.ActualWidth;
                    popup.VerticalOffset   = tvPlace.Height;
                }
                else
                {
                    popup.Placement = PlacementMode.Top;
                }
            }
            else
            {
                popup.Placement        = PlacementMode.Right;
                popup.HorizontalOffset = -333;
                popup.VerticalOffset   = -10;
            }

            if (popup.PlacementTarget != null)
            {
                popup.OpenAndRegister(false);
            }
        }