コード例 #1
0
ファイル: DrawArea.cs プロジェクト: from983002/HeatSink
        private void Point_MouseUp(object sender, MouseEventArgs e)
        {
            if (_selectMode == SelectionMode.NetSelection)
            {
                // Remove old selection rectangle
                ControlPaint.DrawReversibleFrame(
                    RectangleToScreen(DrawRectangle.GetNormalizedRectangle(_startPoint, _lastPoint)),
                    Color.Black,
                    FrameStyle.Dashed);

                // Make group selection
                _graphicsList.SelectInRectangle(DrawRectangle.GetNormalizedRectangle(_startPoint, _lastPoint));

                _selectMode = SelectionMode.None;
            }

            if (_resizedObject != null)
            {
                // after resizing
                _resizedObject.Normalize();
                _resizedObject = null;
            }

            if (_graphicsList.Count > 0)
            {
                ResizeAreaCheck();
            }


            pictureBox1.Capture = false;
            pictureBox1.Refresh();
        }
コード例 #2
0
        /// <summary>
        /// Draw rectangle
        /// </summary>
        /// <param name="g"></param>
        public override void Draw(Graphics g)
        {
            Pen pen = new Pen(Color.LawnGreen, 1);

            g.DrawRectangle(pen, DrawRectangle.GetNormalizedRectangle(Rectangle));

            pen.Dispose();
        }
コード例 #3
0
        /// <summary>
        /// Clone this instance
        /// </summary>
        public override DrawObject Clone()
        {
            DrawRectangle drawRectangle = new DrawRectangle();

            drawRectangle.rectangle = this.rectangle;

            FillDrawObjectFields(drawRectangle);
            return(drawRectangle);
        }
コード例 #4
0
 /// <summary>
 /// Normalize rectangle
 /// </summary>
 public override void Normalize()
 {
     rectangle = DrawRectangle.GetNormalizedRectangle(rectangle);
 }
コード例 #5
0
ファイル: DrawArea.cs プロジェクト: from983002/HeatSink
        private void Point_MouseMove(object sender, MouseEventArgs e)
        {
            var    point    = new Point(e.X, e.Y);
            Point  oldPoint = _lastPoint;
            Cursor cursor   = null;

            // set cursor when mouse button is not pressed
            if (e.Button == MouseButtons.None)
            {
                //Cursor cursor = null;
                _selectMode = SelectionMode.Move;
                for (int i = 0; i < _graphicsList.Count; i++)
                {
                    int n = _graphicsList[i].HitTest(point);

                    if (n > 0)
                    {
                        cursor = _graphicsList[i].GetHandleCursor(n);
                        break;
                    }
                }

                if (cursor == null)
                {
                    cursor = Cursors.Default;
                }

                pictureBox1.Cursor = cursor;

                return;
            }

            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            // Find difference between previous and current position
            int dx = e.X - _lastPoint.X;
            int dy = e.Y - _lastPoint.Y;

            _lastPoint.X = e.X;
            _lastPoint.Y = e.Y;

            // resize
            if (_selectMode == SelectionMode.Size)
            {
                if (_resizedObject != null)
                {
                    _resizedObject.MoveHandleTo(point, _resizedObjectHandle);
                    pictureBox1.Refresh();
                }
            }

            // move
            if (_selectMode == SelectionMode.Move)
            {
                foreach (DrawObject o in _graphicsList.Selection)
                {
                    o.Move(dx, dy);
                }

                pictureBox1.Cursor = Cursors.SizeAll;
                pictureBox1.Refresh();
            }

            if (_selectMode == SelectionMode.NetSelection)
            {
                // Remove old selection rectangle
                ControlPaint.DrawReversibleFrame(RectangleToScreen(DrawRectangle.GetNormalizedRectangle(_startPoint, oldPoint)), Color.Black, FrameStyle.Dashed);

                // Draw new selection rectangle
                ControlPaint.DrawReversibleFrame(RectangleToScreen(DrawRectangle.GetNormalizedRectangle(_startPoint, point)), Color.Black, FrameStyle.Dashed);
            }
        }
コード例 #6
0
ファイル: DrawArea.cs プロジェクト: from983002/HeatSink
        private void Point_MouseDown(object sender, MouseEventArgs e)
        {
            _selectMode = SelectionMode.None;
            var downPoint = new Point(e.X, e.Y);

            int selectObject = Now_Select_Object_Is(downPoint);

            if (selectObject > -1)
            {
                Now_Select_Grid_Row(selectObject);
            }

            // Test for resizing (only if control is selected, cursor is on the handle)
            foreach (DrawObject o in _graphicsList.Selection)
            {
                selectedListNo++;
                int handleNumber = o.HitTest(downPoint);
                Trace.WriteLine(handleNumber.ToString());
                if (handleNumber > 0)
                {
                    _selectMode = SelectionMode.Size;

                    // keep resized object in class member
                    _resizedObject       = o;
                    _resizedObjectHandle = handleNumber;

                    // Since we want to resize only one object, unselect all other objects
                    _graphicsList.UnselectAll();
                    o.Selected = true;

                    break;
                }
            }

            // Test for move (cursor is on the object)
            if (_selectMode == SelectionMode.None)
            {
                int        n1 = _graphicsList.Count;
                DrawObject o  = null;

                for (int i = 0; i < n1; i++)
                {
                    if (_graphicsList[i].HitTest(downPoint) == 0)
                    {
                        o = _graphicsList[i];
                        break;
                    }
                }

                if (o != null)
                {
                    _selectMode = SelectionMode.Move;

                    // Unselect all if Ctrl is not pressed and clicked object is not selected yet
                    if ((ModifierKeys & Keys.Control) == 0 && !o.Selected)
                    {
                        _graphicsList.UnselectAll();
                    }

                    // Select clicked object
                    o.Selected = true;

                    pictureBox1.Cursor = Cursors.SizeAll;
                }
            }

            // Net selection
            if (_selectMode == SelectionMode.None)
            {
                // click on background
                if ((ModifierKeys & Keys.Control) == 0)
                {
                    _graphicsList.UnselectAll();
                }

                _selectMode = SelectionMode.NetSelection;
            }

            _lastPoint.X  = e.X;
            _lastPoint.Y  = e.Y;
            _startPoint.X = e.X;
            _startPoint.Y = e.Y;

            pictureBox1.Capture = true;
            pictureBox1.Refresh();

            if (_selectMode == SelectionMode.NetSelection)
            {
                // Draw selection rectangle in initial position
                ControlPaint.DrawReversibleFrame(
                    RectangleToScreen(DrawRectangle.GetNormalizedRectangle(_startPoint, _lastPoint)), Color.Black,
                    FrameStyle.Dashed);
            }
        }