private void actualizarRadioButtons(string v_actualGate) { if (actualZone.listaPuertas.ContainsKey(v_actualGate)) { Zone.GateDefinition gate = actualZone.listaPuertas[v_actualGate]; switch (gate.type) { case Zone.GateAccessType.Granted: rdbGranted.Checked = true; break; case Zone.GateAccessType.Forbidden: rdbForbidden.Checked = true; break; case Zone.GateAccessType.Entrance: rdbEntrance.Checked = true; break; case Zone.GateAccessType.Exit: rdbExit.Checked = true; break; } } }
private void listViewGates_SelectedIndexChanged(object sender, EventArgs e) { cmbEntrance.Tag = null; // Para que no se haga nada al disparar el evento selectedIndexChange cmbExit.Tag = null; // Para que no se haga nada al disparar el evento selectedIndexChange ListView.SelectedListViewItemCollection itemCollection = listViewGates.SelectedItems; if (itemCollection.Count > 0) { ListViewItem item = itemCollection[0]; actualGate = item.SubItems[0].Text; Zone.GateDefinition gate = actualZone.getGate(actualGate); if (gate != null) { int EntranceReaderID = gate.LNLEntranceReaderID; int ExitReaderID = gate.LNLExitReaderID; if (cmbEntrance.Items.Count > 0) { if (EntranceReaderID == -1) { cmbEntrance.SelectedIndex = 0; } else { cmbEntrance.SelectedItem = buscarReaderDescFromReaderID(EntranceReaderID); } } if (cmbExit.Items.Count > 0) { if (ExitReaderID == -1) { cmbExit.SelectedIndex = 0; } else { cmbExit.SelectedItem = buscarReaderDescFromReaderID(ExitReaderID); } } } cmbEntrance.Enabled = true; cmbExit.Enabled = true; actualizarGateEnMapa(actualGate); } else { actualGate = ""; cmbEntrance.Enabled = false; cmbExit.Enabled = false; } cmbEntrance.Tag = true; cmbExit.Tag = true; }
private void actualizarGateEnMapa(string v_gate) { Zone.GateDefinition selectedGate = actualZone.listaPuertas[v_gate]; Dictionary <string, Zone.GeoCoord> pointsInGate = new Dictionary <string, Zone.GeoCoord>(); pointsInGate.Add(selectedGate.ID + "1", new Zone.GeoCoord(selectedGate.from.position.latitude, selectedGate.from.position.longitude)); pointsInGate.Add(selectedGate.ID + "2", new Zone.GeoCoord(selectedGate.to.position.latitude, selectedGate.to.position.longitude)); actualizarMarkersEnMapa(pointsInGate); }
private void actualizarGateEnMapa(string v_gate) { Zone.GateDefinition selectedGate = actualZone.listaPuertas[v_gate]; markerPoints.Clear(); addPointToMarkers(selectedGate.from); addPointToMarkers(selectedGate.to); ZoomToFit(true); // Dictionary<string, Zone.GeoCoord> pointsInGate = new Dictionary<string, Zone.GeoCoord>(); // pointsInGate.Add(selectedGate.ID + "1", new Zone.GeoCoord(selectedGate.from.position.latitude, selectedGate.from.position.longitude)); // pointsInGate.Add(selectedGate.ID + "2", new Zone.GeoCoord(selectedGate.to.position.latitude, selectedGate.to.position.longitude)); // actualizarMarkersEnMapa(pointsInGate); }
//strZona: Lista de: Lat1,Long1,ORD1,Lat2,Long2,ORD2,TIPOACCESO, LNLEntranceReaderID, LNLExitReaderID: 9 items private void crearZonaPordef(string v_strZona) { actualZone = new Zone(Tools.GetInstance().ZoneName); actualPointID = 0; markerPoints = new Dictionary <string, Zone.GeoCoord>(); string[] listaDatos = v_strZona.Split(','); //MessageBox.Show(v_strZona + ", listaDatos es de largo: " + listaDatos.Length.ToString()); if (listaDatos.Length >= 9) { for (int i = 0; i < listaDatos.Length; i = i + 9) { Zone.ZonePoint desde = new Zone.ZonePoint("F" + (1 + (i / 9)).ToString(), listaDatos[i], listaDatos[i + 1], int.Parse(listaDatos[i + 2])); Zone.ZonePoint hacia = new Zone.ZonePoint("T" + (1 + (i / 9)).ToString(), listaDatos[i + 3], listaDatos[i + 4], int.Parse(listaDatos[i + 5])); string gateType = listaDatos[i + 6]; string LNLEntranceReaderID = listaDatos[i + 7]; string LNLExitReaderID = listaDatos[i + 8]; Zone.GateDefinition nuevaGate = new Zone.GateDefinition(); nuevaGate.from = desde; nuevaGate.to = hacia; //nuevaGate.type = getAccessType(gateType); nuevaGate.type = (Zone.GateAccessType)Enum.Parse(typeof(Zone.GateAccessType), gateType); nuevaGate.ID = "Gate" + (1 + (i / 9)).ToString(); if (LNLEntranceReaderID != "") { nuevaGate.LNLEntranceReaderID = int.Parse(LNLEntranceReaderID); nuevaGate.LNLExitReaderID = int.Parse(LNLExitReaderID); } actualZone.addGate(nuevaGate.ID, nuevaGate); // Ahora actualizo los markers. //Como las puertas estan conectadas, la lista de markers es solo con el punto de salida. addPointToMarkers(desde); } Tools.GetInstance().DoLog("Zona definida: " + actualZone.IDZona + " con: " + actualZone.listaPuertas.Count + " gates"); } actualizarZonaEnMapa(); actualizarListViewGates(); Tools.GetInstance().DoLog("Zona actualizada en el mapa"); }
public Zone.GateDefinition obtenerGatedesdeLNLReaderID(int v_LNLReaderID) { Zone.GateDefinition res = null; foreach (KeyValuePair <string, Zone.GateDefinition> pair in actualZone.listaPuertas) { if (pair.Value.LNLEntranceReaderID == v_LNLReaderID) { res = pair.Value; break; } } return(res); }
// Utiliza el diccionario de markerPoints para crear la Zona // El orden de creacion de las gates se corresponde al orden de los markerPoints por su clave(string) private void crearZonaPorMarkers() { actualZone = new Zone(Tools.GetInstance().ZoneName); Zone.GateDefinition nuevaGate = new Zone.GateDefinition(); string firstLat = ""; string firstLong = ""; string firstID = ""; bool primerPunto = true; int ordPunto = 1; // Lista de Ordinales foreach (KeyValuePair <string, Zone.GeoCoord> pair in markerPoints) { if (primerPunto) { nuevaGate.from = new Zone.ZonePoint("Desde", pair.Value.latitude, pair.Value.longitude, ordPunto); nuevaGate.type = Zone.GateAccessType.Forbidden; //nuevaGate.ID = pair.Key; firstLat = pair.Value.latitude; firstLong = pair.Value.longitude; firstID = pair.Key; ordPunto++; primerPunto = false; } else { nuevaGate.to = new Zone.ZonePoint("Hacia", pair.Value.latitude, pair.Value.longitude, ordPunto); nuevaGate.ID = Tools.GetInstance().ZoneName + "- Gate " + (actualZone.listaPuertas.Count + 1).ToString(); actualZone.listaPuertas.Add(nuevaGate.ID, nuevaGate); nuevaGate = new Zone.GateDefinition(); nuevaGate.from = new Zone.ZonePoint("Desde", pair.Value.latitude, pair.Value.longitude, ordPunto); nuevaGate.type = Zone.GateAccessType.Forbidden; nuevaGate.ID = pair.Key; ordPunto++; } } // La ultima puerta se genera entre el ultimo punto y el primero. nuevaGate.to = nuevaGate.to = new Zone.ZonePoint("Hacia", firstLat, firstLong, 1); // El ordinal del primer punto es 1 nuevaGate.ID = Tools.GetInstance().ZoneName + "- Gate " + (actualZone.listaPuertas.Count + 1).ToString(); actualZone.listaPuertas.Add(nuevaGate.ID, nuevaGate); actualizarZonaEnMapa(); actualizarListViewGates(); }
/// <summary> /// True si quedan licencias de VG disponibles. /// </summary> /// <returns></returns> //private bool checkAvailability() //{ // int VGDefinidas = contarVGates(); // bool res = (StaticCustomOptionsManager.ActualVG - cantVGatesOriginalesZona + VGDefinidas) < StaticCustomOptionsManager.CantVG; // return res; //} private void actualizeAccessType(Zone.GateDefinition v_gate) { if ((v_gate.LNLEntranceReaderID > 0) && (v_gate.LNLExitReaderID > 0)) { v_gate.type = Zone.GateAccessType.Granted; } if ((v_gate.LNLEntranceReaderID > 0) && (v_gate.LNLExitReaderID < 0)) { v_gate.type = Zone.GateAccessType.Entrance; } if ((v_gate.LNLEntranceReaderID < 0) && (v_gate.LNLExitReaderID > 0)) { v_gate.type = Zone.GateAccessType.Exit; } if ((v_gate.LNLEntranceReaderID < 0) && (v_gate.LNLExitReaderID < 0)) { v_gate.type = Zone.GateAccessType.Forbidden; } }
private void tmrLoadZone_Tick(object sender, EventArgs e) { tmrLoadZone.Enabled = false; if (zonaDef != "") { // MessageBox.Show("Va a crear la zona"); crearZonaPordef(zonaDef); //MessageBox.Show("CREO la zona"); if (READERID != "") { Zone.GateDefinition actualGate = obtenerGatedesdeLNLReaderID(int.Parse(READERID)); if (actualGate != null) { markerPoints.Clear(); addPointToMarkers(actualGate.from); addPointToMarkers(actualGate.to); // MessageBox.Show(actualGate.ID.ToString()); listViewGates.Focus(); listViewGates.Items[actualGate.index].Selected = true; } } ZoomToFit(true); } }