public static IEnumerable <LineSegmentDecorator> DecorateLineSegments(ConnectorUI ui, int id) { List <LineSegmentDecorator> lineSegments = new List <LineSegmentDecorator>(); if (ui.Model.Geometry is GeometryGroup geometry) { var path = geometry.Children.First() as PathGeometry; if (path != null && path.Figures.Count() > 0) { foreach (var f in path.Figures) { var pathFigureCollection = f; if (pathFigureCollection.Segments.Count() > 0) { var startPoint = pathFigureCollection.StartPoint; foreach (var segment in pathFigureCollection.Segments.OfType <LineSegment>()) { var endPoint = segment.Point; lineSegments.Add( new LineSegmentDecorator(ui, startPoint, endPoint, id)); startPoint = endPoint; } } } } } return(lineSegments); }
private static ICommandDescriptor CreateAddWaypointMenuItem(ConnectorUI ui) { var descriptor = new CommandDescriptor() { Name = "Add Waypoint", Command = new DelegateCommand(ui.AddWaypoint) }; return(descriptor); }
private static void OnIsMarkedChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) { ConnectorUI connector = source as ConnectorUI; if (e.NewValue != e.OldValue) { connector.NotifyIsMarkedChanged(); } }
public ConnectorAdorner(ISketchItemDisplay parent, ConnectorUI ui) : base(ui) { _parent = parent; _model = ((ConnectorUI)this.AdornedElement).Model as ConnectorModel; this.Visibility = System.Windows.Visibility.Visible; this._model.PropertyChanged += OnModelPropertyChanged; IsHitTestVisible = _model.IsSelected || _model.IsMarked; ui.InvalidateVisual(); }
public WaypointMoveOperation(ConnectorUI ui, Point startPoint, IWaypoint wp) { _ui = ui; _wp = wp; _startPoint = startPoint; _ui.TriggerSnapshot(); _ui.MouseMove += Ui_MouseMove; _ui.MouseUp += Ui_MouseUp; _ui.CaptureMouse(); }
public LineSegmentDecorator(ConnectorUI ui, Point start, Point end, int id) { Start = start; End = end; if (start.X > end.X) { Start = end; End = start; } _id = id; _connector = ui; }
public ScanLine(LineSegmentDecorator s, double x) { if (s.IsHorizontal) { _horizontalLines.Add(s); } else { _verticalLines.Add(s); } _scanPos = x; _connector = s.Connector; }
void AddLineSegments(ConnectorUI ui) { foreach (LineSegmentDecorator l in LineSegmentDecorator.DecorateLineSegments(ui, lineSegments++)) { if (l.IsHorizontal && l.IsVertical) // this is just a point! { continue; } _horizontalScan.Add(new ScanLine(l, l.Start.X)); if (l.IsHorizontal) { System.Diagnostics.Debug.Assert(l.Start.X < l.End.X); _horizontalScan.Add(new ScanLine(l, l.End.X)); } } }
private static void OnSelectedChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) { ConnectorUI connector = source as ConnectorUI; if (e.NewValue != e.OldValue) { bool isSelected = (bool)e.NewValue; var zIndex = 0; if (isSelected) { zIndex = 10; } Canvas.SetZIndex(connector.Shape, zIndex); connector.NotifySelectionChanged(); } }
public MoveConnectorOperation(ConnectorUI ui, Point p) { _ui = ui; _model = ui._model; _startPoint = p; _p0 = p; _moveHelper = _model.StartMove(p); _newMoveDistance = _moveHelper.Distance; _movePointStart = _moveHelper.StartPoint; var from = _moveHelper.StartingFrom; var to = _moveHelper.EndingAt; _fromGeometry = new RectangleGeometry(from.Bounds); _toGeometry = new RectangleGeometry(to.Bounds); if (Keyboard.IsKeyDown(Key.LeftShift)) { if (TryAdjustConnectorLine()) { //_moveHelper.Commit() } StopOperation(false); } else { var initialGeometry = _moveHelper.GetGeometry(_gg, _moveHelper.LineType, _movePointStart, _moveHelper.EndPoint, _moveHelper.Distance); _visualizer = new ConnectorMoveVisualizer(initialGeometry); //tbd //_visualizer.MouseMove += HandleMouseMove; _isSelfTransition = _model.From == _model.To; if (_moveHelper.MoveType == MoveType.MoveStartPoint && _model.CanMoveStart) { _mouseMove = MoveStartPoint; //_allowableDockings = from.AllowableDockings(false); _movingPointDocking = from.GetConnectorDocking(_moveHelper.StartPoint, false); _otherPointDocking = to.GetConnectorDocking(_moveHelper.EndPoint, true); _otherPointPosition = _moveHelper.EndPoint; } else if (_moveHelper.MoveType == MoveType.MoveEndPoint && _model.CanMoveEnd) { //_allowableDockings = to.AllowableDockings(true); _mouseMove = MoveEndPoint; _movingPointDocking = to.GetConnectorDocking(_moveHelper.EndPoint, true); _otherPointDocking = from.GetConnectorDocking(_moveHelper.StartPoint, false); _otherPointPosition = _moveHelper.StartPoint; _movePointStart = _moveHelper.EndPoint; } else if (_moveHelper.MoveType == MoveType.MoveMiddlePoint) { _mouseMove = MoveMiddlePoint; } else { StopOperation(false); return; } _initialOtherPointDocking = _otherPointDocking; _ui.TriggerSnapshot(); _ui.MouseMove += HandleMouseMove; _ui.MouseUp += HandleMouseUp; _ui.CaptureMouse(); _ui._parent.Canvas.Children.Add(_visualizer); } }