public DecoratorAdorner(UIElement uiElement, ISketchItemDisplay parent) : base(uiElement) { _parent = parent; if (uiElement is OutlineUI outline && outline.Model is ConnectableBase connectable) { _model = connectable; } //IsHitTestVisible = false; }
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 OutlineAdorner(OutlineUI adorned, ISketchItemDisplay parent) : base(adorned) { _adorned = adorned; _parent = parent; _realBody = _adorned.Model as ConnectableBase; _shadowGeometry = _realBody.Outline.Clone(); _shadowGeometry.Rect = new Rect(0, 0, adorned.Bounds.Width, adorned.Bounds.Height); //_realBody.Outline.Clone(); _myBrush = _selectedOutlineBrush; ComputeSensitiveBorder(); _myPen = new Pen(_myBrush, _defaultStroke); _defaultDashstile = _myPen.DashStyle; this.Visibility = System.Windows.Visibility.Visible; }
private Brush CreateVisualBrush() { if (_model is ISketchItemContainer container) { _brushDisplay = new SketchItemDisplay(_sketchPad, container, false); _visualBrush = new VisualBrush(_brushDisplay.Canvas); } else { _visualBrush = new VisualBrush( new GeometryBorder() { BorderThickness = new Thickness(1, 1, 1, 1), BorderBrush = _model.Stroke, Background = _model.Fill, BorderGeometry = _model.Geometry } ); } return(_visualBrush); }
public AddConnectorOperation(ISketchItemDisplay pad, ConnectableBase from, Point p) { _from = from; _pad = pad; // // at this point it is not sufficient to consider only the bounds // in case of a lengthy object, we would like to place that start point close to where // the user pressed the button! // hence we should query the from object for a decent start point // var start = p;// ConnectorUtilities.ComputeCenter(from.Bounds); _selector = new ConnectablePairSelector(start, p); _pad.Canvas.Children.Add(_selector); _selector.Visibility = Visibility.Visible; _pad.SetSketchItemEnable(false); _oldContextMenue = _pad.Canvas.ContextMenu; _pad.Canvas.MouseMove += HandleMouseMove; _pad.Canvas.MouseDown += HandleMouseDown; _pad.Canvas.KeyDown += HandleKeyDown; _pad.TakeSnapshot(); }
public RewireConnectorOperation(ISketchItemDisplay pad, ConnectorModel model, Point p) { _connector = model; _pad = pad; IBoundedSketchItemModel ending = model.To; if (ending == null) { ending = model.From; } var start = ConnectorUtilities.ComputeCenter(ending.Bounds); _selector = new ConnectablePairSelector(start, p); _pad.Canvas.Children.Add(_selector); _selector.Visibility = Visibility.Visible; foreach (var ch in _pad.Canvas.Children.OfType <ISketchItemUI>()) { ch.Disable(); } _pad.Canvas.MouseMove += HandleMouseMove; _pad.Canvas.MouseDown += HandleMouseDown; _pad.Canvas.KeyDown += HandleKeyDown; }
public NopHandler(ISketchItemDisplay pad) { _pad = pad; _pad.Canvas.MouseDown += _pad_MouseDown; }
//bool _selecting = false; public SelectUisOperation(ISketchItemDisplay pad) { _pad = pad; _pad.Canvas.MouseLeftButtonDown += MouseLeftButtonDown; _pad.Canvas.KeyDown += KeyDown; }
public AddConnectableItemOperation(ISketchItemDisplay pad) { _pad = pad; _pad.Canvas.Focus(); _pad.Canvas.MouseDown += HandleMouseDown; }
public OutlineUI(SketchPad pad, ISketchItemDisplay parent, object modelInstance) : base() { if (modelInstance is ConnectableBase model) { _sketchPad = pad; _model = model; _model.Decorators.CollectionChanged += Decorators_CollectionChanged; Content = model; IsHitTestVisible = true; Canvas.SetLeft(this, model.Bounds.Left); Canvas.SetTop(this, model.Bounds.Top); _parent = parent; var tools = model.AllowableConnectors; if (tools.Count > 0) { InitTools(tools); } this.DataContext = model; this.SetBinding(LabelProperty, model.LabelPropertyName); var boundsBinding = new Binding(nameof(Bounds)) { Mode = BindingMode.OneWay }; this.SetBinding(BoundsProperty, boundsBinding); this.SetBinding(GeometryProperty, nameof(Geometry)); this.Visibility = System.Windows.Visibility.Visible; // some of the bindings must only occur after the shadow was created! _adorner = new OutlineAdorner(this, parent); _decoratorAdorner = new DecoratorAdorner(this, parent); var isSelecteBinding = new Binding("IsSelected") { Mode = BindingMode.TwoWay }; this.SetBinding(IsSelectedProperty, isSelecteBinding); var isMarkedBinding = new Binding("IsMarked") { Mode = BindingMode.TwoWay }; this.SetBinding(IsMarkedProperty, isMarkedBinding); this.SetBinding(CanChangeSizeProperty, nameof(CanChangeSize)); InitContextMenu(model); } else { throw new NotSupportedException("The model needs to be derived from ConnectableBase"); } }
public ConnectorUI(ISketchItemDisplay parent, object modelInstance) { if (modelInstance is ConnectorModel model) { _model = model; _parent = parent; this.DataContext = _model; _myAdorner = new ConnectorAdorner(_parent, this); _myAdorner.MouseLeftButtonDown += Adorner_MouseLeftButtonDown; _myAdorner.MouseRightButtonDown += Adorner_MouseRightButtonDown; var isSelectedBinding = new Binding("IsSelected") { Mode = BindingMode.TwoWay }; this.SetBinding(IsSelectedPropery, isSelectedBinding); var startLabelBinding = new Binding("ConnectorStartLabel") { Mode = BindingMode.OneWay }; this.SetBinding(ConnectorStartLabelProperty, startLabelBinding); var endLabelBinding = new Binding("ConnectorEndLabel") { Mode = BindingMode.OneWay }; this.SetBinding(ConnectorEndLabelProperty, endLabelBinding); var contextMenuBinding = new Binding("ContextMenuDeclaration") { Mode = BindingMode.OneWay }; this.SetBinding(ContextMenuDeclarationProperty, contextMenuBinding); var fromBinding = new Binding("From") { Mode = BindingMode.OneWay }; this.SetBinding(FromProperty, fromBinding); var toBinding = new Binding("To") { Mode = BindingMode.OneWay }; this.SetBinding(ToProperty, toBinding); SetBinding(StrokeDashArrayProperty, new Binding("StrokeDashArray")); var waypointBinding = new Binding("Waypoints") { Mode = BindingMode.OneWay }; SetBinding(WaypointsProperty, waypointBinding); _model.From.ShapeChanged += From_ShapeChanged; _model.To.ShapeChanged += To_ShapeChanged; this.Visibility = System.Windows.Visibility.Visible; this.Stroke = Brushes.White; this.Fill = Brushes.White; this.StrokeThickness = 1;// ComputeConnectorLine.LineWidth; _myGeometry = _model.Geometry; TryAddAdorner(); this.SetBinding(GeometryProperty, "Geometry"); } else { throw new NotSupportedException("Model needs to be derived from class ConnectorModel"); } }