/// <summary> /// Конструктор /// </summary> /// <param name="element"><see cref="CADLinkType"/> or <see cref="ImportInstance"/></param> /// <param name="uiApplication">Revit uiApp</param> /// <param name="dwgImportManagerVm">Link to main view model</param> /// <param name="deleteElementEvent"></param> /// <param name="changeViewEvent"></param> public DwgImportsItem( Element element, UIApplication uiApplication, DWGImportManagerVM dwgImportManagerVm, DeleteElementEvent deleteElementEvent, ChangeViewEvent changeViewEvent) { _deleteElementEvent = deleteElementEvent; _changeViewEvent = changeViewEvent; _uiApplication = uiApplication; DwgImportManagerVm = dwgImportManagerVm; ViewSpecific = element.ViewSpecific; OwnerViewId = element.OwnerViewId; Category = element.Category; Id = element.Id; Name = GetName(element); if (element is ImportInstance importInstance) { IsLinked = importInstance.IsLinked; } // commands CopyIdToClipboard = new RelayCommandWithoutParameter(CopyIdToClipboardAction); CopyOwnerViewIdToClipboard = new RelayCommandWithoutParameter(CopyOwnerViewIdToClipboardAction); ShowItem = new RelayCommandWithoutParameter(ShowItemAction); DeleteItem = new RelayCommandWithoutParameter(DeleteItemAction); }
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(); } }