using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Controls;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.Display; namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} double xmin, ymin, xmax, ymax;
double Xmin, Ymin, Xmax, Ymax;
int Xvalue = ;
int Yvalue = ;
int Xlarge = ;
int Ylarge = ;
double heightFullenv, h, widthFullEnv, w;
double initScale = 0d;
int vscrollMaxium = ;
int hscrollMaxium = ; IEnvelope pEnvMap = null;
IMapControl2 pMapControl = null;
private void axMapControl1_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e)
{
pEnvMap = e.newEnvelope as IEnvelope;
pMapControl = axMapControl1.Object as IMapControl2;
if(initScale < )
initScale = pMapControl.MapScale; xmin = pEnvMap.XMin;
ymin = pEnvMap.YMin;
xmax = pEnvMap.XMax;
ymax = pEnvMap.YMax;
w = pEnvMap.Width;
h = pEnvMap.Height;
lblLeftBottom.Text = Math.Round(pEnvMap.XMin,).ToString() + "," + Math.Round(pEnvMap.YMin,).ToString();
lblRightTop.Text = Math.Round(pEnvMap.XMax, ).ToString() + "," + Math.Round(pEnvMap.YMax, ).ToString();
lblw.Text = pEnvMap.Width.ToString(); IEnvelope pEnvFull = pMapControl.ActiveView.FullExtent as IEnvelope;
Xmin = pEnvFull.XMin;
Ymin = pEnvFull.YMin;
Xmax = pEnvFull.XMax;
Ymax = pEnvFull.YMax;
widthFullEnv = pEnvFull.Width;
heightFullenv = pEnvFull.Height;
lblLeftBottomFull.Text = Math.Round(pEnvFull.XMin, ).ToString() + "," + Math.Round(pEnvFull.YMin, ).ToString();
lblRightTopFull.Text = Math.Round(pEnvFull.XMax, ).ToString() + "," + Math.Round(pEnvFull.YMax, ).ToString();
lblWf.Text = pEnvFull.Width.ToString(); if (Ymax > ymax && ymin > Ymin)
{
vscrollMaxium = (int)(heightFullenv / );
Yvalue = (int)( (Ymax - ymax) / );
Ylarge = (int)(h / );
if (Yvalue + Ylarge > vscrollMaxium)
{
Yvalue = vscrollMaxium - Ylarge;
}
}
else if (ymax > Ymax)
{
vscrollMaxium = (int)((ymax - Ymin) / );
Yvalue = ;
Ylarge = (int)(h / );
}
else if (Ymin > ymin)
{
vscrollMaxium = (int)((Ymax - ymin) / );
Ylarge = (int)(h / );
Yvalue = vscrollMaxium - Ylarge + ;
}
this.vScrollBar1.Maximum = vscrollMaxium;
this.vScrollBar1.LargeChange = Ylarge;
this.vScrollBar1.Value = Yvalue;
this.vScrollBar1.SmallChange = (int)( * (initScale / pMapControl.MapScale)); if (Xmax > xmax && xmin > Xmin)
{
hscrollMaxium = (int)(widthFullEnv / );
Xvalue = (int)((xmin - Xmin) / );
Xlarge = (int)(w / );
if (Xvalue + Xlarge > hscrollMaxium)
{
Xvalue = hscrollMaxium - Xlarge;
}
}
else if (xmax > Xmax)
{
hscrollMaxium = (int)((xmax - Xmin) / );
Xlarge = (int)(w / );
Xvalue = hscrollMaxium - Xlarge + ;
}
else if (Xmin > xmin)
{
hscrollMaxium = (int)((Xmax - xmin) / );
Xvalue = ;
Xlarge = (int)(w / );
}
this.hScrollBar1.Maximum = hscrollMaxium;
this.hScrollBar1.LargeChange = Xlarge;
this.hScrollBar1.Value = Xvalue;
this.hScrollBar1.SmallChange = (int)( * (initScale / pMapControl.MapScale)); lblYscroll.Text = "Large:" + Ylarge.ToString() + ",Value:" + Yvalue.ToString() +
",Small:" + vScrollBar1.SmallChange.ToString() + ",Max:" + vScrollBar1.Maximum.ToString();
} private void btnSetDemo_Click(object sender, EventArgs e)
{
int max = ;
int value = ;
int smallchange = ;
int largechange = ;
int.TryParse(this.txtSmallChange.Text, out smallchange);
int.TryParse(this.txtMaxinum.Text, out max);
int.TryParse(this.txtValue.Text, out value);
int.TryParse(txtLargeChange.Text, out largechange);
this.vScrollBar3.Maximum = max;
this.vScrollBar3.SmallChange = smallchange;
this.vScrollBar3.LargeChange = largechange;
this.vScrollBar3.Value = value;
} private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
this.axMapControl1.OnExtentUpdated -= this.axMapControl1_OnExtentUpdated;
double newheight = (e.OldValue - e.NewValue) * ;
pEnvMap.Offset(, newheight);
this.pMapControl.Extent = pEnvMap;
this.axMapControl1.OnExtentUpdated += this.axMapControl1_OnExtentUpdated;
} private void hScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
this.axMapControl1.OnExtentUpdated -= this.axMapControl1_OnExtentUpdated;
double w = (e.NewValue - e.OldValue) * ;
pEnvMap.Offset(w, );
this.pMapControl.Extent = pEnvMap;
this.axMapControl1.OnExtentUpdated += this.axMapControl1_OnExtentUpdated;
} }
}

