// Line Demonstration Program

using System;
using System.Windows.Forms;

using IPlusPlus;
using IPlusPlus.Windows;
using IPlusPlus.Graphics;

class LineDemonstration : Form
{
    int W; // width of client
    int H; // height of client

    Brush redBrush;
    Brush greenBrush;
    Brush blueBrush;

    [STAThread]
    public static void Main()
    {
        application.Run(new LineDemonstration());
    }

    LineDemonstration()
    {
        Text = "Line Demonstration";
        BackColor = System.Drawing.Color.white;
        redBrush = new Brush(new Color((int)Colors.Red));
        greenBrush = new Brush(new Color((int)Colors.Green));
        blueBrush = new Brush(new Color((int)Colors.Blue));
        OnSize(this, null);
        Paint += OnPaint;
        Resize += OnSize;
    }

    void OnPaint(object source, PaintEventArgs e)
    {
        DeviceContext deviceContext = new DeviceContext(this);
        deviceContext.Brush = redBrush;
        deviceContext.DrawRectangle(W / 8, H / 8, 7 * W / 8, 7 * H / 8);
        deviceContext.CurrentPosition = new Point(0,0);
        deviceContext.DrawLineTo(W,H);
        deviceContext.CurrentPosition = new Point(0,H);
        deviceContext.DrawLineTo(W,0);
        deviceContext.Brush = greenBrush;
        deviceContext.DrawEllipse(W / 8, H / 8, 7 * W / 8, 7 * H / 8);
        deviceContext.Brush = blueBrush;
        deviceContext.DrawRoundedRectangle(W / 4, H / 4, 3 * W / 4, 3 * H / 4, W / 4, H / 4);
    }

    void OnSize(object sender, EventArgs e)
    {
        System.Drawing.Size sizeClient = ClientSize;
        W = sizeClient.Width;
        H = sizeClient.Height;
        Invalidate();
    }
}