private void Update() { if (!SuspendUpdates && SomethingChanged) { if (ShowFolderHighlight) { _folderHighlight.Height = DragOverBehavior.GetDragOverVisualHeight(DragOverElement) + (LineThicknessScale * LineThickness); _folderHighlight.Width = GetAdornerWidth(); _layoutRoot.Children.Remove(_itemHighlight); if (!_layoutRoot.Children.Contains(_folderHighlight)) { _layoutRoot.Children.Add(_folderHighlight); } } else { _line.X2 = GetAdornerWidth(); _layoutRoot.Children.Remove(_folderHighlight); if (!_layoutRoot.Children.Contains(_itemHighlight)) { _layoutRoot.Children.Add(_itemHighlight); } } InvalidateMeasure(); InvalidateArrange(); SomethingChanged = false; } }
private void InitializeShapes() { _layoutRoot.VerticalAlignment = VerticalAlignment.Center; _layoutRoot.Background = null; _layoutRoot.IsHitTestVisible = false; var treeViewItem = DragOverElement as TreeListViewItem; if (treeViewItem != null) { Indent = treeViewItem.Level * LevelToIndentConverter.IndentSize; } _line.HorizontalAlignment = HorizontalAlignment.Left; _line.X1 = 0; _line.Y1 = 0; _line.X2 = GetAdornerWidth(); _line.Y2 = 0; _line.StrokeThickness = LineThickness; _line.Fill = SystemColors.ControlTextBrush; _line.Stroke = SystemColors.ControlTextBrush; var _leftArrow = new Polygon(); _leftArrow.Fill = SystemColors.ControlTextBrush; _leftArrow.Stroke = SystemColors.ControlTextBrush; _leftArrow.HorizontalAlignment = HorizontalAlignment.Left; _leftArrow.Points = new PointCollection(new Point[] { new Point(0, -LineThicknessScale * LineThickness), new Point(0, LineThicknessScale * LineThickness), new Point(LineThicknessScale * LineThickness, 0) }); var _rightArrow = new Polygon(); _rightArrow.Fill = SystemColors.ControlTextBrush; _rightArrow.Stroke = SystemColors.ControlTextBrush; _rightArrow.HorizontalAlignment = HorizontalAlignment.Right; _rightArrow.Points = new PointCollection(new Point[] { new Point(0, -LineThicknessScale * LineThickness), new Point(0, LineThicknessScale * LineThickness), new Point(-LineThicknessScale * LineThickness, 0) }); _itemHighlight.VerticalAlignment = VerticalAlignment.Center; _itemHighlight.Children.Add(_line); _itemHighlight.Children.Add(_leftArrow); _itemHighlight.Children.Add(_rightArrow); _folderHighlight.Width = GetAdornerWidth(); _folderHighlight.Height = DragOverBehavior.GetDragOverVisualHeight(DragOverElement) + (LineThicknessScale * LineThickness); _folderHighlight.StrokeThickness = LineThickness; _folderHighlight.Stroke = SystemColors.ControlTextBrush; Update(); }
/// <inheritdoc /> protected override Size ArrangeOverride(Size finalSize) { if (_visualCollection != null) { var childLocation = DragOverElement.TranslatePoint(new Point(), AdornedElement); var y = 0.0; var offsetY = _layoutRoot.DesiredSize.Height / 2; var adjustY = 3; switch (DropLocation) { case DropOnItemLocation.TopQuarter: y = childLocation.Y - offsetY + adjustY; break; case DropOnItemLocation.TopMiddleQuarter: if (ShowFolderHighlight) { y = childLocation.Y - LineThickness; } else { y = childLocation.Y - offsetY + adjustY; } break; case DropOnItemLocation.BottomMiddleQuarter: if (ShowFolderHighlight) { y = childLocation.Y - LineThickness; } else { y = childLocation.Y + DragOverBehavior.GetDragOverVisualHeight(DragOverElement) - offsetY + adjustY; } break; case DropOnItemLocation.BottomQuarter: y = childLocation.Y + DragOverBehavior.GetDragOverVisualHeight(DragOverElement) - offsetY + adjustY; break; } Rect elementRect = new Rect((2 * Inset) + Indent, y, _layoutRoot.DesiredSize.Width, _layoutRoot.DesiredSize.Height); _layoutRoot.Arrange(elementRect); } return(finalSize); }