backup_code

scrollbar_test的更多相关文章

  1. Unity3D学习笔记——NGUI之UIScrollBar

    UIScrollBar:这个组件可以用于创建滚动条. 效果图如下: 一:使用步骤 1.这个组件和UISlider很像,也是由三部分组成. 2.首先创建一个Sprite用于组件的背景色. 3.创建第二个 ...

随机推荐

  1. Thread系列之Thread.Sleep(0)

    线程这一概念,可以理解成进程中的一个小单元.这个单元是一个独立的执行单元,但是与进程中的其他线程共享进程中的内存单元. 由于Cpu资源是有限的,所以进程中的多个线程要抢占Cpu,这也导致进程中的多个线 ...

  2. Spring+SpringMVC+Mybatis大整合(SpringMVC采用REST风格、mybatis采用Mapper代理)

    整体目录结构: 其中包下全部是采用mybatis自动生成工具生成. mybatis自动生成文件 <?xml version="1.0" encoding="UTF- ...

  3. Python第三方包的安装和管理

    要想安装第三方的包,首先安装setuptools. 然后再安装pip,这个是用来管理第三方包的. 1. 包管理器pip,安装第三方包,以Selenium为例,运行 pip install seleni ...

  4. zabbix问题处理

    工作的时候回遇到各种各样的问题. 今天遇到一个关于zabbix的问题. "Zabbix agent on host.name is unreachable for 5 minutes&quo ...

  5. JSBinding+Bridge.NET:生成绑定(导出)

    将框架代码导出到 JavaScript.就可以在 JavaScript 中调用 框架代码 的功能. 注意,这个功能是在 Js工程中做的,Cs工程没有这回事. 如何导出? 1. 将需要导出的类添加到 J ...

  6. C#中dynamic的正确用法

    C#中dynamic的正确用法  http://www.cnblogs.com/qiuweiguo/archive/2011/08/03/2125982.html dynamic是FrameWork4 ...

  7. iso 培训笔记

    protocol协议 + 类方法- 实例方法:继承()方法 <> [] 方法调用 .属性:参数mvc storyboard 资源文件info.plist 权限viewcontroller ...

  8. tomcat解决加载JSP文件过大错误

    当遇到多个Jsp include一起的时候加载时遇到如下错误: Error:SEVERE: Servlet.service() for servlet jsp threw exception org. ...

  9. suspendlayout

    c# this.suspendlayout有什么作用 为了防止layout事件的发生.这个事件将引发重新绘图的事件,如果介面上控件较多的话,改变控件某些属性时,由于不断地重画,性能变低,所以用susp ...

  10. 自身对highcharts理解

    最近公司要求做一些图标,动态的添加数据,展示在手机上,以前对Echarts,d3,highcharts只是听说,也没实际去花一定的时间玩玩,也是自以为是,不就看看api的事,结果呢?-----被他们给 ...