tags:

views:

93

answers:

3

I have a problem I am trying to solve in an elegant manner. I have a .net application that I have created. I am trying to get one of the forms to be shown from a webpage. This sounds strange I'll admit, so here is the backstory

We have some large monitors at work, that show information on them. I have no control over how the information is displayed. Currently they are just using a browser and tabbing in the browser to show each different piece of information on the screen. Most of the info they show is just standard html stuff, text and images.

Now along comes my winforms application. The part of the application I need to show is a graphical display. Everything on this display is drawn using GDI+, if that matters. I need to get this form into a format that I can show. Below is my own solution, but I am pretty sure this is not the best method, but it may be the only method I can use

Create a console application. The application would do the following 1. Run as a service on a server 2. Create the display in memory, and save it to a bitmap every so ofter 3. Save the bitmap to a location on the network. 4. have an HTML file that links the image that can be shown in the browser

I though about doing something with the clients, however the clients are not always up, so I could have periods where the image wouldnt be updated. I also was thinking about an ASP.net solution, but that would require me to learn ASP.net, and I am not quite ready to take that challenge

+1  A: 

In IE you can host a winforms app/control as an ActiveX control, like so:

<object id="DateTimePicker" height="31" width="177" 
  classid="bin/Web.Controls.DateTime.dll#Web.Controls.DateTime.DateTimePicker" VIEWASTEXT>
</object>

See this article for more information: http://www.codeproject.com/KB/miscctrl/htmlwincontrol.aspx

Now, I'm not claiming that this is any more elegant than your solution, but it is an alternative.

I think using Asp.Net to serve a dynamic image using a HttpHandler would be the best approach, but depending on your skills and time this may not be an option. Here is a nice tutorial: http://www.codeguru.com/columns/dotnet/article.php/c11013

Ryan Cook
A: 

IMHO The best way to build this would be as a browser plug-in, like how Flash works. Microsoft has created a plug-in framework called SpicIE, that allows you develop managed plug-ins for IE. This is probably your best bet.

The old unmanaged way is to build out your WinForms dll app and then package it in a signed cab file, and then reference that cab file with an HTML object tag (codebase arg is the one you need).

i.e.,

document.write("<object CLASSID='clsid:DC187740-46A9-11D5-A815-00B0D0428C0C' CODEBASE='/MyFormsApp/MyFormsApp.cab#Version=1,00,0000' />");

The first time the user hits the page they will be asked to allow for the installer to load its payload (dll's). Once they do, they will have a fully fledged WinForms desktop APP running through a browser window.

James
A: 

I took the easy route on this one. I created a small winform app, that coverts the GDI objects to a bitmap, and then I save the bitmap to a network share. This file is refenced in a simple HTML file that is displayed on the monitor.

I chose the winform app, because it makes it really easy for me to set this up in task manager, and run it every 10 minutes to update.

Aaron M