forked from SharpMap/SharpMap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormMapBox.cs
More file actions
85 lines (75 loc) · 2.71 KB
/
FormMapBox.cs
File metadata and controls
85 lines (75 loc) · 2.71 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;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;
using SharpMap.Forms;
using SharpMap.Layers;
namespace WinFormSamples
{
public partial class FormMapBox : Form
{
private static readonly Dictionary<string, Type> MapDecorationTypes = new Dictionary<string, Type>();
private static bool AddToListView;
public FormMapBox()
{
AddToListView = false;
AppDomain.CurrentDomain.AssemblyLoad += HandleAssemblyLoad;
InitializeComponent();
mapBox1.ActiveTool = MapBox.Tools.Pan;
AddToListView = true;
foreach (var name in MapDecorationTypes.Keys)
{
lvwDecorations.Items.Add(name);
}
pgMapDecoration.SelectedObject = null;
}
private void HandleAssemblyLoad(object sender, AssemblyLoadEventArgs args)
{
var mdtype = typeof (SharpMap.Rendering.Decoration.IMapDecoration);
foreach (Type type in args.LoadedAssembly.GetTypes())
{
//if (type.FullName.StartsWith("SharpMap.Decoration"))
// Console.WriteLine(type.FullName);
if (mdtype.IsAssignableFrom(type))
{
if (!type.IsAbstract)
{
if (AddToListView)
lvwDecorations.Items.Add(new ListViewItem(type.Name));
MapDecorationTypes.Add(type.Name, type);
}
}
}
}
private void UpdatePropertyGrid()
{
if (pgMap.InvokeRequired)
pgMap.Invoke(new MethodInvoker(() => pgMap.Update()));
else
pgMap.Update();
}
private static void AdjustRotation(LayerCollection lc, float angle)
{
foreach (ILayer layer in lc)
{
if (layer is VectorLayer)
((VectorLayer) layer).Style.SymbolRotation = -angle;
else if (layer is LabelLayer)
((LabelLayer)layer).Style.Rotation = -angle;
}
}
private static string[] GetOpenFileName(string filter)
{
using (var ofd = new OpenFileDialog())
{
ofd.CheckFileExists = true;
ofd.ShowReadOnly = false;
ofd.Multiselect = true;
ofd.Filter = filter;
if (ofd.ShowDialog() == DialogResult.OK)
return ofd.FileNames;
return null;
}
}
}
}