HTML/CSS/JS in desktop applications - c#

I've read about XSS vulnerability in desktop applications like Skype and ICQ.
I wonder why they choose to use html in this kind of applications that can also be written without any html. Is there a simple reason?
Does someone know if Skype uses html on pages like "Skype Home" only or is the whole GUI written in html?
I'm asking because I'm writing a web application that runs within the browser and will be ported to mobile and desktop platforms once finished. You can compare it to instant messengers but it's something different in fact.
I thought about using PhoneGap to simply "copy" the project to mobile platforms and using system functions via the PhoneGap API. But I think it may be slow and/or not good-looking. Also it wouldn't look native, the question then is whether too use our own html GUI on all platforms (so it looks the same everywhere) or to adapt the design concepts of each platform (using native controls in native languages or e.g. Titanium (which is unfortunately too expensive)).
But I never thought about using HTML in desktop applications. How do you embed that anyway? I'm using C#. Using WebBrowser form element or using some kind of web browser rendering engine?

To answer the initial question (in your 1st paragraph):
I assume they chose to wrote it using HTML as a way to make it cross-platform more easily.

You can't make desktop applications using purely HTML/CSS/JS and have them looking native. However you can use Sencha Touch to make your Phonegap applications look native (to an extent).

Mozilla Prism was written with this idea in mind: http://prism.mozillalabs.com/

Have you tried Appcelerator Titanium Desktop/Mobile. They have a similar idea there - http://www.appcelerator.com/
Thanks.

You can use the WebBrowser control to basically host an internet explorer session in your windows application. This is platform specific, but there is a commercial version which is available for some smartphones: http://en.wikipedia.org/wiki/Mono_(software)#MonoTouch_and_Mono_for_Android.
You can make an HTML5 application which will give you a lot of the benefits of a fat client while maximizing portability with smartphones. You can still have the user save the application to the desktop: http://miniapps.co.uk/installation/. But, that's clunky and, like the desbest said, it will run in a web browser. If you want to maximize the customization, then it looks like PhoneGap is an choice worth taking a look at to me as well.

Related

Cross platform desktop development with HTML5 GUI

