Tuesday, February 7, 2012

drawing axes for a graph using GDI+ on a panel in C#


private void DrawBoundaryAndGraphAxes(Graphics g)
        {
            origin = new Point(margin, histogramPanel.Height - margin);
            Point xmax = new Point(histogramPanel.Width - margin, histogramPanel.Height - margin);
            Point ymax = new Point(margin, margin);
            Point xymax = new Point(histogramPanel.Width - margin, margin);

            Pen p = new Pen(Color.Black);
            g.DrawLines(p, new Point[] { ymax, origin, xmax });          
           
            p.Dispose();
}

pointers in C#



if p is a variable denoting a pointer, and *p is the variable it points to, then:

p[e] is equivalent to *(p+e)