-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainForm.cs
543 lines (467 loc) · 18.3 KB
/
MainForm.cs
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
using PIE.AxControls;
using PIE.Carto;
using PIE.Controls;
using PIE.Geometry;
using PIE.SystemUI;
using PIE.CommonAlgo;
using PIE.Framework;
using PIE.Plugin;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AnalyseImageCshap;
using System.Threading;
using System.Windows.Forms;
namespace PIESDKUser
{
public partial class MainForm : Form
{
#region 成员变量
public static MainForm parentForm = null;
/// <summary>
/// 地图控件对象
/// </summary>
PIE.SystemUI.ITrackerCancel m_TrackerCancel = new PIE.SystemUI.TrackerCancel();
//MapControl m_MapControl;
/// <summary>
/// TOC控件对象
/// </summary>
TOCControl m_TOCControl;
public MapControl axMapControl2;
//ProgressBar progressBar = new ProgressBar();
//StatusBar m_StatusBar;
#endregion
#region 构造函数
/// <summary>
/// 构造函数
/// </summary>
public MainForm()
{
InitializeComponent();
// 添加MapControl,this.axMapControl2 = new PIE.AxControls.MapControl();
axMapControl2 = new PIE.AxControls.MapControl();
axMapControl2.ActiveView.TrackerCancel = m_TrackerCancel;
//m_MapControl = new MapControl();
axMapControl2.Dock = DockStyle.Fill;
splitContainer1.Panel2.Controls.Add(axMapControl2);
axMapControl2.MouseMove += axMapControl2_MouseMove;
axMapControl2.MouseClick += axMapControl2_MouseClick;
//splitContainer1.Panel2.MouseClick+= axMapControl2_MouseClick;
//axMapControl2.Click += axMapControl2_MouseClick;
//IMap map = axMapControl2.FocusMap;
// 添加TOCControl
m_TOCControl = new TOCControl();
m_TOCControl.SetBuddyControl(axMapControl2);
m_TOCControl.Dock = DockStyle.Fill;
splitContainer1.Panel1.Controls.Add(m_TOCControl);
m_TOCControl.MouseClick += m_TOCControl_MouseClick;
//状态栏
//m_StatusBar = statusStrip1 as IStatusBar;
//m_StatusBar.Initial();
// TOC按钮绑定
//ActiveMap_MenuItem.Tag = new ActivateMapCommand();
VectorLoader_MenuItem.Tag = new VectorLoaderMenuCommand();
RasterLoader_MenuItem.Tag = new RasterLoaderMenuCommand();
TurnOffAll_MenuItem.Tag = new TurnOffAllLayersCommand();
TurnOffAllGroupLayer_MenuItem.Tag = new TurnOffAllLayersCommand();
TurnOnAll_MenuItem.Tag = new TurnOnAllLayersCommand();
TurnOnAllGroupLayer_MenuItem.Tag = new TurnOnAllLayersCommand();
ClearAll_MenuItem.Tag = new ClearAllLayersCommand();
ClearAllGroupLayer_MenuItem.Tag = new ClearAllLayersCommand();
OpenFilePathFeatureLayer_MenuItem.Tag = new OpenFilePathCommand();
OpenFilePathGroupLayer_MenuItem.Tag = new OpenFilePathCommand();
OpenFilePathRasterLayer_MenuItem.Tag = new OpenFilePathCommand();
DeleteFeatureLayer_MenuItem.Tag = new DeleteLayerCommand();
DeleteRasterLayer_MenuItem.Tag = new DeleteLayerCommand();
DeleteGroupLayer_MenuItem.Tag = new DeleteLayerCommand();
ZoomtoFeatureLayer_MenuItem.Tag = new ZoomToLayerCommand();
ZoomToGroupLayer_MenuItem.Tag = new ZoomToLayerCommand();
ZoomTORasterLayer_MenuItem.Tag = new ZoomToLayerCommand();
AnnotationFeatureLayer_MenuItem.Tag = new FeatureLayerAnnotationCommand();
AttributeToolStripMenuItem.Tag = new FeatureLayerAttributeCommand();
LayerAttributeMenuItem.Tag = new LayerPropertyCommand();
ZoomInToolStripMenuItem.Tag = new MapZoomInTool();
//ISODATA.Tag = new MyISODATA();
//ISODATA.Tag = new PIE.Plugin.ISODataClassificationCommand();
//PCAfusion.Tag = new ISODataClassificationAlgo();
parentForm = this;
}
#endregion
#region 控件事件
private void axMapControl2_MouseClick(object sender,MouseEventArgs e)
{
if(e.Button==MouseButtons.Right)
{
contextMenuStrip_mapcontrol.Show(axMapControl2, new System.Drawing.Point(e.X, e.Y));
}
}
/// <summary>
/// TOC右键菜单显示
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void m_TOCControl_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
PIETOCNodeType type = PIETOCNodeType.Null;
IMap map = null;
ILayer layer = null;
Object unk = Type.Missing;
Object data = Type.Missing;
m_TOCControl.HitTest(e.X, e.Y, ref type, ref map, ref layer, ref unk, ref data);
switch (type)
{
case PIETOCNodeType.Map:
this.contextMenuStrip_Map.Show(m_TOCControl, new System.Drawing.Point(e.X, e.Y));
break;
case PIETOCNodeType.FeatureLayer:
this.contextMenuStrip_FeatureLayer.Show(m_TOCControl, new System.Drawing.Point(e.X, e.Y));
break;
case PIETOCNodeType.RasterLayer:
this.contextMenuStrip_RasterLayer.Show(m_TOCControl, new System.Drawing.Point(e.X, e.Y));
break;
case PIETOCNodeType.GroupLayer:
this.contextMenuStrip_GroupLayer.Show(m_TOCControl, new System.Drawing.Point(e.X, e.Y));
break;
case PIETOCNodeType.MultiLayer:
this.contextMenuStrip_GroupLayer.Show(m_TOCControl, new System.Drawing.Point(e.X, e.Y));
break;
case PIETOCNodeType.GraphicsLayer:
break;
}
}
}
/// <summary>
/// 鼠标移动事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void axMapControl2_MouseMove(object sender, MouseEventArgs e)
{
//IList<IMap> maps= axMapControl2.GetMaps();
//if(maps!=null)
txtBox_PiexlCoord.Text = string.Format("{0},{1}", e.X, e.Y);
IPoint point = axMapControl2.ToMapPoint(e.X, e.Y);
txtBox_GeoCoord.Text = string.Format("{0},{1}", point.X.ToString("0.0000"), point.Y.ToString("0.0000"));
ISpatialReference spatialReference = axMapControl2.SpatialReference;
if (spatialReference == null) return;
lbl_SpatialReference.Text = "坐标系:" + spatialReference.Name;
}
#endregion
#region TOC右键菜单命令
/// <summary>
/// 创建右键菜单命令
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ContextMenuStrip_VisibleChanged(object sender, EventArgs e)
{
ContextMenuStrip contextMenuStrip = sender as ContextMenuStrip;
if (contextMenuStrip == null) return;
if (contextMenuStrip.Visible == false) return;
int count = contextMenuStrip.Items.Count;
ToolStripMenuItem item = null;
ICommand command = null;
for (int i = 0; i < count; i++)
{
item = contextMenuStrip.Items[i] as ToolStripMenuItem;
if (item == null) continue;
if (item.Tag == null) continue;
command = item.Tag as ICommand;
if (command == null) continue;
command.OnCreate(axMapControl2);
item.Checked = command.Checked;
item.Text = command.Caption;
item.Enabled = command.Enabled;
item.Image = command.Image;
}
}
/// <summary>
/// TOCMenuItem点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TOCMenuItem_Click(object sender, EventArgs e)
{
ToolStripMenuItem item = sender as ToolStripMenuItem;
if (item == null) return;
ICommand command = item.Tag as ICommand;
if (command == null) return;
command.OnClick();
}
#endregion
#region 按钮及工具
/// <summary>
/// 打开矢量数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripButton_OpenVector_Click(object sender, EventArgs e)
{
ICommand command = new VectorCommand();
command.OnCreate(axMapControl2);
command.OnClick();
}
/// <summary>
/// 打开栅格数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripButton_OpenRaster_Click(object sender, EventArgs e)
{
ICommand command = new RasterCommand();
command.OnCreate(axMapControl2);
command.OnClick();
}
/// <summary>
/// 打开科学数据集
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripButton_HDF_Click(object sender, EventArgs e)
{
ICommand command = new ScientificDatasetCommand();
command.OnCreate(axMapControl2);
command.OnClick();
}
/// <summary>
/// 拉框放大
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripButton_ZoomIn_Click(object sender, EventArgs e)
{
ITool tool = new MapZoomInTool();
ICommand command = tool as ICommand;
command.OnCreate(axMapControl2);
axMapControl2.CurrentTool = tool;
}
/// <summary>
/// 拉框缩小
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripButton_ZoomOut_Click(object sender, EventArgs e)
{
ITool tool = new MapZoomOutTool();
ICommand command = tool as ICommand;
command.OnCreate(axMapControl2);
axMapControl2.CurrentTool = tool;
}
/// <summary>
/// 中心放大
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripButton_CenterZoomIn_Click(object sender, EventArgs e)
{
ICommand command = new CenterZoomInCommand();
command.OnCreate(axMapControl2);
command.OnClick();
}
/// <summary>
/// 中心缩小
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripButton_CenterZoomOut_Click(object sender, EventArgs e)
{
ICommand command = new CenterZoomOutCommand();
command.OnCreate(axMapControl2);
command.OnClick();
}
/// <summary>
/// 漫游
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripButton_Pan_Click(object sender, EventArgs e)
{
ITool tool = new PanTool();
ICommand command = tool as ICommand;
command.OnCreate(axMapControl2);
axMapControl2.CurrentTool = tool;
}
/// <summary>
/// 全图
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripButton_FullExtent_Click(object sender, EventArgs e)
{
ICommand command = new FullExtentCommand();
command.OnCreate(axMapControl2);
command.OnClick();
}
/// <summary>
/// 1:1显示
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripButton_OneVOne_Click(object sender, EventArgs e)
{
ICommand command = new ZoomToNativeCommand();
command.OnCreate(axMapControl2);
command.OnClick();
}
/// <summary>
/// 前一视图
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripButton_PreviousExtent_Click(object sender, EventArgs e)
{
ICommand command = new ZoomToPreviousExtentCommand();
command.OnCreate(axMapControl2);
command.OnClick();
}
/// <summary>
/// 后一视图
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripButton_NextExtent_Click(object sender, EventArgs e)
{
ICommand command = new ZoomToNextExtentCommand();
command.OnCreate(axMapControl2);
command.OnClick();
}
/// <summary>
/// 卷帘
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripButton_SwiperLayer_Click(object sender, EventArgs e)
{
ITool tool = new SwipeLayerTool();
ICommand command = tool as ICommand;
command.OnCreate(axMapControl2);
axMapControl2.CurrentTool = tool;
command.OnClick();
}
/// <summary>
/// 拉框放大测试
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripButton_ZoomInDemo_Click(object sender, EventArgs e)
{
ITool tool = new MapZoomInTool();
ICommand command = tool as ICommand;
command.OnCreate(axMapControl2);
axMapControl2.CurrentTool = tool;
}
/// <summary>
/// 全图显示测试
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripButton_FullExtentDemo_Click(object sender, EventArgs e)
{
ICommand cmd = new FullExtentCommand();
cmd.OnCreate(axMapControl2);
cmd.OnClick();
}
#endregion
private void Form1_Load(object sender, EventArgs e)
{
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
//MyIODATA_FRM myIODATA_FRM = new MyIODATA_FRM();
//myIODATA_FRM.Show();
MyISODATA myISODATA = new MyISODATA();
myISODATA.OnCreate(axMapControl2);
myISODATA.OnClick();
}
private void toolStripButton1_Click_1(object sender, EventArgs e)
{
PCAfusion pCAfusion = new PCAfusion();
pCAfusion.OnCreate(axMapControl2);
pCAfusion.OnClick();
}
private void axMapControl2_Click(object sender, EventArgs e)
{
}
private void statusStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
}
private void AlgoProgressBar_Click(object sender, EventArgs e)
{
}
private void toolStripProgressBar1_Click(object sender, EventArgs e)
{
}
private void toolStripButton1_Click_2(object sender, EventArgs e)
{
Neural neural = new Neural();
neural.OnCreate(axMapControl2);
neural.OnClick();
}
private void 新建ToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}
private void toolStripButton1_Click_3(object sender, EventArgs e)
{
KMeans kMeans = new KMeans();
kMeans.OnCreate(axMapControl2);
kMeans.OnClick();
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
//int result=Class1.AnalyseImage(imagePath, rulePath);
//MessageBox.Show(result.ToString());
SegClassForm segClassForm = new SegClassForm();
segClassForm.ShowDialog();
if (RuleSetMessage.OutShpPath != null || RuleSetMessage.OutClassResultsPath != null)
{
if(RuleSetMessage.OutShpPath!=null&&RuleSetMessage.AlgoOptions==0)
{
ILayer layer = LayerFactory.CreateDefaultLayer(RuleSetMessage.OutShpPath);
//axMapControl2.FocusMap.AddLayer(layer);
axMapControl2.AddLayer(layer,1);
axMapControl2.ActiveView.PartialRefresh(ViewDrawPhaseType.ViewAll);
}
else
{
ILayer layer = LayerFactory.CreateDefaultLayer(RuleSetMessage.OutClassResultsPath);
axMapControl2.AddLayer(layer, 1);
axMapControl2.ActiveView.PartialRefresh(ViewDrawPhaseType.ViewAll);
}
}
}
private void toolStripButton_RasterIdentify_Click(object sender, EventArgs e)
{
ITool tool = new RasterIdentifyTool();
ICommand command = tool as ICommand;
command.OnCreate(axMapControl2);
axMapControl2.CurrentTool = tool;
command.OnClick();
}
private void label3_Click(object sender, EventArgs e)
{
}
private void 放大ToolStripMenuItem_Click(object sender, EventArgs e)
{
ToolStripMenuItem item = sender as ToolStripMenuItem;
if (item == null) return;
ICommand command = item.Tag as ICommand;
if (command == null) return;
command.OnClick();
}
private void splitContainer1_Panel2_Paint(object sender, PaintEventArgs e)
{
}
private void 帮助ToolStripMenuItem_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("help_app\\index.html");
}
}
}