1

我正在尝试开发以下用户控件。

用户控件构建没有错误。当我尝试在 Visual Studios 中加载工具包时,我收到 Visual Studio 错误

无法加载文件或程序集“Bentley.Interop.MicrostationDGN”

这是因为它试图Bentley.Interop在工具包加载期间加载。在此工具包中的其他用户控件中,我能够检查Bentley.Interop并忽略此错误。但是,IlocateCommandEvents代码中显示的接口是部分ClsPointSelector类构造。有没有办法Bentley.Interop在这个级别(开发级别)检查,并且在主应用程序托管时仍然具有正确的用户控制功能。

该工具包由一个插件应用程序托管,而该插件应用程序又由 Microstation 托管。

using System;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using BCOM = Bentley.Interop.MicroStationDGN;

namespace cds.microstation.win.forms
{
    [DisplayName(@"Point Selector")]
    [Description("Microstation Point Selector.")]
    [ToolboxBitmap(typeof(PointSelector), "PointSelector.bmp")]
    public partial class PointSelector : UserControl
    {
        private BCOM.ApplicationClass BCOM = new BCOM.ApplicationClass();
        private BCOM.Application _ustn = null;                
        public event OnChangedEventHandler OnChanged;

        protected virtual void OnValueChanged(OnChangedEventArgs e)
        {
            if (OnChanged != null)
                OnChanged(this, e);
        }

        public PointSelector()
        {
            InitializeComponent();
        }      

        public static BCOM.Point3d point3D { get; set; }

        private void btnPointSelector_Click(object sender, EventArgs e)
        {           
            _ustn = BCOM;
            ClsPointSelector pointSelector = new ClsPointSelector();
            _ustn.CommandState.StartLocate(pointSelector);                       
         }    
    }

    class ClsPointSelector : ILocateCommandEvents
    {    
        private ApplicationClass BCOM = new ApplicationClass();
        private Application _ustn = null;

        public void Start()
        {
            _ustn = BCOM;
            _ustn.ShowCommand("");
            _ustn.ShowPrompt("Select Data Point");
            _ustn.CommandState.SetLocateCursor();                           
        }

        public void LocateReset()
        {
            _ustn = BCOM;
            _ustn.CommandState.StartDefaultCommand();           
        }

        public void LocateFilter(Element element, ref Point3d point3D, ref bool accepted)
        {          
            accepted = true;
        }

        public void Accept(Element element, ref Point3d point3D, View view)
        {
            PointSelector.point3D = point3D;
        }

        public void LocateFailed()
        {
            // required for interface
        }

        public void Dynamics(ref Point3d point, View view, MsdDrawingMode drawMode)
        {
            // required for interface
        }

        public void Cleanup()
        {
            // required for interface
        }
    }    
}
4

0 回答 0