| | |
| | | if (_resizeType == ResizeType.Canvas && _resizeTarget is InnerWindow _inner) |
| | | { |
| | | Canvas parent = GetCanvas(_inner); |
| | | // 如果是个InnerWindow,就把InnerWindowZIndex置顶 |
| | | // TODO 可以改成接口或者DependencyPrope来做 |
| | | CanvasHelper.SetTopZIndex(_inner, parent, _inner.GetType()); |
| | | } |
| | | } |
| | |
| | | return; |
| | | } |
| | | |
| | | double oldLeft = double.IsNaN(Canvas.GetLeft(target)) ? 0 : Canvas.GetLeft(target), |
| | | oldTop = double.IsNaN(Canvas.GetTop(target)) ? 0 : Canvas.GetTop(target), |
| | | oldWidth = double.IsNaN(target.ActualWidth) ? 0 : target.ActualWidth, |
| | | oldHeight = double.IsNaN(target.ActualHeight) ? 0 : target.ActualHeight;
|
| | | |
| | | double left, top, width, height; |
| | | if (thumb.HorizontalAlignment == HorizontalAlignment.Left) |
| | | double x = e.HorizontalChange, y = e.VerticalChange; |
| | | bool toLeft = x < 0, toTop = y < 0;
|
| | | bool isLeft = thumb.HorizontalAlignment == HorizontalAlignment.Left,
|
| | | isTop = thumb.VerticalAlignment == VerticalAlignment.Top;
|
| | | if (isLeft) |
| | | { |
| | | left = double.IsNaN(Canvas.GetLeft(target)) ? 0 : Canvas.GetLeft(target) + e.HorizontalChange; |
| | | width = (double.IsNaN(target.ActualWidth) ? 0 : target.ActualWidth) - e.HorizontalChange; |
| | | // 左侧的拖拽 |
| | | left = oldLeft + x; |
| | | width = oldWidth - x; |
| | | if (left < 0) { left = 0; width = oldWidth - (left - oldLeft); } |
| | | width = width < MinWidth ? MinWidth : width; |
| | | } |
| | | else |
| | | { |
| | | left = Canvas.GetLeft(target); |
| | | width = (double.IsNaN(target.ActualWidth) ? 0 : target.ActualWidth) + e.HorizontalChange; |
| | | // 右侧的拖拽 |
| | | left = oldLeft >= 0 ? oldLeft : 0; |
| | | width = oldWidth + x; |
| | | width = width < MinWidth ? MinWidth : width; |
| | | if (left + width > parent.ActualWidth) width = parent.ActualWidth - left; |
| | | } |
| | | if (thumb.VerticalAlignment == VerticalAlignment.Top) |
| | | |
| | | if (isTop) |
| | | { |
| | | top = double.IsNaN(Canvas.GetTop(target)) ? 0 : Canvas.GetTop(target) + e.VerticalChange; |
| | | height = (double.IsNaN(target.ActualHeight) ? 0 : target.ActualHeight) - e.VerticalChange; |
| | | // 上边的拖拽 |
| | | top = oldTop + y; |
| | | height = oldHeight - y; |
| | | if (top < 0) { top = 0; height = oldHeight - (top - oldTop); } |
| | | height = height < MinHeight ? MinHeight : height; |
| | | } |
| | | else |
| | | { |
| | | top = Canvas.GetTop(target); |
| | | height = (double.IsNaN(target.ActualHeight) ? 0 : target.ActualHeight) + e.VerticalChange; |
| | | // 下边的拖拽 |
| | | top = oldTop > 0 ? oldTop : 0; |
| | | height = oldHeight + y; |
| | | height = height < MinHeight ? MinHeight : height; |
| | | if (top + height > parent.ActualHeight) height = parent.ActualHeight - top; |
| | | } |
| | | if (thumb.HorizontalAlignment != HorizontalAlignment.Center && thumb.HorizontalAlignment != HorizontalAlignment.Stretch) |
| | | |
| | | if (thumb.HorizontalAlignment != HorizontalAlignment.Center &&
|
| | | thumb.HorizontalAlignment != HorizontalAlignment.Stretch) |
| | | { |
| | | if (e.HorizontalChange > 0 || (width >= MinWidth && left >= 0)) |
| | | { |
| | | // 水平方向最终判断 |
| | | Canvas.SetLeft(target, left); |
| | | target.Width = width; |
| | | //if ((isLeft && toLeft && left >= 0) ||
|
| | | // (isLeft && !toLeft && width >= MinWidth) ||
|
| | | // (!isLeft && toLeft && width >= MinWidth) ||
|
| | | // (!isLeft && !toLeft && (left + width) <= parent.ActualWidth))
|
| | | //{
|
| | | // Canvas.SetLeft(target, left); |
| | | // target.Width = width; |
| | | //} |
| | | } |
| | | } |
| | | if (thumb.VerticalAlignment != VerticalAlignment.Center && thumb.VerticalAlignment != VerticalAlignment.Stretch) |
| | | |
| | | if (thumb.VerticalAlignment != VerticalAlignment.Center &&
|
| | | thumb.VerticalAlignment != VerticalAlignment.Stretch) |
| | | { |
| | | if (e.VerticalChange > 0 || (height >= MinHeight && top >= 0)) |
| | | { |
| | | // 垂直方向最终判断 |
| | | Canvas.SetTop(target, top); |
| | | target.Height = height; |
| | | } |
| | | //if ((isTop && toTop && top >= 0) ||
|
| | | // (isTop && !toTop && height >= MinHeight) ||
|
| | | // (!isTop && toTop && height >= MinHeight) ||
|
| | | // (!isTop && !toTop && (top + height) <= parent.ActualHeight))
|
| | | //{
|
| | | // Canvas.SetTop(target, top); |
| | | // target.Height = height; |
| | | //} |
| | | } |
| | | } |
| | | break; |