// This is invoked whenever and item is dragged over one of our drop targets. // The main job is to determine whether this is a viable drop. // If we say nothing, the default answer is no. public void DragOver(IDropInfo dropInfo) { // Drops are only valid on to writable profiles if (IsSelectedProfileWritable) { var Source = window.IdentifyControl(dropInfo.DragInfo.VisualSource); var Target = window.IdentifyControl(dropInfo.VisualTarget); // Dropping a group onto Full Details if (Source == ProfileControls.Groups && Target == ProfileControls.FullDetails) { // Check group is not already there string group = dropInfo.Data as string; if (group != null && !SelectedProfile.HasGroupInFullDetails(group)) { dropInfo.DropTargetAdorner = DropTargetAdorners.Insert; dropInfo.Effects = DragDropEffects.Copy; } } // Dropping a property onto Full Details else if (Source == ProfileControls.Properties && Target == ProfileControls.FullDetails) { //System.Diagnostics.Trace.WriteLine(String.Format("DragOver {0} at {1}", ((TreeItem)dropInfo.Data).Name, // dropInfo.TargetItem == null ? "null" : ((TreeItem)dropInfo.TargetItem).Name)); // Check at least one group is present if (SelectedProfile.FullDetails.Count > 0) { // Check property is not already there var ti = dropInfo.Data as TreeItem; string property = state.GetSystemPropertyName(ti); if (property != null && !SelectedProfile.HasPropertyInFullDetails(property)) { dropInfo.DropTargetAdorner = DropTargetAdorners.Insert; dropInfo.Effects = DragDropEffects.Copy; } } } // Reordering within Full Details else if (Source == ProfileControls.FullDetails && Target == ProfileControls.FullDetails) { //System.Diagnostics.Trace.WriteLine(String.Format("DragOver {0} at {1}", ((TreeItem)dropInfo.Data).Name, // dropInfo.TargetItem == null ? "null" : ((TreeItem)dropInfo.TargetItem).Name)); var ti = dropInfo.Data as TreeItem; if (ti != null) { dropInfo.DropTargetAdorner = DropTargetAdorners.Insert; dropInfo.Effects = DragDropEffects.Move; } } // Dragging from Full Details to Preview Details else if (Source == ProfileControls.FullDetails && Target == ProfileControls.PreviewDetails) { var ti = dropInfo.Data as TreeItem; // Can only drag properties, not groups, and only if they are not already present if (ti != null && (PropType)ti.Item == PropType.Normal && !SelectedProfile.HasPropertyInPreviewDetails(ti.Name)) { dropInfo.DropTargetAdorner = DropTargetAdorners.Insert; dropInfo.Effects = DragDropEffects.Copy; } } // Reordering within Preview Details else if (Source == ProfileControls.PreviewDetails && Target == ProfileControls.PreviewDetails) { var property = dropInfo.Data as PropertyListEntry; if (property != null) { dropInfo.DropTargetAdorner = DropTargetAdorners.Insert; dropInfo.Effects = DragDropEffects.Move; } } // Dragging from Full Details to InfoTip else if (Source == ProfileControls.FullDetails && Target == ProfileControls.InfoTip) { var ti = dropInfo.Data as TreeItem; // Can only drag properties, not groups, and only if they are not already present if (ti != null && (PropType)ti.Item == PropType.Normal && !SelectedProfile.HasPropertyInInfoTip(ti.Name)) { dropInfo.DropTargetAdorner = DropTargetAdorners.Insert; dropInfo.Effects = DragDropEffects.Copy; } } // Reordering within InfoTip else if (Source == ProfileControls.InfoTip && Target == ProfileControls.InfoTip) { var property = dropInfo.Data as PropertyListEntry; if (property != null) { dropInfo.DropTargetAdorner = DropTargetAdorners.Insert; dropInfo.Effects = DragDropEffects.Move; } } } }