private void DrawShape() { MapWindow.Interfaces.Draw d = m_globals.MapWin.View.Draw; MapWindow.Interfaces.Layer l = m_globals.MapWin.Layers[m_globals.MapWin.Layers.CurrentLayer]; PointD prev = null; for (int i = 0; i < m_Shape.NumPoints; i++) { PointD p = m_Shape[i]; d.DrawPoint(p.x, p.y, m_PointSize, System.Drawing.Color.Blue); if (prev != null) { if (l.LayerType == MapWindow.Interfaces.eLayerType.PolygonShapefile) { d.DrawLine(prev.x, prev.y, p.x, p.y, (int)l.LineOrPointSize, l.OutlineColor); } else { d.DrawLine(prev.x, prev.y, p.x, p.y, (int)l.LineOrPointSize, l.Color); } } prev = p; } }
private void MouseMoveEvent(int ScreenX, int ScreenY, ref bool Handled) { try { if ((m_globals.CurrentMode == GlobalFunctions.Modes.AddShape) && (this.Visible)) { m_globals.MapWin.View.UserCursorHandle = m_cursor.Handle.ToInt32(); double x = 0, y = 0; m_globals.MapWin.View.PixelToProj((double)ScreenX, (double)ScreenY, ref x, ref y); PointD snappedPoint = null; System.Collections.ArrayList bestPoints = null; if (m_snapper != null && m_snapper.CanSnap(m_globals.CurrentTolerance, x, y, m_Shape, ref bestPoints)) { snappedPoint = ((SnapData)bestPoints[0]).point; this.txtX.Text = snappedPoint.x.ToString(); this.txtY.Text = snappedPoint.y.ToString(); if (m_Shape.NumPoints > 0) { m_globals.MapWin.View.Draw.ClearDrawing(m_drawHandle); m_drawHandle = m_globals.MapWin.View.Draw.NewDrawing(MapWinGIS.tkDrawReferenceList.dlSpatiallyReferencedList); DrawShape(); MapWindow.Interfaces.Draw d = m_globals.MapWin.View.Draw; if (m_globals.MapWin.Layers[m_globals.MapWin.Layers.CurrentLayer].LayerType == MapWindow.Interfaces.eLayerType.PolygonShapefile) { d.DrawLine(m_Shape[m_Shape.NumPoints - 1].x, m_Shape[m_Shape.NumPoints - 1].y, snappedPoint.x, snappedPoint.y, 2, m_globals.MapWin.Layers[m_globals.MapWin.Layers.CurrentLayer].OutlineColor); } else { d.DrawLine(m_Shape[m_Shape.NumPoints - 1].x, m_Shape[m_Shape.NumPoints - 1].y, snappedPoint.x, snappedPoint.y, 2, m_globals.MapWin.Layers[m_globals.MapWin.Layers.CurrentLayer].Color); } } } else { this.txtX.Text = x.ToString(); this.txtY.Text = y.ToString(); if (m_Shape.NumPoints > 0) { m_globals.MapWin.View.Draw.ClearDrawing(m_drawHandle); m_drawHandle = m_globals.MapWin.View.Draw.NewDrawing(MapWinGIS.tkDrawReferenceList.dlSpatiallyReferencedList); DrawShape(); MapWindow.Interfaces.Draw d = m_globals.MapWin.View.Draw; d.DrawLine(m_Shape[m_Shape.NumPoints - 1].x, m_Shape[m_Shape.NumPoints - 1].y, x, y, 2, System.Drawing.Color.Blue); } } } } catch { } }