private void SetSelectedSolutionItem(ISolutionItem item) { if (item == null) { return; } SolutionSelectedItem = item; DisposeCurrentEditPage(); // Create new document according to new selection var parent = SolutionSelectedItem.GetParent(); CurrentEditPage = CreateDocumentPageViewModel(parent, SolutionSelectedItem, this.mProcessItems); if (CurrentEditPage is EditSolutionDocumentViewModel || CurrentEditPage is EditProjectDocumentViewModel) { // Create a new DocumentPageViewModel to edit SOLUTION or PROJECT properties var pageViewmodel = CurrentEditPage as IEditSolutionDocument; pageViewmodel.InitDocument(mSolution.Root, SolutionSelectedItem); } else { // Load source and target files belonging to this project (if any) // Is current document a EditTranslationsDocumentViewModel? // Then try to load default data for it... if (CurrentEditPage is EditTranslationsDocumentViewModel) { // Create a new DocumentPageViewModel var pageViewmodel = CurrentEditPage as EditTranslationsDocumentViewModel; LoadEditPage(pageViewmodel, parent.Path, SolutionSelectedItem.Path); } else { throw new System.NotImplementedException(string.Format("No default view available for {0} with parent: {1}", mSolutionSelectedItem.GetType(), (parent == null ? "(null)" : parent.GetType().ToString()))); } } }
/// <summary> /// Creates a new viewmodel for a given combination of parent and child <seealso cref="ISolutionItem"/>s. /// </summary> /// <param name="parent"></param> /// <param name="child"></param> /// <returns></returns> private DocumentViewModelBase CreateDocumentPageViewModel(ISolutionItem parent, ISolutionItem child, IProcessItems processItems) { if (child is ProjectViewModel) { return(new EditProjectDocumentViewModel(processItems, RequestedAction)); } if (child is SolutionRootViewModel) { return(new EditSolutionDocumentViewModel(processItems)); } // Is a target file under a project currently selected? var project = parent as ProjectViewModel; var fileref = child as FileReferenceViewModel; if (project != null && fileref != null) { var vm = new EditTranslationsDocumentViewModel(processItems); var optionsEngine = GetService <ISettingsManager>().Options; var group = optionsEngine.GetOptionGroup("Options"); vm.InitializeSettings(group); return(vm); } throw new System.NotImplementedException(string.Format("No default view available for {0} with child: {1}", (parent == null ? "(null)" : parent.GetType().ToString()), (child == null ? "(null)" : child.GetType().ToString()))); }
public SolutionItemEditorNotFoundException(ISolutionItem item) : base($"Editor for type {item.GetType()} wasn't found") { }