private void panel1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { color = Color.Red; } else if (e.Button == MouseButtons.Right) { color = Color.Green; } pen.Color = color; panel1.BackColor = Color.AliceBlue; // g.DrawEllipse(pen, 100, 100, 200, 200) //g.DrawArc(pen, e.X, e.Y + 50, e.Y + 10, e.X - 10, e.Y - 10, e.X + 20); g.DrawPie(pen, e.X, e.Y + 50, e.Y + 10, e.X - 10, e.Y - 10, e.X + 20); g.DrawRectangle(pen, 2, 2, 10, 10); Ship(e.X, e.Y, color); }
private void inkCanvas_MouseMove(object sender, MouseEventArgs e) { if (drawing) { Pen pen = new Pen(System.Drawing.Color.FromArgb(255, mainView.ResultColor.R, mainView.ResultColor.G, mainView.ResultColor.B )); pen.Width = Convert.ToSingle(mainView.BorderWidth); if (!mainView.IsExperiment) { Image img = Image.FromHbitmap(tempBitmap.GetHbitmap()); mainView.WorkImage = new Bitmap(img); } Graphics g = Graphics.FromImage(mainView.WorkImage); SolidBrush brush = new SolidBrush(pen.Color); Point point = e.GetPosition(inkCanvas); if (mainView.IsRectangle) { RectangleF rect = new RectangleF(Math.Min((int)startPoint.X, (int)point.X), Math.Min((int)startPoint.Y, (int)point.Y), Math.Abs((int)point.X - (int)startPoint.X), Math.Abs((int)point.Y - (int)startPoint.Y)); if (mainView.IsFill) { g.FillRectangle(brush, rect); } else { g.DrawRectangle(pen, System.Drawing.Rectangle.Round(rect)); } } else if (mainView.IsEllipse) { RectangleF rect = new RectangleF((int)startPoint.X, (int)startPoint.Y, (int)point.X - (int)startPoint.X, (int)point.Y - (int)startPoint.Y); if (mainView.IsFill) { g.FillEllipse(brush, rect); } else { g.DrawEllipse(pen, System.Drawing.Rectangle.Round(rect)); } } else if (mainView.IsLine) { g.DrawLine(pen, (int)startPoint.X, (int)startPoint.Y, (int)point.X, (int)point.Y); } else if (mainView.IsText) { g.DrawString(mainView.ResultText, mainView.ResultFont, brush, (int)point.X, (int)point.Y); } else if (mainView.IsArc) { RectangleF rect = new RectangleF(Math.Min((int)startPoint.X, (int)point.X), Math.Min((int)startPoint.Y, (int)point.Y), Math.Abs((int)point.X - (int)startPoint.X), Math.Abs((int)point.Y - (int)startPoint.Y)); try { g.DrawArc(pen, rect, mainView.StartAngle, mainView.SweepAngle); } catch { }; } if (mainView.IsPie) { System.Drawing.Rectangle rect = new System.Drawing.Rectangle(Math.Min((int)startPoint.X, (int)point.X), Math.Min((int)startPoint.Y, (int)point.Y), Math.Abs((int)point.X - (int)startPoint.X), Math.Abs((int)point.Y - (int)startPoint.Y)); try { if (mainView.IsFill) { g.FillPie(brush, rect, mainView.StartAngle, mainView.SweepAngle); } else { g.DrawPie(pen, rect, mainView.StartAngle, mainView.SweepAngle); } } catch { }; } mainView.WorkImage = mainView.WorkImage; } }