Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
29 changes: 12 additions & 17 deletions Examples/DemoWinForm/ConvertProjectionAndCoordinatesForm.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DemoWinForm
{
public partial class ConvertProjectionAndCoordinatesForm : Form
{
public ConvertProjectionAndCoordinatesForm()
{
InitializeComponent();
}
public partial class ConvertProjectionAndCoordinatesForm : Form
{
public ConvertProjectionAndCoordinatesForm()
{
InitializeComponent();
}

protected override void OnResize(EventArgs e)
{
base.OnResize(e);
protected override void OnResize(EventArgs e)
{
base.OnResize(e);

MainSplitContainer.SplitterDistance = (Width - MainSplitContainer.SplitterWidth) / 2;
}
}
MainSplitContainer.SplitterDistance = (Width - MainSplitContainer.SplitterWidth) / 2;
}
}
}
8 changes: 4 additions & 4 deletions Examples/DemoWinForm/DemoWinForm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
<Reference Include="System.Windows.Forms" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="ProjNet4GeoAPI" Version="1.4.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\SharpMap\SharpMap.csproj" />
<ProjectReference Include="..\..\SharpMap.UI\SharpMap.UI.csproj" />
Expand All @@ -37,4 +33,8 @@
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.1.1" />
</ItemGroup>

</Project>
57 changes: 28 additions & 29 deletions Examples/DemoWinForm/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@
// along with SharpMap; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using DemoWinForm.Properties;
using NetTopologySuite.Geometries;
using SharpMap.Data;
using SharpMap.Data.Providers;
using SharpMap.Forms;
using GeoAPI.Geometries;
using SharpMap.Layers;
using GeoPoint = GeoAPI.Geometries.Coordinate;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using GeoPoint = NetTopologySuite.Geometries.Coordinate;

