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.
root / trunk / DomotiGa / FFloorplanEditor.class @ 761
History | View | Annotate | Download (2.5 kB)
| 1 | ' Gambas class file |
|---|---|
| 2 | |
| 3 | ' Description: |
| 4 | ' FFloorplanEditor.class |
| 5 | ' Place devices on floorplan image to determine correct X and Y coordinates. |
| 6 | |
| 7 | ' Development Status: |
| 8 | ' Just started, must be worked on. |
| 9 | |
| 10 | ' DomotiGa - an open source home automation program. |
| 11 | ' Copyright(C) 2008-2011 Ron Klinkien |
| 12 | |
| 13 | ' Read file called COPYING for license details. |
| 14 | |
| 15 | PUBLIC imgFloorPlanImage AS Image |
| 16 | |
| 17 | PUBLIC SUB Form_Open() |
| 18 | |
| 19 | DIM rDevice AS Result |
| 20 | |
| 21 | ME.Move(FMain.X + 50, FMain.Y + 70) |
| 22 | |
| 23 | TRY rDevice = Main.hDB.Exec("SELECT * FROM devices WHERE id = &1", FDevices.tbvDevices[FDevices.iCurRow, 0].Text)
|
| 24 | IF rDevice.Count THEN |
| 25 | pbIcon.Picture = Picture[Main.sBaseDir &/ "icons" &/ rDevice!onicon] |
| 26 | txtX.Text = rDevice!x |
| 27 | txtY.Text = rDevice!y |
| 28 | ELSE |
| 29 | pbIcon.Picture = Picture[Main.sBaseDir &/ "icons" &/ "phone.png"] |
| 30 | ENDIF |
| 31 | FFloorPlans.DisplayFloorplan(FDeviceEditor.GetFloorplan(), svFloorplanPict) |
| 32 | |
| 33 | END |
| 34 | |
| 35 | PUBLIC SUB Form_Resize() |
| 36 | |
| 37 | svFloorplanPict.Move(1, 1, ME.ClientWidth - 100, ME.ClientHeight - 2) |
| 38 | frameIcon.Move(ME.ClientWidth - 94, 0) |
| 39 | lblX.Move(ME.ClientWidth - 90, 84) |
| 40 | lblY.Move(ME.ClientWidth - 90, 109) |
| 41 | txtX.Move(ME.ClientWidth - 70, 84) |
| 42 | txtY.Move(ME.ClientWidth - 70, 109) |
| 43 | btnCancel.Move(ME.ClientWidth - 94, 159) |
| 44 | btnSave.Move(ME.ClientWidth - 94, 195) |
| 45 | |
| 46 | END |
| 47 | |
| 48 | ' provide drag/drop for deviceicon image |
| 49 | PUBLIC SUB DeviceIcon_MouseDrag() |
| 50 | |
| 51 | IF Mouse.Left THEN |
| 52 | Drag.IconX = 0 |
| 53 | Drag.IconY = 0 |
| 54 | Drag.Icon = LAST.Picture |
| 55 | LAST.Drag(LAST.Picture.Image) |
| 56 | ENDIF |
| 57 | |
| 58 | END |
| 59 | |
| 60 | PUBLIC SUB PlanIcon_MouseDrag() |
| 61 | |
| 62 | IF Mouse.Left THEN |
| 63 | Drag.IconX = 0 |
| 64 | Drag.IconY = 0 |
| 65 | Drag.Icon = LAST.Picture |
| 66 | LAST.Drag(LAST.Picture.Image) |
| 67 | ENDIF |
| 68 | |
| 69 | END |
| 70 | |
| 71 | PUBLIC SUB Plan_DragMove() |
| 72 | |
| 73 | Drag.Show(LAST) |
| 74 | |
| 75 | END |
| 76 | |
| 77 | PUBLIC SUB Plan_Drop() |
| 78 | |
| 79 | txtX.Text = Drag.X |
| 80 | txtY.Text = Drag.Y |
| 81 | AddToFloorPlan(Drag.Icon, Drag.X, Drag.Y) |
| 82 | |
| 83 | END |
| 84 | |
| 85 | PUBLIC SUB AddToFloorplan(imgIcon AS Picture, X AS Integer, Y AS Integer) |
| 86 | |
| 87 | DIM hPictureBox AS PictureBox |
| 88 | |
| 89 | ' recreate floorplan image |
| 90 | hPictureBox = NEW PictureBox(svFloorplanPict) AS "FloorIcon" |
| 91 | WITH hPictureBox |
| 92 | .Picture = imgIcon |
| 93 | .Height = imgIcon.Height |
| 94 | .Width = imgIcon.Width |
| 95 | .Drop = TRUE |
| 96 | .Tag = "PlanIcon" |
| 97 | .X = X |
| 98 | .Y = Y |
| 99 | END WITH |
| 100 | |
| 101 | END |
| 102 | |
| 103 | PUBLIC SUB btnSave_Click() |
| 104 | |
| 105 | FDeviceEditor.tbX.Text = txtX.Text |
| 106 | FDeviceEditor.tbY.Text = txtY.Text |
| 107 | ME.Close |
| 108 | |
| 109 | END |
| 110 | |
| 111 | PUBLIC SUB FloorIcon_MouseDrag() |
| 112 | |
| 113 | IF Mouse.Left THEN |
| 114 | Drag.IconX = 0 |
| 115 | Drag.IconY = 0 |
| 116 | Drag.Icon = LAST.Picture |
| 117 | LAST.Drag(LAST.Picture.Image) |
| 118 | ENDIF |
| 119 | |
| 120 | END |
| 121 | |
| 122 | PUBLIC SUB FloorIcon_DragMove() |
| 123 | |
| 124 | Drag.Show(LAST) |
| 125 | |
| 126 | END |
| 127 | |
| 128 | PUBLIC SUB btnCancel_Click() |
| 129 | |
| 130 | ME.Close |
| 131 | |
| 132 | END |
