There is an open source windows form client for Xibo that contains embedded web browsers. The problem is that while one web browser is getting busy, the other browsers and controls in the form can't respond and they actually pause. So I thought maybe it is a good idea to have one thread for each web browser with it's own application message loop. But it seems unsafe to add controllers created in different threads to a single form. In fact I was lucky to have some browsers in different threads by a few lines of code refactor before I realized it actually should not work at all!
Is it a good way to make it possible? What is the best solution to make such an application multithreaded with minimum coding?
I am designing an app which basically is going to check for new data, my initial thought for this is to use a windows service. If i get any new data i need to display a winforms app which i'll populate with this data so that the user can acknowledge it.
I know there are restrictions running UI apps from a service so i'm just wondering what others believe is the best approach for both. Also i need to run this on XP
The timer that gets the data
how to launch the WinForms App
As im writing this i've also been toying with the idea of using a console app but nothing seems to be fitting together in terms of functionality.
You can use a regular Winforms app. As soon as the application loads, hide the entry form from within the Form_Load method, this will keep the form hidden from the user. Keep a timer on the entry form that frequently checks for relevant data and pops up windows as and when required.
I have a WPF browser application that collects user data and adds it to a database to tell them when their software is out of date.
All of that works fine, but the problem is when the application finishes its stuff, I want the web page itself to change (i.e., detect the web app has hit a 'finished' state, then autonagivate to a results page or something).
I can't think of a way to accomplish this, since the web app itself doesn't seem to be able to change the IFRAME it's contained in, much less the page outside of that, or signal to javascript or anything.
Any ideas?
I'd make an variable to keep progress/step of work. And a timer which would check if progress=="done" or sth.
Maybe this is not the best way of solving this but I don't know WPF much and that solution first came to mind
I've read tons of other questions and googled the issue, but I can only figure out how to do it if I'm using winforms. I'm currently writing a library, and one of the functions of the library is to handle logging. One of the features I'm implementing for it is to automatically take a screenshot of the page before writing the issue to the log. The issue with this is that I don't know which monitor to take a screenshot of, so if the user moves the browser to a different monitor, I still take a shot of the Primary one.
public static Bitmap ScreenShot(string saveLocation, string fileName)
{
Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics.FromImage(bitmap).CopyFromScreen(0, 0, 0, 0, bitmap.Size);
string savePath = Path.Combine(Path.GetDirectoryName(saveLocation), "ScreenShots");
if (!Directory.Exists(savePath))
Directory.CreateDirectory(savePath);
bitmap.Save(Path.Combine(savePath, fileName), ImageFormat.Png);
return bitmap;
}
I've tried Screen.FromControl(), but since it's not a winforms application, I don't have any System.Windows.Forms.Controls for it to find.
Does ASP.NET have any equivalent? Or something I can explicitly cast to a winform control?
This just won't work. Your c# code is running on the web server, not on the user's web browser and not on their computer. The only monitors that code will have access to are the monitor attached to your web server.
This probably appears to work on your development platform, but only because there your web server and your client machine are the same machine.
The best you can hope for is to include a flash or silverlight object on the page that can take the capture, and even that probably won't work.
Surely any code you're running here will be running on the server so will have no idea where its being displayed
In theory you could use JS to capture the DOM and then send it back to the service via an Ajax call - that's the closest you'll get I would think
You're trying to take a screenshot of the client's screen from an ASP.NET application? That isn't possible. You may be able to log the entire request including the HTML then re-render it somewhere else, but you can't have that kind of interaction with the client from a server-side application framework.
if the user moves the browser to a different monitor, I still take a shot of the Primary one
ASP.NET runs on the server, so writing server code to screen capture the browser is meaningless. You may have better luck using client-side code (javascript) to take a screenshot.
This thread uses an ActiveX solution:
Take a screenshot of a webpage with JavaScript?
ASP.Net WebForms do not work as you might be thinking they do. The short answer is no, you cannot do this in ASP.Net. There is no equivalent.
WinForms are displayed by interacting with the Windows operating system and are shown on the same computer's desktop. WebForms are displayed by generating HTML and sending the HTML to another computer's browser. Your ASP.Net code is not running on the other computer's browser. If your code is attempting to take a screen shot, then at-best, you will get the server's (or your computer's) display.
You can run code on the browser using JavaScript - but you still shouldn't be taking screen shots (and I don't think JavaScript will let you - at least not automatically). For one, you will be including other information from their screen which may not be related.
When ASP.Net encounters a problem, it will log the details in the Windows log on the server and also (with less detail) in the IIS log files. Consider emailing yourself an alert when an error is encountered and looking in the logs to see what went wrong.
I would steal the algorithm currently used by google+. I definitely do not have the exact algorithm, or even one that is close to the actual thing, but I think this is what it's doing:
user clicks on 'log/report error'
server renders the current page using the position of the scroll bar and the size of the window (accessible through JS).
server renders a div covering the entire window and places the image inside of it. This div has the highest z-index.
when the user clicks on the div, a new div is generated that allows the user to "highlight" selected areas. The user is then allowed to attach a comment to this selected area.
It's genius in execution.
The only possiblity I can think of is something client-side that asks the browser to take a screenshot and then upload it. FogBugz does something like this with its new-case tool but that's an add-in your users would have to download and install.
I did this for a bug tracking app a long time ago using an ActiveX control written in --gasp-- Visual Basic. Something like that (other than the cool Google+ trick mentioned) is about your only choice.
Hi
I would like to create a script which loads a program on my windows based computer, clicks on one of its buttons, and checks the data inside it (it gets its data from the web). Should I do that in C#? Any example out there?
The program contacts the web and displays information. I would like to get notified when that data has changed.
UPDATE: I've learned that the application doesn't contact a web-service using Charles. This means I have to load the windows application, click the button and look there. How can I do such a thing? I know it is disruptive, and still I would like to do that.
You need to download Wireshark to see what http(s) the program is using.
And once you come to know about http(s) used, you can use the WebRequest and WebResponse classes for making request to the server.
The method you described in checking for changes is quite disruptive: the script you intend to write needs to load the program and clicks the button. The loading and clicking is enough to disrupt whatever you are doing when the script runs.
I suggest changing the method to access the web directly to check for changes, and only displays a notification (WPF or whatever method you are comfortable with) when the data changes.