Recent Posts
C++ | 13 sec ago
None | 1 min ago
Lua | 2 min ago
None | 3 min ago
None | 3 min ago
None | 3 min ago
Java | 3 min ago
None | 3 min ago
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Domain Reports
By Tom Glenn on the 8th of Feb 2010 09:25:05 AM
Download |
Raw |
Embed |
Report
public void MouseLeftButtonReleased(object sender, MouseButtonEventArgs e)
{
// If we are adding a line
if(Mode == Mode.Add && selectedObject != null)
{
// Get the width of the line
var line = (LineElement)selectedObject;
var lineWidth = line.Line.X2 - line.Line.X1;
var lineHeight = line.Line.Y2 - line.Line.Y1;
// If the line width is negative, flip the X positions and reposition the control
if (lineWidth < 0)
{
// Invert the X positions so that X2 now becomes 0 and X1 now becomes the right side of the control
line.Line.X1 = Math.Abs(lineWidth);
line.Line.X2 = 0;
// Move the control to the left so that it matches where it was before
line.SetValue(Canvas.LeftProperty, (double)line.GetValue(Canvas.LeftProperty) - Math.Abs(lineWidth));
}
// If the line height is negative, flip the Y positions and reposition the control
if (lineHeight < 0)
{
// Invert the Y positions so that Y2 now becomes 0 and Y2 now becomes the top of the control
line.Line.Y1 = Math.Abs(lineHeight);
line.Line.Y2 = 0;
// Move the control up so that it matches where it was before
line.SetValue(Canvas.TopProperty, (double)line.GetValue(Canvas.TopProperty) - Math.Abs(lineHeight));
}
}
Submit a correction or amendment below.
Make A New Post