I have work with imagen editor, in where load image and tried make Zoom in/out together with draw lines.
- In the moment of make Zoom the lines can´t resize de lines, only cant zoom the graphics and the coordinates not rotate.
- For rotate can´t resixe the lines, only can rotate the graphics, the coordinates not rotate.
someone can help me!! thanks.
For draw the line in the picture:
private void image_Paint(object sender, PaintEventArgs e)
{
int bDos, dDos, aDos, cDos; ;
double puntoADos, puntoBDos, zDos, mmDos, resultDos;
e.Graphics.ScaleTransform(1.06F, 1.06F);
if (linea.BackColor == Color.FromArgb(255, 0, 0) || girar.BackColor == Color.FromArgb(255, 0, 0) || mover.BackColor == Color.FromArgb(255, 0, 0) || zoom.BackColor == Color.FromArgb(255, 0, 0) || zoomOut.BackColor == Color.FromArgb(255, 0, 0))
{
for (int i = 0; i < Pt1.Count; i++)
{
Pen greenPen = new Pen(Colores.BackColor);
e.Graphics.DrawLine(greenPen, Pt1[i], Pt2[i]);
}
int Talvez = 0;
foreach (Point pt in Pt1)
{
Rectangle rect = new Rectangle(pt.X - object_radius, pt.Y - object_radius, 2 * object_radius + 1, 2 * object_radius + 1);
e.Graphics.FillEllipse(Brushes.Red, rect);
e.Graphics.DrawEllipse(Pens.Red, rect);
aDos = pt.X;
cDos = pt.Y;
Point ptFinal = Pt2[Talvez];
Rectangle RectFinal = new Rectangle(ptFinal.X - object_radius, ptFinal.Y - object_radius, 2 * object_radius + 1, 2 * object_radius + 1);
e.Graphics.FillEllipse(Brushes.Red, RectFinal);
e.Graphics.DrawEllipse(Pens.Red, RectFinal);
bDos = ptFinal.X;
dDos = ptFinal.Y;
puntoADos = Math.Pow(bDos - aDos, 2);
puntoBDos = Math.Pow(dDos - cDos, 2);
zDos = Math.Sqrt(puntoADos + puntoBDos);
mmDos = zDos / 3.779527559;
resultDos = Math.Round(mmDos, 2);
string drawString = Convert.ToString(resultDos);
Font drawFont = new Font("Arial", 8);
SolidBrush myBrush = new SolidBrush(Color.FromArgb(100, 245, 171, 0));
e.Graphics.FillRectangle(myBrush, new Rectangle(ptFinal.X + 5, ptFinal.Y + 2, 60, 20));
SolidBrush drawBrush = new SolidBrush(Color.Yellow);
e.Graphics.DrawString(" " + drawString + " mm", drawFont, drawBrush, ptFinal.X + 5, ptFinal.Y + 5);
Talvez++;
e.Graphics.Transform = MyMatrix;
}
if (IsDrawing)
{
Pen greenPen = new Pen(Colores.BackColor);
e.Graphics.DrawLine(greenPen, NewPt1, NewPt2);
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
}
}
}
For change the cursor for draw or move pictureBox:
private void image_MouseMove(object sender, MouseEventArgs e)
{
if (linea.BackColor == Color.FromArgb(255, 0, 0) || zoom.BackColor == Color.FromArgb(255, 0, 0))
{
Cursor new_cursor = Cursors.Cross;
Point hit_point;
int segment_number;
if (MouseIsOverEndpoint(e.Location, out segment_number, out hit_point))
{
new_cursor = Cursors.Hand;
}
else if (MouseIsOverSegment(e.Location, out segment_number))
{
new_cursor = Cursors.Hand;
}
if (image.Cursor != new_cursor)
image.Cursor = new_cursor;
image.Refresh();
}
if (mover.BackColor == Color.FromArgb(255, 0, 0))
{
if (e.Button == MouseButtons.Left)
{
panel1.Location = new Point(panel1.Left + e.X - izquierdo, panel1.Top + e.Y - alto);
}
}
}
What I have tried:
- Can make Zoom in/out in the picturebox with image.Size = new Size(image.Width + 50, image.Height + 50).
- For Zoom graphics occupy e.graphics.ScaledTransform(1.06F, 1.06F);
- this is link where this the application https://1drv.ms/f/s!ArkkNJAikHkShFAoiXCExZw3ILAf