예제 #1
0
        // TODO Should be done in one function insted of split onto two.

        public void PerformIsFreeHand(object obj)
        {
            //_drawingMode = false;
            _shapeMode           = _lineMode = false;
            _tempLine            = null;
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Hand;
        }
예제 #2
0
        /// <summary>
        /// PerformShapeMouseDown - Selects the shape associated with the recieved event and
        /// stores the starting position in-case a drag is initialized.
        /// </summary>
        /// <param name="e">Click event</param>
        private void PerformShapeMouseDown(MouseButtonEventArgs e)
        {
            var source = e.Source as UIElement;

            // Start the line mode.
            if (_lineMode && (source != null))
            {
                var fElement = source as FrameworkElement;
                var shape    = fElement.DataContext as ShapeViewModel;
                // End point
                if (_tempLine != null)
                {
                    _tempLine.To        = shape.Id;
                    _tempLine.ToShape   = shape;
                    _tempLine.ToOffsetX = shape.OffsetX;
                    _tempLine.ToOffsetY = shape.OffsetY;
                    Lines.Add(_tempLine);
                    IUndoRedoCommand cmd = new AddLineCommand(_tempLine, this);
                    _undoRedo.InsertInUndoRedo(cmd);
                    _tempLine = null;
                }
                else
                {
                    _tempLine             = new LineViewModel(new UMLLine(shape.Id, _toolboxLineValue));
                    _tempLine.FromShape   = shape;
                    _tempLine.FromOffsetX = shape.OffsetX;
                    _tempLine.FromOffsetY = shape.OffsetY;
                }
                // Skip the event call ladder.
                e.Handled = true;
            }
            // Selection of a shape / drag event.
            else if (!_shapeMode && (source != null))
            {
                // Deselect previous
                if (SelectedElements != null)
                {
                    //ClearSelection();
                }
                // Select new
                DoSelection(source);
            }
        }