Advertisement
Guest User

Untitled

a guest
Nov 8th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 1.09 KB | None | 0 0
  1. open System.Windows.Forms
  2. open System.Drawing
  3.  
  4. let f = new Form(Text="Clock", TopMost= true)
  5.  
  6. let pi = System.Math.PI
  7.  
  8. type AnalogClock()=
  9.      inherit UserControl()
  10.  
  11.      let mutable current = System.DateTime.Now
  12.  
  13.      member this.DateTIme
  14.           with get() = current
  15.           and set(v) = current <- v;
  16.  
  17.      override this.OnPaint e =
  18.           let g = e.Graphics
  19.           g.SmoothingMode <- Drawing2D.SmoothingMode.HighQuality
  20.  
  21.           //creo centro
  22.           let center = PointF(50.f, 50.f)
  23.  
  24.           let angoloMovimento = pi / 6.
  25.  
  26.           let transform = g.Transform
  27.  
  28.           for i = 1 to 12 do
  29.                g.DrawLine(Pens.Black, c.X + 50 - 5, c.Y, c.X + 50, c.Y)
  30.                let t = g.Transform
  31.                t.RotateAt(30.f, center)
  32.                g.Transform <- t
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. ///////////////////////////////////////////////
  40. let clock1 = new AnalogClock()
  41.  
  42. let t = new Timer(Interval=100)
  43. t.Tick.Add(fun _ ->
  44.      clock1.DateTIme <- System.DateTime.Now
  45.      clock1.Invalidate()
  46.      )
  47. t.Start()
  48.  
  49. f.Controls.Add(clock1)
  50.  
  51.  
  52.  
  53. Application.Run(f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement