Example #1
0
        private void DrawPanel_MouseMove(object sender, MouseEventArgs e)
        {
            if (!_startPaint)
            {
                return;
            }

            Reload(_bitmap_save);
            _currentShape.Init(e.X, e.Y);
            _currentShape.Draw(_graphics, _pen);
            DrawPanel.Image = _map;
        }
Example #2
0
        private void PanelDraw_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left && CurrentFigure != null)
            {
                using (var graphics = PanelDraw.CreateGraphics())
                {
                    CurrentFigure.Color    = colorDialog1.Color;
                    CurrentFigure.Location = e.Location;
                    CurrentFigure.Draw(graphics);
                    CurrentFigure.Index = FigureList
                                          .Select(f => f.Index)
                                          .OrderBy(i => i)
                                          .LastOrDefault() + 1;
                }

                FigureList.Add(CurrentFigure);
                Mode.Text = "Right Click On The Figure Will Select It";

                CurrentFigure = null;
                if (SelectedFigure != null)
                {
                    SelectedFigure.Color = OriginalColor;
                    SelectedFigure       = null;
                }
            }

            else if (e.Button == MouseButtons.Right)
            {
                //If the figure is no longer selected, figure's color turnes back to original color
                if (SelectedFigure != null)
                {
                    SelectedFigure.Color = OriginalColor;
                    Mode.Text            = "Figure:";
                }

                SelectedFigure = FigureList
                                 .OrderByDescending(i => i.Index)
                                 .Where(f => f.Contains(e.Location))
                                 .FirstOrDefault();

                //Selected figure turns Red
                if (SelectedFigure != null)
                {
                    OriginalColor        = SelectedFigure.Color;
                    SelectedFigure.Color = Color.Red;

                    if (SelectedFigure is Circle)
                    {
                        Mode.Text = "Figure: Circle is Selected";
                    }
                    if (SelectedFigure is Triangle)
                    {
                        Mode.Text = "Figure: Triangle is Selected";
                    }
                    if (SelectedFigure is Rectangle)
                    {
                        Mode.Text = "Figure: Rectangle is Selected";
                    }
                }

                //Checking if selected figure is clicked once again- figure is moving
                if (SelectedFigure != null && e.Button == MouseButtons.Right)
                {
                    IsMoving = true;
                }

                if (SelectedFigure != null)
                {
                    DeltaX = e.Location.X - SelectedFigure.Location.X;
                    DeltaY = e.Location.Y - SelectedFigure.Location.Y;
                }
            }
            CalculateAreaPermiters();
            PanelDraw.Invalidate();
        }
Example #3
0
 private void DrawObjectsWithoutHiddenEdges()
 {
     ReInitPolyShape();
     polyShape.Draw(CreateGraphics(), lightSource, COLOR_TO_DRAW, cbFill.Checked, cbDrawEdges.Checked);
 }