how to development cesiumn in .NetFrameWork using C# (WinForm Application)

i want to use cesiumn in my winform application ,how to this? is there any web broswer control support webgl5 like chrome that i can use it in Visual Studio 2010

There’s no good solution for embedding Cesium in a .NET application at this time. I expect this to improve greatly as soon as Internet Explorer 11 supports enough WebGL for Cesium to run. At that point you’ll be able to use the standard Web Browser control. In the mean time, you’re best bet would be to look for one of the many projects that try and wrap Chrome/Firefox/WebKit in a C# API; though when I’ve looked for these in the past, I was never able to find one that was satisfactory. If you have any success, I’d be interested in hearing more about it.

thank you very much for your replay and thank you for you can understand my poor english. i install ie11, but i found that standard Web Browser control did not support webgl at this time.so i am studing WebKit now, and it works well .

在 2014年2月10日星期一UTC+8下午11时26分21秒,Matthew Amato写道:

There is a book called 3D Engine Design for Virtual Globes written by Kevin and Patrick. The demos in the book use C# and OpenGL to provide similar functionalities like Cesium. Since Kevin and Patrick are both Cesium’s developers, I think the book shares some same design concept as Cesium. It would be helpful if you want to build a cesium-like application.

Steven

在 2014年2月10日星期一UTC-8上午3时30分30秒,FKAss写道:

Hi, it's always imposible to use Cesium in a winform application?

Thanks

Cesium works great inside of a Windows Forms app with WebBrowser control; you just need to be sure to register your application as needing 3D acceleration for web pages. See this StackOverflow link for some details on that: http://stackoverflow.com/questions/25051072/ie-11-webgl-performance-slow-when-using-webbrowser-control

Just use CefSharp (https://github.com/cefsharp/CefSharp) and never have to worry about what version of Internet Explorer you’re embedding because you’ll be embedding the best WebGL-capable browser out there: Chrome

This took me only several minutes to get working (mostly fudging around with build settings to ensure CEF unmanaged dlls are properly copied)

  • Jackie

@Matthew : Thanks! I tried this soluce last week, but I made a mistake... I forgot my debug session doesn't have same name (*.exe and *.shost.exe)... So my KEY config was not working ^^

After a last graphic drivers update, this soluce work!

Inter'

Jackie, I had tried CEFSharp a while back but ran into a bunch of issues. Good to know it’s working now.

Hi Matthew

Is there an example app for getting Cesium to work in a Windows form application using the webbrowser? I have installed the node.js, but cannot work out how to visualise the Cesium engine as yet. I am using Visual Studio Community 2013 express.

Thanks.

Just to be clear, Cesium does not depend or otherwise require Node.js. We use it during internal development, but writing Cesium apps can do whatever they want.

Using Cesium in a Windows WebBrowser control is no different than using any other web content. You just need to initialize hardware accelerated browser content on application startup. I usually do this in Program.cs at the top of Main()

using (var software = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(“Software”))

using (var microsoft = software.OpenSubKey(“Microsoft”))

using (var internetExplorer = microsoft.OpenSubKey(“Internet Explorer”))

using (var main = internetExplorer.OpenSubKey(“Main”))

using (var featureControl = main.OpenSubKey(“FeatureControl”, true))

{

using (var gpu = featureControl.CreateSubKey("FEATURE_GPU_RENDERING"))

{

    gpu.SetValue(Path.GetFileName(Application.ExecutablePath), 1, Microsoft.Win32.RegistryValueKind.DWord);

}

}

To test this, you can just set the WebBrowser URL to http://cesiumjs.org/Cesium/Build/Apps/CesiumViewer/index.html and you’ll get the demo Viewer app that ships with Cesium.

One caveat is that using any WebGL content inside of a WebBrowser control requires the system have IE 11 installed on it, since that is the earliest version that supports WebGL.

Hi Matthew

Thanks so much for your quick response. I am very new to Cesium and still trying to follow exactly how it works. Normally program in VB and very little in the way of web. I do not see a control available for Cesium within Visual Studio and have simply placed a web browser, added the code you just after the static void Main() line, however know I am missing something to enable it to work.

Could you please let me know how I can get the initial project working?

Thanks.

You may also need to check “FEATURE_BROWSER_EMULATION” in the registry to enforce the use of IE11, see https://msdn.microsoft.com/en-us/library/ee330730(v=vs.85).aspx .
With all that in place you can have a browser-control on your Form that works with Cesium.

Willem

Hi Matthew and Willem

I now have the code in a VS2013 C# project and have used the Helloworld.html file as my url. How though do I incorporate the javascript 'var viewer = new Cesium.Viewer('cesiumContainer');' to active the viewer?

Thanks,

Nigel

I assume your url points to Cesium/Apps/HelloWorld.html , and the browser shows the Cesium globe.
The HelloWorld.html already has the javascript to start the viewer, that is a good starting point for your app.

Hi Willem

Thanks for your response. I did a test on the url on the form to point it to my localhost (http://localhost:8080/Apps/HelloWorld.html) page, which produced an error about the webGL of the widget. If I change the FEATURE_BROWSER_EMULATION registry, it seems that this would create the fix (I have not done this yet), however would it be better to use a browser, within Visual Studio, that is already able to handle webGL? i.e. if I give the software to someone to use, would they then need to edit their registry etc, which I would not want?

This is the code I am using to load the HelloWorld.html file:

            string curDir = "D/Visual Studio/Source/Repos/SenseIt/Cesium/Apps/HelloWorld.html";
            webBrowser1.Url = new System.Uri(curDir, System.UriKind.Absolute);

PS. I have attached the screen I get from the localhost error.

Thanks, Nigel

check out my question some threads below.
I posted there a sample code which uses Chrome and it works without any problems.

Hi

I cannot see any sample code on this group thread. Could you send the link?

Thanks.

Hi Nigel,

I think Karl refers to a post titled “How to use C# with CesiumJS to display one or many GPS points?” where he uses a Chrome browser. Simply do a search for that title.

If you use IE11 in the webform, the registry must be set correctly on the PC. This can also be done in software, see Matthew’s code of April 22 in this thread.

Willem

Hi Willem and Karl

I take it then that you have Chrome on your machine as a browser and then use that as a control on your form, loading it as a reference?

Currently I only have Firefox on the machine I am coding on.

Thanks,

Nigel