zoukankan      html  css  js  c++  java
  • 基础的Mapgis三维二次开发-插件式

    最近在做一个杭州石油的项目开发一个小系统。


    1.命令必须是 ICommand 的派生类

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Drawing;
    using MapGIS.PluginEngine;
    using System.Windows.Forms;
    using MapGIS.Scene3D;
    
    
    namespace ThreeDimenModeling
    {
        class IsoheightModeling : ICommand
        {
            //应用框架对象
            IApplication hock = null;
            //场景视图控件
            SceneControl sceneCtrl = null; 
    
            #region ICommand成员 
    
            public Bitmap Bitmap
            {
                get { return null; }
            }
    
            public string Caption
            {
                get { return "等高线建模"; }
            }
    
            public string Category
            {
                get { return "ThreeDimenModeling"; }
            }
    
            public bool Checked
            {
                get { return false; }
            }
    
            public bool Enabled
            {
                get { return true; }
            }
    
            public string Message
            {
                get { return ""; }
            }
    
            public string Name
            {
                get { return "等高线建模"; }
            }
    
            public string Tooltip
            {
                get { return ""; }
            }
    
            public void OnClick()
            {
                sceneCtrl = (this.hock.ActiveContentsView as ISceneContentsView).SceneControl;
                IsoheightModelingForm IsoHeiMoForm = new IsoheightModelingForm(sceneCtrl ); 
                if (IsoHeiMoForm.ShowDialog() != DialogResult.OK) return;         
            }
            public void OnCreate(IApplication hook)
            {
                if (hook != null)
                {
                    this.hock = hook;
                    this.hock.StateManager.StateChangedEvent += new StateChangedHandler(StateManager_StateChangedEvent);
                }
            }
            void StateManager_StateChangedEvent(object sender, StateEventArgs e)
            {
                this.hock.PluginContainer.PluginEnable(this, false);
                bool bEnable = false;
                if (this.hock.ActiveContentsView != null && this.hock.ActiveContentsView is ISceneContentsView)
                {
                    //当存在当前编辑状态的图层时,才可以进行查询
                    SceneControl ctr = (this.hock.ActiveContentsView as ISceneContentsView).SceneControl;
                    if (ctr != null && ctr.GetSceneNum() > 0)
                    {
                        bEnable = true;
                    }
                }
                this.hock.PluginContainer.PluginEnable(this, bEnable); 
                return;
            }
            private void PluginContainer_ContentsViewClosingEvent(IContentsView contentsView, ContentsViewClosingEventArgs args)
            {
                if (contentsView is ISceneContentsView)
                {
                    SceneControl ctr = (this.hock.ActiveContentsView as ISceneContentsView).SceneControl;
                }
            }
            #endregion
        }
    }
    

    2.弹出Form

    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 MapGIS.Scene3D; 
    
    namespace ThreeDimenModeling
    {
        public partial class IsoheightModelingForm : Form
        {
            //场景控件
            SceneControl sceneCtrl = null; 
    
            public IsoheightModelingForm(SceneControl sCtrl )
            {
                InitializeComponent();
                this.sceneCtrl = sCtrl; 
            }
        }
    }
    

  • 相关阅读:
    Mifare系列3-卡的能源和数据传递(转)
    Mifare系列2-非接触卡标准(转)
    Mifare系列1-简介(转)
    oot 空间不足解决方法
    C语言位操作(转)
    C语言面试题(三)
    C语言运算符和优先级
    C语言面试题(二)
    C语言面试题(一)
    Ubuntu+Win7双系统grub的修复问题
  • 原文地址:https://www.cnblogs.com/lightmare/p/10398850.html
Copyright © 2011-2022 走看看