Short story: is there a way to write a desktop application with a GUI in HTML5 and core in a cross-platform language like python (or even C#/Mono)?
Longer story: I'm a C# developer, for small personal projects I seldom do, running both under Windows and OSX, I use C# (Mono) with a frontend leveraging on Eto.Forms
I'd like to understand if there's a mature way to achieve the same results using an HTML5 GUI, since I'd like to learn that and believe it could be a good option for near-future Windows desktop UIs (or otherwise a nice tool to have in my skillset). Of course if the code running behind the scenes is C# I'll be more than happy, but also getting my feet wet in another, maybe more cross-platform like python would be good.
At this stage I'm not interested in any mobile-oriented solution.
Electron (formerly Atom shell) has really matured as of late. In fact it's what VSCode is built on.
There's a great tutorial and starter code on using Angular 2 and Typescript, and you can even use VSCode to write and build it.
For me this is the best way to transition from the WPF world to HTML5.
the NW.js look pretty promising... you might even be able to use TypeScript which would be much closer to C# than plain ol' js. If you're open to using PHP, you can check out the nightrain project https://github.com/naetech/nightrain.
Give http://www.tidesdk.org/ a try.
Your app will run on Windows 8, MacOS and Linux. You can use HTML5, Javascript and CSS3.
But you can also extend the functionality of your app with a scripting language you are comfortable with. TideSDK currently supports Python, PHP, and Ruby.
I have recently worked with Chromium Embedded Framework, basically a browser component for WPF an WinForms. It works very well and provides kind of a two-way interoperability from website to .NET-app and vice versa. Basically, you:
Create a WPF desktop app
Include CEFSharp and place a full-screen browser on the window
Call methods in JavaScript:
// .NET
var mainFrame = browser.GetMainFrame();
mainFrame.ExecuteJavaScriptAsync("any js code");
Bind a .NET-object
// .NET
browser.RegisterJsObject("boundObject", this);
Call methods on a bound .NET-object from the website/JS:
// JS
boundObject.someMethod();
On this basis you could build a mediation layer (ViewModels, controllers, ...) between HTML/JS-UI and .NET logic...
I wrote an APP with http://kivy.org/ it is capable to create apps for different systems.
Qt node https://github.com/arturadib/node-qt seems also interesting, but i did not test it myself.
And last https://chrome.google.com/webstore/launcher
You can create web apps for chrome, which should run in supported systems.
Kivy is a Python solution. Qt node is maybe what you are looking for.
Here are some nice tutorials for kivy:
https://www.youtube.com/playlist?list=PLQVvvaa0QuDe_l6XiJ40yGTEqIKugAdTy
NW.js
But it's Javascript (node), not python nor C#.
A very interesting project I think is Chromium Embedded Framework. You basically embed a (stripped down) web browser in your application. For python, many GUI Toolkits are supported. Check this for more information.
Since you are used to C#, maybe Java with JavaFX and FXML is an option. FXML is not HTML but you can style it with CSS as well. You can also use Scene Builder with it for faster UI creation. Many JVM languages support this toolkit so Jython instead of Java will also work. I will recommend Java however, because the support for other languages, while there, is not perfect yet.
Using C# and the Windows App Store WebView is also an option. You can check MSDN for more information.
I am sure there are other options (Kivy, Node.js, etc.) as well. Some of them are already mentioned in this thread.
I would recommend Node-Webkit which is based on nodejs.You can still use some python scripts to do some backend job integrated with Node-Webkit which is easy to deal with.I've already saw some successful applications using this(like wunderlist).TideSDK is another choice but the python support in TideSDK is not mature enough.The Node-Webkit project hosted at
https://github.com/nwjs/nw.js/

What engine to use for creating .net 2 c# application based on HTML layout?

I'm browsing the net now for days, but still couldn't find what I'm looking for. Basically I'd like to develop my application interface, the GUI using HTML and CSS, with of course keeping the events, and the chance to modify parts of the layout at runtime (like a content of a div). The application is a database manager displaying visually the datas, and updating them at runtime.
IE aka using System.Windows.Forms.WebBrowser, this is what I try to avoid, it depends on the client system, stops at version 7, hard to link with the application
HTMLayout - http://www.terrainformatica.com/htmlayout/ : seems interesting, but the .net c# part, the nabu-library is dead
Sciter - http://www.terrainformatica.com/sciter/ : from the same group as HTMLayout, but couldn't really understand the integration, and I'm not sure if this is what I want - also couldn't find .net c# infos
Awesomium - http://awesomium.com/ : which really seems nice at first, but it needs .net 4 , and we have to stay at .net 2 - also it seems too much to handle, to use, and .net wiki is a little weak: http://wiki.awesomium.net/
and finally Gecko http://code.google.com/p/geckofx/ and Webkit http://code.google.com/p/open-webkit-sharp/ - but currently I'm not sure that they can be used to render the whole application, they just seem to be a WebBrowser with another engine.
Did I miss something?
Sciter integration principles are outlined here and here.
Sciter and HTMLayout both use the same integration principles and API architecture.
As of .NET wrapper, check these projects:
https://github.com/midiway/SciterSharp
https://code.google.com/p/expemerent/
Not sure if this fits your requirements but I currently use Webkit.NET http://webkitdotnet.sourceforge.net/
Essentially I use its Webkit Browser Control for the interface, store the HTML/CSS markup as variables and then I use C# to perform server-side logic, then output the results to the Browser Control (C# in this case acting in place of PHP since I am not including a portable web server with my application).
I did want to update it to achieve some newer functionality/standards so this article was most helpful.
http://peterdn.com/post/(First!)-Using-WebKit-nightly-builds-with-WebKit-NET.aspx

Can an exe compiled from C# be integrated into a website?

I'm a beginner in programming. I've just made a program called "Guessing Game". And it seems to work fine. Can I integrate it into a website? The CMS that I'm using is Mambo.
===
additional info's
Thanks for all your suggestions.
I still don't have any background about Silverlight, WPF and Java Script which I think sounds good. I'm using Windows and I programmed my "Guessing Game" from Microsoft Visual Studio 2008 and it's using Window application forms.
Yes I guess, for the moment I let it be and start to learn Silverlight or Java Script so that I can integrate it on my website:-)
Thanks for all your input guys:-)
Cheers
A standalone executable cannot be directly integrated into a website. You have a few choices though:
Allow your users to download the executable and run it locally for themselves
Rewrite your program in JavaScript to have it run directly inside of an HTML page, though this could obviously involve a fair amount of reworking
Use Microsoft's Silverlight technology, which allows you to code in C# and produce a web-based frontend similar to Adobe Flash. Your program logic should remain the same and you should only have to change the UI code. In fact if you're already using WPF for the front end, the transition will be even easier.
There are several questions that you still need to answer.
What is your server running? If its not Windows, your exe will not run at all unless it is compatible with Mono or a similar framework for your server's operating system.
How does your "Guessing game" interact with the user? If it is through a WinForms GUI, it will you will not be able to use that GUI on the web. If your game is a WPF application your easiest route may be to port it to Silverlight and serve it up on a web page.
It is typically not trivial to make a regular windows application run in a web environment since on on the web you are really running in the browser, not on Windows.
Yes - in general, when you're talking about software, anything is possible. The question is, how difficult will it be?
To understand that, you have to give us more details about "Guessing Game" including how it is designed, what it's interfaces are, how readily extensible it is, and how prepared you are to change or extend it.
For example, if it is a Windows Forms GUI app, then it will be diifficult to integrate into a web app. If it is a console app, then it will be a little easier. If you can modify it to run as a Windows Service, then a little easier. If you can modify it to accept input from the network (as opposed to getting input solely from the keyboard + mouse), still easier.
You may be able to use reflection to load your assembly into the web application, but most likely, the answer is no.
Your best solution is probably to re-write the game in javascript.
The short answer to your question is now. I'm presuming that since you're running Mambo you're web environment is a LAMP stack. However, you're "Guessing Game" is most likely a Windows application from the sound of it. For a beginner in programming, there is no integration path you're going to be able to take that will allow you to have your game running on your website.
However, here are avenues you can take, which will require a significant amount of time to learn. I'm not saying you shouldn't take time to learn, by all means you should! I'm simply trying to illustrate the fact that this is not something that is going to be doable in a couple of hours.
Silverlight - allows you to run C# code with a WPF like interface on your client's browser and can integrate with your web site through javascript.
Let your client download it from your website and run it off of their PC. This would actually be fairly trivial and would be your quickest option, but it sounds like it's not the kind of integration you were looking for.

