forked from SharpMap/SharpMap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapDecorationTest.cs
More file actions
85 lines (77 loc) · 2.93 KB
/
MapDecorationTest.cs
File metadata and controls
85 lines (77 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System.Collections.Generic;
using System.Drawing;
using GeoAPI.Geometries;
using NUnit.Framework;
using SharpMap;
using SharpMap.Data.Providers;
using SharpMap.Rendering.Decoration;
//using SharpMap.Geometries;
using SharpMap.Rendering.Decoration.ScaleBar;
using SharpMap.Layers;
using GeoPoint = GeoAPI.Geometries.Coordinate;
namespace UnitTests
{
public class TestDecoration : MapDecoration
{
protected override Size InternalSize(Graphics g, MapViewport map)
{
return new Size(50, 30);
}
protected override void OnRender(Graphics g, MapViewport map)
{
g.FillRegion(new SolidBrush(OpacityColor(Color.Red)), g.Clip);
}
}
public class MapDecorationTest
{
[Test]
public void TestMapDecorationTest()
{
var m = new Map(new Size(780, 540)) {BackColor = Color.White};
var p = new GeometryProvider(new List<IGeometry>());
var pts = new [] {new GeoPoint(0, 0), new GeoPoint(779, 539)};
var ls = m.Factory.CreateLineString(pts);
p.Geometries.Add(ls);
m.Layers.Add(new VectorLayer("t",p));
m.ZoomToExtents();
m.Decorations.Add(new TestDecoration
{
Anchor = MapDecorationAnchor.LeftTop,
BorderColor = Color.Green,
BackgroundColor = Color.LightGreen,
BorderWidth = 2,
Location = new Point(10, 10),
BorderMargin = new Size(5, 5),
RoundedEdges = true,
Opacity = 0.6f
});
m.Decorations.Add(new TestDecoration
{
Anchor = MapDecorationAnchor.RightTop,
BorderColor = Color.Red,
BackgroundColor = Color.LightCoral,
BorderWidth = 2,
Location = new Point(10, 10),
BorderMargin = new Size(5, 5),
RoundedEdges = true,
Opacity = 0.2f
});
m.Decorations.Add(new ScaleBar
{
Anchor = MapDecorationAnchor.Default,
BorderColor = Color.Blue,
BackgroundColor = Color.CornflowerBlue,
BorderWidth = 2,
Location = new Point(10, 10),
BorderMargin = new Size(5, 5),
RoundedEdges = true,
BarWidth = 4,
ScaleText =ScaleBarLabelText.RepresentativeFraction,
NumTicks = 2,
Opacity = 1f
});
using (var bmp = m.GetMap())
bmp.Save(System.IO.Path.Combine(UnitTestsFixture.GetImageDirectory(this), "TestMapDecorationTest.bmp"));
}
}
}