Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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;
        }