Beispiel #1
0
        void picturebox_MouseDown(object sender, MouseEventArgs e)
        {
            if (!_active)
            {
                return;
            }

            _curMousePoint = _picturebox.GetPositionViewToWorld(new MyVector(e.X, e.Y, 0));
            _cursorBlip.Sphere.Position.StoreNewValues(_curMousePoint);

            if (e.Button == MouseButtons.Left)
            {
                _isMouseDown = MouseButtonDown.Left;
            }
            else if (e.Button == MouseButtons.Right)
            {
                _isMouseDown = MouseButtonDown.Right;
            }
        }
Beispiel #2
0
        void picturebox_MouseDown(object sender, MouseEventArgs e)
        {
            if (_mode == AddingMode.Inactive)
            {
                return;
            }

            if (e.Button == MouseButtons.Left)
            {
                _isMouseDown                = true;
                _mouseDownPoint             = _picturebox.GetPositionViewToWorld(new MyVector(e.X, e.Y, 0));
                _curMousePoint              = _mouseDownPoint.Clone();
                _lastCreateTime             = Environment.TickCount;
                _createdBallDuringMouseDrag = false;
                //_diminishPercent = 1d;

                if (_newBallProps.SizeMode == BallProps.SizeModes.Draw)
                {
                    // I need to create an object now (but don't commit it to the map), so that the user can see
                    // it while they drag the size
                    _drawingBall = BuildObject();
                }
            }
        }
Beispiel #3
0
        void picturebox_MouseDown(object sender, MouseEventArgs e)
        {
            if (!_active)
            {
                return;
            }

            if (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right)
            {
                _mouseDownPoint = _picturebox.GetPositionViewToWorld(new MyVector(e.X, e.Y, 0));
                _curMousePoint  = _mouseDownPoint.Clone();
                _prevMousePositions.Clear();
                _tempStationaryObjects.Clear();         // this should be cleared by now anyway
            }

            if (e.Button == MouseButtons.Left)
            {
                #region Left

                _isMouseDown = MouseButtonDown.Left;

                // Get all the blips
                List <RadarBlip> remainingBlips = new List <RadarBlip>(_map.GetAllBlips());

                bool selectedPrevious = false;
                #region See if they selected one of the previously selected objects

                foreach (long token in _selectedObjects)
                {
                    RadarBlip blip = FindAndRemove(token, remainingBlips);

                    if (blip == null)
                    {
                        continue;
                    }

                    if (selectedPrevious)
                    {
                        // I just wanted to remove this blip from the total list
                        continue;
                    }

                    if (SelectionTest(blip, _curMousePoint))
                    {
                        selectedPrevious = true;
                    }
                }

                #endregion

                // Check for ctrl or shift key being pressed (if they are, don't clear the previous)
                if (!selectedPrevious && !(_isShiftPressed || _isCtrlPressed))
                {
                    _selectedObjects.Clear();
                }

                bool selectedNew = false;
                #region See if they clicked on any other objects

                foreach (RadarBlip blip in remainingBlips)
                {
                    if (SelectionTest(blip, _curMousePoint))
                    {
                        _selectedObjects.Add(blip.Token);
                        selectedNew = true;
                    }
                }

                #endregion

                // Set my mode
                if (selectedPrevious || selectedNew)
                {
                    _mode = SelectionMode.Selected;

                    #region Rebuild the offsets list (and temp stationary)

                    _draggingPositionOffsets.Clear();
                    foreach (RadarBlip blip in _map.GetAllBlips())
                    {
                        if (_selectedObjects.Contains(blip.Token))
                        {
                            _draggingPositionOffsets.Add(blip.Token, blip.Sphere.Position - _curMousePoint);

                            if (blip.CollisionStyle == CollisionStyle.Standard)
                            {
                                _tempStationaryObjects.Add(blip.Token);
                                blip.CollisionStyle = CollisionStyle.Stationary;
                            }
                        }
                    }

                    #endregion
                }
                else
                {
                    _mode = SelectionMode.Rectangle;
                }

                #endregion
            }
            else if (e.Button == MouseButtons.Right)
            {
                #region Right

                if (_mode == SelectionMode.Selected && _selectedObjects.Count > 0)
                {
                    _isMouseDown = MouseButtonDown.Right;
                }
                else
                {
                    // If nothing is selected, then there is nothing for me to do
                    _isMouseDown = MouseButtonDown.None;
                }

                #endregion
            }
        }