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
Please check out our new and improved Firefox Add-on. hide message
By Tom Glenn on the 8th of Feb 2010 09:25:05 AM Download | Raw | Embed | Report
  1.                 public void MouseLeftButtonReleased(object sender, MouseButtonEventArgs e)
  2.                 {
  3.                         // If we are adding a line
  4.                         if(Mode == Mode.Add && selectedObject != null)
  5.                         {
  6.                                 // Get the width of the line
  7.                                 var line = (LineElement)selectedObject;
  8.                                 var lineWidth = line.Line.X2 - line.Line.X1;
  9.                                 var lineHeight = line.Line.Y2 - line.Line.Y1;
  10.  
  11.                                 // If the line width is negative, flip the X positions and reposition the control
  12.                                 if (lineWidth < 0)
  13.                                 {
  14.                                         // Invert the X positions so that X2 now becomes 0 and X1 now becomes the right side of the control
  15.                                         line.Line.X1 = Math.Abs(lineWidth);
  16.                                         line.Line.X2 = 0;
  17.  
  18.                                         // Move the control to the left so that it matches where it was before
  19.                                         line.SetValue(Canvas.LeftProperty, (double)line.GetValue(Canvas.LeftProperty) - Math.Abs(lineWidth));
  20.                                 }
  21.  
  22.                                 // If the line height is negative, flip the Y positions and reposition the control
  23.                                 if (lineHeight < 0)
  24.                                 {
  25.                                         // Invert the Y positions so that Y2 now becomes 0 and Y2 now becomes the top of the control
  26.                                         line.Line.Y1 = Math.Abs(lineHeight);
  27.                                         line.Line.Y2 = 0;
  28.  
  29.                                         // Move the control up so that it matches where it was before
  30.                                         line.SetValue(Canvas.TopProperty, (double)line.GetValue(Canvas.TopProperty) - Math.Abs(lineHeight));
  31.                                 }
  32.                         }
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: