private void Down(MouseButtonEventArgs e) { bool onlyCtrl = Keyboard.Modifiers == ModifierKeys.Control; bool onlyShift = Keyboard.Modifiers == ModifierKeys.Shift; bool sourceIsThumb = ((e.OriginalSource as FrameworkElement).TemplatedParent) is Thumb; Point sheetPoint = e.GetPosition(_sheetController.State.OverlaySheet.GetParent() as FrameworkElement); ImmutablePoint sheetPosition = new ImmutablePoint(sheetPoint.X, sheetPoint.Y); Point rootPoint = e.GetPosition(this); ImmutablePoint rootPosition = new ImmutablePoint(rootPoint.X, rootPoint.Y); var args = new InputArgs() { OnlyControl = onlyCtrl, OnlyShift = onlyShift, SourceType = sourceIsThumb ? ItemType.Thumb : ItemType.None, SheetPosition = sheetPosition, RootPosition = rootPosition, Handled = (handled) => e.Handled = handled, Delta = 0, Clicks = e.ClickCount }; switch (e.ChangedButton) { case MouseButton.Left: args.Button = InputButton.Left; break; case MouseButton.Middle: args.Button = InputButton.Middle; break; case MouseButton.Right: args.Button = InputButton.Right; break; default: args.Button = InputButton.None; break; } _sheetController.Down(args); }
private void RightUp(MouseButtonEventArgs e) { bool onlyCtrl = Keyboard.Modifiers == ModifierKeys.Control; bool onlyShift = Keyboard.Modifiers == ModifierKeys.Shift; bool sourceIsThumb = ((e.OriginalSource as FrameworkElement).TemplatedParent) is Thumb; Point sheetPoint = e.GetPosition(_sheetController.State.OverlaySheet.GetParent() as FrameworkElement); ImmutablePoint sheetPosition = new ImmutablePoint(sheetPoint.X, sheetPoint.Y); Point rootPoint = e.GetPosition(this); ImmutablePoint rootPosition = new ImmutablePoint(rootPoint.X, rootPoint.Y); var args = new InputArgs() { OnlyControl = onlyCtrl, OnlyShift = onlyShift, SourceType = sourceIsThumb ? ItemType.Thumb : ItemType.None, SheetPosition = sheetPosition, RootPosition = rootPosition, Handled = (handled) => e.Handled = handled, Delta = 0, Button = InputButton.Left, Clicks = 1 }; _sheetController.RightUp(args); }
public void Init(ImmutablePoint p) { double x = _itemController.Snap(p.X, _state.Options.SnapSize); double y = _itemController.Snap(p.Y, _state.Options.SnapSize); SelectionStartPoint = new ImmutablePoint(x, y); TempEllipse = _blockFactory.CreateEllipse(_state.Options.LineThickness / _state.ZoomController.Zoom, x, y, 0.0, 0.0, false, ArgbColors.Black, ArgbColors.Transparent); _state.OverlaySheet.Add(TempEllipse); _state.OverlaySheet.Capture(); }
public void Move(ImmutablePoint p) { double sx = SelectionStartPoint.X; double sy = SelectionStartPoint.Y; double x = _itemController.Snap(p.X, _state.Options.SnapSize); double y = _itemController.Snap(p.Y, _state.Options.SnapSize); _blockHelper.SetLeft(TempEllipse, Math.Min(sx, x)); _blockHelper.SetTop(TempEllipse, Math.Min(sy, y)); _blockHelper.SetWidth(TempEllipse, Math.Abs(sx - x)); _blockHelper.SetHeight(TempEllipse, Math.Abs(sy - y)); }
public void Move(ImmutablePoint p) { double x = _itemController.Snap(p.X, _state.Options.SnapSize); double y = _itemController.Snap(p.Y, _state.Options.SnapSize); double x2 = _blockHelper.GetX2(TempLine); double y2 = _blockHelper.GetY2(TempLine); if (Math.Round(x, 1) != Math.Round(x2, 1) || Math.Round(y, 1) != Math.Round(y2, 1)) { _blockHelper.SetX2(TempLine, x); _blockHelper.SetY2(TempLine, y); _blockHelper.SetLeft(TempEndEllipse, x - 4.0); _blockHelper.SetTop(TempEndEllipse, y - 4.0); } }
public void Init(ImmutablePoint p, XPoint start) { double x = _itemController.Snap(p.X, _state.Options.SnapSize); double y = _itemController.Snap(p.Y, _state.Options.SnapSize); TempLine = _blockFactory.CreateLine(_state.Options.LineThickness / _state.ZoomController.Zoom, x, y, x, y, ArgbColors.Black); if (start != null) { TempLine.Start = start; } TempStartEllipse = _blockFactory.CreateEllipse(_state.Options.LineThickness / _state.ZoomController.Zoom, x - 4.0, y - 4.0, 8.0, 8.0, true, ArgbColors.Black, ArgbColors.Black); TempEndEllipse = _blockFactory.CreateEllipse(_state.Options.LineThickness / _state.ZoomController.Zoom, x - 4.0, y - 4.0, 8.0, 8.0, true, ArgbColors.Black, ArgbColors.Black); _state.OverlaySheet.Add(TempLine); _state.OverlaySheet.Add(TempStartEllipse); _state.OverlaySheet.Add(TempEndEllipse); _state.OverlaySheet.Capture(); }
public void CreateImmutableValueTypes() { IFixture fixture = new Fixture(); // Autofixture can also create values of non-primitive value types. ImmutablePoint immutablePoint = fixture.Create <ImmutablePoint>(); DateTime time1 = fixture.Create <DateTime>(); DateTimeOffset time2 = fixture.Create <DateTimeOffset>(); // By default it can only handle value types that have a defined constructor with parameters. Assert.Throws( Is.InstanceOf <ObjectCreationException>(), () => fixture.Create <MutablePoint>() ); // If you need to create a value of a mutable value type // and set the properties afterwards, you can instruct AutoFixture to do so // by using a Customization. Customizations will be covered in-depth in another tutorial file. fixture.Customize(new SupportMutableValueTypesCustomization()); MutablePoint mutablePoint = fixture.Create <MutablePoint>(); }
private void UserControl_Drop(object sender, DragEventArgs e) { Point point = e.GetPosition(_sheetController.State.OverlaySheet.GetParent() as FrameworkElement); ImmutablePoint position = new ImmutablePoint(point.X, point.Y); if (e.Data.GetDataPresent(BlockDropFormat)) { var blockItem = e.Data.GetData(BlockDropFormat) as BlockItem; if (blockItem != null) { _sheetController.Insert(blockItem, position, true); e.Handled = true; } } else if (e.Data.GetDataPresent(DataDropFormat)) { var dataItem = e.Data.GetData(DataDropFormat) as DataItem; if (dataItem != null) { _sheetController.TryToBindData(position, dataItem); e.Handled = true; } } }
public bool HitTest(ISheet sheet, XBlock block, ImmutablePoint p, double size, XBlock selected, bool findOnlyOne, bool findInsideBlock) { return(HitTest(sheet, block, new ImmutableRect(p.X - size, p.Y - size, 2 * size, 2 * size), selected, findOnlyOne, findInsideBlock)); }