-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathQueryMapPropertyEditor.cs
More file actions
172 lines (147 loc) · 4.87 KB
/
Copy pathQueryMapPropertyEditor.cs
File metadata and controls
172 lines (147 loc) · 4.87 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.IO;
using OSGeo.MapServer;
namespace DMS.MapLibrary
{
/// <summary>
/// Represents a UserControl for editing the MapScript scalebarObj parameters.
/// </summary>
public partial class QueryMapPropertyEditor : UserControl, IPropertyEditor
{
private MapObjectHolder target;
private queryMapObj queryMap;
private bool dirtyFlag;
private mapObj map;
/// <summary>
/// Constructs a new ScalebarPropertyEditor object.
/// </summary>
public QueryMapPropertyEditor()
{
InitializeComponent();
}
/// <summary>
/// Sets the modify flag of the editor.
/// </summary>
/// <param name="dirty">The modify flag to be set.</param>
private void SetDirty(bool dirty)
{
dirtyFlag = dirty;
if (dirty)
{
if (target != null)
target.RaisePropertyChanging(this);
}
}
/// <summary>
/// Update the scalebar object according to the current Editor state.
/// </summary>
/// <param name="queryMap">The object to be updated.</param>
private void Update(queryMapObj queryMap)
{
if (comboBoxStatus.SelectedItem.ToString() == "MS_ON")
queryMap.status = mapscript.MS_ON;
else
queryMap.status = mapscript.MS_OFF;
queryMap.style = (int)comboBoxStyle.SelectedItem;
this.colorPickerColor.ApplyTo(queryMap.color);
}
#region IPropertyEditor Members
/// <summary>
/// Cancel the pending changes in the underlying object.
/// </summary>
public void CancelEditing()
{
}
/// <summary>
/// Update the preview according to the current Editor state.
/// In case of the preview a temporary object will only be updated.
/// </summary>
public void UpdateValues()
{
if (queryMap == null)
return;
if (dirtyFlag)
{
Update(this.queryMap);
if (target != null)
target.RaisePropertyChanged(this);
SetDirty(false);
}
}
/// <summary>
/// Returns the modified state of the Editor.
/// </summary>
/// <returns>The current modified state.</returns>
public bool IsDirty()
{
return dirtyFlag;
}
#endregion
#region IMapControl Members
/// <summary>
/// Refresh the controls according to the underlying object.
/// </summary>
public void RefreshView()
{
if (queryMap == null)
return;
comboBoxStatus.Items.AddRange(new object[] { "MS_ON", "MS_OFF"});
if (queryMap.status == mapscript.MS_ON)
comboBoxStatus.SelectedItem = "MS_ON";
else
comboBoxStatus.SelectedItem = "MS_OFF";
comboBoxStyle.DataSource = Enum.GetValues(typeof(MS_QUERYMAP_STYLES));
comboBoxStyle.SelectedItem = (MS_QUERYMAP_STYLES)queryMap.style;
this.colorPickerColor.SetColor(queryMap.color);
SetDirty(false);
}
/// <summary>
/// Gets and sets the target object of the editor.
/// </summary>
public MapObjectHolder Target
{
get
{
return target;
}
set
{
if (value != null)
{
if (value.GetType() != typeof(queryMapObj))
throw new ApplicationException("Invalid object type.");
queryMap = value;
target = value;
// tracking down the root object
map = target.GetParent();
RefreshView();
SetDirty(false);
return;
}
queryMap = null;
target = null;
map = null;
}
}
/// <summary>
/// The EditProperties event handler. Called when a child object should be edited
/// </summary>
public event EditPropertiesEventHandler EditProperties = delegate { };
#endregion
/// <summary>
/// Common function to sign that a value have been changed.
/// </summary>
/// <param name="sender">The source object of this event.</param>
/// <param name="e">The event parameters.</param>
private void ValueChanged(object sender, EventArgs e)
{
SetDirty(true);
}
}
}