internal PatientItem GetById(DicomAttributeCollection dataSet) { PatientNode node = _collection.GetPatientById(dataSet); if (!_map.ContainsKey(node)) { base.Add(new PatientItem(node)); } return(_map[node]); }
protected override void RemoveItem(int index) { PatientNode node = base[index].Node; _map[node].PropertyChanged -= Item_PropertyChanged; _map.Remove(node); _collection.Remove(node); base.RemoveItem(index); }
protected override void InsertItem(int index, PatientItem item) { PatientNode node = item.Node; _map.Add(node, item); if (!_collection.Contains(node)) // this method is also called when initializing the list from the collection, so we need to check this to avoid re-adding { _collection.Add(node); } base.InsertItem(index, item); item.PropertyChanged += Item_PropertyChanged; }
protected override void SetItem(int index, PatientItem item) { PatientNode oldNode = base[index].Node; PatientNode newNode = item.Node; _map.Add(newNode, item); _map[oldNode].PropertyChanged -= Item_PropertyChanged; _map.Remove(oldNode); _collection.Remove(oldNode); _collection.Add(newNode); item.PropertyChanged += Item_PropertyChanged; base.SetItem(index, item); }
protected override DragDropOption PerformDropForeignItems(IList <IGalleryItem> droppingItems, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers) { PatientItem patient = (PatientItem)targetItem; DragDropOption action = DragDropOption.None; foreach (IGalleryItem droppingItem in droppingItems) { if (droppingItem is StudyItem) { StudyItem study = (StudyItem)droppingItem; if (modifiers == ModifierFlags.None) { if (!patient.Studies.Contains(study)) { patient.Studies.Add(study.Copy()); action = DragDropOption.Move; } } else if (modifiers == ModifierFlags.Shift) { patient.Studies.Add(study.Copy()); action = DragDropOption.Copy; } } else if (droppingItem is SeriesItem) { SeriesItem series = (SeriesItem)droppingItem; if (modifiers == ModifierFlags.None) { StudyNode studyNode = (StudyNode)GetNodeAncestor(series.Node, 1); PatientNode patientNode = (PatientNode)GetNodeAncestor(studyNode, 1); if (patient.Node != patientNode) { StudyItem study = new StudyItem(studyNode.Copy(false)); study.Series.Add(series.Copy()); study.UpdateIcon(); patient.Studies.Add(study); action = DragDropOption.Move; } } else if (modifiers == ModifierFlags.Shift) { StudyNode studyNode = (StudyNode)GetNodeAncestor(series.Node, 1); StudyItem study = new StudyItem(studyNode.Copy(false)); study.Series.Add(series.Copy()); study.UpdateIcon(); patient.Studies.Add(study); action = DragDropOption.Copy; } } else if (droppingItem is ImageItem) { ImageItem image = (ImageItem)droppingItem; if (modifiers == ModifierFlags.None) { SeriesNode seriesNode = (SeriesNode)GetNodeAncestor(image.Node, 1); StudyNode studyNode = (StudyNode)GetNodeAncestor(seriesNode, 1); PatientNode patientNode = (PatientNode)GetNodeAncestor(studyNode, 1); if (patient.Node != patientNode) { SeriesItem series = new SeriesItem(seriesNode.Copy(false)); StudyItem study = new StudyItem(studyNode.Copy(false)); series.Images.Add(image.Copy()); series.UpdateIcon(); study.Series.Add(series); study.UpdateIcon(); patient.Studies.Add(study); action = DragDropOption.Move; } } else if (modifiers == ModifierFlags.Shift) { SeriesNode seriesNode = (SeriesNode)GetNodeAncestor(image.Node, 1); StudyNode studyNode = (StudyNode)GetNodeAncestor(seriesNode, 1); SeriesItem series = new SeriesItem(seriesNode.Copy(false)); StudyItem study = new StudyItem(studyNode.Copy(false)); series.Images.Add(image.Copy()); series.UpdateIcon(); study.Series.Add(series); study.UpdateIcon(); patient.Studies.Add(study); action = DragDropOption.Copy; } } } return(action); }