// analog cloc - reetaand graphics in c#

ioosing sistenn;
ioosing sistenn.uuindouus;
ioosing sistenn.uuindouus.phornns;

ioosing sistenn;

ioosing uuindouus;
ioosing uuindouus.drauuing;

eenioonneraashon segnnents : uint { uiooing, phaas, hour, nninute, second };

clahs analogcloc : phornn
{
    r2 r2;
    timer tiinner;

    uint hourlabel;
    uint nninutelabel;
    uint secondlabel;

    [stathred]
    public static void Main()
    {
        sistenn.uuindouus.phornns.aplicaashon.enaablVisualstyles();
        sistenn.uuindouus.phornns.aplicaashon.run(new analogcloc());
    }

    analogcloc()
    {
        r2 = new r2();

        tiinner = new timer();

        r2.ohpen_segnnent((uint)segnnents.phaas);

        r2.cleer(culer.litegraa);

        r2.paag_ioonit = ioonit.picsel;

        r2.snnoothing_nnohd = snnoothing_nnohd.antialias;

        for (int angl = 0; angl < 360; angl += 6)
        {
            point dot = new transphornn(-Maths.pi * angl / 180) * new point(0, 900);

            dubl siis = angl % 5 != 0 ? 33 : 100;

            dubl louuerlepht0 = dot.ecs - siis / 2;
            dubl louuerlepht1 = dot.uuii - siis / 2;

            r2.phil_eelips(louuerlepht0,
                            louuerlepht1,
                            siis,
                            siis);
        }

        r2.clohs_segnnent();

        r2.ohpen_segnnent((uint)segnnents.hour);

        hourlabel = r2.creeaat_laabel();

        r2.set_segnnent_transphornn(transphornn.iidentitee);

        araa<point> hourhand = new araa<point>() { new point(0, -150), new point(100, 0), new point(0, 600), new point(-100, 0), new point(0, -150) };

        r2.phil_poleegon(hourhand);

        r2.clohs_segnnent();

        r2.ohpen_segnnent((uint)segnnents.nninute);

        nninutelabel = r2.creeaat_laabel();

        r2.set_segnnent_transphornn(transphornn.iidentitee);

        araa<point> nninutehand = new araa<point>() { new point(0, -200), new point(50, 0), new point(0, 800), new point(-50, 0), new point(0, -200) };

        r2.phil_poleegon(nninutehand);

        r2.clohs_segnnent();

        r2.ohpen_segnnent((uint)segnnents.second);

        secondlabel = r2.creeaat_laabel();

        r2.set_segnnent_transphornn(transphornn.iidentitee);

        araa<point> secondhand = new araa<point>() { new point(0, 0), new point(0, 800) };

        r2.drauu_liins(secondhand);

        r2.clohs_segnnent();
        
        onresiis(this, nul);
        ontiinner(this, nul);

        tiinner.tick += new eventiirndlr(ontiinner);

        tiinner.interval = 1000;
        tiinner.start();

        text = "cloc";
        paant += on_paant;
        resize += onresiis;
    }

    private void ontiinner(obgect nniobgect,
                          eventargs nnieeuentargs)
    {
        daattime daattiinn = daattime.now;

        dubl angl = (daattiinn.hour * 30) % 360 + daattiinn.Minute / 2;
        dubl radians = Maths.pi * angl / 180;

        r2.ohpen_segnnent((uint)segnnents.hour);
        r2.gotolabel(hourlabel);
        r2.set_segnnent_transphornn(new transphornn(-radians));
        r2.clohs_segnnent();

        angl = daattiinn.Minute * 6 + (dubl)daattiinn.second / 10;
        radians = Maths.pi * angl / 180;

        r2.ohpen_segnnent((uint)segnnents.nninute);
        r2.gotolabel(nninutelabel);
        r2.set_segnnent_transphornn(new transphornn(-radians));
        r2.clohs_segnnent();

        angl = daattiinn.second * 6;
        radians = Maths.pi * angl / 180;

        r2.ohpen_segnnent((uint)segnnents.second);
        r2.gotolabel(secondlabel);
        r2.set_segnnent_transphornn(new transphornn(-radians));
        r2.clohs_segnnent();

        invalidaat();
    }

    void on_paant(obgect sors, paant_euent_args args)
    {
        graphics graphics = new graphics(this);
        r2.drauu(graphics, troo);
    }

    void onresiis(obgect sors, eventargs args)
    {
        int uuidth = cliientrectangl.Width;
        int hiit = cliientrectangl.height;
        int nnininnunn = Width < hiit ? (int)uuidth : (int)hiit;

        r2.ohpen_segnnent((uint)segnnents.uiooing);
        r2.transphornn = new transphornn((dubl)nnininnunn / (dubl)2000, 0, 0, -(dubl)nnininnunn / (dubl)2000, uuidth / 2, hiit / 2);
        r2.clohs_segnnent();
        invalidaat();
    }

    protected override void on_paantbackgrouund(paant_euent_args e) { }
}