namespace DemoWinForm
{
Expand Down Expand Up @@ -67,16 +66,16 @@ private void registerSymbols()

private static void registerKnownColors(Dictionary<string, Color> colorTable)
{
foreach (string colorName in Enum.GetNames(typeof (KnownColor)))
foreach (string colorName in Enum.GetNames(typeof(KnownColor)))
{
KnownColor color = (KnownColor) Enum.Parse(typeof (KnownColor), colorName);
KnownColor color = (KnownColor)Enum.Parse(typeof(KnownColor), colorName);
colorTable[colorName] = Color.FromKnownColor(color);
}
}

private void registerLayerFactories()
{
// ConfigurationManager.GetSection("LayerFactories");
// ConfigurationManager.GetSection("LayerFactories");
_layerFactoryCatalog[".shp"] = new ShapeFileLayerFactory();
}

Expand All @@ -90,7 +89,7 @@ private void addLayer(ILayer layer)
private void addNewRandomGeometryLayer()
{
Random rndGen = new Random();
Collection<IGeometry> geometry = new Collection<IGeometry>();
Collection<Geometry> geometry = new Collection<Geometry>();

VectorLayer layer = new VectorLayer(String.Empty);
var gf = new GeometryFactory();
Expand Down Expand Up @@ -157,35 +156,35 @@ private Color GetRandomColor(Random rndGen)
return Color.FromArgb(rndGen.Next(255), rndGen.Next(255), rndGen.Next(255));
}

private static void GeneratePolygons(IGeometryFactory factory, ICollection<IGeometry> geometry, Random rndGen)
private static void GeneratePolygons(GeometryFactory factory, ICollection<Geometry> geometry, Random rndGen)
{
int numPolygons = rndGen.Next(10, 100);
for (var polyIndex = 0; polyIndex < numPolygons; polyIndex++)
{
var vertices = new GeoPoint[5];
var upperLeft = new GeoPoint(rndGen.NextDouble()*1000, rndGen.NextDouble()*1000);
var sideLength = rndGen.NextDouble()*50;
var upperLeft = new GeoPoint(rndGen.NextDouble() * 1000, rndGen.NextDouble() * 1000);
var sideLength = rndGen.NextDouble() * 50;

// Make a square
vertices[0] = new GeoPoint(upperLeft.X, upperLeft.Y);
vertices[1] = new GeoPoint(upperLeft.X + sideLength, upperLeft.Y);
vertices[2] = new GeoPoint(upperLeft.X + sideLength, upperLeft.Y - sideLength);
vertices[3] = new GeoPoint(upperLeft.X, upperLeft.Y - sideLength);
vertices[4] = upperLeft;

geometry.Add(factory.CreatePolygon(factory.CreateLinearRing(vertices), null));
}
}

private static void GenerateLines(IGeometryFactory factory, ICollection<IGeometry> geometry, Random rndGen)
private static void GenerateLines(GeometryFactory factory, ICollection<Geometry> geometry, Random rndGen)
{
var numLines = rndGen.Next(10, 100);
for (var lineIndex = 0; lineIndex < numLines; lineIndex++)
{
var numVerticies = rndGen.Next(4, 15);
var vertices = new GeoPoint[numVerticies];

var lastPoint = new GeoPoint(rndGen.NextDouble()*1000, rndGen.NextDouble()*1000);
var lastPoint = new GeoPoint(rndGen.NextDouble() * 1000, rndGen.NextDouble() * 1000);
vertices[0] = lastPoint;

for (var vertexIndex = 1; vertexIndex < numVerticies; vertexIndex++)
Expand All @@ -200,12 +199,12 @@ private static void GenerateLines(IGeometryFactory factory, ICollection<IGeometr
}
}

private static void GeneratePoints(IGeometryFactory factory, ICollection<IGeometry> geometry, Random rndGen)
private static void GeneratePoints(GeometryFactory factory, ICollection<Geometry> geometry, Random rndGen)
{
var numPoints = rndGen.Next(10, 100);
for (var pointIndex = 0; pointIndex < numPoints; pointIndex++)
{
var point = new GeoPoint(rndGen.NextDouble()*1000, rndGen.NextDouble()*1000);
var point = new GeoPoint(rndGen.NextDouble() * 1000, rndGen.NextDouble() * 1000);
geometry.Add(factory.CreatePoint(point));
}
}
Expand Down Expand Up @@ -273,7 +272,7 @@ private void changeMode(MapBox.Tools tool)

private object getLayerTypeIcon(Type type)
{
if (type == typeof (VectorLayer))
if (type == typeof(VectorLayer))
{
return Resources.polygon;
}
Expand Down Expand Up @@ -335,32 +334,32 @@ private void MainMapImage_MapQueried(FeatureDataTable data)

private void AddLayerToolStripButton_Click(object sender, EventArgs e)
{
BeginInvoke((MethodInvoker) delegate { LoadLayer(); });
BeginInvoke((MethodInvoker)delegate { LoadLayer(); });
}

private void RemoveLayerToolStripButton_Click(object sender, EventArgs e)
{
BeginInvoke((MethodInvoker) delegate { RemoveLayer(); });
BeginInvoke((MethodInvoker)delegate { RemoveLayer(); });
}

private void AddLayerToolStripMenuItem_Click(object sender, EventArgs e)
{
BeginInvoke((MethodInvoker) delegate { LoadLayer(); });
BeginInvoke((MethodInvoker)delegate { LoadLayer(); });
}

private void RemoveLayerToolStripMenuItem_Click(object sender, EventArgs e)
{
BeginInvoke((MethodInvoker) delegate { RemoveLayer(); });
BeginInvoke((MethodInvoker)delegate { RemoveLayer(); });
}

private void ZoomToExtentsToolStripButton_Click(object sender, EventArgs e)
{
BeginInvoke((MethodInvoker) delegate { zoomToExtents(); });
BeginInvoke((MethodInvoker)delegate { zoomToExtents(); });
}

private void PanToolStripButton_Click(object sender, EventArgs e)
{
BeginInvoke((MethodInvoker) delegate { changeMode(MapBox.Tools.Pan); });
BeginInvoke((MethodInvoker)delegate { changeMode(MapBox.Tools.Pan); });
}

private void QueryModeToolStripButton_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -418,7 +417,7 @@ private void MoveDownToolStripMenuItem_Click(object sender, EventArgs e)

private void LayersDataGridView_SelectionChanged(object sender, EventArgs e)
{
BeginInvoke((MethodInvoker) delegate
BeginInvoke((MethodInvoker)delegate
{
changeUIOnLayerSelectionChange();

Expand All @@ -437,7 +436,7 @@ private void MainMapImage_MouseMove(GeoPoint WorldPos, MouseEventArgs ImagePos)

private void AddNewRandomGeometryLayer_Click(object sender, EventArgs e)
{
BeginInvoke((MethodInvoker) delegate { addNewRandomGeometryLayer(); });
BeginInvoke((MethodInvoker)delegate { addNewRandomGeometryLayer(); });
}
}
}
14 changes: 6 additions & 8 deletions Examples/DemoWinForm/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
// along with SharpMap; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

using System;
using System.Text;
using System.Windows.Forms;
using NetTopologySuite;
using ProjNet.CoordinateSystems;
using ProjNet.CoordinateSystems.Transformations;
using SharpMap.CoordinateSystems;
using System;
using System.Windows.Forms;

namespace DemoWinForm
{
Expand All @@ -32,13 +32,11 @@ internal static class Program
[STAThread]
private static void Main()
{
var gss = new NtsGeometryServices();
var css = new SharpMap.CoordinateSystems.CoordinateSystemServices(
var gss = NtsGeometryServices.Instance;
var css = new CoordinateSystemServices(
new CoordinateSystemFactory(),
new CoordinateTransformationFactory(),
SharpMap.Converters.WellKnownText.SpatialReference.GetAllReferenceSystems());

GeoAPI.GeometryServiceProvider.Instance = gss;
SharpMap.Session.Instance
.SetGeometryServices(gss)
.SetCoordinateSystemServices(css)
Expand All @@ -49,4 +47,4 @@ private static void Main()
Application.Run(new MainForm());
}
}
}
}
6 changes: 3 additions & 3 deletions Examples/ExampleCodeSnippets/ClipLabelPosition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/// </summary>
public class ClipLabelPosition
{
private GeoAPI.Geometries.IGeometry _clip;
private GeoAPI.Geometries.Prepared.IPreparedGeometry _prepClip;
private NetTopologySuite.Geometries.Geometry _clip;
private NetTopologySuite.Geometries.Prepared.IPreparedGeometry _prepClip;

/// <summary>
/// Creates an instance of this class
Expand All @@ -27,7 +27,7 @@ public ClipLabelPosition(SharpMap.Map map)
/// </summary>
/// <param name="row">A feature</param>
/// <returns>A label position</returns>
public GeoAPI.Geometries.Coordinate GetClippedPosition(SharpMap.Data.FeatureDataRow row)
public NetTopologySuite.Geometries.Coordinate GetClippedPosition(SharpMap.Data.FeatureDataRow row)
{
var g = _prepClip.Contains(row.Geometry)
? row.Geometry
Expand Down
Loading