I am trying to develop the following user control.
The user control builds with no errors. As I try to load the the toolkit in Visual Studios, I receive the Visual Studio error
Could not load file or assembly 'Bentley.Interop.MicrostationDGN'
This is because it is trying to load the Bentley.Interop
during the toolkit load. In other user controls within this toolkit, I am able to check for the Bentley.Interop
and ignore this error. However, the IlocateCommandEvents
interface as shown in the code is part ClsPointSelector
class construct. Is there a way to check for the Bentley.Interop
at this level (the development level) and still have the user control function correctly when hosted by the primary application.
The toolkit is hosted by an addin application which in turn is hosted by 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
}
}
}