I'm learning DirectX but I don't know C++ very well so I decided to use SharpDX instead. But I'm stuck on this part in C++ they use the address of a function in the TypedEventHandler, but I don't know how to write that in C#? Can anyone help?
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();
}
};
My conversion so far
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();
}
}
ref new
? That's not legal. The rest of your code is C++/CLI, not standard C++. C++/CLI should be very straightforward to translate into C#.gcnew
. Is thisC++/CX
?