当前位置: 编程技术>.net/c#/asp.net
C#+MO实现一些渲染功能
来源: 互联网 发布时间:2014-10-13
本文导语: using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace DbInMo { /// /// Form1 的摘要说明。 /// public class 渲染示例 : System.Windows.For...
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace DbInMo
{
///
/// Form1 的摘要说明。
///
public class 渲染示例 : System.Windows.Forms.Form
{
private AxMapObjects2.AxMap map;
private System.Windows.Forms.Button 直方图;
private System.Windows.Forms.Button 饼图;
private System.Windows.Forms.Button 点密度;
private System.Windows.Forms.Button 按值渲染;
private System.Windows.Forms.Button 分类渲染;
private System.Windows.Forms.Button Z值渲染;
private System.Windows.Forms.Button 组渲染;
private System.Windows.Forms.Button 退出;
private System.Windows.Forms.Panel 操作板;
private System.Windows.Forms.Button 删除所有渲染;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Button 全图;
private System.Windows.Forms.Button 拖动;
private System.Windows.Forms.Button 缩小;
private System.Windows.Forms.Button 放大;
private System.Windows.Forms.Panel 分隔符;
private System.Windows.Forms.Button 标注渲染;
///
/// 必需的设计器变量。
///
private System.ComponentModel.Container components = null;
public 渲染示例()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
///
/// 清理所有正在使用的资源。
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(渲染示例));
this.map = new AxMapObjects2.AxMap();
this.操作板 = new System.Windows.Forms.Panel();
this.直方图 = new System.Windows.Forms.Button();
this.饼图 = new System.Windows.Forms.Button();
this.点密度 = new System.Windows.Forms.Button();
this.按值渲染 = new System.Windows.Forms.Button();
this.分类渲染 = new System.Windows.Forms.Button();
this.Z值渲染 = new System.Windows.Forms.Button();
this.组渲染 = new System.Windows.Forms.Button();
this.退出 = new System.Windows.Forms.Button();
this.标注渲染 = new System.Windows.Forms.Button();
this.删除所有渲染 = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.全图 = new System.Windows.Forms.Button();
this.拖动 = new System.Windows.Forms.Button();
this.缩小 = new System.Windows.Forms.Button();
this.放大 = new System.Windows.Forms.Button();
this.分隔符 = new System.Windows.Forms.Panel();
((System.ComponentModel.ISupportInitialize)(this.map)).BeginInit();
this.操作板.SuspendLayout();
this.SuspendLayout();
//
// map
//
this.map.Dock = System.Windows.Forms.DockStyle.Fill;
this.map.Location = new System.Drawing.Point(0, 0);
this.map.Name = "map";
this.map.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("map.OcxState")));
this.map.Size = new System.Drawing.Size(616, 429);
this.map.TabIndex = 0;
this.map.MouseDownEvent += new AxMapObjects2._DMapEvents_MouseDownEventHandler(this.map_MouseDownEvent);
//
// 操作板
//
this.操作板.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.操作板.Controls.Add(this.删除所有渲染);
this.操作板.Controls.Add(this.panel1);
this.操作板.Controls.Add(this.全图);
this.操作板.Controls.Add(this.拖动);
this.操作板.Controls.Add(this.缩小);
this.操作板.Controls.Add(this.放大);
this.操作板.Controls.Add(this.分隔符);
this.操作板.Controls.Add(this.标注渲染);
this.操作板.Controls.Add(this.退出);
this.操作板.Controls.Add(this.组渲染);
this.操作板.Controls.Add(this.Z值渲染);
this.操作板.Controls.Add(this.分类渲染);
this.操作板.Controls.Add(this.按值渲染);
this.操作板.Controls.Add(this.点密度);
this.操作板.Controls.Add(this.饼图);
this.操作板.Controls.Add(this.直方图);
this.操作板.Dock = System.Windows.Forms.DockStyle.Right;
this.操作板.Location = new System.Drawing.Point(496, 0);
this.操作板.Name = "操作板";
this.操作板.Size = new System.Drawing.Size(120, 429);
this.操作板.TabIndex = 1;
//
// 直方图
//
this.直方图.Dock = System.Windows.Forms.DockStyle.Top;
this.直方图.Location = new System.Drawing.Point(0, 0);
this.直方图.Name = "直方图";
this.直方图.Size = new System.Drawing.Size(116, 24);
this.直方图.TabIndex = 0;
this.直方图.Text = "直方图";
this.直方图.Click += new System.EventHandler(this.直方图_Click);
//
// 饼图
//
this.饼图.Dock = System.Windows.Forms.DockStyle.Top;
this.饼图.Location = new System.Drawing.Point(0, 24);
this.饼图.Name = "饼图";
this.饼图.Size = new System.Drawing.Size(116, 24);
this.饼图.TabIndex = 1;
this.饼图.Text = "饼图";
this.饼图.Click += new System.EventHandler(this.饼图_Click);
//
// 点密度
//
this.点密度.Dock = System.Windows.Forms.DockStyle.Top;
this.点密度.Location = new System.Drawing.Point(0, 48);
this.点密度.Name = "点密度";
this.点密度.Size = new System.Drawing.Size(116, 23);
this.点密度.TabIndex = 2;
this.点密度.Text = "点密度";
this.点密度.Click += new System.EventHandler(this.点密度_Click);
//
// 按值渲染
//
this.按值渲染.Dock = System.Windows.Forms.DockStyle.Top;
this.按值渲染.Location = new System.Drawing.Point(0, 71);
this.按值渲染.Name = "按值渲染";
this.按值渲染.Size = new System.Drawing.Size(116, 23);
this.按值渲染.TabIndex = 3;
this.按值渲染.Text = "按值渲染";
this.按值渲染.Click += new System.EventHandler(this.按值渲染_Click);
//
// 分类渲染
//
this.分类渲染.Dock = System.Windows.Forms.DockStyle.Top;
this.分类渲染.Location = new System.Drawing.Point(0, 94);
this.分类渲染.Name = "分类渲染";
this.分类渲染.Size = new System.Drawing.Size(116, 23);
this.分类渲染.TabIndex = 4;
this.分类渲染.Text = "分类渲染";
this.分类渲染.Click += new System.EventHandler(this.分类渲染_Click);
//
// Z值渲染
//
this.Z值渲染.Dock = System.Windows.Forms.DockStyle.Top;
this.Z值渲染.Location = new System.Drawing.Point(0, 117);
this.Z值渲染.Name = "Z值渲染";
this.Z值渲染.Size = new System.Drawing.Size(116, 23);
this.Z值渲染.TabIndex = 5;
this.Z值渲染.Text = "Z值渲染";
this.Z值渲染.Click += new System.EventHandler(this.Z值渲染_Click);
//
// 组渲染
//
this.组渲染.Dock = System.Windows.Forms.DockStyle.Top;
this.组渲染.Location = new System.Drawing.Point(0, 140);
this.组渲染.Name = "组渲染";
this.组渲染.Size = new System.Drawing.Size(116, 23);
this.组渲染.TabIndex = 6;
this.组渲染.Text = "组渲染";
this.组渲染.Click += new System.EventHandler(this.组渲染_Click);
//
// 退出
//
this.退出.Dock = System.Windows.Forms.DockStyle.Bottom;
this.退出.Location = new System.Drawing.Point(0, 402);
this.退出.Name = "退出";
this.退出.Size = new System.Drawing.Size(116, 23);
this.退出.TabIndex = 7;
this.退出.Text = "退出";
this.退出.Click += new System.EventHandler(this.退出_Click);
//
// 标注渲染
//
this.标注渲染.Dock = System.Windows.Forms.DockStyle.Top;
this.标注渲染.Location = new System.Drawing.Point(0, 163);
this.标注渲染.Name = "标注渲染";
this.标注渲染.Size = new System.Drawing.Size(116, 23);
this.标注渲染.TabIndex = 7;
this.标注渲染.Text = "标注渲染";
this.标注渲染.Click += new System.EventHandler(this.标注渲染_Click);
//
// 删除所有渲染
//
this.删除所有渲染.Dock = System.Windows.Forms.DockStyle.Top;
this.删除所有渲染.Location = new System.Drawing.Point(0, 319);
this.删除所有渲染.Name = "删除所有渲染";
this.删除所有渲染.Size = new System.Drawing.Size(116, 23);
this.删除所有渲染.TabIndex = 22;
this.删除所有渲染.Text = "删除所有渲染";
this.删除所有渲染.Click += new System.EventHandler(this.删除所有渲染_Click);
//
// panel1
//
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 299);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(116, 20);
this.panel1.TabIndex = 21;
//
// 全图
//
this.全图.Dock = System.Windows.Forms.DockStyle.Top;
this.全图.Location = new System.Drawing.Point(0, 276);
this.全图.Name = "全图";
this.全图.Size = new System.Drawing.Size(116, 23);
this.全图.TabIndex = 20;
this.全图.Text = "全图";
this.全图.Click += new System.EventHandler(this.全图_Click);
//
// 拖动
//
this.拖动.Dock = System.Windows.Forms.DockStyle.Top;
this.拖动.Location = new System.Drawing.Point(0, 253);
this.拖动.Name = "拖动";
this.拖动.Size = new System.Drawing.Size(116, 23);
this.拖动.TabIndex = 19;
this.拖动.Text = "拖动";
this.拖动.Click += new System.EventHandler(this.拖动_Click);
//
// 缩小
//
this.缩小.Dock = System.Windows.Forms.DockStyle.Top;
this.缩小.Location = new System.Drawing.Point(0, 230);
this.缩小.Name = "缩小";
this.缩小.Size = new System.Drawing.Size(116, 23);
this.缩小.TabIndex = 18;
this.缩小.Text = "缩小";
this.缩小.Click += new System.EventHandler(this.缩小_Click);
//
// 放大
//
this.放大.Dock = System.Windows.Forms.DockStyle.Top;
this.放大.Location = new System.Drawing.Point(0, 207);
this.放大.Name = "放大";
this.放大.Size = new System.Drawing.Size(116, 23);
this.放大.TabIndex = 17;
this.放大.Text = "放大";
this.放大.Click += new System.EventHandler(this.放大_Click);
//
// 分隔符
//
this.分隔符.Dock = System.Windows.Forms.DockStyle.Top;
this.分隔符.Location = new System.Drawing.Point(0, 186);
this.分隔符.Name = "分隔符";
this.分隔符.Size = new System.Drawing.Size(116, 21);
this.分隔符.TabIndex = 16;
//
// 渲染示例
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(616, 429);
this.Controls.Add(this.操作板);
this.Controls.Add(this.map);
this.Name = "渲染示例";
this.Text = "渲染示例";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
((System.ComponentModel.ISupportInitialize)(this.map)).EndInit();
this.操作板.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
///
/// 应用程序的主入口点。
///
[STAThread]
static void Main()
{
Application.Run(new 渲染示例());
}
///
/// 退出系统
///
private void 退出_Click(object sender, System.EventArgs e)
{
this.Close();
}
///
/// 图表渲染,值方图
///
private void 直方图_Click(object sender, System.EventArgs e)
{
//直方图的例子中使用Lakers图层
//
//定义图标渲染变量
MapObjects2.ChartRenderer cr = new MapObjects2.ChartRendererClass();
//设置渲染类型为直方图
cr.ChartType = MapObjects2.ChartTypeConstants.moBar;
//设置直方图显示的字段个数为两个,就是直方图显示两个柱子
cr.FieldCount = 2;
//设置第一个字段,请参看lakes.dbf
cr.set_Field(0,"SURF_ELEV");
//设置这个直方图的柱子颜色为红色
cr.set_Color(0,(uint)MapObjects2.ColorConstants.moRed);
//设置第二个柱子
cr.set_Field(1,"DEPTH");
cr.set_Color(1,(uint)MapObjects2.ColorConstants.moGreen);
MapObjects2.MapLayer lyr = (MapObjects2.MapLayer)(map.Layers.Item("lakes"));
lyr.Renderer = cr;
//使用Refresh()刷新老也是刷新不好,正没办法。。。,设为全图倒是不错的注意,^_^
map.Refresh();
}
///
/// 全图视野
///
private void 全图_Click(object sender, System.EventArgs e)
{
map.Extent = map.FullExtent;
}
///
/// 拖动,只设置图标
///
private void 拖动_Click(object sender, System.EventArgs e)
{
map.MousePointer = MapObjects2.MousePointerConstants.moPan;
}
///
/// 缩小,只设置图标
///
private void 缩小_Click(object sender, System.EventArgs e)
{
map.MousePointer = MapObjects2.MousePointerConstants.moZoomOut;
}
///
/// 放大,只设置图标
///
private void 放大_Click(object sender, System.EventArgs e)
{
map.MousePointer = MapObjects2.MousePointerConstants.moZoomIn;
}
///
/// 鼠标按下时间,处理地图放大、缩小、拖动等。
///
private void map_MouseDownEvent(object sender, AxMapObjects2._DMapEvents_MouseDownEvent e)
{
MapObjects2.Rectangle rect;
MapObjects2.Point pt = map.ToMapPoint(e.x,e.y);
if(e.button == 2)//右键点击取消
{
map.MousePointer = MapObjects2.MousePointerConstants.moDefault;
}
if(map.MousePointer == MapObjects2.MousePointerConstants.moPan)//拖动
{
map.Pan();
}
else if(map.MousePointer == MapObjects2.MousePointerConstants.moZoomIn)//放大
{
rect = map.TrackRectangle();
if(rect == null|| (rect.Width
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace DbInMo
{
///
/// Form1 的摘要说明。
///
public class 渲染示例 : System.Windows.Forms.Form
{
private AxMapObjects2.AxMap map;
private System.Windows.Forms.Button 直方图;
private System.Windows.Forms.Button 饼图;
private System.Windows.Forms.Button 点密度;
private System.Windows.Forms.Button 按值渲染;
private System.Windows.Forms.Button 分类渲染;
private System.Windows.Forms.Button Z值渲染;
private System.Windows.Forms.Button 组渲染;
private System.Windows.Forms.Button 退出;
private System.Windows.Forms.Panel 操作板;
private System.Windows.Forms.Button 删除所有渲染;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Button 全图;
private System.Windows.Forms.Button 拖动;
private System.Windows.Forms.Button 缩小;
private System.Windows.Forms.Button 放大;
private System.Windows.Forms.Panel 分隔符;
private System.Windows.Forms.Button 标注渲染;
///
/// 必需的设计器变量。
///
private System.ComponentModel.Container components = null;
public 渲染示例()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
///
/// 清理所有正在使用的资源。
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(渲染示例));
this.map = new AxMapObjects2.AxMap();
this.操作板 = new System.Windows.Forms.Panel();
this.直方图 = new System.Windows.Forms.Button();
this.饼图 = new System.Windows.Forms.Button();
this.点密度 = new System.Windows.Forms.Button();
this.按值渲染 = new System.Windows.Forms.Button();
this.分类渲染 = new System.Windows.Forms.Button();
this.Z值渲染 = new System.Windows.Forms.Button();
this.组渲染 = new System.Windows.Forms.Button();
this.退出 = new System.Windows.Forms.Button();
this.标注渲染 = new System.Windows.Forms.Button();
this.删除所有渲染 = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.全图 = new System.Windows.Forms.Button();
this.拖动 = new System.Windows.Forms.Button();
this.缩小 = new System.Windows.Forms.Button();
this.放大 = new System.Windows.Forms.Button();
this.分隔符 = new System.Windows.Forms.Panel();
((System.ComponentModel.ISupportInitialize)(this.map)).BeginInit();
this.操作板.SuspendLayout();
this.SuspendLayout();
//
// map
//
this.map.Dock = System.Windows.Forms.DockStyle.Fill;
this.map.Location = new System.Drawing.Point(0, 0);
this.map.Name = "map";
this.map.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("map.OcxState")));
this.map.Size = new System.Drawing.Size(616, 429);
this.map.TabIndex = 0;
this.map.MouseDownEvent += new AxMapObjects2._DMapEvents_MouseDownEventHandler(this.map_MouseDownEvent);
//
// 操作板
//
this.操作板.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.操作板.Controls.Add(this.删除所有渲染);
this.操作板.Controls.Add(this.panel1);
this.操作板.Controls.Add(this.全图);
this.操作板.Controls.Add(this.拖动);
this.操作板.Controls.Add(this.缩小);
this.操作板.Controls.Add(this.放大);
this.操作板.Controls.Add(this.分隔符);
this.操作板.Controls.Add(this.标注渲染);
this.操作板.Controls.Add(this.退出);
this.操作板.Controls.Add(this.组渲染);
this.操作板.Controls.Add(this.Z值渲染);
this.操作板.Controls.Add(this.分类渲染);
this.操作板.Controls.Add(this.按值渲染);
this.操作板.Controls.Add(this.点密度);
this.操作板.Controls.Add(this.饼图);
this.操作板.Controls.Add(this.直方图);
this.操作板.Dock = System.Windows.Forms.DockStyle.Right;
this.操作板.Location = new System.Drawing.Point(496, 0);
this.操作板.Name = "操作板";
this.操作板.Size = new System.Drawing.Size(120, 429);
this.操作板.TabIndex = 1;
//
// 直方图
//
this.直方图.Dock = System.Windows.Forms.DockStyle.Top;
this.直方图.Location = new System.Drawing.Point(0, 0);
this.直方图.Name = "直方图";
this.直方图.Size = new System.Drawing.Size(116, 24);
this.直方图.TabIndex = 0;
this.直方图.Text = "直方图";
this.直方图.Click += new System.EventHandler(this.直方图_Click);
//
// 饼图
//
this.饼图.Dock = System.Windows.Forms.DockStyle.Top;
this.饼图.Location = new System.Drawing.Point(0, 24);
this.饼图.Name = "饼图";
this.饼图.Size = new System.Drawing.Size(116, 24);
this.饼图.TabIndex = 1;
this.饼图.Text = "饼图";
this.饼图.Click += new System.EventHandler(this.饼图_Click);
//
// 点密度
//
this.点密度.Dock = System.Windows.Forms.DockStyle.Top;
this.点密度.Location = new System.Drawing.Point(0, 48);
this.点密度.Name = "点密度";
this.点密度.Size = new System.Drawing.Size(116, 23);
this.点密度.TabIndex = 2;
this.点密度.Text = "点密度";
this.点密度.Click += new System.EventHandler(this.点密度_Click);
//
// 按值渲染
//
this.按值渲染.Dock = System.Windows.Forms.DockStyle.Top;
this.按值渲染.Location = new System.Drawing.Point(0, 71);
this.按值渲染.Name = "按值渲染";
this.按值渲染.Size = new System.Drawing.Size(116, 23);
this.按值渲染.TabIndex = 3;
this.按值渲染.Text = "按值渲染";
this.按值渲染.Click += new System.EventHandler(this.按值渲染_Click);
//
// 分类渲染
//
this.分类渲染.Dock = System.Windows.Forms.DockStyle.Top;
this.分类渲染.Location = new System.Drawing.Point(0, 94);
this.分类渲染.Name = "分类渲染";
this.分类渲染.Size = new System.Drawing.Size(116, 23);
this.分类渲染.TabIndex = 4;
this.分类渲染.Text = "分类渲染";
this.分类渲染.Click += new System.EventHandler(this.分类渲染_Click);
//
// Z值渲染
//
this.Z值渲染.Dock = System.Windows.Forms.DockStyle.Top;
this.Z值渲染.Location = new System.Drawing.Point(0, 117);
this.Z值渲染.Name = "Z值渲染";
this.Z值渲染.Size = new System.Drawing.Size(116, 23);
this.Z值渲染.TabIndex = 5;
this.Z值渲染.Text = "Z值渲染";
this.Z值渲染.Click += new System.EventHandler(this.Z值渲染_Click);
//
// 组渲染
//
this.组渲染.Dock = System.Windows.Forms.DockStyle.Top;
this.组渲染.Location = new System.Drawing.Point(0, 140);
this.组渲染.Name = "组渲染";
this.组渲染.Size = new System.Drawing.Size(116, 23);
this.组渲染.TabIndex = 6;
this.组渲染.Text = "组渲染";
this.组渲染.Click += new System.EventHandler(this.组渲染_Click);
//
// 退出
//
this.退出.Dock = System.Windows.Forms.DockStyle.Bottom;
this.退出.Location = new System.Drawing.Point(0, 402);
this.退出.Name = "退出";
this.退出.Size = new System.Drawing.Size(116, 23);
this.退出.TabIndex = 7;
this.退出.Text = "退出";
this.退出.Click += new System.EventHandler(this.退出_Click);
//
// 标注渲染
//
this.标注渲染.Dock = System.Windows.Forms.DockStyle.Top;
this.标注渲染.Location = new System.Drawing.Point(0, 163);
this.标注渲染.Name = "标注渲染";
this.标注渲染.Size = new System.Drawing.Size(116, 23);
this.标注渲染.TabIndex = 7;
this.标注渲染.Text = "标注渲染";
this.标注渲染.Click += new System.EventHandler(this.标注渲染_Click);
//
// 删除所有渲染
//
this.删除所有渲染.Dock = System.Windows.Forms.DockStyle.Top;
this.删除所有渲染.Location = new System.Drawing.Point(0, 319);
this.删除所有渲染.Name = "删除所有渲染";
this.删除所有渲染.Size = new System.Drawing.Size(116, 23);
this.删除所有渲染.TabIndex = 22;
this.删除所有渲染.Text = "删除所有渲染";
this.删除所有渲染.Click += new System.EventHandler(this.删除所有渲染_Click);
//
// panel1
//
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 299);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(116, 20);
this.panel1.TabIndex = 21;
//
// 全图
//
this.全图.Dock = System.Windows.Forms.DockStyle.Top;
this.全图.Location = new System.Drawing.Point(0, 276);
this.全图.Name = "全图";
this.全图.Size = new System.Drawing.Size(116, 23);
this.全图.TabIndex = 20;
this.全图.Text = "全图";
this.全图.Click += new System.EventHandler(this.全图_Click);
//
// 拖动
//
this.拖动.Dock = System.Windows.Forms.DockStyle.Top;
this.拖动.Location = new System.Drawing.Point(0, 253);
this.拖动.Name = "拖动";
this.拖动.Size = new System.Drawing.Size(116, 23);
this.拖动.TabIndex = 19;
this.拖动.Text = "拖动";
this.拖动.Click += new System.EventHandler(this.拖动_Click);
//
// 缩小
//
this.缩小.Dock = System.Windows.Forms.DockStyle.Top;
this.缩小.Location = new System.Drawing.Point(0, 230);
this.缩小.Name = "缩小";
this.缩小.Size = new System.Drawing.Size(116, 23);
this.缩小.TabIndex = 18;
this.缩小.Text = "缩小";
this.缩小.Click += new System.EventHandler(this.缩小_Click);
//
// 放大
//
this.放大.Dock = System.Windows.Forms.DockStyle.Top;
this.放大.Location = new System.Drawing.Point(0, 207);
this.放大.Name = "放大";
this.放大.Size = new System.Drawing.Size(116, 23);
this.放大.TabIndex = 17;
this.放大.Text = "放大";
this.放大.Click += new System.EventHandler(this.放大_Click);
//
// 分隔符
//
this.分隔符.Dock = System.Windows.Forms.DockStyle.Top;
this.分隔符.Location = new System.Drawing.Point(0, 186);
this.分隔符.Name = "分隔符";
this.分隔符.Size = new System.Drawing.Size(116, 21);
this.分隔符.TabIndex = 16;
//
// 渲染示例
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(616, 429);
this.Controls.Add(this.操作板);
this.Controls.Add(this.map);
this.Name = "渲染示例";
this.Text = "渲染示例";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
((System.ComponentModel.ISupportInitialize)(this.map)).EndInit();
this.操作板.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
///
/// 应用程序的主入口点。
///
[STAThread]
static void Main()
{
Application.Run(new 渲染示例());
}
///
/// 退出系统
///
private void 退出_Click(object sender, System.EventArgs e)
{
this.Close();
}
///
/// 图表渲染,值方图
///
private void 直方图_Click(object sender, System.EventArgs e)
{
//直方图的例子中使用Lakers图层
//
//定义图标渲染变量
MapObjects2.ChartRenderer cr = new MapObjects2.ChartRendererClass();
//设置渲染类型为直方图
cr.ChartType = MapObjects2.ChartTypeConstants.moBar;
//设置直方图显示的字段个数为两个,就是直方图显示两个柱子
cr.FieldCount = 2;
//设置第一个字段,请参看lakes.dbf
cr.set_Field(0,"SURF_ELEV");
//设置这个直方图的柱子颜色为红色
cr.set_Color(0,(uint)MapObjects2.ColorConstants.moRed);
//设置第二个柱子
cr.set_Field(1,"DEPTH");
cr.set_Color(1,(uint)MapObjects2.ColorConstants.moGreen);
MapObjects2.MapLayer lyr = (MapObjects2.MapLayer)(map.Layers.Item("lakes"));
lyr.Renderer = cr;
//使用Refresh()刷新老也是刷新不好,正没办法。。。,设为全图倒是不错的注意,^_^
map.Refresh();
}
///
/// 全图视野
///
private void 全图_Click(object sender, System.EventArgs e)
{
map.Extent = map.FullExtent;
}
///
/// 拖动,只设置图标
///
private void 拖动_Click(object sender, System.EventArgs e)
{
map.MousePointer = MapObjects2.MousePointerConstants.moPan;
}
///
/// 缩小,只设置图标
///
private void 缩小_Click(object sender, System.EventArgs e)
{
map.MousePointer = MapObjects2.MousePointerConstants.moZoomOut;
}
///
/// 放大,只设置图标
///
private void 放大_Click(object sender, System.EventArgs e)
{
map.MousePointer = MapObjects2.MousePointerConstants.moZoomIn;
}
///
/// 鼠标按下时间,处理地图放大、缩小、拖动等。
///
private void map_MouseDownEvent(object sender, AxMapObjects2._DMapEvents_MouseDownEvent e)
{
MapObjects2.Rectangle rect;
MapObjects2.Point pt = map.ToMapPoint(e.x,e.y);
if(e.button == 2)//右键点击取消
{
map.MousePointer = MapObjects2.MousePointerConstants.moDefault;
}
if(map.MousePointer == MapObjects2.MousePointerConstants.moPan)//拖动
{
map.Pan();
}
else if(map.MousePointer == MapObjects2.MousePointerConstants.moZoomIn)//放大
{
rect = map.TrackRectangle();
if(rect == null|| (rect.Width