void DisplayRectDragOver(object sender, DragEventArgs e) { try { StackPanel target = sender as StackPanel; e.Handled = true; if (marker != null) { AdornerLayer.GetAdornerLayer(marker.AdornedElement).Remove(marker); marker = null; } if (target != null) { FrameworkElement element = target.InputHitTest(e.GetPosition(target)) as FrameworkElement; if (e.Data.GetData(typeof(XElement)) != null && (element is StackPanel || element.TemplatedParent is Label)) { marker = DragDropMarkerAdorner.CreateAdornerContentMove(target, element); e.Effects = DragDropEffects.Move; return; } } e.Effects = DragDropEffects.None; } catch (Exception ex) { Core.LoggingService.Error(ex); } }
public static DragDropMarkerAdorner CreateAdornerCellMove(FrameworkElement element) { DragDropMarkerAdorner adorner = new DragDropMarkerAdorner(element); if (element is GridLengthEditor) { GridLengthEditor editor = element as GridLengthEditor; if (editor.Orientation == Orientation.Horizontal) { adorner.start = new Point(5,5); adorner.end = new Point(5, editor.ActualWidth + 50); } else { adorner.start = new Point(5,5); adorner.end = new Point(editor.ActualHeight + 250, 5); } } else if (element is StackPanel) { StackPanel panel = element as StackPanel; Dock dockState = (Dock)panel.GetValue(DockPanel.DockProperty); if (dockState == Dock.Right) { adorner.start = new Point(5,5); adorner.end = new Point(5, panel.ActualHeight); } else if (dockState == Dock.Bottom) { adorner.start = new Point(5,5); adorner.end = new Point(panel.ActualWidth - 10, 5); } } AdornerLayer.GetAdornerLayer(element).Add(adorner); return adorner; }
void EditorDragOver(object sender, DragEventArgs e) { try { GridLengthEditor target = sender as GridLengthEditor; GridLengthEditor source = e.Data.GetData(typeof(GridLengthEditor)) as GridLengthEditor; e.Handled = true; if (marker != null) { AdornerLayer.GetAdornerLayer(marker.AdornedElement).Remove(marker); marker = null; } if (target != null && source != null && source.Orientation == target.Orientation && (target != source && (target.Cell < source.Cell || target.Cell > source.Cell + 1))) { marker = DragDropMarkerAdorner.CreateAdornerCellMove(target); e.Effects = DragDropEffects.Move; return; } e.Effects = DragDropEffects.None; } catch (Exception ex) { Core.LoggingService.Error(ex); } }
void ButtonPanelDragOver(object sender, DragEventArgs e) { try { StackPanel target = sender as StackPanel; GridLengthEditor source = e.Data.GetData(typeof(GridLengthEditor)) as GridLengthEditor; e.Handled = true; if (marker != null) { AdornerLayer.GetAdornerLayer(marker.AdornedElement).Remove(marker); marker = null; } if (target != null && source != null && source.Orientation == Orientation.Vertical && source.Cell + 1 < rowDefitions.Elements().Count()) { marker = DragDropMarkerAdorner.CreateAdornerCellMove(target); e.Effects = DragDropEffects.Move; return; } e.Effects = DragDropEffects.None; } catch (Exception ex) { Core.LoggingService.Error(ex); } }
public static DragDropMarkerAdorner CreateAdornerContentMove(StackPanel panel, FrameworkElement aboveElement) { DragDropMarkerAdorner adorner; if (aboveElement is StackPanel) { aboveElement = (panel.Children.Count > 0 ? panel.Children[panel.Children.Count - 1] : panel) as FrameworkElement; adorner = new DragDropMarkerAdorner(aboveElement); adorner.start = new Point(5, 5 + aboveElement.DesiredSize.Height); adorner.end = new Point(panel.ActualWidth - 10, 5 + aboveElement.DesiredSize.Height); } else { aboveElement = aboveElement.TemplatedParent as FrameworkElement; adorner = new DragDropMarkerAdorner(aboveElement); adorner.start = new Point(5, 0); adorner.end = new Point(panel.ActualWidth - 10, 0); } AdornerLayer.GetAdornerLayer(aboveElement).Add(adorner); return adorner; }
public static DragDropMarkerAdorner CreateAdornerCellMove(FrameworkElement element) { DragDropMarkerAdorner adorner = new DragDropMarkerAdorner(element); if (element is GridLengthEditor) { GridLengthEditor editor = element as GridLengthEditor; if (editor.Orientation == Orientation.Horizontal) { adorner.start = new Point(5, 5); adorner.end = new Point(5, editor.ActualWidth + 50); } else { adorner.start = new Point(5, 5); adorner.end = new Point(editor.ActualHeight + 250, 5); } } else if (element is StackPanel) { StackPanel panel = element as StackPanel; Dock dockState = (Dock)panel.GetValue(DockPanel.DockProperty); if (dockState == Dock.Right) { adorner.start = new Point(5, 5); adorner.end = new Point(5, panel.ActualHeight); } else if (dockState == Dock.Bottom) { adorner.start = new Point(5, 5); adorner.end = new Point(panel.ActualWidth - 10, 5); } } AdornerLayer.GetAdornerLayer(element).Add(adorner); return(adorner); }
public static DragDropMarkerAdorner CreateAdornerContentMove(StackPanel panel, FrameworkElement aboveElement) { DragDropMarkerAdorner adorner; if (aboveElement is StackPanel) { aboveElement = (panel.Children.Count > 0 ? panel.Children[panel.Children.Count - 1] : panel) as FrameworkElement; adorner = new DragDropMarkerAdorner(aboveElement); adorner.start = new Point(5, 5 + aboveElement.DesiredSize.Height); adorner.end = new Point(panel.ActualWidth - 10, 5 + aboveElement.DesiredSize.Height); } else { aboveElement = aboveElement.TemplatedParent as FrameworkElement; adorner = new DragDropMarkerAdorner(aboveElement); adorner.start = new Point(5, 0); adorner.end = new Point(panel.ActualWidth - 10, 0); } AdornerLayer.GetAdornerLayer(aboveElement).Add(adorner); return(adorner); }