Also about Eagle Eye (ae+c#)

Source: Internet
Author: User
Tags transparent color ipoint

Recently, there have been a lot of friends looking for Hawk-eye problems. Ae+c# Eagle Eye in the online code has been a lot of, I also put a version up today, mainly has the following several functions:

1. After the main map window view scope changes, the Eagle Eye window draws a red box to display the current area;

2. When the scale of the main map changes, the scale of the Eagle's eye map also changes, but only the degree of change will be small; (this is different from other code on the Internet, for reference to the Google Map Eagle Eye display effect)

3. On the Eagle Eye map, with the left mouse button you can move the red area box, after releasing the mouse, the main window map view range to update the scope of the box after the move;

4. On the Eagle Eye map, with the right mouse button you can pull a box, the main window view range is updated to the scope of this box.

Well, not much words, full code release:

1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Text;
7 using System.Windows.Forms;
8 using ESRI. Arcgis.carto;
9 using ESRI. Arcgis.geometry;
Using ESRI. Arcgis.display;
Using ESRI. Arcgis.esrisystem;
12
Namespace WindowsFormsApplication19
14 {
public partial class Form1:form
16 {
Form1 Public ()
18 {
InitializeComponent ();
20}
21st
22
The private void Form1_Load (object sender, EventArgs e)
24 {
Addlayertooverviewmap (); Add a map to the Eagle's eye.
26}
27
28
///<summary>
30///when the main map is replaced, the Eagle Eye window is updated
///</summary>
///<param name= "Sender" ></param>
///<param name= "E" ></param>
The private void mainmapcontrol_onmapreplaced (object sender, ESRI. ArcGIS.Controls.IMapControlEvents2_OnMapReplacedEvent e)
35 {
Addlayertooverviewmap ();
37}
///<summary>
39///, add the map to the Eagle's eye.
///</summary>
The private void Addlayertooverviewmap ()
42 {
Overviewmapcontrol.clearlayers ();
for (int i = 0; i < Mainmapcontrol.layercount; i++)
45 {
Iobjectcopy objectcopy = new Objectcopyclass ();
The Object tocopylayer = Mainmapcontrol.get_layer (i);
The object copiedlayer = objectcopy. Copy (Tocopylayer);
Ilayer C = (new Featurelayerclass ()) as Ilayer;
Object tooverwritelayer = C;
Wuyi Objectcopy. Overwrite (Copiedlayer, ref tooverwritelayer);
Overviewmapcontrol.addlayer (C, i);
53}
54}
55
///<summary>
57///The main map window when the view range changes, update the red rectangular frame on the Eagle's eye
///</summary>
///<param name= "Sender" ></param>
///<param name= "E" ></param>
The private void mainmapcontrol_onextentupdated (object sender, ESRI. ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e)
62 {
A try
64 {
Igraphicscontainer Pgraphicscontainer = Overviewmapcontrol.map as Igraphicscontainer;
Iactiveview pAv = Pgraphicscontainer as Iactiveview;
Pgraphicscontainer.deleteallelements ();
Irectangleelement precelement = new Rectangleelementclass ();
IElement PEle = precelement as ielement;
Pele.geometry = E.newenvelope as Ienvelope;
71
ienvelope mm = new Envelopeclass ();
MM. Xmax = PEle.Geometry.Envelope.XMax + 3;
MM. Xmin = pele.geometry.envelope.xmin-3;
MM. Ymax = PEle.Geometry.Envelope.YMax + 3;
MM. Ymin = pele.geometry.envelope.ymin-3;
overviewmapcontrol.extent = mm;
78
Irgbcolor Pcolor = new Rgbcolorclass ();
pcolor.red = 200;
Bayi Pcolor.green = 0;
Pcolor.blue = 0;
Pcolor.transparency = 255;
84
85//Produces a line symbol object
Ilinesymbol Plinesymbol = new Simplelinesymbolclass ();
Plinesymbol.width = 2;
Plinesymbol.color = Pcolor;
89
90//Set the padding symbol properties
Ifillsymbol Pfillsymbol = new Simplefillsymbolclass ();
92
93//Set Transparent Color
pcolor.transparency = 0;
Pfillsymbol.color = Pcolor;
Pfillsymbol.outline = Plinesymbol;
97
98//
Ifillshapeelement pfillshapeelement = precelement as ifillshapeelement;
Pfillshapeelement.symbol = Pfillsymbol;
101
102 Pgraphicscontainer.addelement (pEle, 0);
OverViewMapControl.ActiveView.PartialRefresh (esriviewdrawphase.esriviewgraphics, NULL, NULL);
104
105//
106}
EY catch (Exception)
108 {
109}
110}
111
112///<summary>
113///Eagle Eye window, with the right mouse button pull box, change the main window current view range
114///</summary>
///<param name= "Sender" ></param>
116///<param name= "E" ></param>
117 private void Overviewmapcontrol_onmousedown (object sender, ESRI. ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
118 {
119 #region Eagle Eye
if (E.button = 2)
121 {
122 try
123 {
124 IPoint pPt = new Pointclass ();
Ppt.x = E.MAPX;
126 Ppt.y = e.mapy;
127 Ienvelope Penvelope = Overviewmapcontrol.trackrectangle ();
128 mainmapcontrol.extent = Penvelope;
129}
130 catch
131 {}
132}
#endregion
134}
135
136///<summary>
137///Eagle Eye window, move view range with left mouse button
138///</summary>
139///<param name= "Sender" ></param>
140///<param name= "E" ></param>
The Overviewmapcontrol_onmousemove private void (object sender, ESRI. ArcGIS.Controls.IMapControlEvents2_OnMouseMoveEvent e)
142 {
143
144 if (E.button = 1)
145 {
146 Try
147 {
148 IPoint pPt = new Pointclass ();
149 Ppt.x = E.MAPX;
Ppt.y = e.mapy;
151//
152 Ienvelope Penvelope = mainmapcontrol.extent as Ienvelope;
153 Penvelope.centerat (PPT);
154 Iactiveview PAv;
Igraphicscontainer Pgraphicscontainer = Overviewmapcontrol.map as Igraphicscontainer;
156 pAv = Pgraphicscontainer as Iactiveview;
157 pgraphicscontainer.deleteallelements ();
158 irectangleelement precelement = new Rectangleelementclass ();
159 IElement PEle = precelement as ielement;
160 pele.geometry = Penvelope;
161//Color
162 Irgbcolor Pcolor = new Rgbcolorclass ();
163 pcolor.red = 200;
164 Pcolor.green = 0;
165 Pcolor.blue = 0;
166 pcolor.transparency = 255;
167
168//produces a line symbol object
169 Ilinesymbol Plinesymbol = new Simplelinesymbolclass ();
170 plinesymbol.width = 2;
171 Plinesymbol.color = Pcolor;
172
173//Set the padding symbol properties
174 Ifillsymbol Pfillsymbol = new Simplefillsymbolclass ();
175
176//Set Transparent Color
177 pcolor.transparency = 0;
178 Pfillsymbol.color = Pcolor;
179 pfillsymbol.outline = Plinesymbol;
180
181//
Ifillshapeelement pfillshapeelement = precelement as ifillshapeelement;
183 Pfillshapeelement.symbol = Pfillsymbol;
184
185 pgraphicscontainer.addelement (PEle, 0);
186 OverViewMapControl.ActiveView.PartialRefresh (esriviewdrawphase.esriviewgraphics, NULL, NULL);
187
188}
189 catch
190 {
191}
192}
193
194
195}
196
197///<summary>
198///Eagle Eye window, left arrow move view box, update main window
199///</summary>
///<param name= "Sender" ></param>
201///<param name= "E" ></param>
The private void Overviewmapcontrol_onmouseup (object sender, ESRI. ArcGIS.Controls.IMapControlEvents2_OnMouseUpEvent e)
203 {
204 #region Eagle Eye
205 if (E.button = 1)
206 {
207 Try
208 {
209 IPoint pPt = new Pointclass ();
210 ppt.x = e.mapx;
211 Ppt.y = e.mapy;
212
213 Ienvelope Penvelope = mainmapcontrol.extent as Ienvelope;
214 Penvelope.centerat (PPT);
215 mainmapcontrol.extent = Penvelope;
216}
217 Catch
218 {
219}
220}
221 #endregion
222}
223
224}
225}
226

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.