-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScrollButton.fsx
46 lines (38 loc) · 1.21 KB
/
ScrollButton.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
open System.Drawing
open System.Drawing.Drawing2D
//direzioni delle freccie
type ArrowDirection =
| UP
| DOWN
| LEFT
| RIGHT
type ScrollButton( direction:ArrowDirection, area:Point[] ) =
// path grafico per il calcolo dell'area del bottone
let mutable gp = new GraphicsPath()
// lista di punti raffiguranti il bottone
let mutable points = area
//direzione della freccia da disegnare
let mutable dir = direction
let clickEvt = new Event<System.EventArgs>()
member this.Click = clickEvt.Publish
// controlla la direzione del bottone
member this.Direction
with get() = dir
and set( v ) =
dir <- v
// assegna/ottiene l'area del bottone
member this.ButtonArea
with get() = points
and set( r ) =
points <- r
gp.Reset()
gp.AddPolygon( points )
// determina se il punto premuto e' all'interno della freccia
member this.contains( p:Point ) =
let ret = gp.IsVisible( p )
if ret then
clickEvt.Trigger( new System.EventArgs() )
ret
member this.paint( g:Graphics ) =
g.FillPolygon( Brushes.Red, points )