Add map surrounds using the SymbologyControl
/ Copyright 2010 ESRI// // All rights reserved under the copyright laws of the United States// and applicable international laws, treaties, and conventions.// // You may freely redistribute and use this sample code, with or// without modification, provided you include the original copyright// notice and use restrictions.// // See the use restrictions at <your ArcGIS install location>/DeveloperKit10.0/userestrictions.txt.// using System;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.ADF.CATIDs;
using System.Runtime.InteropServices; namespace AddMapSurrounds
{
[ClassInterface(ClassInterfaceType.None)]
[Guid("5175B831-F18E-4cff-A016-146A7923681D")] publicsealedclass CreateNorthArrow : BaseTool
{
private IHookHelper m_HookHelper;
private INewEnvelopeFeedback m_Feedback;
private IPoint m_Point;
privatebool m_InUse; //Windows API functions to capture mouse and keyboard//input to a window when the mouse is outside the window
[DllImport("User32", CharSet=CharSet.Auto)]
privatestaticexternint SetCapture(int hWnd);
[DllImport("User32", CharSet=CharSet.Auto)]
privatestaticexternint GetCapture();
[DllImport("User32", CharSet=CharSet.Auto)]
privatestaticexternint ReleaseCapture(); #region Component Category Registration
[ComRegisterFunction()]
[ComVisible(false)]
staticvoid RegisterFunction(String sKey)
{
ControlsCommands.Register(sKey);
}
[ComUnregisterFunction()]
[ComVisible(false)]
staticvoid UnregisterFunction(String sKey)
{
ControlsCommands.Unregister(sKey);
}
#endregionpublic CreateNorthArrow()
{
//Create an IHookHelper object
m_HookHelper = new HookHelperClass(); //Set the tool propertiesbase.m_bitmap = new System.Drawing.Bitmap(GetType().Assembly.GetManifestResourceStream(GetType(), "NorthArrow.bmp"));
base.m_caption = "NorthArrow";
base.m_category = "myCustomCommands(C#)";
base.m_message = "Add a north arrow map surround";
base.m_name = "myCustomCommands(C#)_NorthArrow";
base.m_toolTip = "Add a north arrow";
base.m_deactivate = true;
} publicoverridevoid OnCreate(object hook)
{
m_HookHelper.Hook = hook;
} publicoverridevoid OnMouseDown(int Button, int Shift, int X, int Y)
{
//Create a point in map coordinates
m_Point = m_HookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); //Start capturing mouse events
SetCapture(m_HookHelper.ActiveView.ScreenDisplay.hWnd); m_InUse = true;
} publicoverridevoid OnMouseMove(int Button, int Shift, int X, int Y)
{
if (m_InUse == false) return; //Start an envelope feedbackif (m_Feedback == null )
{
m_Feedback = new NewEnvelopeFeedbackClass();
m_Feedback.Display = m_HookHelper.ActiveView.ScreenDisplay;
m_Feedback.Start(m_Point);
} //Move the envelope feedback
m_Feedback.MoveTo(m_HookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y));
} publicoverridevoid OnMouseUp(int Button, int Shift, int X, int Y)
{
if (m_InUse == false) return; //Stop capturing mouse eventsif (GetCapture() == m_HookHelper.ActiveView.ScreenDisplay.hWnd)
ReleaseCapture(); //If an envelope has not been tracked or its height/width is 0if (m_Feedback == null)
{
m_Feedback = null;
m_InUse = false;
return;
}
IEnvelope envelope = m_Feedback.Stop();
if ((envelope.IsEmpty) || (envelope.Width == 0) || (envelope.Height == 0))
{
m_Feedback = null;
m_InUse = false;
return;
} //Create the form with the SymbologyControl
SymbolForm symbolForm = new SymbolForm();
//Get the IStyleGalleryItem
IStyleGalleryItem styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassNorthArrows);
//Release the form
symbolForm.Dispose();
if (styleGalleryItem == null) return; //Get the map frame of the focus map
IMapFrame mapFrame = (IMapFrame) m_HookHelper.ActiveView.GraphicsContainer.FindFrame(m_HookHelper.ActiveView.FocusMap); //Create a map surround frame
IMapSurroundFrame mapSurroundFrame = new MapSurroundFrameClass();
//Set its map frame and map surround
mapSurroundFrame.MapFrame = mapFrame;
mapSurroundFrame.MapSurround = (IMapSurround) styleGalleryItem.Item; //QI to IElement and set its geometry
IElement element = (IElement) mapSurroundFrame;
element.Geometry = envelope; //Add the element to the graphics container
m_HookHelper.ActiveView.GraphicsContainer.AddElement((IElement)mapSurroundFrame, 0);
//Refresh
m_HookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, mapSurroundFrame, null); m_Feedback = null;
m_InUse = false;
}
}
}
Add map surrounds using the SymbologyControl的更多相关文章
- java 使用map返回多个对象组装
Object json=JSONObject.fromObject("{}"); List<Object> list = new ArrayList<Object ...
- a=av###b=bv###c=cv map键值对 (a,av) (b,bv) (c,cv)
import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; impo ...
- xml/map转换器,递归设计思路
xml/map转换器 图片:http://pan.baidu.com/s/1nuKJD13 应用场景,为什么要把xml转map?我直接用jdom,dom4j操作不行吗? 如果你了解模板引擎(像velo ...
- List<Map<String,Object>>使用Java代码遍历
List<Map<String,Object>>的结果集怎么使用Java代码遍历以获取String,Object的值: package excel; import java.u ...
- java中对List<Map<String,Object>>中的中文汉字排序
import java.text.Collator;import java.util.ArrayList;import java.util.Collections;import java.util.C ...
- java解析json与map,list相互之间的转换
运行这个类需要加载jar包:ezmorph-1.0.6.jar.json-lib-2.4-jdk15.jar.jsoup-1.6.1.jar.commons-beanutils-1.8.0.jar.c ...
- JAVA基础学习day16--集合三-Map、HashMap,TreeMap与常用API
一.Map简述 1.1.简述 public interface Map<K,V> 类型参数: K - 此映射所维护的键的类型 key V - 映射值的类型 value 该集合提供键--值的 ...
- 迭代输出Map和List<Map<String,Object>>的方法
一.Map<String,Object> String:key的类型 Object:value的类型,value可能是String,或者int类型,什么类型都可以 对于Map接口来说,本身 ...
- 修改Map中确定key对应的value问题
今天在码代码的时候出现一个没有预料的问题: 先看下面的代码: public static void main(String[] args) { String[] files=new String[]{ ...
随机推荐
- node 本地静态服务器
直接上代码 const connect = require("connect"); const serveStatic = require("serve-static&q ...
- OS之内存管理 ---基本的内存管理策略(一)
基本概念 基本硬件 CPU可以直接访问的通用存储只有内存和处理器的内置的寄存器.机器指令可以用内存地址作为参数,而不能用磁盘地址作为参数.所以执行指令以及指令使用的数据,应在这些可执行访问的存储设备上 ...
- 利用BitviseSSH免root实现Windows vs Linux的文件互传
虚拟机截图,,,质量有点差,大家看看! ------------------- 在拿不到Linux root账户的情况下,winscp等工具是无法实现文件传输的,此时我们可以借用Bitvise SSH ...
- Visual Studio 2015中使用gdb远程调试linux程序
VS的debug功能非常强大,相比而言linux上的图形化调试一直不是很好用. 如果可以使用VS来调试linux程序,应该是一件比较愉快的事情. 这在2015中变得可能,因为从2015开始VS支持An ...
- HDFS DATANODE 磁盘容量的最小值
HDFS的DATANODE的剩余空间具体要到多大?关于这个问题,下面记录下对这个问题的调查 昨天,讨论群里面给出了一个异常: op@odbtest bin]$ hadoop fs -put ../tm ...
- Maven-pom.xml文件报错 Plugin execution not covered by lifecycle configuration
问题: Eclipse中新导入的项目pom.xml文件报错: Plugin execution not covered by lifecycle configuration: org.jacoco:j ...
- 【C#小知识】C#中一些易混淆概念总结(七)---------解析抽象类,抽象方法
目录: [C#小知识]C#中一些易混淆概念总结--------数据类型存储位置,方法调用,out和ref参数的使用 [C#小知识]C#中一些易混淆概念总结(二)--------构造函数,this关键字 ...
- 一款高效视频播放控件的设计思路(c# WPF版)
因工作的需要,开发了一款视频播放程序.期间也经历许多曲折,查阅了大量资料,经过了反复测试,终于圆满完成了任务. 我把开发过程中的一些思路.想法写下来,以期对后来者有所帮助. 视频播放的本质 就是连续的 ...
- Maven 学习笔记(三)
Maven生命周期 在上次我们使用maven package 对项目进行打包.这里就是为其指定一个生命周期.生命周期是包含在一个项目构建中的一系列有序的阶段.Maven有许多不同的生命周期,比如验证( ...
- java 基本理论知识点
通过JAVAOO 的笔试后,总结了一些理论的知识点. 1.main方法是怎么写的 public static void main(String [] args){}//最习惯的 public stat ...