首页 > 其他分享 >ArcObjects SDK开发 022 开发框架搭建-FrameWorkUI包设计

ArcObjects SDK开发 022 开发框架搭建-FrameWorkUI包设计

时间:2022-12-25 10:44:16浏览次数:50  
标签:Items Tool 022 ArcObjects Add UI FrameWorkUI ._ new

1、CommandUIs部分

这部分主要是定义承载Command和Tool的具体UI。如下图所示。

image1.png

以CommandUI结尾的这几个类都是继承了Framework.Engine里面的ICommandUI接口,这样我们定义的Command和Tool就可以和这些UI绑定到一起了。

其中BarButtonItemCommandUI是DEV库中普通的按钮,BarCheckItemCommandUI是DEV库中由选中状态的按钮,MenuItemCommandUI是菜单按钮,一般右键菜单项会用这个UI,ToolStripMenuItemCommandUI是Winform下右键菜单项,在TocControl图层树中的右键菜单会采用这个按钮项。

2、Controls部分

主要定义了常用的UI。如下图所示。

image4.png

3、常用命令和工具

image6.png

我们看下最常用的地图放大工具的定义。

public class MapZoomInTool : MapTool
{
    private readonly ESRI.ArcGIS.SystemUI.ITool _EsriTool = null;
    public MapZoomInTool(MapApplication pMapApplication)
        : base(pMapApplication)
    {
        this._EsriTool = new ControlsMapZoomInToolClass();
        this.SetIcon(CommandIconSize.IconSize16, "MapTools/Res/MapZoomIn16.png");
    }

    /// <summary>
    /// 激活执行的函数
    /// </summary>
    public override void OnActive()
    {
        base.OnActive();
        (this._EsriTool as ESRI.ArcGIS.SystemUI.ICommand).OnCreate(this.MapApplication.ActiveControl);
        this.MapApplication.ActiveControl.CurrentTool = this._EsriTool;
    }

    /// <summary>
    /// 工具失活执行的函数
    /// </summary>
    public override void OnDeActivate()
    {
        base.OnDeActivate();
        this.MapApplication.ActiveControl.CurrentTool = null;
    }

    /// <summary>
    /// 鼠标按下执行的函数
    /// </summary>
    /// <param name="button"></param>
    /// <param name="shift"></param>
    /// <param name="x"></param>
    /// <param name="y"></param>
    public override void onm ouseDown(int button, int shift, int x, int y)
    {
        if (button == 4)
        {
            this.MapApplication.AxControlPan();
        }
        base.OnMouseDown(button, shift, x, y);
    }
}

这就意味着,只要继承实现了MapApplication这个类,就可以直接使用该工具。例如我们的系统首页,定义了一个MapApplication实例,那么可以在此基础上初始化地图放大工具。

我们系统里面其他功能也要用这个工具的时候,也可以初始化一个MapApplication,或者实现一个继承MapApplication的类。例如系统中的出图模板设计功能。

这个功能里面,我们继承MapApplication,定义了LayoutDesignApplication。如下图所示。

public class LayoutDesignApplication : MapApplication
{
    /// <summary>
    /// 版式设计主程序类
    /// </summary>
    /// <param name="pAxMapControl"></param>
    /// <param name="pAxPageLayoutControl"></param>
    public LayoutDesignApplication(AxMapControl pAxMapControl, AxPageLayoutControl pAxPageLayoutControl)
        : base(pAxMapControl, pAxPageLayoutControl)
    {
        this.LayoutDesign = new LayoutDesign();
    }

    /// <summary>
    /// 当前打开的 模板文件路径
    /// </summary>
    public string ShmFilePath { get; set; } = "";

    /// <summary>
    /// 版式设计对象
    /// </summary>
    public LayoutDesign LayoutDesign { get; private set; } = null;

    /// <summary>
    /// 当前打开地图的元数据
    /// </summary>
    public GeoChemMetaData GeoChemMetaData { get; private set; }

    /// <summary>
    /// 得到页面布局对象
    /// </summary>
    public IPageLayout PageLayout
    {
        get
        {
            return this.PageLayoutControl.PageLayout;
        }
    }
    /// <summary>
    /// 加载属性面板的UI
    /// </summary>
    public Border PropertyBorder { get; set; } = null;
}

添加工具的代码如下。

