private void PaintBox_MouseClick(object sender, MouseEventArgs e) { Point point = Point_Initialization(Img, e.X, e.Y); if (Flag == false) { StartX = point.X; //first click we get the 2 start points// StartY = point.Y; Flag = true; } else { EndX = point.X; // second click we get the end points (flag=false)// EndY = point.Y; switch (DrawStyle.Text) { case "קו": g.DrawLine(pencel, StartX, StartY, EndX, EndY); break; case "אליפסה": g.DrawEllipse(pencel, StartX, StartY, EndX - StartX, EndY - StartY); break; } PaintBox.Refresh(); Flag = false; } }
private void FlipY_Click(object sender, EventArgs e) { PaintBox.Image.RotateFlip(RotateFlipType.RotateNoneFlipY); Img = new Bitmap(PaintBox.Image); g = Graphics.FromImage(Img); PaintBox.Image = Img; PaintBox.Refresh(); RotatePanel.Visible = false; }
private void backColors_Click(object sender, EventArgs e) { if (ColorSelect.ShowDialog() == System.Windows.Forms.DialogResult.OK) { PaintBox.BackColor = ColorSelect.Color; g.Clear(ColorSelect.Color); PaintBox.Refresh(); } }
private void PaintBox_MouseMove(object sender, MouseEventArgs e) { Xaxis = e.X; Yaxis = e.Y; YboxLocation.Text = Yaxis.ToString(); XboxLocation.Text = Xaxis.ToString(); secondPoint = e.Location; if (draw) { //g = PaintBox.CreateGraphics(); switch (CurrItem) { case Item.Rectangle: break; case Item.Ellipse: break; case Item.Eraser: g.FillEllipse(new SolidBrush(PaintBox.BackColor), e.X - x + x, e.Y - y + y, Convert.ToInt32(ToolSizeBox.Text), Convert.ToInt32(ToolSizeBox.Text)); break; case Item.Pen: g.DrawLine(new Pen(paintcolor, Convert.ToInt32(ToolSizeBox.Text)), firstPoint, secondPoint); firstPoint = secondPoint; break; case Item.Line: break; case Item.Triangle: break; case Item.RightTriangle: break; default: break; } PaintBox.Refresh(); } }
private void PictureView_TextChanged(object sender, EventArgs e) { switch (PictureView.Text) { case "Zoom": PaintBox.SizeMode = PictureBoxSizeMode.Zoom; break; case "Strech": PaintBox.SizeMode = PictureBoxSizeMode.StretchImage; break; case "Normal": PaintBox.SizeMode = PictureBoxSizeMode.Normal; break; } PaintBox.Refresh(); }
private void PaintBox_MouseUp(object sender, MouseEventArgs e) { draw = false; lx = e.X; ly = e.Y; switch (CurrItem) { case Item.Rectangle: g.DrawRectangle(new Pen(paintcolor), x, y, secondPoint.X - x, secondPoint.Y - y); break; case Item.Ellipse: g.DrawEllipse(new Pen(paintcolor), x, y, secondPoint.X - x, secondPoint.Y - y); break; case Item.Eraser: g.FillEllipse(new SolidBrush(PaintBox.BackColor), secondPoint.X - x + x, secondPoint.Y - y + y, Convert.ToInt32(ToolSizeBox.Text), Convert.ToInt32(ToolSizeBox.Text)); break; case Item.Pen: break; case Item.Line: g.DrawLine(new Pen(paintcolor), firstPoint, secondPoint); break; case Item.FloodFill: break; case Item.Triangle: Point[] points = { new Point(x, secondPoint.Y), new Point((secondPoint.X + x) / 2, y), new Point(secondPoint.X, secondPoint.Y) }; g.DrawPolygon(new Pen(paintcolor), points); break; case Item.RightTriangle: g.DrawPolygon(new Pen(paintcolor), PryamugTreug(firstPoint, secondPoint)); break; default: break; } PaintBox.Refresh(); }
private void Paintform_Resize(object sender, EventArgs e) { PaintBox.Width = this.Width - 2 * PaintBox.Left; PaintBox.Height = this.Height - 2 * PaintBox.Top; PaintBox.Refresh(); }
private void DeleteFile_Btn_Click(object sender, EventArgs e) { g.Clear(Color.White); PaintBox.Refresh(); }