/// <summary> /// This event is called when a plugin is loaded or turned on in the MapWindow. /// </summary> /// <param name="MapWin">The interface to use to access the MapWindow.</param> /// <param name="ParentHandle">The window handle of the MapWindow form. This handle is useful for /// making the MapWindow the owner of plugin forms.</param> public void Initialize(MapWindow.Interfaces.IMapWin MapWin, int ParentHandle) { try { _mapWin = MapWin; MapWindow.Interfaces.Toolbar t = MapWin.Toolbar; //Resources: clsResources cResources = new clsResources(); t.AddToolbar(_toolbarName); MapWindow.Interfaces.ToolbarButton b = t.AddButton(_btnNameShp2Grid, _toolbarName, "", ""); b.BeginsGroup = true; b.Tooltip = _toolTipShp2Grid; b.Category = _toolbarName; System.Drawing.Icon oIcon = cResources.GetEmbeddedIcon("shp2grid6.ico"); b.Picture = new System.Drawing.Icon(oIcon, new System.Drawing.Size(16, 16)); //Clean up: t = null; b = null; } catch (Exception ex) { _mapWin.ShowErrorDialog(ex); } }
public AddShapeClass(GlobalFunctions g) { m_globals = g; g.Events.AddHandler(new MapWindow.Events.ItemClickedEvent(ItemClickedEvent)); m_MapWin = g.MapWin; m_hDraw = -1; }
public frmIdentByShape(MapWindow.Interfaces.IMapWin MapWin, mwIdentPlugin Plugin) { InitializeComponent(); m_MapWin = MapWin; m_Plugin = Plugin; }
public bool UserActivatedPlugin = false; //used to check if this plug-in should react on GUI #region Implementation of IPlugin /// <summary> /// This event is called when a plugin is loaded or turned on in the MapWindow. /// </summary> /// <param name="MapWin">The interface to use to access the MapWindow.</param> /// <param name="ParentHandle">The window handle of the MapWindow form. This handle is useful for /// making the MapWindow the owner of plugin forms.</param> public void Initialize(MapWindow.Interfaces.IMapWin MapWin, int ParentHandle) { try { _mapWin = MapWin; _parentHandle = ParentHandle; //Needed to not let the forms fall behind MapWindow //Resources: var cResources = new clsResources(); MapWindow.Interfaces.Toolbar t = MapWin.Toolbar; t.AddToolbar(_toolbarName); MapWindow.Interfaces.ToolbarButton b = t.AddButton(_btnNameLoadData, _toolbarName, "", ""); b.BeginsGroup = true; b.Tooltip = _toolTipLoadData; b.Category = _toolbarName; System.Drawing.Icon oIcon = cResources.GetEmbeddedIcon("TemplatePluginVS2008.ico"); b.Picture = new System.Drawing.Icon(oIcon, new System.Drawing.Size(16, 16)); //Clean up: t = null; b = null; } catch (Exception ex) { _mapWin.ShowErrorDialog(ex); } }
public void FireInitializeEvent(MapWindow.Interfaces.IMapWin MapWin, int ParentHandle) { if (m_Initialize != null) { m_Initialize(MapWin, ParentHandle); } }
public void Initialize(MapWindow.Interfaces.IMapWin MapWin, int ParentHandle) { try { m_MapWin = MapWin; m_ParentHandle = ParentHandle; MapWindow.Interfaces.ToolbarButton button; //Add the tool bar if (m_ToolbarName.Length > 0) { m_MapWin.Toolbar.AddToolbar(m_ToolbarName); } //add buttons and the tool tip button = m_MapWin.Toolbar.AddButton("DB Luncher", m_ToolbarName, null, null); button.Tooltip = "DB Luncher"; //button.Picture = labelIcon; } catch (System.Exception ex) { ShowErrorBox("Initialize()", ex.Message); } }
private void ItemClicked(string ItemName, ref bool Handled) { try { m_MapWin = m_globals.MapWin; if (ItemName == GlobalFunctions.c_MoveShapesButton) { if (m_globals.SelectedShapefileIsReadonly()) { MapWinUtility.Logger.Msg("The selected shapefile is read-only and cannot be edited.", "Read-Only Shapefile"); return; } if (m_globals.CurrentMode != GlobalFunctions.Modes.MoveShape) { m_globals.CurrentMode = GlobalFunctions.Modes.MoveShape; // Chris Michaelis 12/9/2006 - As soon as somebody // enables the "Move Shape" mode, turn off the select mode // and set the map mouse pointer to a useful "Move" icon. // Setting the cursor mode to None causes the selection mode to turn off, // since the Cursor Mode is no longer "Selection". m_globals.MapWin.View.CursorMode = MapWinGIS.tkCursorMode.cmNone; // Set a nice "Move" icon m_Cursor = new Cursor(this.GetType(), "Moveshape.cur"); m_globals.MapWin.View.UserCursorHandle = m_Cursor.Handle.ToInt32(); m_globals.MapWin.View.MapCursor = MapWinGIS.tkCursor.crsrUserDefined; //update the buttons on the toolbar m_globals.UpdateButtons(); //save the previous cusor mode m_globals.SaveCusorMode(); } else { // Chris Michaelis 12/9/2006 -- Moved this functionality into a single function call TurnOffMoveShape(); } //Handled = true; } else { if (m_MapWin.Toolbar.ButtonItem(GlobalFunctions.c_MoveShapesButton).Pressed) { // Chris Michaelis 12/9/2006 -- Moved into a single function. TurnOffMoveShape(); } } } catch (System.Exception ex) { m_globals.LogWrite(ex.StackTrace); //m_MapWin.ShowErrorDialog(ex); } }
public void Initialize(MapWindow.Interfaces.IMapWin MapWin, int ParentHandle) { try { m_MapWin = MapWin; m_ParentHandle = ParentHandle; m_shpFilePropfrm = new mwIdentifier.Forms.frmShapeFileProp(this); m_GridPropfrm = new mwIdentifier.Forms.frmGridProp(this); m_WMSPropfrm = new mwIdentifier.Forms.frmWMSProp(this); System.Drawing.Icon icon; System.Drawing.Icon icon2; icon = m_shpFilePropfrm.Icon; icon2 = new System.Drawing.Icon(this.GetType(), "IdentByShape.ico"); MapWindow.Interfaces.ToolbarButton button; //Add the tool bar if (m_ToolbarName.Length > 0) { m_MapWin.Toolbar.AddToolbar(m_ToolbarName); } //add buttons and the tool tip // button = m_MapWin.Toolbar.AddButton("Identifier", m_ToolbarName, null, null); button = m_MapWin.Toolbar.AddButton("ddIdentifier", m_ToolbarName, true); if (button == null) { throw new Exception("Failed to add Identifier Button (" + m_MapWin.LastError + ")"); } button.Tooltip = "Identifier"; button.Text = ""; m_IdentBtn = button; m_IdentBtn.Picture = icon; button = m_MapWin.Toolbar.AddButton("Identify", m_ToolbarName, "ddIdentifier", ""); if (button == null) { throw new Exception("Failed to add Identifier Button (" + m_MapWin.LastError + ")"); } button.Text = "Identifier"; m_IdentBtn2 = button; m_IdentBtn2.Picture = icon; button = m_MapWin.Toolbar.AddButton("Identify by Shape(s)", m_ToolbarName, "ddIdentifier", ""); if (button == null) { throw new Exception("Failed to add Identifier Button (" + m_MapWin.LastError + ")"); } button.Text = "Identify by Shape(s)"; m_IdentByShape = button; m_IdentByShape.Picture = icon2; } catch (System.Exception ex) { ShowErrorBox("Initialize()", ex.Message); } }
/// <summary> /// Constructor /// </summary> public GlobalFunctions(MapWindow.Interfaces.IMapWin mw, System.Windows.Forms.Form ParentForm) { m_MapWin = mw; m_MapWindowForm = ParentForm; m_events = new MapWindow.Events(); m_CurrentMode = Modes.None; SnapTolerancePixelRadius = 4; m_LayerSize = 0; }
public void Terminate() { //Close the labeler form if (m_Labelerfrm != null && !m_Labelerfrm.IsDisposed) { m_Labelerfrm.Close(); } m_MapWin = null; }
/// <summary> /// creates a new form /// </summary> /// <param name="IMapWin">reference to the current MapWindow /// GIS application (implements IMapWin interface)</param> public frmShapefile(MapWindow.Interfaces.IMapWin IMapWin) { //called by the winforms designer InitializeComponent(); //set global variables and initial appearance m_MapWin = IMapWin; populateLayers(); }
/// <summary> /// This event is called when a plugin is loaded or turned on in the MapWindow. /// </summary> /// <param name="MapWin">The interface to use to access the MapWindow.</param> /// <param name="ParentHandle">The window handle of the MapWindow form. This handle is useful for making the MapWindow the owner of plugin forms.</param> public void Initialize(MapWindow.Interfaces.IMapWin MapWin, int ParentHandle) { log.Debug("Initializing ....."); this.MapWin = MapWin; //Remove Allen's watershed menus MapWin.Menus.AddMenu("Geodatabase", "mnuFile", null, "Geodatabase", "mnuOpen"); MapWin.Menus.AddMenu("Load Features", "Geodatabase"); MapWin.Menus.AddMenu("Export Database to Shapefiles", "Geodatabase"); MapWin.Menus.AddMenu("Import Shapefile into Database", "Geodatabase"); }
public MoveShapeClass(GlobalFunctions globals) { m_globals = globals; m_MapWin = globals.MapWin; //add events //register delegates with event handler m_globals.Events.AddHandler(new MapWindow.Events.MapMouseDownEvent(MapMouseDown)); m_globals.Events.AddHandler(new MapWindow.Events.MapMouseMoveEvent(MapMouseMove)); m_globals.Events.AddHandler(new MapWindow.Events.ItemClickedEvent(ItemClicked)); m_globals.Events.AddHandler(new MapWindow.Events.MapMouseUpEvent(MapMouseUp)); }
/// <summary> /// This method is called when a plugin is unloaded. The plugin should remove all toolbars, buttons and menus that it added. /// </summary> public void Terminate() { _mapWin.Toolbar.RemoveButton(_btnNameLoadData); if (_mapWin.Toolbar.NumToolbarButtons(_toolbarName) == 0) { //If all buttons are removed, remove toolbar as well: _mapWin.Toolbar.RemoveToolbar(_toolbarName); } //Clean up: _mapWin = null; frm = null; GC.Collect(); }
public void Terminate() { //unload the buttons m_MapWin.Toolbar.RemoveButton("DB Luncher"); //unload the toolbar if (m_ToolbarName.Length > 0) { m_MapWin.Toolbar.RemoveToolbar(m_ToolbarName); } m_MapWin = null; }
public void Initialize(MapWindow.Interfaces.IMapWin MapWin, int ParentHandle) { try { m_MapWin = MapWin; m_ParentHandle = ParentHandle; m_MapWindowForm = (System.Windows.Forms.Form)System.Windows.Forms.Control.FromHandle((System.IntPtr)ParentHandle); } catch (System.Exception ex) { ShowErrorBox("Initialize()", ex.Message); } }
public MoveShapeClass(GlobalFunctions globals) { m_globals = globals; m_MapWin = globals.MapWin; m_Cursor = new Cursor(this.GetType(), "Moveshape.cur"); //add events //register delegates with event handler m_globals.Events.AddHandler(new MapWindow.Events.MapMouseDownEvent(MapMouseDown)); m_globals.Events.AddHandler(new MapWindow.Events.MapMouseMoveEvent(MapMouseMove)); m_globals.Events.AddHandler(new MapWindow.Events.ItemClickedEvent(ItemClicked)); m_globals.Events.AddHandler(new MapWindow.Events.MapMouseUpEvent(MapMouseUp)); m_globals.Events.AddHandler(new MapWindow.Events.ShapesSelectedEvent(ShapesSelected)); }
//private System.Collections.ArrayList m_Points; public MoveVertexClass(GlobalFunctions globals) { m_globals = globals; m_MapWin = globals.MapWin; //load the cursor m_cursor = new Cursor(this.GetType(), "Move.cur"); m_snapCursor = new Cursor(this.GetType(), "MoveSnap.cur"); m_hDraw = -1; //add events //register delegates with event handler m_globals.Events.AddHandler(new MapWindow.Events.MapMouseDownEvent(MapMouseDown)); m_globals.Events.AddHandler(new MapWindow.Events.MapMouseMoveEvent(MapMouseMove)); m_globals.Events.AddHandler(new MapWindow.Events.ItemClickedEvent(ItemClicked)); m_globals.Events.AddHandler(new MapWindow.Events.MapMouseUpEvent(MapMouseUp)); }
public void Terminate() { if (m_HavePanel && m_UIPanel != null) { m_MapWin.UIPanel.DeletePanel("Identifier"); m_HavePanel = false; m_UIPanel = null; } //unload the buttons m_MapWin.Toolbar.RemoveButton("Identifier"); //unload the toolbar if (m_ToolbarName.Length > 0) { m_MapWin.Toolbar.RemoveToolbar(m_ToolbarName); } m_MapWin = null; }
public Direcciones(MapWindow.Interfaces.IMapWin mw) { InitializeComponent(); MapWin = mw; Datos = new DataAccess(); geocodificacion = new /*Geocodificacion.*/ Geocodificacion(); // leer comunas Comunas = Datos.ObtenerComunas(); ComunasCuerpo = Datos.ObtenerComunasCuerpo(); CallesSinComuna = Datos.ObtenerCallesSinComuna(); //CallesCuerpo = new List<string>(); // calles con comuna //foreach (string s in ComunasCuerpo) //{ // CallesCuerpo.AddRange(Datos.ObtenerCallesConComuna(s)); //} CallesCuerpo = Datos.ObtenerCallesCuerpo(); comboComuna.Items.AddRange(ComunasCuerpo.ToArray()); }
/// <summary> /// Creates a new form object for setting properties of the /// new grid /// </summary> /// <param name="IMapWin">The MapWindow interface</param> /// <param name="shpFileName">File name of the shapefile</param> /// <param name="fieldType">Type of field containing data</param> public frmGrid(MapWindow.Interfaces.IMapWin IMapWin, string shpFileName, MapWinGIS.FieldType fieldType) { InitializeComponent(); //setup event handler this.txtCellSize.TextChanged += new EventHandler(txtCellSize_TextChanged); //initialize the global variables and default values m_MapWin = IMapWin; m_ShpFileName = shpFileName; m_FieldType = fieldType; m_DefaultCellSize = calcDefaultCellsize(); m_DefaultNodataValue = -9999F; m_GridHeader = new MapWinGIS.GridHeader(); //populate the combo boxes populateGridList(); populateExtentLayers(); populateDataTypes(); populateFileTypes(); }
/// <summary> /// Constructor. /// Bulds a snap list from a MapWinGIS.Shapefile. /// </summary> /// <param name="sf">MapWinGIS.Shapefile used to create the list of points to snap on.</param> public SnapClass(MapWindow.Interfaces.IMapWin MapWin) { int startPos = MapWin.Layers.CurrentLayer; int endPos = MapWin.Layers.CurrentLayer + 1; if (MapWin.Menus[GlobalFunctions.c_SnapToAllLayersButton].Checked) { startPos = 0; endPos = MapWin.Layers.NumLayers; } for (int i = startPos; i < endPos; i++) { if (MapWin.Layers[i].LayerType == MapWindow.Interfaces.eLayerType.LineShapefile || MapWin.Layers[i].LayerType == MapWindow.Interfaces.eLayerType.PointShapefile || MapWin.Layers[i].LayerType == MapWindow.Interfaces.eLayerType.PolygonShapefile) { m_sfs.Add(MapWin.Layers[i].Handle, (MapWinGIS.Shapefile)MapWin.Layers[i].GetObject()); MapWinGIS.Shapefile m_sf = (MapWinGIS.Shapefile)m_sfs[MapWin.Layers[i].Handle]; try { m_lists.Add(MapWin.Layers[i].Handle, new System.Collections.SortedList()); System.Collections.SortedList m_list = (System.Collections.SortedList)m_lists[MapWin.Layers[i].Handle]; int numShapes = m_sf.NumShapes; //int numPoints = 0; for (int j = 0; j < numShapes; j++) { AddShapeData(j, MapWin.Layers[i].Handle); } } catch { } } } }
public ShapeGridInfo(MapWindow.Interfaces.IMapWin IMapWin) { m_MapWin = IMapWin; shapeForm = new frmShapefile(m_MapWin); }
private void ItemClicked(string ItemName, ref bool Handled) { try { m_MapWin = m_globals.MapWin; if (ItemName == GlobalFunctions.c_RemoveVertexButton) { if (m_globals.SelectedShapefileIsReadonly()) { MapWinUtility.Logger.Msg("The selected shapefile is read-only and cannot be edited.", "Read-Only Shapefile"); return; } if (m_globals.CurrentMode != GlobalFunctions.Modes.RemoveVertex) { m_globals.CurrentMode = GlobalFunctions.Modes.RemoveVertex; //update the buttons on the toolbar m_globals.UpdateButtons(); //save the previous cusor mode m_globals.SaveCusorMode(); //set cursor mode m_MapWin.View.CursorMode = MapWinGIS.tkCursorMode.cmNone; m_MapWin.View.MapCursor = MapWinGIS.tkCursor.crsrUserDefined; m_MapWin.View.UserCursorHandle = (int)m_cursor.Handle; //create as new snap class if (m_globals.CurrentLayer != null) { m_snapClass = new SnapClass(m_MapWin); } m_prevShape = -1; } else { m_MapWin.View.Draw.ClearDrawing(m_hDraw); m_globals.CurrentMode = GlobalFunctions.Modes.None; //set back the old cursor settings m_globals.RestoreCursorMode(); //update the buttons on the toolbar m_globals.UpdateButtons(); } Handled = true; } else { if (m_MapWin.Toolbar.ButtonItem(GlobalFunctions.c_RemoveVertexButton).Pressed) { m_MapWin.View.Draw.ClearDrawing(m_hDraw); m_globals.CurrentMode = GlobalFunctions.Modes.None; //update the buttons on the toolbar m_globals.UpdateButtons(); } } } catch (System.Exception ex) { m_MapWin.ShowErrorDialog(ex); } }
private void ItemClickedEvent(string ItemName, ref bool Handled) { try { m_MapWin = m_globals.MapWin; m_MapWin.View.Draw.ClearDrawing(m_hDraw); //if (m_MapWin.Layers.CurrentLayer != -1) - This produces a crash with a new project loading! if (m_MapWin.Layers.NumLayers > 0) { if (!m_MapWin.Layers[m_MapWin.Layers.CurrentLayer].VerticesVisible) { m_MapWin.Layers[m_MapWin.Layers.CurrentLayer].HideVertices(); } } if (m_snapper != null) { m_snapper.ClearSnapData(); m_snapper = null; } if (ItemName == GlobalFunctions.c_AddShapeButton) { if (m_globals.SelectedShapefileIsReadonly()) { MapWinUtility.Logger.Msg("The selected shapefile is read-only and cannot be edited.", "Read-Only Shapefile"); return; } // Add a new shape now if (m_globals.CurrentMode == GlobalFunctions.Modes.AddShape) { m_globals.CurrentMode = GlobalFunctions.Modes.None; m_globals.UpdateButtons(); if (m_AddShapeForm != null) { m_AddShapeForm.Close(); } } else { m_globals.CurrentMode = GlobalFunctions.Modes.AddShape; m_globals.UpdateButtons(); AddNewShape(); } Handled = true; } else { if (m_MapWin.Toolbar.ButtonItem(GlobalFunctions.c_AddShapeButton).Pressed) { if (m_snapper != null) { m_snapper.ClearSnapData(); m_snapper = null; } m_MapWin.View.Draw.ClearDrawing(m_hDraw); m_globals.CurrentMode = GlobalFunctions.Modes.None; //get current shapefile layer if (m_MapWin.Layers.NumLayers > 0) { if (!m_MapWin.Layers[m_MapWin.Layers.CurrentLayer].VerticesVisible) { m_MapWin.Layers[m_MapWin.Layers.CurrentLayer].HideVertices(); } } //update the buttons on the toolbar m_globals.UpdateButtons(); } } } catch (System.Exception ex) { m_MapWin.ShowErrorDialog(ex); } }
public bool LoadLabelInfo(MapWindow.Interfaces.IMapWin m_MapWin, MapWindow.Interfaces.Layer layer, ref Forms.Label label, System.Windows.Forms.Form owner) { if (layer == null) { return(false); } //make sure the file exists string filename = ""; if (m_MapWin.View.LabelsUseProjectLevel) { if (m_MapWin.Project.FileName != null && m_MapWin.Project.FileName.Trim() != "") { filename = System.IO.Path.GetFileNameWithoutExtension(m_MapWin.Project.FileName) + @"\" + System.IO.Path.ChangeExtension(System.IO.Path.GetFileName(layer.FileName), ".lbl"); } } if (filename == "" || !System.IO.File.Exists(filename)) { filename = System.IO.Path.ChangeExtension(layer.FileName, ".lbl"); } if (!System.IO.File.Exists(filename)) { return(false); } try { //load the xml file m_doc.Load(filename); //get the root of the file System.Xml.XmlElement root = m_doc.DocumentElement; label.points = new System.Collections.ArrayList(); label.labelShape = new System.Collections.ArrayList(); XmlNodeList nodeList = root.GetElementsByTagName("Labels"); //get the font int field = int.Parse(nodeList[0].Attributes.GetNamedItem("Field").InnerText); int field2 = 0; if (nodeList[0].Attributes.GetNamedItem("Field2") != null) { field2 = int.Parse(nodeList[0].Attributes.GetNamedItem("Field2").InnerText); } string fontName = nodeList[0].Attributes.GetNamedItem("Font").InnerText; float size = float.Parse(nodeList[0].Attributes.GetNamedItem("Size").InnerText); System.Drawing.Color color = System.Drawing.Color.FromArgb(int.Parse(nodeList[0].Attributes.GetNamedItem("Color").InnerText)); int justification = int.Parse(nodeList[0].Attributes.GetNamedItem("Justification").InnerText); bool UseMinZoom = bool.Parse(nodeList[0].Attributes.GetNamedItem("UseMinZoomLevel").InnerText); bool Scaled = false; bool UseShadows = false; System.Drawing.Color ShadowColor = System.Drawing.Color.White; int Offset = 0; double StandardViewWidth = 0.0; bool UseLabelCollision = false; bool RemoveDuplicateLabels = false; string RotationField = ""; try { if (nodeList[0].Attributes.GetNamedItem("Scaled") != null) { Scaled = bool.Parse(nodeList[0].Attributes.GetNamedItem("Scaled").InnerText); } if (nodeList[0].Attributes.GetNamedItem("UseShadows") != null) { UseShadows = bool.Parse(nodeList[0].Attributes.GetNamedItem("UseShadows").InnerText); } if (nodeList[0].Attributes.GetNamedItem("ShadowColor") != null) { ShadowColor = System.Drawing.Color.FromArgb(int.Parse(nodeList[0].Attributes.GetNamedItem("ShadowColor").InnerText)); } if (nodeList[0].Attributes.GetNamedItem("Offset") != null) { Offset = int.Parse(nodeList[0].Attributes.GetNamedItem("Offset").InnerText); } if (nodeList[0].Attributes.GetNamedItem("StandardViewWidth") != null) { StandardViewWidth = double.Parse(nodeList[0].Attributes.GetNamedItem("StandardViewWidth").InnerText); } } catch { Scaled = false; UseShadows = false; ShadowColor = System.Drawing.Color.White; Offset = 0; StandardViewWidth = 0.0; } if (nodeList[0].Attributes.GetNamedItem("UseLabelCollision") != null) { UseLabelCollision = bool.Parse(nodeList[0].Attributes.GetNamedItem("UseLabelCollision").InnerText); } if (nodeList[0].Attributes.GetNamedItem("RemoveDuplicateLabels") != null) { RemoveDuplicateLabels = bool.Parse(nodeList[0].Attributes.GetNamedItem("RemoveDuplicateLabels").InnerText); } if (nodeList[0].Attributes.GetNamedItem("RotationField") != null) { RotationField = nodeList[0].Attributes.GetNamedItem("RotationField").InnerText; } double xMin = double.Parse(nodeList[0].Attributes.GetNamedItem("xMin").InnerText); double yMin = double.Parse(nodeList[0].Attributes.GetNamedItem("yMin").InnerText); double xMax = double.Parse(nodeList[0].Attributes.GetNamedItem("xMax").InnerText); double yMax = double.Parse(nodeList[0].Attributes.GetNamedItem("yMax").InnerText); //set all the properties of the label label.font = new System.Drawing.Font(fontName, size); label.color = color; label.field = field; label.field2 = field2; label.handle = layer.Handle; label.alignment = (MapWinGIS.tkHJustification)justification; label.UseMinExtents = UseMinZoom; label.Scaled = Scaled; label.UseShadows = UseShadows; label.shadowColor = ShadowColor; label.Offset = Offset; label.StandardViewWidth = StandardViewWidth; label.RotationField = RotationField; if (nodeList[0].Attributes.GetNamedItem("UseLabelCollision") != null) { label.UseLabelCollision = UseLabelCollision; } if (nodeList[0].Attributes.GetNamedItem("RemoveDuplicateLabels") != null) { label.RemoveDuplicates = RemoveDuplicateLabels; } if (nodeList[0].Attributes.GetNamedItem("AppendLine1") != null) { label.AppendLine1 = nodeList[0].Attributes.GetNamedItem("AppendLine1").InnerText; } if (nodeList[0].Attributes.GetNamedItem("AppendLine2") != null) { label.AppendLine2 = nodeList[0].Attributes.GetNamedItem("AppendLine2").InnerText; } if (nodeList[0].Attributes.GetNamedItem("PrependLine1") != null) { label.PrependLine1 = nodeList[0].Attributes.GetNamedItem("PrependLine1").InnerText; } if (nodeList[0].Attributes.GetNamedItem("PrependLine2") != null) { label.PrependLine2 = nodeList[0].Attributes.GetNamedItem("PrependLine2").InnerText; } label.extents = new MapWinGIS.ExtentsClass(); label.extents.SetBounds(xMin, yMin, 0, xMax, yMax, 0); label.Modified = false; label.LabelExtentsChanged = false; label.updateHeaderOnly = true; //add all the points to this label Forms.Point p; XmlNode node; double x, y, rotation = 0; System.Collections.IEnumerator enumerator = nodeList[0].ChildNodes.GetEnumerator(); while (enumerator.MoveNext()) { node = (XmlNode)enumerator.Current; x = double.Parse(node.Attributes.GetNamedItem("X").InnerText); y = double.Parse(node.Attributes.GetNamedItem("Y").InnerText); if (nodeList[0].Attributes.GetNamedItem("Rotation") != null) { rotation = double.Parse(node.Attributes.GetNamedItem("Rotation").InnerText); } p = new Forms.Point(); p.x = x; p.y = y; p.rotation = rotation; label.points.Add(p); } label.xml_LblFile = m_doc.InnerXml; } catch { return(false); } return(true); }
/// <summary> /// Exports the shapes that are selected in the MapWindow view to a new shapefile. /// </summary> /// <param name="MapWin">A reference to the running MapWindow.</param> /// <param name="ExportToSFPath">The full path to where the result shapefile should be saved.</param> /// <param name="AddToMap">Indicates that the output should be added to the map view immediately.</param> /// <returns>False if an error occurs, true otherwise.</returns> public static bool ExportSelectedMWViewShapes(MapWindow.Interfaces.IMapWin MapWin, string ExportToSFPath, bool AddToMap) { MapWinUtility.Logger.Dbg("ExportSelectedMWViewShapes(MapWin: IMapWin,\n" + " ExportToSFPath: " + ExportToSFPath + ",\n" + " AddToMap: " + AddToMap.ToString() + ")"); if (MapWin.Layers.NumLayers == 0) { gErrorMsg = "Please select a layer first."; Error.SetErrorMsg(gErrorMsg); MapWinUtility.Logger.Dbg(gErrorMsg); return(false); } if (MapWin.View.SelectedShapes.NumSelected == 0) { gErrorMsg = "There are no selected features to export. Please select a feature first."; Error.SetErrorMsg(gErrorMsg); MapWinUtility.Logger.Dbg(gErrorMsg); return(false); } MapWinGIS.Shapefile sf = new MapWinGIS.Shapefile(); MapWinGIS.Shapefile tollSF = new MapWinGIS.Shapefile(); MapWinGIS.Field fld = new MapWinGIS.Field(); MapWinGIS.Shape seg = new MapWinGIS.Shape(); int Segments; bool Status; Status = sf.Open(MapWin.Layers[MapWin.Layers.CurrentLayer].FileName, null); if (Status == false) { gErrorMsg = sf.get_ErrorMsg(sf.LastErrorCode); Error.SetErrorMsg(gErrorMsg); MapWinUtility.Logger.Dbg(gErrorMsg); return(false); } if (System.IO.File.Exists(ExportToSFPath)) { try { DataManagement.DeleteShapefile(ref ExportToSFPath); } catch { gErrorMsg = "The destination file already exists, but could not be deleted. Please check to make sure the file isn't in use."; Error.SetErrorMsg(gErrorMsg); MapWinUtility.Logger.Dbg(gErrorMsg); return(false); } } Status = tollSF.CreateNew(ExportToSFPath, sf.ShapefileType); if (Status == false) { gErrorMsg = tollSF.get_ErrorMsg(tollSF.LastErrorCode); Error.SetErrorMsg(gErrorMsg); MapWinUtility.Logger.Dbg(gErrorMsg); return(false); } try { tollSF.Projection = sf.Projection; } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); } Status = tollSF.StartEditingShapes(true, null); if (Status == false) { gErrorMsg = tollSF.get_ErrorMsg(tollSF.LastErrorCode); Error.SetErrorMsg(gErrorMsg); MapWinUtility.Logger.Dbg(gErrorMsg); return(false); } fld.Name = "MWShapeID"; fld.Type = MapWinGIS.FieldType.INTEGER_FIELD; fld.Width = 12; Segments = 0; // Chris M -- This is already opened above, why open // it again here? // sf.Open(MapWin.Layers[MapWin.Layers.CurrentLayer].FileName, null); for (int j = 0; j <= sf.NumFields - 1; j++) { tollSF.EditInsertField(sf.get_Field(j), ref j, null); } MapWin.View.MapCursor = MapWinGIS.tkCursor.crsrWait; try { for (int i = 0; i <= MapWin.View.SelectedShapes.NumSelected - 1; i++) { seg = sf.get_Shape(MapWin.View.SelectedShapes[i].ShapeIndex); Status = tollSF.EditInsertShape(seg, ref Segments); if (Status == false) { gErrorMsg = tollSF.get_ErrorMsg(tollSF.LastErrorCode); Error.SetErrorMsg(gErrorMsg); MapWinUtility.Logger.Dbg(gErrorMsg); return(false); } for (int h = 0; h <= sf.NumFields - 1; h++) { tollSF.EditCellValue(h, i, sf.get_CellValue(h, MapWin.View.SelectedShapes[i].ShapeIndex)); } Segments = Segments + 1; } sf.Close(); tollSF.StopEditingShapes(true, true, null); } catch (Exception ex) { gErrorMsg = ex.Message; Error.SetErrorMsg(gErrorMsg); MapWinUtility.Logger.Dbg(gErrorMsg); } MapWin.View.MapCursor = MapWinGIS.tkCursor.crsrArrow; tollSF.Close(); if (AddToMap) { MapWin.View.LockMap(); MapWindow.Interfaces.Layer thelayer; thelayer = MapWin.Layers.Add(ExportToSFPath, System.IO.Path.GetFileNameWithoutExtension(ExportToSFPath), true); thelayer.ClearLabels(); MapWin.View.UnlockMap(); } MapWinUtility.Logger.Dbg("Finished ExportSelectedMWViewShapes"); return(true); }
// Chris Michaelis August 15 2006 /// <summary> /// Exports the shapes that are selected in the MapWindow view to a new shapefile. /// </summary> /// <param name="MapWin">A reference to the running MapWindow.</param> /// <param name="ExportToSFPath">The full path to where the result shapefile should be saved.</param> /// <returns>False if an error occurs, true otherwise.</returns> public static bool ExportSelectedMWViewShapes(MapWindow.Interfaces.IMapWin MapWin, string ExportToSFPath) { return(ExportSelectedMWViewShapes(MapWin, ExportToSFPath, false)); }
public Coincidencias(/*Geocodificacion.*/ GeoReferencia[] DC, MapWindow.Interfaces.IMapWin mw, List <string> comunas) { InitializeComponent(); this.MapWin = mw; this.DC = DC; // setear columnas if (DC[0].TipoRef == /*Geocodificacion.*/ TipoReferencia.Altura) { listCalles.Columns.Add(HeaderConAltura[0]); listCalles.Columns.Add(HeaderConAltura[1]); listCalles.Columns.Add(HeaderConAltura[2]); listCalles.Columns[0].Width = (listCalles.Width * 49 / 100); listCalles.Columns[1].Width = (listCalles.Width * 20 / 100); listCalles.Columns[2].Width = (listCalles.Width * 30 / 100); } if (DC[0].TipoRef == /*Geocodificacion.*/ TipoReferencia.Esquina) { listCalles.Columns.Add(HeaderInterseccion[0]); listCalles.Columns.Add(HeaderInterseccion[1]); listCalles.Columns.Add(HeaderInterseccion[2]); listCalles.Columns[0].Width = (listCalles.Width * 35 / 100); listCalles.Columns[1].Width = (listCalles.Width * 35 / 100); listCalles.Columns[2].Width = (listCalles.Width * 29 / 100); } if (DC[0].TipoRef == /*Geocodificacion.*/ TipoReferencia.Tramo) { listCalles.Columns.Add(HeaderTramo[0]); listCalles.Columns.Add(HeaderTramo[1]); listCalles.Columns.Add(HeaderTramo[2]); listCalles.Columns[0].Width = (listCalles.Width * 20 / 100); listCalles.Columns[1].Width = (listCalles.Width * 49 / 100); listCalles.Columns[2].Width = (listCalles.Width * 30 / 100); } // agregar coincidencias foreach (/*Geocodificacion.*/ GeoReferencia gr in DC) { ListViewItem Li = listCalles.Items.Add(gr.Dato1); Li.SubItems.Add(gr.Dato2); Li.SubItems.Add(gr.Dato3); switch (gr.TipoRef) { case /*Geocodificacion.*/ TipoReferencia.Altura: case /*Geocodificacion.*/ TipoReferencia.Esquina: Li.BackColor = Color.LightGreen; break; case /*Geocodificacion.*/ TipoReferencia.Tramo: Li.BackColor = Color.LightYellow; break; } /* * const string fic = @"Plugins\Referencias.txt"; * string texto3 = gr.Punto1.ToString(); * string texto4 = gr.Punto2.ToString(); * * System.IO.StreamWriter sw = new System.IO.StreamWriter(fic); * sw.WriteLine(texto1); * sw.WriteLine(texto2); * sw.WriteLine("-----------------------------"); * sw.WriteLine(texto3); * sw.WriteLine(texto4); * sw.Close(); * */ } //if (DC.Length == 1) // listCalles.Items[0].Selected = true; // mostrar primero if (DC.Length != 0) { Mostrar(0); listCalles.Items[0].Selected = true; listCalles.Select(); } }
private void ItemClicked(string ItemName, ref bool Handled) { try { m_MapWin = m_globals.MapWin; if (ItemName == GlobalFunctions.c_MoveShapesButton) { if (m_globals.CurrentMode != GlobalFunctions.Modes.MoveShape) { m_globals.CurrentMode = GlobalFunctions.Modes.MoveShape; //update the buttons on the toolbar m_globals.UpdateButtons(); //save the previous cusor mode m_globals.SaveCusorMode(); //set cursor mode m_MapWin.View.CursorMode = MapWinGIS.tkCursorMode.cmNone; m_MapWin.View.MapCursor = MapWinGIS.tkCursor.crsrUserDefined; m_MapWin.View.UserCursorHandle = (int)m_cursor.Handle; //get current shapefile layer if (m_globals.CurrentLayer == null) { return; } MapWinGIS.Shapefile shpFile = m_globals.CurrentLayer; m_prevShape = -1; //create as new snap class if (m_globals.CurrentLayer == null) { return; } m_snapClass = new SnapClass(m_MapWin); } else { m_MapWin.View.Draw.ClearDrawing(m_hDraw); m_globals.CurrentMode = GlobalFunctions.Modes.None; //set back the old cursor settings m_globals.RestoreCursorMode(); //update the buttons on the toolbar m_globals.UpdateButtons(); } Handled = true; } else { if (m_MapWin.Toolbar.ButtonItem(GlobalFunctions.c_MoveShapesButton).Pressed) { m_MapWin.View.Draw.ClearDrawing(m_hDraw); m_globals.CurrentMode = GlobalFunctions.Modes.None; //get current shapefile layer m_MapWin.Layers[m_MapWin.Layers.CurrentLayer].HideVertices(); //update the buttons on the toolbar m_globals.UpdateButtons(); } } } catch (System.Exception ex) { m_MapWin.ShowErrorDialog(ex); } }