private void HandleItemSelected(TreeNode selectedTreeNode) { ReferencedFileSave rfs = null; if (selectedTreeNode != null) { rfs = selectedTreeNode.Tag as ReferencedFileSave; } if (rfs != null) { if (control == null) { viewModel = new FileReferenceViewModel(); control = new FileReferenceControl(); control.DataContext = viewModel; AddToTab(PluginManager.CenterTab, control, "Referenced Files"); } else { AddTab(); } } else { base.RemoveTab(); } if (viewModel != null) { viewModel.ReferencedFileSave = rfs; } }
/// <summary> /// Remove the given item from the colleciton of target files. /// </summary> /// <param name="fileReferenceViewModel"></param> /// <returns></returns> protected override bool RemoveTargetFileCommandExecuted(FileReferenceViewModel fileReferenceViewModel) { if (fileReferenceViewModel == null) { return(false); } if (mProject.RemoveTargetFile(fileReferenceViewModel) == true) { IsDirty = true; return(true); } return(false); }
/// <summary> /// Adds new target file references into the collection of target files. /// </summary> /// <param name="fr"></param> internal void AddTargetFileCommandExecuted(FileReferenceViewModel fr, bool updateFields = true) { mExceptionDisplay.ForwardExceptionToDisplay(null); try { if (string.IsNullOrEmpty(fr.Path) == true) { return; } if (string.IsNullOrEmpty(fr.Type) == true) { return; } IsValidFIlename(fr.Path); var item = mTargetFilesCollection.SingleOrDefault(p => string.Compare(p.Path, fr.Path, true) == 0); if (item == null) { mTargetFilesCollection.Add(new FileReferenceViewModel(fr)); } else { if (updateFields == true) { // Just adjust non key values if this item is already there item.Comment = fr.Comment; item.Type = fr.Type; } } IsDirty = true; } catch (System.Exception exp) { mExceptionDisplay.ForwardExceptionToDisplay(exp); } }
/// <summary> /// Remove the given item from the colleciton of target files. /// </summary> /// <param name="fileReferenceViewModel"></param> /// <returns></returns> protected abstract bool RemoveTargetFileCommandExecuted(FileReferenceViewModel param);