internal void MoveShape(MouseEventArgs e, Point position) { Model.Shape shape = null; Name = ((FrameworkElement)e.OriginalSource).Name; OriginalSource = ((FrameworkElement)e.OriginalSource); if (Modus == Modus.TurnHandle && e.LeftButton == MouseButtonState.Pressed) { _model.TurnShape(position); } else if ((Modus >= (Modus)0 && Modus <= (Modus)7) && e.LeftButton == MouseButtonState.Pressed) { _model.ResizeShape(position, Modus); } else { try { shape = _shapes.First(x => (x.Value == OriginalSource)).Key; Mouse.OverrideCursor = Cursors.SizeAll; } catch (InvalidOperationException ex) { resize = true; switch (Name) { case "TopLeft": ModusType = (int)(2 * Math.Floor((adorner.Key.Rotation + 45) / 90)); CursorType = (int)(Math.Floor((adorner.Key.Rotation - 22.5) / 45)); Modus = (Modus)ModusType; break; case "TopCenter": ModusType = (int)(2 * Math.Floor((adorner.Key.Rotation + 45) / 90)) + 1; CursorType = (int)(Math.Floor((adorner.Key.Rotation + 22.5) / 45)); Modus = (Modus)ModusType; break; case "TopRight": ModusType = (int)(2 * Math.Floor((adorner.Key.Rotation + 135) / 90)); CursorType = (int)(Math.Floor((adorner.Key.Rotation + 67.5) / 45)); Modus = (Modus)ModusType; break; case "CenterRight": ModusType = (int)(2 * Math.Floor((adorner.Key.Rotation + 135) / 90)) + 1; CursorType = (int)(Math.Floor((adorner.Key.Rotation + 112.5) / 45)); Modus = (Modus)ModusType; break; case "BottomRight": ModusType = (int)(2 * Math.Floor((adorner.Key.Rotation + 225) / 90)); CursorType = (int)(Math.Floor((adorner.Key.Rotation + 157.5) / 45)); Modus = (Modus)ModusType; break; case "BottomCenter": ModusType = (int)(2 * Math.Floor((adorner.Key.Rotation + 225) / 90)) + 1; CursorType = (int)(Math.Floor((adorner.Key.Rotation + 202.5) / 45)); Modus = (Modus)ModusType; break; case "BottomLeft": ModusType = (int)(2 * Math.Floor((adorner.Key.Rotation + 315) / 90)); CursorType = (int)(Math.Floor((adorner.Key.Rotation + 247.5) / 45)); Modus = (Modus)ModusType; break; case "CenterLeft": ModusType = (int)(2 * Math.Floor((adorner.Key.Rotation + 315) / 90)) + 1; CursorType = (int)(Math.Floor((adorner.Key.Rotation + 292.5) / 45)); Modus = (Modus)ModusType; break; case "TurnHandle": Modus = Modus.TurnHandle; Mouse.OverrideCursor = Cursors.Cross; resize = false; break; default: Modus = Modus.Move; Mouse.OverrideCursor = Cursors.SizeAll; resize = false; break; } if (resize) { switch (CursorType) { case 0: case 4: Mouse.OverrideCursor = Cursors.SizeNWSE; break; case 1: case 5: Mouse.OverrideCursor = Cursors.SizeNS; break; case 2: case 6: Mouse.OverrideCursor = Cursors.SizeNESW; break; case 3: case 7: Mouse.OverrideCursor = Cursors.SizeWE; break; } } OnPropertyChanged("ModusType"); } } _model.MoveShape(position); }
internal void MoveShape(PointerRoutedEventArgs e, Point position) { Model.Shape shape = null; Name = ((FrameworkElement)e.OriginalSource).Name; OnPropertyChanged("Name"); OriginalSource = ((FrameworkElement)e.OriginalSource); OnPropertyChanged("OriginalSource"); if (Modus == Modus.TurnHandle && e.Pointer.IsInContact) { _model.TurnShape(position); } else if ((Modus >= (Modus)0 && Modus <= (Modus)7) && e.Pointer.IsInContact) { _model.ResizeShape(position, Modus); } else { try { shape = _shapes.First(x => (x.Value == OriginalSource)).Key; Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.SizeAll, 1); } catch (InvalidOperationException ex) { if (adorner.Key != null) { } switch (Name) { case "TopLeft": ModusType = (int)(2 * Math.Floor((adorner.Key.Rotation + 45) / 90)); CursorType = (int)(Math.Floor((adorner.Key.Rotation - 22.5) / 45)); Modus = (Modus)ModusType; Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor((Windows.UI.Core.CoreCursorType)CursorType, 1); break; case "TopCenter": ModusType = (int)(2 * Math.Floor((adorner.Key.Rotation + 45) / 90)) + 1; CursorType = (int)(Math.Floor((adorner.Key.Rotation + 22.5) / 45)); Modus = (Modus)ModusType; Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor((Windows.UI.Core.CoreCursorType)CursorType, 1); break; case "TopRight": ModusType = (int)(2 * Math.Floor((adorner.Key.Rotation + 135) / 90)); CursorType = (int)(Math.Floor((adorner.Key.Rotation + 67.5) / 45)); Modus = (Modus)ModusType; Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor((Windows.UI.Core.CoreCursorType)CursorType, 1); break; case "CenterRight": ModusType = (int)(2 * Math.Floor((adorner.Key.Rotation + 135) / 90)) + 1; CursorType = (int)(Math.Floor((adorner.Key.Rotation + 112.5) / 45)); Modus = (Modus)ModusType; Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor((Windows.UI.Core.CoreCursorType)CursorType, 1); break; case "BottomRight": ModusType = (int)(2 * Math.Floor((adorner.Key.Rotation + 225) / 90)); CursorType = (int)(Math.Floor((adorner.Key.Rotation + 157.5) / 45)); Modus = (Modus)ModusType; Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor((Windows.UI.Core.CoreCursorType)CursorType, 1); break; case "BottomCenter": ModusType = (int)(2 * Math.Floor((adorner.Key.Rotation + 225) / 90)) + 1; CursorType = (int)(Math.Floor((adorner.Key.Rotation + 202.5) / 45)); Modus = (Modus)ModusType; Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor((Windows.UI.Core.CoreCursorType)CursorType, 1); break; case "BottomLeft": ModusType = (int)(2 * Math.Floor((adorner.Key.Rotation + 315) / 90)); CursorType = (int)(Math.Floor((adorner.Key.Rotation + 247.5) / 45)); Modus = (Modus)ModusType; Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor((Windows.UI.Core.CoreCursorType)CursorType, 1); break; case "CenterLeft": ModusType = (int)(2 * Math.Floor((adorner.Key.Rotation + 315) / 90)) + 1; CursorType = (int)(Math.Floor((adorner.Key.Rotation + 292.5) / 45)); Modus = (Modus)ModusType; Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor((Windows.UI.Core.CoreCursorType)CursorType, 1); break; case "TurnHandle": Modus = Modus.TurnHandle; Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Custom, 101); break; default: Modus = Modus.Move; Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Arrow, 1); break; } OnPropertyChanged("ModusType"); } } _model.MoveShape(position); }