Load Winforms GUI from server - c#

I'm looking for some techniques that allow me to create an application using winforms, the basic idea is to load the gui interface from server, whereas the other files resident in client computer.
It will be applied in LAN environment and the application GUI must be modified repeatedly
thanks in advance

What you basically do is to put the "rendering stuff" work on the server rather on client side. you could archive this using streaming protocol BUT. WHY?
First of all WinForm is the oldest and also the less efficiency way to build windows UI (WPF and UWP are made and always recommended to avoid old technologies like winform and javaswing)
Second if you want to render on the server there are better approaches and technologies to do such as (Blazor serverside, ASP.NET Razor Page, or even the old Web Form would be a better idea) through the Browser.

Related

Open windows form application from a link in locally hosted website

I have created a windows form application that is a face recogniser using EMGU CV. I also have a website which is locally hosted on my laptop, made using ASP.NET MVC4. I want a link on my website which ,upon clicking, opens the facial recognition software. Is it possible to do it? Do I have to create a setup of application and install it to do this or is there any other way?
The effort involved to do what you are asking for is almost certainly much higher than you are willing to take on. I'm only aware of two possible approaches. The first is to use the Microsoft Click-Once technology, which streams binaries through to the client. However, the binaries arrive at the client very untrusted, so you need to do quite a bit of work on the client to set up the appropriate permissions. The other approach is to associate your image recognition form with one of the safe MIME types, and then stream out a file of that MIME type. If your application is the default application for that type, it will be called to handle that file.

Windows Runtime access file from JavaScript in WebView

I am using Three.js to try and implement a cross platform 3D model viewer. At the moment I have got it working and embedded in my XAML and C# application for Win 8.1 and Windows Phone 8.1 with a WebView. At the moment I am using C# code to load models (triangle meshes) from files on the device as well as a bundled file. The problem is that this means that I have to invoke a JavaScript function from C# for every triangle that I want to add and this makes the UI unresponsive for a while. I have tried to run the script async and to run the loader async but it does not really help because the all the JS function calls need to be handled by the Core Dispatcher otherwise I get an invalid thread access exception. In the beginning I did not realize this and thought it would be simpler and of higher performance to do loading in C#. I will now probably have to redo the loader in JS...
What I need to ask now is for some information as of how I should access the files from of JavaScript. I know Windows RT supports its file access API from JS but I am guessing this is more for entire JS applications because it does not seem to work from inside the WebView*. I would also prefer something more cross platform though as this also needs to work for Windows Desktop, iOS, Android and probably Mac and Linux too, so what would be my best option for this?
*I have tried the JS at http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.pickers.fileopenpicker.aspx in my WP 8.1 application but no file selector appears. My the WebView does seem to freeze up though but I also don't get any exceptions or so popping up.
PS. I have a sort of feeling that it might come down to me having to copy files to a temp folder that JS can access. This would not be ideal as copying will waste time but if it's my only option then I will probably have to go for it. If this my only option I would appreciate some help with implementing it because JavaScript is really not my language and I'm only using it because of Three.JS...
As soon are you're using the WebView you end up in a situation where you need to post messages back and forward between your host app (the C# code, assuming you didn't rewrite it) and the website you're hosting in the WebView. The two basically function in isolation from each other.
Can you not load your geometry using the documentation of the Three.js format? It looks to be available here: https://github.com/mrdoob/three.js/wiki/JSON-Geometry-format-4
That way you can proxy the entire geometry across vs. each individual triangle.

running an application inside ASP.NET

I've written an application in C# that I would now like to host within an ASP.NET website (MVC 2).
The application can become quite resource intensive so I would like to set up the system in such a way that each user downloads the application and runs it locally, but still within the web page that I provide.
My first idea to solve this problem was to host the program within a silverlight application. However, the app I want to host was not compiled for Silverlight, and I would like to use MySQL in it, which also appears to not be possible directly (ie without a web service in between).
The bottom line is that don't have experience with these things directly yet, and I need to research the way to make any solution possible. So I would really appreciate some input to put me in the right direction, and not have to implement 3 wrong options before finding the right one. I would also really like to avoid JavaScript if at all possible.
Thanks in advance.
Update
I probably should have specified to begin with what the application is exactly.
The application as I want to host it on the website is a simple chat program. It needs an input box and text output. The old windows forms application won't have to run in ASP, but I want to use the class library behind it, which is a chatbot engine. That engine is the part that can be rather resource intensive.
So you wrote a "rich client" application and you want to serve it as a web/silverlight application. This is not possible without changing the architecture of your app, as you probably guess, expecially because you have to interface a database. If rewriting the application to support such architecture is not an option, the best in order to me is to use Remote Desktop, but you have to pay for licenses in order to support many connections.
If your application is not a web application then it will not run on the server. The only thing your server does is to provide a download location. For that, you wouldn't need a MVC site - static pages could fit. The programming model between normal applications running on the client and server applications running on IIS is completely different. So in short: you won't be able to host your client application in ASP.NET MVC. If this is a requirement you will end up rewriting the application.
If your application is ASP.NET WebForms and it becomes too resource hungry, then you probably won't solve it by just switching to MVC. You have different options then: more resources on the server side, analyzing what could be done to lower the resources required or moving away from a server based application. This is not a black/white decision, maybe a combination might fit.

HTML/CSS/JS in desktop applications

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.

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.

Categories