this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new OpenMxdCommand(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new OpenShmCommand(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new AddDataCommand(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new SaveShmCommand(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new SaveAsShmCommand(this._LayoutDesignAplication)));

this.UI_Tool_Bar.Items.Add(new BarItemLinkSeparator());
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new MapFrameCommand(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new MapGridCommand(this._LayoutDesignAplication)));

this.UI_Tool_Bar.Items.Add(new BarItemLinkSeparator());
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new ResTableCommand(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new ClassTableCommand(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new ClassHistogramCommand(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new HistogramMapCommand(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new NorthArrowCommand(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new ScaleBarCommand(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new LegendCommand(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new TitleCommand(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new PointTextTool(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new PictureCommand(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new NeatlineItemCommand(this._LayoutDesignAplication)));

this.UI_Tool_Bar.Items.Add(new BarItemLinkSeparator());
SelectTool myPLDSelectTool = new SelectTool(this._LayoutDesignAplication);
this.UI_Tool_Bar.Items.Add(new BarCheckItemCommandUI(myPLDSelectTool));
this._LayoutDesignAplication.SelectTool = myPLDSelectTool;

this.UI_Tool_Bar.Items.Add(new BarCheckItemCommandUI(new PageZoomInTool(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarCheckItemCommandUI(new PageZoomOutTool(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarCheckItemCommandUI(new PagePanTool(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new PageZoomInFixedCommand(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new PageZoomOutFixedCommand(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new PageZoomWholePageCommand(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new PageZoom100PercentCommand(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new PageZoomBackCommand(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new PageZoomForwardCommand(this._LayoutDesignAplication)));
this.UI_Tool_Bar.Items.Add(new BarItemLinkSeparator());
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new ViewExportPicCommand(this._LayoutDesignAplication)));

 

再例如,布点的这个模块。

我们继承MapApplication定义了DeployApplication,如下图所示。

public class DeployApplication : MapApplication
{
    private Project _Project = null;
    private object _SelectObjectOnProjectTree = null;
    private IFeature _SelectPointFeature = null;

    /// <summary>
    /// 采样点布置主App
    /// </summary>
    /// <param name="pAxMapControl"></param>
    /// <param name="pAxPageLayoutControl"></param>
    public DeployApplication(AxMapControl pAxMapControl, AxPageLayoutControl pAxPageLayoutControl)
        : base(pAxMapControl, pAxPageLayoutControl)
    {
        this.EngineEditor = new EngineEditorClass();
    }

    /// <summary>
    /// ArcEngine编辑类
    /// </summary>
    public EngineEditorClass EngineEditor { get; private set; }

    /// <summary>
    /// 当前工程对象
    /// </summary>
    public Project Project
    {
        get
        {
            return this._Project;
        }
        set
        {
            this._Project = value;
            this.OnProjectChanged?.Invoke(this, new EventArgs());
        }
    }

    /// <summary>
    /// 得到或设置树上选择的对象
    /// </summary>
    public object SelectObjectOnWorkZoneTree
    {
        get { return this._SelectObjectOnProjectTree; }
        set
        {
            this._SelectObjectOnProjectTree = value;
            this.OnSelectObjectOnProjectTreeChanged?.Invoke(this, new EventArgs());
        }
    }

    /// <summary>
    /// 得到或设置当前选中的采样点要素
    /// </summary>
    public IFeature SelectPointFeature
    {
        get
        {
            return this._SelectPointFeature;
        }
        set
        {
            this._SelectPointFeature = value;
            this.OnSelectPointFeatureChanged?.Invoke(this, new EventArgs());
        }
    }

    /// <summary>
    /// 触发Map25Sheet信息变化事件
    /// </summary>
    public void FireMap25SheetInfoChangedEvent()
    {
        this.OnMap25SheetInfoChanged?.Invoke(this, new EventArgs());
    }

    /// <summary>
    /// 当工程发生变化触发的事件
    /// </summary>
    public event EventHandler<EventArgs> OnProjectChanged;

    /// <summary>
    /// 当在树上选中的对象发生变化触发的事件
    /// </summary>
    public event EventHandler<EventArgs> OnSelectObjectOnProjectTreeChanged;

    /// <summary>
    /// 当选择的采样点元素发生变化触发的事件
    /// </summary>
    public event EventHandler<EventArgs> OnSelectPointFeatureChanged;

    /// <summary>
    /// 当Map25Sheet的信息发生变化后触发的函数
    /// </summary>
    public event EventHandler<EventArgs> OnMap25SheetInfoChanged;
}

添加工具如下。

//初始化Application
this._DeployApplication = new DeployApplication(myAxMapControl, myAxPageLayoutControl);
this._DeployApplication.MainWindow = this;
this._DeployApplication.OnProjectChanged += Application_OnWorkZoneChanged;
this._DeployApplication.OnSelectObjectOnProjectTreeChanged += _Application_OnSelectObjectOnWorkZoneTreeChanged;
this._DeployApplication.OnSelectPointFeatureChanged += Application_OnSelectPointFeatureChanged;
this._DeployApplication.OnMap25SheetInfoChanged += Application_OnMap25SheetInfoChanged;

this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new ProjectNewCommand(this._DeployApplication)));
ProjectOpenCommand myWorkZoneOpenCommand = new ProjectOpenCommand(this._DeployApplication);
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(myWorkZoneOpenCommand));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.Files.AddDataCommand(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarItemLinkSeparator());
this.UI_Tool_Bar.Items.Add(new BarCheckItemCommandUI(new FrameworkUI.MapTools.MapZoomInTool(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarCheckItemCommandUI(new FrameworkUI.MapTools.MapZoomOutTool(this._DeployApplication)));
FrameworkUI.MapTools.MapPanTool myMapPanTool = new FrameworkUI.MapTools.MapPanTool(this._DeployApplication);
this.UI_Tool_Bar.Items.Add(new BarCheckItemCommandUI(myMapPanTool));
this._DeployApplication.CrruteTool = myMapPanTool;
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.MapTools.MapZoomInFixedCommand(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.MapTools.MapZoomOutFixedCommand(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.MapTools.MapFullExtentCommand(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.MapTools.MapZoomBackCommand(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new FrameworkUI.MapTools.MapZoomForwardCommand(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarItemLinkSeparator());
this.UI_Tool_Bar.Items.Add(new BarCheckItemCommandUI(new FrameworkUI.MapTools.MeasureTool(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarItemLinkSeparator());
this.UI_Tool_Bar.Items.Add(new BarCheckItemCommandUI(new Map5SheetSelectTool(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarCheckItemCommandUI(new FrameworkUI.MapTools.FeaturesClearSelectCommand(this._DeployApplication) { Caption = "Clear Select" }));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new MapSheetLabelCommand(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new SamplePointLabelCommand(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new Map5TerrainViewCommand(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarItemLinkSeparator());
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new Map25AutoPointCommand(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new Map25ClearPointCommand(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarItemLinkSeparator());
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new EditorStartCommand(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarCheckItemCommandUI(new EditorEditTool(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarCheckItemCommandUI(new EditorNewPointTool(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new EditorSaveCommand(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new EditorStopCommand(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarItemLinkSeparator());
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new Map25LoadUnitCommand(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new Map25EncodeCommand(this._DeployApplication)));
this.UI_Tool_Bar.Items.Add(new BarButtonItemCommandUI(new Map25ExportCommand(this._DeployApplication)));

标签:Items,Tool,022,ArcObjects,Add,UI,FrameWorkUI,._,new
From: https://www.cnblogs.com/mytudousi/p/17003741.html

相关文章

  • 如何在头条做营销:2022今日头条营销价值洞察报告.pdf(附下载链接)
    本报告共包含如下四大部分:1、趋势:品牌内容营销难题;2、人群:今日头条人群特征;3、内容:今日头条内容生态;4、商业:今日头条商业生态。更多细节和行研干货资料请到小程序省时查报告......
  • 20221313陆玉 实验八Web部署 实验报告
    20221313陆玉实验八Web部署实验报告配置openEuler重新配置yum源:添加内容安装LAMP安装Apache并开启服务设置Apache开机自动,关闭防火墙,禁止防火墙自启动安装mar......
  • P8813 [CSP-J 2022] 乘方 题解
    题目传送门题目大意给定\(a\)和\(b\),如果\(a^b\)的值不超过\({10}^9\),则输出\(a^b\)的值,否则输出-1;解题思路特判即可:如果\(a^b\)的值不超过\({10}^9\),用......
  • 考研数学练习题-2022年12月24日
    数量:10......
  • the third study--2022.12.20
    提高程序可读性的四个技巧1.选择有意义的函数名。(例如:身高--height;体重--weight;英寸--foot等等)2.写注释。当有些函数名不好解释时,可以通过在旁边写注释来进行解释;也可......
  • Script-字符串-2022-12-24
    <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>Title</title><script>//<!--采用严格检查模式usestrict放在第一行//let定义......
  • SCRIPT-严格检查-2022-12-24
    <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>Title</title><script><!--采用严格检查模式usestrict放在第一行let定义局部变......
  • 2022.12.24周总结
    1、Redis支持哪几种数据类型?String、List、Set、SortedSet、hashes2、Redis主要消耗什么物理资源?Redis是一种基于内存高性能的数据库---主要依赖于内存3、Redis有哪......
  • OI 思维与策略杂记 2022.12
    OI思维与策略杂记(一)这个系列的开坑,主要是为记录和总结一些比较典型或创新的有价值的思维与Trick。文内的题目有一定难度质量是很高的,...嗯其实更多是写给自己总结用的......
  • 实验八-web部署-20221308刘志伟
    实验步骤在华为云openEuler安装后,没有配置yum源,我们通过重新配置。输入命令以切换到rpos目录下cd/etc/yum.repos.d输入命令更换yum源viopenEuler_x86_64.repo增加......