示例#1
0
        void HandleMouseDown(object sender, MouseButtonEventArgs e)
        {
            _pad.Canvas.Focus();
            var p = e.GetPosition(_pad.Canvas);

            p = PlacementHelper.RoundToGrid(p);

            var factory = _pad.ItemFactory;

            if (factory.SelectedForCreation != null &&
                factory.SelectedForCreation.GetInterface(
                    nameof(IBoundedSketchItemModel)) != null)
            {
                var cm = factory.CreateConnectableSketchItem(factory.SelectedForCreation, p, _pad);
                if (cm != null)
                {
                    _pad.TakeSnapshot();
                    _pad.SketchItems.Add(cm);
                }
                //_pad.UpdateLayout();
                e.Handled = true;
            }
        }
示例#2
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();
        }
示例#3
0
 public void TriggerSnapshot()
 {
     _parent.TakeSnapshot();
 }