背景是Microsoft NAV 2013 R2允许您使用C#或JavaScript为此软件创建加载项。 C#应该只在Windows客户端工作,javascript加载项应该在两种环境中都有效。
现实情况是,javascript在Windows客户端中的样式很糟糕,因为Windows客户端是用本机代码编写的,并使用在本机代码中编写的某种元素定位代码。 javascript加载项在IE中加载,嵌入到本机窗口窗口中。那么本机代码的作用是什么 - 布局和样式只有IE框架,但不是内部的 - 这取决于个别开发人员。
我认为应该可以在-c#和javascript中实现加载项C#接口,并且当用户使用浏览器时以某种方式加载仅javascript代码,但那是另一天。
现在我想问你(因为我对C#几乎没有经验)如何在C#中实现界面?
我使用这些样本作为例子: For the Javascript add-in和 For the C# add-in
这是我写过的代码:
namespace HelloWorld
{
[ControlAddInExport("Microsoft.Dynamics.Nav.Client.HelloWorld")]
public interface HelloWorld : IControlAddIn
{
[ApplicationVisible]
event MethodInvoker AddInReady;
[ApplicationVisible]
event MethodInvoker onPush;
[ApplicationVisible]
void setButtonImage(string dataUri);
[ApplicationVisible]
void setLabel(string label);
bool AllowCaptionControl();
}
[ControlAddInExport("Microsoft.Dynamics.Nav.Client.Helloworld")]
public class HelloWorldClass : HelloWorld
{
private UserControl1 myUserControl;
private ElementHost presenceHost;
public override bool AllowCaptionControl
{
get
{
return true;
}
}
protected override Control CreateControl()
{
this.myUserControl = new UserControl1();
this.presenceHost = new ElementHost
{
Child = this.myUserControl,
AutoSize = true,
};
this.presenceHost.EnabledChanged += delegate { this.myUserControl.CanEnable = this.presenceHost.Enabled; };
this.presenceHost.ParentChanged += delegate
{
if (HelloWorld.AddInReady != null)
{
HelloWorld.AddInReady();
}
};
return this.presenceHost;
}
}
}
visual studio编译器抛出了这个:
Error 1 'HelloWorld.HelloWorldClass' does not implement interface member 'Microsoft.Dynamics.Framework.UI.Extensibility.IControlAddIn.Initialize(Microsoft.Dynamics.Framework.UI.Extensibility.IControlAddInSite)'
Error 2 'HelloWorld.HelloWorldClass' does not implement interface member 'HelloWorld.HelloWorld.AllowCaptionControl()'
Error 3 'HelloWorld.HelloWorldClass' does not implement interface member 'HelloWorld.HelloWorld.setLabel(string)'
Error 4 'HelloWorld.HelloWorldClass' does not implement interface member 'HelloWorld.HelloWorld.setButtonImage(string)'
Error 5 'HelloWorld.HelloWorldClass' does not implement interface member 'HelloWorld.HelloWorld.onPush'
Error 6 'HelloWorld.HelloWorldClass' does not implement interface member 'HelloWorld.HelloWorld.AddInReady'
Error 7 'HelloWorld.HelloWorldClass.AllowCaptionControl': no suitable method found to override
Error 8 'HelloWorld.HelloWorldClass.CreateControl()': no suitable method found to override
Error 9 The event 'HelloWorld.HelloWorld.AddInReady' can only appear on the left hand side of += or -= (except when used from within the type 'HelloWorld.HelloWorld')
Error 10 The event 'HelloWorld.HelloWorld.AddInReady' can only appear on the left hand side of += or -= (except when used from within the type 'HelloWorld.HelloWorld')
我正在做什么(尝试用类实现HelloWorld接口)是愚蠢的,不可能的还是什么?
怎么做?
谢谢!
答案 0 :(得分:0)
点击 HelloWorld
public class HelloWorldClass : HelloWorld
将鼠标悬停在“ HelloWorld ”下显示的小蓝条上。
单击向下箭头并选择显式或标准实施。