xamarin / urho

Code to integrate with the Urho3D engine
Other
462 stars 122 forks source link

MDI support for UrhoSharp Application #330

Open snkar opened 6 years ago

snkar commented 6 years ago

I was trying to work on an MDI WPF application which will host different models in the UrhoSurface attached to each of the loaded windows. It is not working and the behavior displayed is that the last window is the only one which displays the model while the rest of the earlier loaded windows shows an empty grid/becomes non-responsive.

I was looking at the source code and realized that it is by design that only one active UrhoApplication is allowed with only one UrhoSurface. The UrhoSurface.Show() call exits any existing application and creates a new one in the Render Thread. So the behavior is as per design.

My queries were:

  1. Is there any specific reason why the library was designed to only support one active UrhoSurface where models can be swapped but multiple UrhoSurfaces cannot exist simultaneously?

  2. Also, is there any other workaround/trick/way to have one application load multiple windows with different content loaded in different UrhoSurface controls in the loaded windows?

utekai commented 5 years ago

Look at how the WPF sample handles this. Rather simple ... once the pattern in use is understood.

That sample has all the feature samples in a menu and as you click, it paints.

https://github.com/xamarin/urho-samples/blob/b72d055a424d0e6be825c0239683c225d29ee723/FeatureSamples/WPF/MainWindow.xaml.cs#L35