/// <summary> /// returns the shape's attribute field value /// </summary> private object GetCellValue(MapWinGIS.Shapefile sf, int fieldIndex, int shapeIndex, object noDt) { object value; try { value = sf.get_CellValue(fieldIndex, shapeIndex); } catch (Exception ex) { value = noDt; //if no data is returned } return(value); }
private void PopulateForm(bool ShowAfterward, MapWinGIS.Shapefile shapeFile, int shpIndex, bool calledBySelf) { if (!calledBySelf) { m_HavePanel = !ShowAfterward; } try { System.Windows.Forms.ListViewItem item; int numFields; m_ShapeFile = shapeFile; //clear the list view items lv.Items.Clear(); numFields = shapeFile.NumFields; for (int i = 0; i < numFields; i++) { string s = shapeFile.get_CellValue(i, shpIndex).ToString(); item = lv.Items.Add(shapeFile.get_Field(i).Name); item.SubItems.Add(s); item.ForeColor = Color.Black; if (s.ToLower().StartsWith("http") || s.ToLower().StartsWith("file://")) { item.ForeColor = Color.Blue; } } //color the current shape red if (m_SelShape != -1) { m_parent.m_MapWin.View.SelectedShapes.AddByIndex(m_SelShape, YELLOW); } m_SelShape = shpIndex; m_parent.m_MapWin.View.SelectedShapes.AddByIndex(shpIndex, RED); if (ShowAfterward) { this.Show(); } } catch (System.Exception ex) { ShowErrorBox("PopulateForm()", ex.Message); } }
private void SetLocationMap_Load(object sender, EventArgs e) { idleTimer = DateTime.Now; Timer1.Start(); Timer1.Interval = 5000; int intHandler1; MapWinGIS.Shapefile shapefile1 = new MapWinGIS.Shapefile(); shapefile1.Open("..\\..\\shapefiles\\Form.shp"); intHandler1 = axMap1.AddLayer(shapefile1, true); int intHandler2; MapWinGIS.Shapefile shapefile2 = new MapWinGIS.Shapefile(); shapefile2.Open("..\\..\\shapefiles\\gang.shp"); intHandler2 = axMap1.AddLayer(shapefile2, true); int intHandler7; MapWinGIS.Shapefile shapefile7 = new MapWinGIS.Shapefile(); shapefile7.Open("..\\..\\shapefiles\\Stairs.shp"); intHandler7 = axMap1.AddLayer(shapefile7, true); int intHandler6; MapWinGIS.Shapefile shapefile6 = new MapWinGIS.Shapefile(); shapefile6.Open("..\\..\\shapefiles\\Shape .shp"); string myLabel; //define two double variables to use as a coordinates for label position double x, y; for (int i = 0; i < shapefile6.NumShapes - 1; i++) { //assign the value of the cells of the field number zero to the label myLabel = System.Convert.ToString( shapefile6.get_CellValue(1, i)); //Calculate the x position for the label x = shapefile6.get_Shape(i).Extents.xMin + (shapefile6.get_Shape(i).Extents.xMax - shapefile6.get_Shape(i).Extents.xMin) / 2; //Calculate the y position for the label y = shapefile6.get_Shape(i).Extents.yMin + (shapefile6.get_Shape(i).Extents.yMax - shapefile6.get_Shape(i).Extents.yMin) / 2; shapefile6.Labels.AddLabel(myLabel, x, y, 0, -1); } intHandler6 = axMap1.AddLayer(shapefile6, true); int intHandler3; MapWinGIS.Shapefile shapefile3 = new MapWinGIS.Shapefile(); shapefile3.Open("..\\..\\shapefiles\\Indgang.shp"); intHandler3 = axMap1.AddLayer(shapefile3, true); int intHandler8; MapWinGIS.Shapefile shapefile8 = new MapWinGIS.Shapefile(); shapefile8.Open("..\\..\\shapefiles\\WC.shp"); intHandler8 = axMap1.AddLayer(shapefile8, true); int intHandler4; MapWinGIS.Shapefile shapefile4 = new MapWinGIS.Shapefile(); shapefile4.Open("..\\..\\shapefiles\\navlines.shp"); intHandler4 = axMap1.AddLayer(shapefile4, false); int intHandler5; MapWinGIS.Shapefile shapefile5 = new MapWinGIS.Shapefile(); shapefile5.Open("..\\..\\shapefiles\\navnodes.shp"); intHandler5 = axMap1.AddLayer(shapefile5, true); axMap1.SendMouseDown = true; axMap1.MouseDownEvent += axMap1_MouseDownEvent; axMap1.CursorMode = tkCursorMode.cmNone; if (File.Exists("..\\..\\devloc.txt")) { Loc = Convert.ToInt32(File.ReadAllText("..\\..\\devloc.txt")); } }
public void PopulateForm(bool ShowAfterward, MapWinGIS.Shapefile shapeFile, int[] shpIndex, string layerName, bool calledBySelf) { if (!calledBySelf) { m_HavePanel = !ShowAfterward; } try { System.Windows.Forms.ListViewItem item; int numFields; m_shpIndex = shpIndex; m_LayerName = layerName; m_ShapeFile = shapeFile; SetTitle(); //new selected shapes m_SelShape = -1; //clear the list view items lv.Items.Clear(); //clear the combo Box field Name cb.Items.Clear(); cb.Text = ""; cbFieldName.Items.Clear(); cbFieldName.Items.Add("Shape Index"); //clear the selected box m_parent.m_MapWin.View.Draw.ClearDrawing(m_parent.m_hDraw); numFields = shapeFile.NumFields; for (int i = 0; i < numFields; i++) { item = lv.Items.Add(shapeFile.get_Field(i).Name); item.SubItems.Add(shapeFile.get_CellValue(i, shpIndex[0]).ToString()); //add all the field name to the combo box cbFieldName.Items.Add(shapeFile.get_Field(i).Name); } //color the current shape red if (m_SelShape != -1) { m_parent.m_MapWin.View.SelectedShapes.AddByIndex(m_SelShape, YELLOW); } m_SelShape = shpIndex[0]; m_parent.m_MapWin.View.SelectedShapes.AddByIndex(shpIndex[0], RED); //select the first field if (cbFieldName.Items.IndexOf(m_FieldName) == -1) { cbFieldName.SelectedIndex = 0; } else { cbFieldName.SelectedItem = m_FieldName; } if (ShowAfterward) { this.Show(); } } catch (System.Exception ex) { ShowErrorBox("PopulateForm()", ex.Message); } }