Here's some part of my code is use to draw objects on the screen :Class members:private double cursorX = 0;private double cursorY = 0;private LineObj cursorOldY = new LineObj();private LineObj cursorOldX = new LineObj();private int index1 = 0;private double cursor2X = 0;private double cursor2Y = 0;private LineObj cursor2OldY = new LineObj();private LineObj cursor2OldX = new LineObj();private int index2 = -1;ZedGraph.CurveItem curve = null;Drawing function :private void drawCursors(bool first, bool second, bool fromKeyboard = false, Point mousePoint = new Point()) {    GraphPane p = lineGraphControl1.GraphPane;    if (p.CurveList.Count == 0 || curve == null)        return;    ZedGraph.Axis axis = curve.IsY2Axis ? (Axis)p.Y2AxisList[curve.YAxisIndex] : (Axis)p.YAxisList[curve.YAxisIndex];    ZedGraph.PointPair point = new PointPair(0.0, 0.0);    if (first)    {        p.GraphObjList.Remove(cursorOldY);        p.GraphObjList.Remove(cursorOldX);        if (fromKeyboard)           point = curve.Points[index1];        else if (lineGraphControl1.Graph.XAxis.Mode == XAxisMode.Parameter)        {            ZedGraph.CurveItem outputCurve;            p.FindNearestPoint(mousePoint, curve, out outputCurve, out index1);            if (index1 >= 0)               point = curve.Points[index1];        }        else        {           if (!mousePoint.IsEmpty)               p.ReverseTransform(mousePoint, out cursorX, out cursorY);           point = findPoint(curve, cursorX);        }        cursorX = point.X;        cursorY = transform(point.Y, axis);        cursorOldY = new LineObj(cursorX, p.YAxis.Scale.Min, cursorX, p.YAxis.Scale.Max);        cursorOldX = new LineObj(p.XAxis.Scale.Max, cursorY, p.XAxis.Scale.Min, cursorY);       if (cursorX > p.XAxis.Scale.Min && cursorX < p.XAxis.Scale.Max)           p.GraphObjList.Add(cursorOldY);       if (cursorY > p.YAxis.Scale.Min && cursorY < p.YAxis.Scale.Max)           p.GraphObjList.Add(cursorOldX);   }   if (second)   {       p.GraphObjList.Remove(cursor2OldY);       p.GraphObjList.Remove(cursor2OldX);       if (fromKeyboard)           point = curve.Points[index2];       else if (lineGraphControl1.Graph.XAxis.Mode == XAxisMode.Parameter)       {           ZedGraph.CurveItem outputCurve;           p.FindNearestPoint(mousePoint, curve, out outputCurve, out index2);           if (index2 >= 0)               point = curve.Points[index2];       }       else       {           if (!mousePoint.IsEmpty)               p.ReverseTransform(mousePoint, out cursor2X, out cursor2Y);           point = findPoint(curve, cursor2X);           if (index2 == -1)           {               index2 = (int) Math.Round(curve.NPts * 0.75, 0);               point = curve.Points[index2];           }       }       cursor2X = point.X;       cursor2Y = transform(point.Y, axis);       cursor2OldY = new LineObj(cursor2X, p.YAxis.Scale.Min, cursor2X, p.YAxis.Scale.Max);       cursor2OldX = new LineObj(p.XAxis.Scale.Max, cursor2Y, p.XAxis.Scale.Min, cursor2Y);       if (cursor2X > p.XAxis.Scale.Min && cursor2X < p.XAxis.Scale.Max)           p.GraphObjList.Add(cursor2OldY);       if (cursor2Y > p.YAxis.Scale.Min && cursor2Y < p.YAxis.Scale.Max)           p.GraphObjList.Add(cursor2OldX);    }}Is (structurally speaking) there some optimizations I missed ?
Draw crosshairs on the screen - ZedGraph
c#;optimization
DRY Don't repeat yourself Looking at the method, it is clearly seen that you do the same thing for first == true and for second == true, but you are using different variables.  As the set of variables  private double cursor2X = 0;private double cursor2Y = 0;private LineObj cursor2OldY = new LineObj();private LineObj cursor2OldX = new LineObj();private int index2 = -1;  are defining, what you need to draw a crosshair, you should place them inside a class.  An instance of this class can then be passed instead of the bool first,second to your method. In this way you have less code to maintain, if e.g something should be changed in this drawing part, as you only need to change it once and not twice.  Naming GraphPane pSingle letter variable names should be avoided. For loops as iteration variable they are ok, or for positioning like x,y. Your code would be easier to understand if you would name it pane instead.Based on the naming guidlines you should use PascalCasing casing for method names. 