The files contained in this repository can be downloaded to your computer using a svn client.
On Linux you simply type the command displayed below.

This URL has Read-Only access.

Statistics
| Revision:

root / trunk / DomotiGa / FLocations.class @ 25

History | View | Annotate | Download (2 kB)

1
' Gambas class file
2
3
' Description:
4
' FLocations.class
5
' Display devices locations.
6
7
' Development Status:
8
' Just started.
9
10
' DomotiGa - an open source home automation program.
11
' Copyright(C) 2008 Ron Klinkien
12
13
' Read file called COPYING for license details.
14
15
PRIVATE cLocations AS Collection
16
PRIVATE sLocation AS String
17
PRIVATE tRefresh AS Timer
18
19
PUBLIC SUB Form_Open()
20
21
  PopulateButtons()
22
  RefreshPage()
23
24
  ' create refresh timer
25
  tRefresh = NEW Timer AS "tRefresh"
26
  tRefresh.Delay = 30000 ' 30 seconds
27
  tRefresh.Start
28
29
END
30
31
PUBLIC SUB Form_Close()
32
33
  tRefresh.Stop
34
35
END
36
37
PUBLIC SUB Form_Resize()
38
39
  vbLocations.Width = 86
40
  vbLocations.Height = ME.Height - 10
41
  svLocation.Move(100, 5, ME.ClientWidth - 108, ME.ClientHeight - 18)
42
43
END
44
45
PUBLIC SUB PopulateButtons()
46
47
  DIM rDevice AS Result
48
  DIM rLocation AS Result
49
  DIM hButton AS Button
50
  DIM sLocation AS String
51
52
  cLocations = NEW Collection
53
54
  TRY rDevice = Main.hDB.Exec("SELECT * FROM devices")
55
  IF rDevice.Count THEN
56
    FOR EACH rDevice
57
      TRY rLocation = Main.hDB.Exec("SELECT * FROM locations WHERE id='" & rDevice!location & "'")
58
      IF rLocation.Count THEN
59
        IF NOT rLocation!name THEN CONTINUE
60
        ' get unique list of used location
61
        cLocations.Add(rLocation!name, rLocation!id)
62
      END IF
63
    NEXT
64
  END IF
65
  FOR EACH sLocation IN cLocations
66
    hButton = NEW Button(vbLocations) AS "LocationButton"
67
     WITH hButton
68
    .Text = sLocation
69
    .Height = 28
70
    .Width = 84
71
    .Tag = sLocation
72
    .Font = Font["Sans Serif, 7, Normal"]
73
    END WITH
74
  NEXT
75
END
76
77
PUBLIC SUB LocationButton_Click()
78
79
  sLocation = LAST.Tag
80
  Main.DisplayLocation(sLocation, FLocations.vpnlLocation)
81
82
END
83
84
PUBLIC SUB RefreshPage()
85
86
  IF NOT sLocation THEN RETURN 
87
88
  Main.DisplayLocation(sLocation, FLocations.vpnlLocation)
89
90
END
91
92
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
93
' refresh contents
94
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
95
PUBLIC SUB tRefresh_Timer()
96
97
  RefreshPage()
98
99
END
100
101
PUBLIC SUB btnRefresh_Click()
102
103
  RefreshPage()
104
105
END