scrollbar_test
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的更多相关文章
- Unity3D学习笔记——NGUI之UIScrollBar
UIScrollBar:这个组件可以用于创建滚动条. 效果图如下: 一:使用步骤 1.这个组件和UISlider很像,也是由三部分组成. 2.首先创建一个Sprite用于组件的背景色. 3.创建第二个 ...
随机推荐
- JS 中通过对象关联实现『继承』
JS 中继承其实是种委托,而不是传统面向对象中的复制父类到子类,只是通过原型链将要做的事委托给父类. 下面介绍通过对象关联来实现『继承』的方法: Foo = { // 需要提供一个 init 方法来初 ...
- ie7中ul不能嵌套div和li平级
我要讲一个忧伤的故事,本以为清晰的层次结构,ul里不能嵌套div和li平级,不然会乱乱乱! 代码: <ul class="catshow"> ...
- 安装dubbo-admin遇到的问题和解决之道
这里不多说dubbo的相关知识.简单提示dubbo-admin所需的环境.java的jdk和jre,dubbo-admin.war,tomcat. 今天只是把在win7环境下安装了dubbo-admi ...
- Spring源码学习之:FactoryBean的使用
转载:http://book.51cto.com/art/201311/419081.htm ==========个人理解========================= FactoryBean和B ...
- Python的标准输出
遇到什么就添加到这里来. 首先,是最基本的. print "Number is %d %f %s"%(intA,floatB,stringC) 如果对浮点数的精度有所要求的话,比如 ...
- 利用 Android Gradle 瘦身 apk
http://devyang.me/blog/2014/11/11/li-yong-android-gradleshou-shen-apk/ apk瘦身一般有两条线, 去除无用的代码,例如引用一个比较 ...
- CentOS 6、7下pptp vpn一键安装脚本
之前有折腾过<CentOS 6.7下IPSEC/L2TP VPN一键安装脚本>,不稳定.不支持IOS,因此换成pptp,并已经添加到<lnmp一键安装包>.这个脚本可以单独使用 ...
- cuda-convnet windows8下编译
编译环境: windows8.1 Anaconda python2.7 Visual studio 2012 CUDA6.0 Pthread for windows Intel Math Kernel ...
- C# 获取当前操作系统是32位还是64位
注:判断整型的长度的方式,只有在AnyCPU编译模式下才有用.因此更好的办法是获取真的地址总线位宽(使用WMI,windows management instruementation). .NET 2 ...
- gRaphael——JavaScript 矢量图表库:两行代码实现精美图表
gRaphael 是一个致力于帮助开发人员在网页中绘制各种精美图表的 Javascript 库,基于强大的 Raphael 矢量图形库.你只需要编写几行简单的代码就能创建出精美的条形图.饼图.点图和曲 ...