Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open System.Windows.Forms
- open System.Drawing
- let f = new Form(Text="Clock", TopMost= true)
- let pi = System.Math.PI
- type AnalogClock()=
- inherit UserControl()
- let mutable current = System.DateTime.Now
- member this.DateTIme
- with get() = current
- and set(v) = current <- v;
- override this.OnPaint e =
- let g = e.Graphics
- g.SmoothingMode <- Drawing2D.SmoothingMode.HighQuality
- //creo centro
- let center = PointF(50.f, 50.f)
- let angoloMovimento = pi / 6.
- let transform = g.Transform
- for i = 1 to 12 do
- g.DrawLine(Pens.Black, c.X + 50 - 5, c.Y, c.X + 50, c.Y)
- let t = g.Transform
- t.RotateAt(30.f, center)
- g.Transform <- t
- ///////////////////////////////////////////////
- let clock1 = new AnalogClock()
- let t = new Timer(Interval=100)
- t.Tick.Add(fun _ ->
- clock1.DateTIme <- System.DateTime.Now
- clock1.Invalidate()
- )
- t.Start()
- f.Controls.Add(clock1)
- Application.Run(f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement