|
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
namespace DiagramDesigner
{
public class MoveThumb : Thumb
{
private RotateTransform rotateTransform;
private ContentControl designerItem;
public MoveThumb()
{
DragStarted += new DragStartedEventHandler(this.MoveThumb_DragStarted);
DragDelta += new DragDeltaEventHandler(this.MoveThumb_DragDelta);
}
private void MoveThumb_DragStarted(object sender, DragStartedEventArgs e)
{
this.designerItem = DataContext as ContentControl;
if (this.designerItem != null)
{
this.rotateTransform = this.designerItem.RenderTransform as RotateTransform;
}
}
private void MoveThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
if (this.designerItem != null)
{
Point dragDelta = new Point(e.HorizontalChange, e.VerticalChange);
if (this.rotateTransform != null)
{
dragDelta = this.rotateTransform.Transform(dragDelta);
}
Canvas.SetLeft(this.designerItem, Canvas.GetLeft(this.designerItem) + dragDelta.X);
Canvas.SetTop(this.designerItem, Canvas.GetTop(this.designerItem) + dragDelta.Y);
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.