Air_Hockey_Simulator.AirHockeySimCtrl.DrawLine C# (CSharp) Method

DrawLine() public method

public DrawLine ( Graphics g, Line l, Pen p ) : void
g System.Drawing.Graphics
l Line
p System.Drawing.Pen
return void
        public void DrawLine(Graphics g, Line l, Pen p)
        {
            if (l.Slope == null) {
                g.DrawLine(p, s(l.Point.X), 0, s(l.Point.X), s(Table.Height));
            } else {
                double bottom_x = 0;
                double bottom_y = l.Y(bottom_x).Value;
                if (bottom_y < 0) {
                    bottom_y = 0;
                    bottom_x = l.X(bottom_y).Value;
                }
                double top_x = Table.Width;
                double top_y = l.Y(top_x).Value;
                if (top_y > Table.Height) {
                    top_y = Table.Height;
                    top_x = l.X(top_y).Value;
                }
                try {
                    g.DrawLine(p, s(bottom_x), s(bottom_y), s(top_x), s(top_y));
                } catch {
                    //Somepin' not right. Figure this out later
                }
            }
        }