Drawing Lines in Autoscroll form c#
up vote
1
down vote
favorite
I just want to transform the points when scrolling. I already use the e.Graphics.TranslateTransform() but it only works on drawing. The point of the line wont change the offset.
private void Form1_Scroll(object sender, ScrollEventArgs e)
Point scrollOffset = this.AutoScrollPosition;
for (int lk = 0; lk < Pt1.Count; lk++)
Pt1[lk] = new Point(Pt1[lk].X + scrollOffset.X, Pt1[lk].Y + scrollOffset.Y);
Pt2[lk] = new Point(Pt2[lk].X + scrollOffset.X, Pt2[lk].Y + scrollOffset.Y);
this.Invalidate();
this.Update();
this.Refresh();
private void Form1_Paint(object sender, PaintEventArgs e)
Point scrollOffset = this.AutoScrollPosition;
e.Graphics.TranslateTransform(scrollOffset.X, scrollOffset.Y);
e.Graphics.Clear(this.BackColor);
e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
Pen greenPen = new Pen(Color.Green,1);
greenPen.DashPattern = new float 5.0F, 5.0F, 5.0F, 5.0F ;
Pen red = new Pen(Color.Red,1);
red.DashPattern = new float 5.0F, 5.0F, 5.0F, 5.0F ;
Pen Grey = new Pen(Color.Gray,1);
Grey.DashPattern = new float 5.0F, 5.0F, 5.0F, 5.0F ;
#region "Draw Line using cursor"
Pen SolidGreen = new Pen(Color.Green, 1);
Pen SolidGrey = new Pen(Color.Gray, 1);
Pen Red = new Pen(Color.Red, 1);
for (int pl = 0; pl < Pt1j.Count; pl++)
PointF pointsj = new PointF
new PointF(Pt2j[pl].X, Pt2j[pl].Y),
new PointF(Pt3j[pl].X , Pt3j[pl].Y),
new PointF(Pt4j[pl].X , Pt4j[pl].Y),
new PointF(Pt5j[pl].X , Pt5j[pl].Y),
;
e.Graphics.DrawLine(Pens.Green, Pt1j[pl].X , Pt1j[pl].Y, Pt2j[pl].X, Pt2j[pl].Y);
e.Graphics.DrawCurve(Pens.Green, pointsj);
e.Graphics.DrawLine(Pens.Green, Pt5j[pl].X , Pt5j[pl].Y, Pt6j[pl].X, Pt6j[pl].Y);
for (int pl = 0; pl < Pt1DashedGray.Count; pl++)
e.Graphics.DrawLine(Grey, Pt1DashedGray[pl], Pt2DashedGray[pl]);
PointF pointsdhg = new PointF
new PointF(Pt2DashedGray[pl].X, Pt2DashedGray[pl].Y),
new PointF(Pt3DashedGray[pl].X, Pt3DashedGray[pl].Y),
new PointF(Pt4DashedGray[pl].X, Pt4DashedGray[pl].Y),
new PointF(Pt5DashedGray[pl].X, Pt5DashedGray[pl].Y),
;
e.Graphics.DrawCurve(Grey, pointsdhg);
e.Graphics.DrawLine(Grey, Pt5DashedGray[pl], Pt6DashedGray[pl]);
for (int pl = 0; pl < Pt1SolidGray.Count; pl++)
e.Graphics.DrawLine(SolidGrey, Pt1SolidGray[pl], Pt2SolidGray[pl]);
PointF pointsdhg = new PointF
new PointF(Pt2SolidGray[pl].X, Pt2SolidGray[pl].Y),
new PointF(Pt3SolidGray[pl].X, Pt3SolidGray[pl].Y),
new PointF(Pt4SolidGray[pl].X, Pt4SolidGray[pl].Y),
new PointF(Pt5SolidGray[pl].X, Pt5SolidGray[pl].Y),
;
e.Graphics.DrawCurve(SolidGrey, pointsdhg);
e.Graphics.DrawLine(SolidGrey, Pt5SolidGray[pl], Pt6SolidGray[pl]);
for (int pl = 0; pl < Pt1DashGreen.Count; pl++)
e.Graphics.DrawLine(greenPen, Pt1DashGreen[pl], Pt2DashGreen[pl]);
PointF pointsdhg = new PointF
new PointF(Pt2DashGreen[pl].X, Pt2DashGreen[pl].Y),
new PointF(Pt3DashGreen[pl].X, Pt3DashGreen[pl].Y),
new PointF(Pt4DashGreen[pl].X, Pt4DashGreen[pl].Y),
new PointF(Pt5DashGreen[pl].X, Pt5DashGreen[pl].Y),
;
e.Graphics.DrawCurve(greenPen, pointsdhg);
e.Graphics.DrawLine(greenPen, Pt5DashGreen[pl], Pt6DashGreen[pl]);
for (int i = 0; i < Pt1.Count; i++)
e.Graphics.DrawLine(SolidGreen, Pt1[i], Pt2[i]);
for (int l = 0; l < DashedGreen1.Count; l++)
e.Graphics.DrawLine(greenPen, DashedGreen1[l], DashedGreen2[l]);
for (int k = 0; k < SolidGrey1.Count; k++)
e.Graphics.DrawLine(SolidGrey, SolidGrey1[k], SolidGrey2[k]);
for (int j = 0; j < DashedGrey1.Count; j++)
e.Graphics.DrawLine(Grey, DashedGrey1[j], DashedGrey2[j]);
if (IsDrawing)
e.Graphics.DrawLine(Red, NewPt1.X, NewPt1.Y, NewPt2.X, NewPt2.Y);
if (Draw_Dashed_Green)
e.Graphics.DrawLine(red, DashedGreenPT1, DashedGreenPT2);
if (Draw_Solid_Grey)
e.Graphics.DrawLine(Red, SolidGreyPT1, SolidGreyPT2);
if (Draw_dashed_Grey)
e.Graphics.DrawLine(red, DashedGreyPT1, DashedGreyPT2);
Need Help
Here is my code so far.
BDW, The point of the line is stored in the list from.
The Drawn lines in Paint event also include the line jumpers which has 6 points on it to make a jumps.
So the only problem is I would like to change the Points of the lines as I use the scroll bar.
Thanks for answering my question.
c# winforms gdi+
|
show 3 more comments
up vote
1
down vote
favorite
I just want to transform the points when scrolling. I already use the e.Graphics.TranslateTransform() but it only works on drawing. The point of the line wont change the offset.
private void Form1_Scroll(object sender, ScrollEventArgs e)
Point scrollOffset = this.AutoScrollPosition;
for (int lk = 0; lk < Pt1.Count; lk++)
Pt1[lk] = new Point(Pt1[lk].X + scrollOffset.X, Pt1[lk].Y + scrollOffset.Y);
Pt2[lk] = new Point(Pt2[lk].X + scrollOffset.X, Pt2[lk].Y + scrollOffset.Y);
this.Invalidate();
this.Update();
this.Refresh();
private void Form1_Paint(object sender, PaintEventArgs e)
Point scrollOffset = this.AutoScrollPosition;
e.Graphics.TranslateTransform(scrollOffset.X, scrollOffset.Y);
e.Graphics.Clear(this.BackColor);
e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
Pen greenPen = new Pen(Color.Green,1);
greenPen.DashPattern = new float 5.0F, 5.0F, 5.0F, 5.0F ;
Pen red = new Pen(Color.Red,1);
red.DashPattern = new float 5.0F, 5.0F, 5.0F, 5.0F ;
Pen Grey = new Pen(Color.Gray,1);
Grey.DashPattern = new float 5.0F, 5.0F, 5.0F, 5.0F ;
#region "Draw Line using cursor"
Pen SolidGreen = new Pen(Color.Green, 1);
Pen SolidGrey = new Pen(Color.Gray, 1);
Pen Red = new Pen(Color.Red, 1);
for (int pl = 0; pl < Pt1j.Count; pl++)
PointF pointsj = new PointF
new PointF(Pt2j[pl].X, Pt2j[pl].Y),
new PointF(Pt3j[pl].X , Pt3j[pl].Y),
new PointF(Pt4j[pl].X , Pt4j[pl].Y),
new PointF(Pt5j[pl].X , Pt5j[pl].Y),
;
e.Graphics.DrawLine(Pens.Green, Pt1j[pl].X , Pt1j[pl].Y, Pt2j[pl].X, Pt2j[pl].Y);
e.Graphics.DrawCurve(Pens.Green, pointsj);
e.Graphics.DrawLine(Pens.Green, Pt5j[pl].X , Pt5j[pl].Y, Pt6j[pl].X, Pt6j[pl].Y);
for (int pl = 0; pl < Pt1DashedGray.Count; pl++)
e.Graphics.DrawLine(Grey, Pt1DashedGray[pl], Pt2DashedGray[pl]);
PointF pointsdhg = new PointF
new PointF(Pt2DashedGray[pl].X, Pt2DashedGray[pl].Y),
new PointF(Pt3DashedGray[pl].X, Pt3DashedGray[pl].Y),
new PointF(Pt4DashedGray[pl].X, Pt4DashedGray[pl].Y),
new PointF(Pt5DashedGray[pl].X, Pt5DashedGray[pl].Y),
;
e.Graphics.DrawCurve(Grey, pointsdhg);
e.Graphics.DrawLine(Grey, Pt5DashedGray[pl], Pt6DashedGray[pl]);
for (int pl = 0; pl < Pt1SolidGray.Count; pl++)
e.Graphics.DrawLine(SolidGrey, Pt1SolidGray[pl], Pt2SolidGray[pl]);
PointF pointsdhg = new PointF
new PointF(Pt2SolidGray[pl].X, Pt2SolidGray[pl].Y),
new PointF(Pt3SolidGray[pl].X, Pt3SolidGray[pl].Y),
new PointF(Pt4SolidGray[pl].X, Pt4SolidGray[pl].Y),
new PointF(Pt5SolidGray[pl].X, Pt5SolidGray[pl].Y),
;
e.Graphics.DrawCurve(SolidGrey, pointsdhg);
e.Graphics.DrawLine(SolidGrey, Pt5SolidGray[pl], Pt6SolidGray[pl]);
for (int pl = 0; pl < Pt1DashGreen.Count; pl++)
e.Graphics.DrawLine(greenPen, Pt1DashGreen[pl], Pt2DashGreen[pl]);
PointF pointsdhg = new PointF
new PointF(Pt2DashGreen[pl].X, Pt2DashGreen[pl].Y),
new PointF(Pt3DashGreen[pl].X, Pt3DashGreen[pl].Y),
new PointF(Pt4DashGreen[pl].X, Pt4DashGreen[pl].Y),
new PointF(Pt5DashGreen[pl].X, Pt5DashGreen[pl].Y),
;
e.Graphics.DrawCurve(greenPen, pointsdhg);
e.Graphics.DrawLine(greenPen, Pt5DashGreen[pl], Pt6DashGreen[pl]);
for (int i = 0; i < Pt1.Count; i++)
e.Graphics.DrawLine(SolidGreen, Pt1[i], Pt2[i]);
for (int l = 0; l < DashedGreen1.Count; l++)
e.Graphics.DrawLine(greenPen, DashedGreen1[l], DashedGreen2[l]);
for (int k = 0; k < SolidGrey1.Count; k++)
e.Graphics.DrawLine(SolidGrey, SolidGrey1[k], SolidGrey2[k]);
for (int j = 0; j < DashedGrey1.Count; j++)
e.Graphics.DrawLine(Grey, DashedGrey1[j], DashedGrey2[j]);
if (IsDrawing)
e.Graphics.DrawLine(Red, NewPt1.X, NewPt1.Y, NewPt2.X, NewPt2.Y);
if (Draw_Dashed_Green)
e.Graphics.DrawLine(red, DashedGreenPT1, DashedGreenPT2);
if (Draw_Solid_Grey)
e.Graphics.DrawLine(Red, SolidGreyPT1, SolidGreyPT2);
if (Draw_dashed_Grey)
e.Graphics.DrawLine(red, DashedGreyPT1, DashedGreyPT2);
Need Help
Here is my code so far.
BDW, The point of the line is stored in the list from.
The Drawn lines in Paint event also include the line jumpers which has 6 points on it to make a jumps.
So the only problem is I would like to change the Points of the lines as I use the scroll bar.
Thanks for answering my question.
c# winforms gdi+
Can you explain what is the effect that you looking for? Are you trying to move the lines position on the surface using the Scrollbars? Or keep them steady? TheAutoScrollPosition
reports negative values. (Btw, you just needInvalidate()
)
– Jimi
yesterday
Uhmmm ... I would like to move the lines position when using the scrollbar. I already use Invalidate() and I put the e.Graphics.TranslateTransform() in the paint event and it works. But the only problem is the point didnt move , only the drawn lines.
– jayromel lawas
yesterday
Then post the Paint event code. As it is, this is very uncleary to me what you're trying to achieve. Also because, as I said beforeAutoScrollPosition
gives negative values. Then, I already use Invalidate(). I meant you needInvalidate()
alone. AddingUpdate()
andRefresh()
causes a second repaint for eachScroll()
event change.
– Jimi
yesterday
private void Form1_Paint(object sender, PaintEventArgs e) { Point scrollOffset = this.AutoScrollPosition; e.Graphics.TranslateTransform(scrollOffset.X, scrollOffset.Y); e.Graphics.Clear(this.BackColor);
– jayromel lawas
23 hours ago
Nope, you need to Edit your question, adding any code snippet or description that can further explain your case. Don't insert code in comments.
– Jimi
23 hours ago
|
show 3 more comments
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I just want to transform the points when scrolling. I already use the e.Graphics.TranslateTransform() but it only works on drawing. The point of the line wont change the offset.
private void Form1_Scroll(object sender, ScrollEventArgs e)
Point scrollOffset = this.AutoScrollPosition;
for (int lk = 0; lk < Pt1.Count; lk++)
Pt1[lk] = new Point(Pt1[lk].X + scrollOffset.X, Pt1[lk].Y + scrollOffset.Y);
Pt2[lk] = new Point(Pt2[lk].X + scrollOffset.X, Pt2[lk].Y + scrollOffset.Y);
this.Invalidate();
this.Update();
this.Refresh();
private void Form1_Paint(object sender, PaintEventArgs e)
Point scrollOffset = this.AutoScrollPosition;
e.Graphics.TranslateTransform(scrollOffset.X, scrollOffset.Y);
e.Graphics.Clear(this.BackColor);
e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
Pen greenPen = new Pen(Color.Green,1);
greenPen.DashPattern = new float 5.0F, 5.0F, 5.0F, 5.0F ;
Pen red = new Pen(Color.Red,1);
red.DashPattern = new float 5.0F, 5.0F, 5.0F, 5.0F ;
Pen Grey = new Pen(Color.Gray,1);
Grey.DashPattern = new float 5.0F, 5.0F, 5.0F, 5.0F ;
#region "Draw Line using cursor"
Pen SolidGreen = new Pen(Color.Green, 1);
Pen SolidGrey = new Pen(Color.Gray, 1);
Pen Red = new Pen(Color.Red, 1);
for (int pl = 0; pl < Pt1j.Count; pl++)
PointF pointsj = new PointF
new PointF(Pt2j[pl].X, Pt2j[pl].Y),
new PointF(Pt3j[pl].X , Pt3j[pl].Y),
new PointF(Pt4j[pl].X , Pt4j[pl].Y),
new PointF(Pt5j[pl].X , Pt5j[pl].Y),
;
e.Graphics.DrawLine(Pens.Green, Pt1j[pl].X , Pt1j[pl].Y, Pt2j[pl].X, Pt2j[pl].Y);
e.Graphics.DrawCurve(Pens.Green, pointsj);
e.Graphics.DrawLine(Pens.Green, Pt5j[pl].X , Pt5j[pl].Y, Pt6j[pl].X, Pt6j[pl].Y);
for (int pl = 0; pl < Pt1DashedGray.Count; pl++)
e.Graphics.DrawLine(Grey, Pt1DashedGray[pl], Pt2DashedGray[pl]);
PointF pointsdhg = new PointF
new PointF(Pt2DashedGray[pl].X, Pt2DashedGray[pl].Y),
new PointF(Pt3DashedGray[pl].X, Pt3DashedGray[pl].Y),
new PointF(Pt4DashedGray[pl].X, Pt4DashedGray[pl].Y),
new PointF(Pt5DashedGray[pl].X, Pt5DashedGray[pl].Y),
;
e.Graphics.DrawCurve(Grey, pointsdhg);
e.Graphics.DrawLine(Grey, Pt5DashedGray[pl], Pt6DashedGray[pl]);
for (int pl = 0; pl < Pt1SolidGray.Count; pl++)
e.Graphics.DrawLine(SolidGrey, Pt1SolidGray[pl], Pt2SolidGray[pl]);
PointF pointsdhg = new PointF
new PointF(Pt2SolidGray[pl].X, Pt2SolidGray[pl].Y),
new PointF(Pt3SolidGray[pl].X, Pt3SolidGray[pl].Y),
new PointF(Pt4SolidGray[pl].X, Pt4SolidGray[pl].Y),
new PointF(Pt5SolidGray[pl].X, Pt5SolidGray[pl].Y),
;
e.Graphics.DrawCurve(SolidGrey, pointsdhg);
e.Graphics.DrawLine(SolidGrey, Pt5SolidGray[pl], Pt6SolidGray[pl]);
for (int pl = 0; pl < Pt1DashGreen.Count; pl++)
e.Graphics.DrawLine(greenPen, Pt1DashGreen[pl], Pt2DashGreen[pl]);
PointF pointsdhg = new PointF
new PointF(Pt2DashGreen[pl].X, Pt2DashGreen[pl].Y),
new PointF(Pt3DashGreen[pl].X, Pt3DashGreen[pl].Y),
new PointF(Pt4DashGreen[pl].X, Pt4DashGreen[pl].Y),
new PointF(Pt5DashGreen[pl].X, Pt5DashGreen[pl].Y),
;
e.Graphics.DrawCurve(greenPen, pointsdhg);
e.Graphics.DrawLine(greenPen, Pt5DashGreen[pl], Pt6DashGreen[pl]);
for (int i = 0; i < Pt1.Count; i++)
e.Graphics.DrawLine(SolidGreen, Pt1[i], Pt2[i]);
for (int l = 0; l < DashedGreen1.Count; l++)
e.Graphics.DrawLine(greenPen, DashedGreen1[l], DashedGreen2[l]);
for (int k = 0; k < SolidGrey1.Count; k++)
e.Graphics.DrawLine(SolidGrey, SolidGrey1[k], SolidGrey2[k]);
for (int j = 0; j < DashedGrey1.Count; j++)
e.Graphics.DrawLine(Grey, DashedGrey1[j], DashedGrey2[j]);
if (IsDrawing)
e.Graphics.DrawLine(Red, NewPt1.X, NewPt1.Y, NewPt2.X, NewPt2.Y);
if (Draw_Dashed_Green)
e.Graphics.DrawLine(red, DashedGreenPT1, DashedGreenPT2);
if (Draw_Solid_Grey)
e.Graphics.DrawLine(Red, SolidGreyPT1, SolidGreyPT2);
if (Draw_dashed_Grey)
e.Graphics.DrawLine(red, DashedGreyPT1, DashedGreyPT2);
Need Help
Here is my code so far.
BDW, The point of the line is stored in the list from.
The Drawn lines in Paint event also include the line jumpers which has 6 points on it to make a jumps.
So the only problem is I would like to change the Points of the lines as I use the scroll bar.
Thanks for answering my question.
c# winforms gdi+
I just want to transform the points when scrolling. I already use the e.Graphics.TranslateTransform() but it only works on drawing. The point of the line wont change the offset.
private void Form1_Scroll(object sender, ScrollEventArgs e)
Point scrollOffset = this.AutoScrollPosition;
for (int lk = 0; lk < Pt1.Count; lk++)
Pt1[lk] = new Point(Pt1[lk].X + scrollOffset.X, Pt1[lk].Y + scrollOffset.Y);
Pt2[lk] = new Point(Pt2[lk].X + scrollOffset.X, Pt2[lk].Y + scrollOffset.Y);
this.Invalidate();
this.Update();
this.Refresh();
private void Form1_Paint(object sender, PaintEventArgs e)
Point scrollOffset = this.AutoScrollPosition;
e.Graphics.TranslateTransform(scrollOffset.X, scrollOffset.Y);
e.Graphics.Clear(this.BackColor);
e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
Pen greenPen = new Pen(Color.Green,1);
greenPen.DashPattern = new float 5.0F, 5.0F, 5.0F, 5.0F ;
Pen red = new Pen(Color.Red,1);
red.DashPattern = new float 5.0F, 5.0F, 5.0F, 5.0F ;
Pen Grey = new Pen(Color.Gray,1);
Grey.DashPattern = new float 5.0F, 5.0F, 5.0F, 5.0F ;
#region "Draw Line using cursor"
Pen SolidGreen = new Pen(Color.Green, 1);
Pen SolidGrey = new Pen(Color.Gray, 1);
Pen Red = new Pen(Color.Red, 1);
for (int pl = 0; pl < Pt1j.Count; pl++)
PointF pointsj = new PointF
new PointF(Pt2j[pl].X, Pt2j[pl].Y),
new PointF(Pt3j[pl].X , Pt3j[pl].Y),
new PointF(Pt4j[pl].X , Pt4j[pl].Y),
new PointF(Pt5j[pl].X , Pt5j[pl].Y),
;
e.Graphics.DrawLine(Pens.Green, Pt1j[pl].X , Pt1j[pl].Y, Pt2j[pl].X, Pt2j[pl].Y);
e.Graphics.DrawCurve(Pens.Green, pointsj);
e.Graphics.DrawLine(Pens.Green, Pt5j[pl].X , Pt5j[pl].Y, Pt6j[pl].X, Pt6j[pl].Y);
for (int pl = 0; pl < Pt1DashedGray.Count; pl++)
e.Graphics.DrawLine(Grey, Pt1DashedGray[pl], Pt2DashedGray[pl]);
PointF pointsdhg = new PointF
new PointF(Pt2DashedGray[pl].X, Pt2DashedGray[pl].Y),
new PointF(Pt3DashedGray[pl].X, Pt3DashedGray[pl].Y),
new PointF(Pt4DashedGray[pl].X, Pt4DashedGray[pl].Y),
new PointF(Pt5DashedGray[pl].X, Pt5DashedGray[pl].Y),
;
e.Graphics.DrawCurve(Grey, pointsdhg);
e.Graphics.DrawLine(Grey, Pt5DashedGray[pl], Pt6DashedGray[pl]);
for (int pl = 0; pl < Pt1SolidGray.Count; pl++)
e.Graphics.DrawLine(SolidGrey, Pt1SolidGray[pl], Pt2SolidGray[pl]);
PointF pointsdhg = new PointF
new PointF(Pt2SolidGray[pl].X, Pt2SolidGray[pl].Y),
new PointF(Pt3SolidGray[pl].X, Pt3SolidGray[pl].Y),
new PointF(Pt4SolidGray[pl].X, Pt4SolidGray[pl].Y),
new PointF(Pt5SolidGray[pl].X, Pt5SolidGray[pl].Y),
;
e.Graphics.DrawCurve(SolidGrey, pointsdhg);
e.Graphics.DrawLine(SolidGrey, Pt5SolidGray[pl], Pt6SolidGray[pl]);
for (int pl = 0; pl < Pt1DashGreen.Count; pl++)
e.Graphics.DrawLine(greenPen, Pt1DashGreen[pl], Pt2DashGreen[pl]);
PointF pointsdhg = new PointF
new PointF(Pt2DashGreen[pl].X, Pt2DashGreen[pl].Y),
new PointF(Pt3DashGreen[pl].X, Pt3DashGreen[pl].Y),
new PointF(Pt4DashGreen[pl].X, Pt4DashGreen[pl].Y),
new PointF(Pt5DashGreen[pl].X, Pt5DashGreen[pl].Y),
;
e.Graphics.DrawCurve(greenPen, pointsdhg);
e.Graphics.DrawLine(greenPen, Pt5DashGreen[pl], Pt6DashGreen[pl]);
for (int i = 0; i < Pt1.Count; i++)
e.Graphics.DrawLine(SolidGreen, Pt1[i], Pt2[i]);
for (int l = 0; l < DashedGreen1.Count; l++)
e.Graphics.DrawLine(greenPen, DashedGreen1[l], DashedGreen2[l]);
for (int k = 0; k < SolidGrey1.Count; k++)
e.Graphics.DrawLine(SolidGrey, SolidGrey1[k], SolidGrey2[k]);
for (int j = 0; j < DashedGrey1.Count; j++)
e.Graphics.DrawLine(Grey, DashedGrey1[j], DashedGrey2[j]);
if (IsDrawing)
e.Graphics.DrawLine(Red, NewPt1.X, NewPt1.Y, NewPt2.X, NewPt2.Y);
if (Draw_Dashed_Green)
e.Graphics.DrawLine(red, DashedGreenPT1, DashedGreenPT2);
if (Draw_Solid_Grey)
e.Graphics.DrawLine(Red, SolidGreyPT1, SolidGreyPT2);
if (Draw_dashed_Grey)
e.Graphics.DrawLine(red, DashedGreyPT1, DashedGreyPT2);
Need Help
Here is my code so far.
BDW, The point of the line is stored in the list from.
The Drawn lines in Paint event also include the line jumpers which has 6 points on it to make a jumps.
So the only problem is I would like to change the Points of the lines as I use the scroll bar.
Thanks for answering my question.
c# winforms gdi+
c# winforms gdi+
edited 23 hours ago
asked yesterday
jayromel lawas
114
114
Can you explain what is the effect that you looking for? Are you trying to move the lines position on the surface using the Scrollbars? Or keep them steady? TheAutoScrollPosition
reports negative values. (Btw, you just needInvalidate()
)
– Jimi
yesterday
Uhmmm ... I would like to move the lines position when using the scrollbar. I already use Invalidate() and I put the e.Graphics.TranslateTransform() in the paint event and it works. But the only problem is the point didnt move , only the drawn lines.
– jayromel lawas
yesterday
Then post the Paint event code. As it is, this is very uncleary to me what you're trying to achieve. Also because, as I said beforeAutoScrollPosition
gives negative values. Then, I already use Invalidate(). I meant you needInvalidate()
alone. AddingUpdate()
andRefresh()
causes a second repaint for eachScroll()
event change.
– Jimi
yesterday
private void Form1_Paint(object sender, PaintEventArgs e) { Point scrollOffset = this.AutoScrollPosition; e.Graphics.TranslateTransform(scrollOffset.X, scrollOffset.Y); e.Graphics.Clear(this.BackColor);
– jayromel lawas
23 hours ago
Nope, you need to Edit your question, adding any code snippet or description that can further explain your case. Don't insert code in comments.
– Jimi
23 hours ago
|
show 3 more comments
Can you explain what is the effect that you looking for? Are you trying to move the lines position on the surface using the Scrollbars? Or keep them steady? TheAutoScrollPosition
reports negative values. (Btw, you just needInvalidate()
)
– Jimi
yesterday
Uhmmm ... I would like to move the lines position when using the scrollbar. I already use Invalidate() and I put the e.Graphics.TranslateTransform() in the paint event and it works. But the only problem is the point didnt move , only the drawn lines.
– jayromel lawas
yesterday
Then post the Paint event code. As it is, this is very uncleary to me what you're trying to achieve. Also because, as I said beforeAutoScrollPosition
gives negative values. Then, I already use Invalidate(). I meant you needInvalidate()
alone. AddingUpdate()
andRefresh()
causes a second repaint for eachScroll()
event change.
– Jimi
yesterday
private void Form1_Paint(object sender, PaintEventArgs e) { Point scrollOffset = this.AutoScrollPosition; e.Graphics.TranslateTransform(scrollOffset.X, scrollOffset.Y); e.Graphics.Clear(this.BackColor);
– jayromel lawas
23 hours ago
Nope, you need to Edit your question, adding any code snippet or description that can further explain your case. Don't insert code in comments.
– Jimi
23 hours ago
Can you explain what is the effect that you looking for? Are you trying to move the lines position on the surface using the Scrollbars? Or keep them steady? The
AutoScrollPosition
reports negative values. (Btw, you just need Invalidate()
)– Jimi
yesterday
Can you explain what is the effect that you looking for? Are you trying to move the lines position on the surface using the Scrollbars? Or keep them steady? The
AutoScrollPosition
reports negative values. (Btw, you just need Invalidate()
)– Jimi
yesterday
Uhmmm ... I would like to move the lines position when using the scrollbar. I already use Invalidate() and I put the e.Graphics.TranslateTransform() in the paint event and it works. But the only problem is the point didnt move , only the drawn lines.
– jayromel lawas
yesterday
Uhmmm ... I would like to move the lines position when using the scrollbar. I already use Invalidate() and I put the e.Graphics.TranslateTransform() in the paint event and it works. But the only problem is the point didnt move , only the drawn lines.
– jayromel lawas
yesterday
Then post the Paint event code. As it is, this is very uncleary to me what you're trying to achieve. Also because, as I said before
AutoScrollPosition
gives negative values. Then, I already use Invalidate(). I meant you need Invalidate()
alone. Adding Update()
and Refresh()
causes a second repaint for each Scroll()
event change.– Jimi
yesterday
Then post the Paint event code. As it is, this is very uncleary to me what you're trying to achieve. Also because, as I said before
AutoScrollPosition
gives negative values. Then, I already use Invalidate(). I meant you need Invalidate()
alone. Adding Update()
and Refresh()
causes a second repaint for each Scroll()
event change.– Jimi
yesterday
private void Form1_Paint(object sender, PaintEventArgs e) { Point scrollOffset = this.AutoScrollPosition; e.Graphics.TranslateTransform(scrollOffset.X, scrollOffset.Y); e.Graphics.Clear(this.BackColor);
– jayromel lawas
23 hours ago
private void Form1_Paint(object sender, PaintEventArgs e) { Point scrollOffset = this.AutoScrollPosition; e.Graphics.TranslateTransform(scrollOffset.X, scrollOffset.Y); e.Graphics.Clear(this.BackColor);
– jayromel lawas
23 hours ago
Nope, you need to Edit your question, adding any code snippet or description that can further explain your case. Don't insert code in comments.
– Jimi
23 hours ago
Nope, you need to Edit your question, adding any code snippet or description that can further explain your case. Don't insert code in comments.
– Jimi
23 hours ago
|
show 3 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53219621%2fdrawing-lines-in-autoscroll-form-c-sharp%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Can you explain what is the effect that you looking for? Are you trying to move the lines position on the surface using the Scrollbars? Or keep them steady? The
AutoScrollPosition
reports negative values. (Btw, you just needInvalidate()
)– Jimi
yesterday
Uhmmm ... I would like to move the lines position when using the scrollbar. I already use Invalidate() and I put the e.Graphics.TranslateTransform() in the paint event and it works. But the only problem is the point didnt move , only the drawn lines.
– jayromel lawas
yesterday
Then post the Paint event code. As it is, this is very uncleary to me what you're trying to achieve. Also because, as I said before
AutoScrollPosition
gives negative values. Then, I already use Invalidate(). I meant you needInvalidate()
alone. AddingUpdate()
andRefresh()
causes a second repaint for eachScroll()
event change.– Jimi
yesterday
private void Form1_Paint(object sender, PaintEventArgs e) { Point scrollOffset = this.AutoScrollPosition; e.Graphics.TranslateTransform(scrollOffset.X, scrollOffset.Y); e.Graphics.Clear(this.BackColor);
– jayromel lawas
23 hours ago
Nope, you need to Edit your question, adding any code snippet or description that can further explain your case. Don't insert code in comments.
– Jimi
23 hours ago