Example #1
0
            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);
            }