private void SearchImportsAndBind(bool newActiveViewModel)
        {
            var col = GetElements(_currentDocument);

            if (col.Any())
            {
                if (MainWindow == null)
                {
                    MainWindow = new DWGImportManagerWindow();
                    _deleteManyElementsEvent.MainWindow = MainWindow;
                    MainWindow.Loaded     += MainWindowOnLoaded;
                    MainWindow.Closed     += MainWindow_Closed;
                    _dwgImportManagerVm    = new DWGImportManagerVM(_uiApplication, col, _deleteElementEvent, _changeViewEvent, _deleteManyElementsEvent);
                    MainWindow.DataContext = _dwgImportManagerVm;
                    MainWindow.Show();
                }
                else
                {
                    MainWindow.Activate();
                    if (newActiveViewModel)
                    {
                        _dwgImportManagerVm    = new DWGImportManagerVM(_uiApplication, col, _deleteElementEvent, _changeViewEvent, _deleteManyElementsEvent);
                        MainWindow.DataContext = _dwgImportManagerVm;
                    }
                }
            }
            else
            {
                MessageBox.Show(Language.GetItem(LangItem, "msg2"));
                MainWindow?.Close();
            }
        }
 private void MainWindow_Closed(object sender, EventArgs e)
 {
     try
     {
         MainWindow = null;
         _removeEvents.SetAction(Application_DocumentClosed, UiApplication_ViewActivated, Application_DocumentChanged, Application_DocumentCreated);
     }
     catch (Exception exception)
     {
         ExceptionBox.Show(exception);
     }
 }