ArcGIS Engine+C# 初学者实例代码(4)

2019-04-09 19:11

m_pageLayoutControl.PageLayout.ReplaceMaps(maps); //assign the new map to the MapControl //把新的map赋给MapControl m_mapControl.Map = newMap;

//reset the active tools //重设active tools

m_pageLayoutActiveTool = null; m_mapActiveTool = null;

//make sure that the last active control is activated //确定最后活动的control被激活 if (activateMapFirst) this.ActivateMap(); else

this.ActivatePageLayout(); }

///

///by passing the application's toolbars and TOC to the synchronization class, it saves you the

///management of the buddy control each time the active control changes. This method ads the framework

///control to an array; once the active control changes, the class iterates through the array and

///calles SetBuddyControl on each of the stored framework control. ///

///

public void AddFrameworkControl(object control) {

if (control == null) throw new Exception(\control is not initialized!\

m_frameworkControls.Add(control); }

///

/// Remove a framework control from the managed list of controls ///

///

public void RemoveFrameworkControl(object control) {

if (control == null) throw new Exception(\to be removed is not initialized!\

m_frameworkControls.Remove(control); }

///

/// Remove a framework control from the managed list of controls by specifying its index in the list

///

///

public void RemoveFrameworkControlAt(int index) {

if (m_frameworkControls.Count < index) throw new Exception(\

m_frameworkControls.RemoveAt(index); }

///

/// when the active control changes, the class iterates through the array of the framework controls

/// and calles SetBuddyControl on each of the controls. ///

///

try {

if (buddy == null)

throw new Exception(\Buddy Control is not initialized!\

foreach (object obj in m_frameworkControls) {

if (obj is IToolbarControl) {

((IToolbarControl)obj).SetBuddyControl(buddy); }

else if (obj is ITOCControl) {

((ITOCControl)obj).SetBuddyControl(buddy); } } }

catch (Exception ex) {

throw

Exception(string.Format(\ } }

#endregion } }

new

2、新建Maps类

在同步类中,要用到Maps类,用于管理地图对象。与新建同步类ControlsSynchronizer类似,我们新建一Maps类,其所有代码如下所示:

using System;

using System.Collections;

using System.Collections.Generic; using System.Text;

using System.Runtime.InteropServices;

using ESRI.ArcGIS.Carto;

namespace _sdnMap {

[Guid(\ [ClassInterface(ClassInterfaceType.None)] [ProgId(\

public class Maps : IMaps, IDisposable {

//class member - using internally an ArrayList to manage the Maps collection private ArrayList m_array = null;

#region class constructor public Maps() {

m_array = new ArrayList(); }

#endregion

#region IDisposable Members

///

/// Dispose the collection ///

public void Dispose() {

if (m_array != null) {

m_array.Clear(); m_array = null; } }

#endregion

#region IMaps Members

///

/// Remove the Map at the given index ///

///

if (Index > m_array.Count || Index < 0)

throw new Exception(\

m_array.RemoveAt(Index); }

///

/// Reset the Maps array ///

public void Reset() {

m_array.Clear(); }

///

/// Get the number of Maps in the collection ///

public int Count {

get {

return m_array.Count; } }

///

/// Return the Map at the given index ///

///

public IMap get_Item(int Index) {

if (Index > m_array.Count || Index < 0)

throw new Exception(\

return m_array[Index] as IMap; }

///

/// Remove the instance of the given Map ///

///

m_array.Remove(Map); }

///

/// Create a new Map, add it to the collection and return it to the caller ///

/// public IMap Create() {

IMap newMap = new MapClass(); m_array.Add(newMap);

return newMap; }

///

/// Add the given Map to the collection ///

///


ArcGIS Engine+C# 初学者实例代码(4).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:医学遗传学习题

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: