You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.4 KiB
56 lines
1.4 KiB
using System; |
|
using System.Collections.Generic; |
|
using System.Linq; |
|
using System.Text; |
|
using System.Windows; |
|
using SharpDevelop.XamlDesigner.Dom; |
|
|
|
namespace SharpDevelop.XamlDesigner.Placement |
|
{ |
|
class ResizeOperation |
|
{ |
|
public ResizeOperation(DesignItem item, ResizeDirection dir) |
|
{ |
|
this.dir = dir; |
|
|
|
PlacementInfo = new PlacementInfo(); |
|
PlacementInfo.Item = item; |
|
PlacementInfo.OriginalBounds = item.GetBounds(); |
|
} |
|
|
|
public PlacementInfo PlacementInfo; |
|
ResizeDirection dir; |
|
|
|
public void Resize(Vector delta) |
|
{ |
|
double dx = 0; |
|
double dy = 0; |
|
|
|
var ha = ResizeThumb.GetHorizontalAlignment(dir); |
|
var va = ResizeThumb.GetVerticalAlignmentt(dir); |
|
|
|
if (ha == HorizontalAlignment.Left) dx = -delta.X; |
|
if (ha == HorizontalAlignment.Right) dx = delta.X; |
|
if (va == VerticalAlignment.Top) dy = -delta.Y; |
|
if (va == VerticalAlignment.Bottom) dy = delta.Y; |
|
|
|
var newWidth = Math.Round(Math.Max(0, PlacementInfo.OriginalBounds.Width + dx)); |
|
var newHeight = Math.Round(Math.Max(0, PlacementInfo.OriginalBounds.Height + dy)); |
|
|
|
//item.Properties.GetProperty(FrameworkElement.WidthProperty).SetValue(newWidth); |
|
//item.Properties.GetProperty(FrameworkElement.HeightProperty).SetValue(newHeight); |
|
|
|
PlacementInfo.Item.View.Width = newWidth; |
|
PlacementInfo.Item.View.Height = newHeight; |
|
PlacementInfo.NewBoundsInContainer = PlacementInfo.Item.GetBounds(); |
|
} |
|
|
|
public void Abort() |
|
{ |
|
} |
|
|
|
public void Commit() |
|
{ |
|
} |
|
} |
|
}
|
|
|