您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 公司方案 > 第六章、C#+AE二次开发之第一个桌面应用系统
1AE+C#AE+C#二次开发之二次开发之------开发第一个应用开发第一个应用GISGIS系统系统张传才张传才安徽理工大学测绘学院安徽理工大学测绘学院地信教研室地信教研室2011-7-31安徽理工大学GIS—张传才2目标:设计一个数据浏览兼绘图程序目标:设计一个数据浏览兼绘图程序1.1.功能:功能:①①加载数据加载数据②②浏览数据浏览数据③③绘图(点线面)绘图(点线面)④④选择数据选择数据⑤⑤控制图层显示控制图层显示2011-7-31安徽理工大学GIS—张传才3界面设计界面设计2011-7-31安徽理工大学GIS—张传才4I.I.使用的主要控件使用的主要控件1.1..net.net控件控件①①GroupBoxGroupBox②②TableLayoutPanelTableLayoutPanel③③menuStripmenuStrip④④toolStriptoolStrip⑤⑤SplitContainerSplitContainer2.2.AEAE控件控件①①ToCControlToCControl②②MapControlMapControl③③ToolBarControlToolBarControl④④LayerOutControlLayerOutControl2011-7-31安徽理工大学GIS—张传才5II.II.导入程序所用图标导入程序所用图标2011-7-31安徽理工大学GIS—张传才61.1.修改属性修改属性2011-7-31安徽理工大学GIS—张传才7II.II.维护工具栏按钮的按下与弹起维护工具栏按钮的按下与弹起1.1.按钮的两种类型按钮的两种类型((使用使用ARCMAPARCMAP演示演示))①①commandbutton;commandbutton;②②toolbuttontoolbutton2.2.只允许工具栏上仅有一个按钮按下。只允许工具栏上仅有一个按钮按下。2011-7-31安徽理工大学GIS—张传才8II.II.2.2.设计窗体类(设计窗体类(form1form1)的一个方法)的一个方法1.1.privatevoiduncheckallitem()privatevoiduncheckallitem()2.2.{{3.3.toolStripButtonZOOMIN.Checked=false;toolStripButtonZOOMIN.Checked=false;4.4.toolStripButtonPan.Checked=false;toolStripButtonPan.Checked=false;5.5.toolStripButtonpoly.Checked=false;toolStripButtonpoly.Checked=false;6.6.toolStripButtonrect.Checked=false;toolStripButtonrect.Checked=false;7.7.toolStripButtondraw.Checked=false;toolStripButtondraw.Checked=false;8.8.toolStripButtonline.Checked=false;toolStripButtonline.Checked=false;9.9.toolStripButtonselect.Checked=false;toolStripButtonselect.Checked=false;10.10.toolStripButtonselectbypolygon.Checked=false;toolStripButtonselectbypolygon.Checked=false;11.11.}}2011-7-31安徽理工大学GIS—张传才9II.II.使用使用ToolBarControlToolBarControl组织常见功能组织常见功能1.1.在其上在其上右击右击2.2.选择属选择属性性2011-7-31安徽理工大学GIS—张传才10II.II.添加命名按钮添加命名按钮2011-7-31安徽理工大学GIS—张传才11II.II.绑定绑定2011-7-31安徽理工大学GIS—张传才12II.II.ToccontrolToccontrol与与mapcontrolmapcontrol绑定绑定2011-7-31安徽理工大学GIS—张传才13II.II.HowtocastbetweeninterfacesHowtocastbetweeninterfaces1.1.SummarySummary2.2..NETusescastingtojumpfromone.NETusescastingtojumpfromoneinterfacetoanotherinterfaceontheinterfacetoanotherinterfaceonthesameclass.InCOM,thisiscalledasameclass.InCOM,thisiscalledaQueryInterfaceQueryInterface.VB.NETandC#cast.VB.NETandC#castdifferently.differently.2011-7-31安徽理工大学GIS—张传才14II.II.111.1.CastinginC#CastinginC#2.2.InC#,thebestmethodforcastingInC#,thebestmethodforcastingbetweeninterfacesistousetheasbetweeninterfacesistousetheasoperator.Usingtheasoperatorisaoperator.Usingtheasoperatorisabettercodingstrategythanastraightbettercodingstrategythanastraightcast,becauseityieldsanullonacast,becauseityieldsanullonaconversionfailureratherthanraisinganconversionfailureratherthanraisinganexception.exception.2011-7-31安徽理工大学GIS—张传才151.1.ThefirstlineinthefollowingcodeisaThefirstlineinthefollowingcodeisastraightcast.Thisisanacceptablestraightcast.Thisisanacceptablepractice,ifyouarecertaintheobjectinpractice,ifyouarecertaintheobjectinquestionimplementsbothinterfaces.questionimplementsbothinterfaces.2.2.IftheobjectdoesnotimplementtheIftheobjectdoesnotimplementtheinterfaceyouareattemptingtogetainterfaceyouareattemptingtogetahandleto,.NETthrowsanexception.handleto,.NETthrowsanexception.3.3.Asafermodeltouseistheasoperator,Asafermodeltouseistheasoperator,whichreturnsanull,iftheobjectcannotwhichreturnsanull,iftheobjectcannotreturnareferencetothedesiredreturnareferencetothedesiredinterface.Seethefollowing:interface.Seethefollowing:I.I.222011-7-31安徽理工大学GIS—张传才16II.II.331.1.[C#][C#]2.2.//Straightcast.//Straightcast.3.3.IGeometrygeometry=(IGeometry)point;IGeometrygeometry=(IGeometry)point;4.4.//Asoperator//Asoperator5.5.IGeometrygeometry=pointasIGeometry;IGeometrygeometry=pointasIGeometry;2011-7-31安徽理工大学GIS—张传才171.1.ThefollowingcodeexampleshowshowThefollowingcodeexampleshowshowtotomanagethepossibilityofareturnedmanagethepossibilityofareturnednullinterfacehandleafteranexplicitcast:nullinterfacehandleafteranexplicitcast:I.I.442011-7-31安徽理工大学GIS—张传才18II.II.551.1.Alternatively,youcantestifanAlternatively,youcantestifanobjectimplementsacertainobjectimplementsacertaininterfaceinterfaceatatruntimeruntimeusingtheiskeywordusingtheiskeywordbeforeperformingastraightcast.beforeperformingastraightcast.Seethefollowing:Seethefollowing:2011-7-31安徽理工大学GIS—张传才19II.II.要素选择方法的设计要素选择方法的设计2011-7-31安徽理工大学GIS—张传才20II.II.绘图方法绘图方法2011-7-31安徽理工大学GIS—张传才21II.II.通用通用ARCENGINEARCENGINE封装好的类封装好的类2011-7-31安徽理工大学GIS—张传才22II.II.tagRECTtagRECTStructureStructure1.1.[C#][C#]publicpublictagRECTtagRECT{{intintleft,left,intinttop,top,intintright,right,intintbottombottom}}2011-7-31安徽理工大学GIS—张传才231.1.ThisThiscoclasscoclassisaisaSingletonSingleton..2011-7-31安徽理工大学GIS—张传才241.1.ProvidesawayofcreatinggeometriesProvidesawayofcreatinggeometriesfromdifferentinputsandsetting/gettingfromdifferentinputsandsetting/gettingglobalvariablesforcontrollingbehaviorglobalvariablesforcontrollingbehaviorofgeometrymethods.ofgeometrymethods.2011-7-31安徽理工大学GIS—张传才25II.II.IntroductiontospatialreferencesandcoordinategridsIntroductiontospatialreferencesandcoordinategrids1.1.GeometriesaregeoreferencedtotherealworldGeometriesare
本文标题:第六章、C#+AE二次开发之第一个桌面应用系统
链接地址:https://www.777doc.com/doc-4673974 .html