private void loadMapPoints(SQLiteConnection conn) { SQLiteCommand command = new SQLiteCommand("SELECT ID, Door, Map, x, y from mappoint", conn); SQLiteDataReader reader = command.ExecuteReader(); MapPoint point; while (reader.Read()) { point = new MapPoint( reader.GetInt16(3), reader.GetInt16(4), getDoorById(reader.GetInt16(1)), reader.GetInt16(2), reader.GetInt16(0) ); mappoints.Add(point); } }
private void pictureBox1_Click(object sender, EventArgs e) { // Click when adding a point if (addingMapPoint) { foreach (Door door in objects.doors) { if (door.RoomNumber.Equals(cbDoors.SelectedItem)) { // Jared - making some changes here to save new point to the db. MapPoint point = new MapPoint(x - 5, y - 5, door, currentFloor); objects.mappoints.Add(point); // changed from dataPoints point.Save(); } } this.Cursor = Cursors.Default; pictureBox1.Invalidate(); RefreshDoorLst(); addingMapPoint = false; cbDoors.SelectionLength = 0; } // Click when deleting a point if (deletingPoint) { MapPoint deleted = null; foreach (MapPoint point in objects.mappoints) { if (x >= point.x && x <= point.x + 10) { if (y >= point.y && y <= point.y + 10) { DialogResult dialogResult = MessageBox.Show("Remove " + point.door.RoomNumber + "?\n\nThis will remove just the map marker, not to door itself.", "Remote", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { deleted = point; point.Delete(); } } } } if (deleted != null) { objects.mappoints.Remove(deleted); } this.Cursor = Cursors.Default; pictureBox1.Invalidate(); RefreshDoorLst(); deletingPoint = false; } }