Advertisement
Guest User

Untitled

a guest
Nov 17th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 1.00 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. type AnalogClock()=
  7.      inherit UserControl()
  8.  
  9.      let mutable current = 0.f
  10.      let mutable x,y = 10.f,10.f
  11.  
  12.      member this.DateTIme
  13.           with get() = current
  14.           and set(v) = current <- v;
  15.  
  16.      override this.OnPaint e =
  17.           let g = e.Graphics
  18.           let t = g.Transform
  19.           let transform = g.Transform
  20.           t.Translate(x,y)
  21.           g.Transform <- t
  22.           g.DrawRectangle(Pens.Red, 0.f, 0.f,50.f,50.f)
  23.           g.Transform <- transform
  24.           x <- x + 1.f
  25.           y <- y + 1.f
  26.  
  27.  
  28.  
  29.  
  30.  
  31. ///////////////////////////////////////////////
  32. let mutable clock1 = new AnalogClock(Size=Size(f.Width, f.Height))
  33.  
  34. let t = new Timer(Interval=50)
  35. t.Tick.Add(fun _ ->
  36.      clock1.Invalidate() //Importantissimo altrimenti non va
  37.      f.Invalidate()
  38.      clock1.Size <- Size(f.Width, f.Height)
  39.      )
  40. t.Start()
  41.  
  42. f.Controls.Add(clock1)
  43.  
  44.  
  45.  
  46. Application.Run(f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement