private static void Resize(ICanvasItem canvasItem, SizeChangeEventArgs sizeChange, double currentParentLeft) { var currentLeft = canvasItem.Left - currentParentLeft; var currentWidth = canvasItem.Width; var leftProportion = currentLeft / sizeChange.OldValue; var widthProportion = currentWidth / sizeChange.OldValue; canvasItem.Left = currentParentLeft + sizeChange.NewValue * leftProportion; canvasItem.Width = sizeChange.NewValue * widthProportion; }
private void SetWidth(SizeChangeEventArgs sizeChangeEventArgs, double currentParentLeft) { foreach (var canvasItem in Children) { Resize(canvasItem, sizeChangeEventArgs, currentParentLeft); } }
private void OnHeightChanged(object sender, SizeChangeEventArgs sizeChangeEventArgs) { Children.SwapCoordinates(); SetWidth(sizeChangeEventArgs, Top); Children.SwapCoordinates(); }
private void OnWidthChanged(object sender, SizeChangeEventArgs sizeChangeEventArgs) { SetWidth(sizeChangeEventArgs, Left); }
protected virtual void OnWidthChanged(SizeChangeEventArgs e) { var handler = WidthChanged; if (handler != null) handler(this, e); }