我正在学习 DirectX,但我不太了解 C++,所以我决定改用 SharpDX。但是我被困在 C++ 中的这一部分,他们使用 TypedEventHandler 中的函数地址,但我不知道如何用 C# 编写它?任何人都可以帮忙吗?
ref class App sealed : public IFrameworkView
{
public:
virtual void Initialize(CoreApplicationView^ AppView)
{
AppView->Activated += ref new TypedEventHandler
<CoreApplicationView^, IActivatedEventArgs^>(this, &App::OnActivated);
}
virtual void SetWindow(CoreWindow^ Window) {}
virtual void Load(String^ EntryPoint) {}
virtual void Run() {}
virtual void Uninitialize() {}
void OnActivated(CoreApplicationView^ CoreAppView, IActivatedEventArgs^ Args)
{
CoreWindow^ Window = CoreWindow::GetForCurrentThread();
Window->Activate();
}
};
到目前为止我的转换
internal class App : IFrameworkView
{
public void Initialize(CoreApplicationView AppView)
{
// Call OnActivated() when the Activated event is triggered
AppView.Activated += new TypedEventHandler<CoreApplicationView, IActivatedEventArgs>(this,this.OnActivated);
}
public void SetWindow(CoreWindow Window) {}
public void Load(String EntryPoint) {}
public void Run() {}
public void Uninitialize() {}
public void OnActivated(CoreApplicationView CoreAppView, IActivatedEventArgs Args)
{
CoreWindow Window = CoreWindow.GetForCurrentThread();
Window.Activate();
}
}