Advertisement
Guest User

Untitled

a guest
May 17th, 2013
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. #region Window: Resizing
  2. private void Resizing_MouseDown(object sender, MouseButtonEventArgs e) {
  3. var t = sender as Shape;
  4. if (t == null) { Debug.Assert(false); return; }
  5. t.CaptureMouse(); }
  6. private void Resizing_MouseUp(object sender, MouseButtonEventArgs e) {
  7. var t = sender as Shape;
  8. if (t == null) { Debug.Assert(false); return; }
  9. t.ReleaseMouseCapture(); }
  10. private void Resizing_WE(object sender, MouseEventArgs e) {
  11. var t = sender as Shape;
  12. if (t == null) { Debug.Assert(false); return; }
  13. if (!t.IsMouseCaptured) return;
  14. this.Width = Math.Max(e.GetPosition(this).X + 5, 0); }
  15. private void Resizing_EW(object sender, MouseEventArgs e) {
  16. var t = sender as Shape;
  17. if (t == null) { Debug.Assert(false); return; }
  18. if (!t.IsMouseCaptured) return;
  19. var x = e.GetPosition(this).X;
  20. var w = this.ActualWidth;
  21. this.Width = Math.Max(this.ActualWidth - x, 0);
  22. if (w != this.ActualWidth)
  23. this.Left += w - this.ActualWidth; }
  24. private void Resizing_NS(object sender, MouseEventArgs e) {
  25. var t = sender as Shape;
  26. if (t == null) { Debug.Assert(false); return; }
  27. if (!t.IsMouseCaptured) return;
  28. this.Height = Math.Max(e.GetPosition(this).Y + 5, 0); }
  29. private void Resizing_NWSE(object sender, MouseEventArgs e) {
  30. var t = sender as Shape;
  31. if (t == null) { Debug.Assert(false); return; }
  32. if (!t.IsMouseCaptured) return;
  33. var p = e.GetPosition(this);
  34. this.Width = Math.Max(p.X + 5, 0);
  35. this.Height = Math.Max(p.Y + 5, 0); }
  36. private void Resizing_NESW(object sender, MouseEventArgs e) {
  37. var t = sender as Shape;
  38. if (t == null) { Debug.Assert(false); return; }
  39. if (!t.IsMouseCaptured) return;
  40. var p = e.GetPosition(this);
  41. this.Height = Math.Max(p.Y + 5, 5);
  42. var w = this.ActualWidth;
  43. this.Width = Math.Max(this.ActualWidth - p.X, 5);
  44. if (w != this.ActualWidth)
  45. this.Left += w - this.ActualWidth; }
  46. #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement