DesignerThumb CreateThumb(PlacementAlignment alignment, Cursor cursor) { DesignerThumb designerThumb = new ResizeThumb( cursor == Cursors.SizeNS, cursor == Cursors.SizeWE ); designerThumb.Cursor = cursor; designerThumb.Alignment = alignment; AdornerPanel.SetPlacement(designerThumb, Place(ref designerThumb, alignment)); adornerPanel.Children.Add(designerThumb); DragListener drag = new DragListener(designerThumb); drag.Started += new DragHandler(drag_Started); drag.Changed += new DragHandler(drag_Changed); drag.Completed += new DragHandler(drag_Completed); return designerThumb; }
/// <summary> /// Places resize thumbs at their respective positions /// and streches out thumbs which are at the center of outline to extend resizability across the whole outline /// </summary> /// <param name="resizeThumb"></param> /// <param name="alignment"></param> /// <returns></returns> private RelativePlacement Place(ref ResizeThumb resizeThumb,PlacementAlignment alignment) { RelativePlacement placement = new RelativePlacement(alignment.Horizontal,alignment.Vertical); if (alignment.Horizontal == HorizontalAlignment.Center) { placement.WidthRelativeToContentWidth = 1; placement.HeightOffset = 6; resizeThumb.Opacity = 0; return placement; } if (alignment.Vertical == VerticalAlignment.Center) { placement.HeightRelativeToContentHeight = 1; placement.WidthOffset = 6; resizeThumb.Opacity = 0; return placement; } placement.WidthOffset = 6; placement.HeightOffset = 6; return placement; }