WPF in a browser and printing

Can WPF be hosted in a web browser? If so how? (I think it can as I have seen some examples of it.)
While hosted in the web browser what printing support does it have?
What are the drawbacks to using WPF in a browser?
My company is looking for a rich web app platform. They will not choose Silverlight because it ignores any printing needs (at least as far as I understand). Right now a solution from Adobe is in the lead because it supports printing.
Most (if not all) of the apps written for browsers will be used internally by my company (ie we control the computers and browsers). (We want to use browsers for easy of deployment.)
Have you checked out XBAP (Xaml Browser APplications)?
The major drawbacks I am aware of concern security. When some coworkers of mine were developing an XBAP product, they often ran into problems with security, as the XBAP model is pretty strict.
I can't answer about printing, but I'd tend to think that might be a problem with the security considerations.
Hope I was able to help.
If the apps are solely internal and you control the target platform; and the reason for choosing to host your apps in the browser is 'ease of deployment', I would seriously consider writing Full Trust applications in WPF, and deploying them with ClickOnce... Your users would simply have a shortcut on their desktops that would check a server to see if their version of the app is current, and download the newest version if not.
You get all the benefits of the full WPF platform (greater feature-set than Silverlight), and do not need to conform to the Partial-Trust restrictions of XBAP (although you will need to configure the ClickOnce server to allow for Trusted Application Deployment)
No. That's what Silverlight is for right now and yes there are printing limitations. However, printing anything using a web app is not straight forward.
I would suggest Silverlight/Flex solution for web based app and for printing need the best way to do is use iTextSharp library and generate PDF for your reports or printing need, which can be fetched from a URL. PDF is a very standard and adobe reader will always print it right, printing will not be a problem, we went through lot of options and it requires reinventing wheel where else generating PDF through iTextSharp is very easy as creating normal html in javascript way.

Is there any better web browser control in C# (.NET)?

I need JavaScript working almost perfectly in my application that should be able to access web content and let user take a control of it. However, webbrowser component pops new windows in separate instance / application of Internet Explorer and dotBrowser doesn't work with JavaScript properly.
Please, give me some advice - I'd even take some working example and enhance it with function I need it for.
Give a look to GeckoFX, is on open-source component for embedding the Mozilla Gecko (Firefox) in .NET applications.
I could be mistaken, but I believe new windows can be controlled (or at least suppressed) using the Web Browser control in .NET. Have a look at the NewWindow event.
I have had experience embedding both WebKit (Apple Core, used in Chrome) and XULRunner (Gecko) cores in .NET winforms applications. Let me give you some advice:
GeckoFX is your best bet. It is licensed under MPL and it works pretty much out of the box.
Follow the instructions carefully and pull the exact XUL version that is indicated. I would say it works better than the WebBrowser control. There is some talk of a significant delay when loading XUL for the first time but I've found it to be negligible. Branding and the like is fully customizable via external files.
WebKit is embeddable with SwiftDotNet. If all you need is solid javascript performance then this may be an option. If you need to be able to download files, then you have some work cut out for you.
Your downside with both routes is a nasty ~7-8mb overhead, even with compression (although I was able to get 6.5mb with lz compression in NSIS). If you are not creating distributable consumer-facing software then this may not be a problem for you.

Categories