Scraping Data from Silverlight Control within Browser - silverlight

I have been using Excel VBA and WPF applications to scrape data from various websites, and all has gone well. But now I have run into something I cant get past.
The website is displaying its data within a Silverlight control:
<OBJECT width="100%" height=400 id=rnSilverlightGrid
data="data:application/x-oleobject;base64,QfXq3+...blah blah thousands of characters...AAAA=="
type=application/x-silverlight-2
</OBJECT>
(Left out what I thought was not helpful.)
getElementById("rnSilverlightGrid") returns nothing, but I am able to get a handle to the object with ie.document.all.tags("Object").Item(0), but have been unable to go further into the object to get data.
Can anyone tell me how now to get the data out of this Silverlight grid? This is currently coded in Excel VBA, but if necessary I can switch to WPF and use the WebBrowser control. I would rather not make the switch if avoidable (not sure how to do it there either anyways). I looked into White (seems like a dead end), and have seen other questions about this which have gone unanswered.
Thanks in advance!

Silverlight has the capability to make certain objects available to JavaScript calls so that JavaScript developers can affect the Silverlight application externally.
These are called "Scriptable Objects".
further reading: https://msdn.microsoft.com/en-us/library/cc645085(v=vs.95).aspx
My understanding is that this feature is available in SL4 and SL5.

Related

FsharpCharts for silverlight / f#

This might be a stupid question, but there are soo many combinations of approach (wpf, silverlight, winforms, html5) with incompatibility at mscorlib level, that I got completely lost.
I would like to be able to have a few windows mainly displaying realtime charts.
Probably with interaction among the windows (click in one, pop and display a new windows)
If it can be viewed on the web, perfect.
But I dont want to have to deal with another layer of nasty stuff for those features (like having to setup some "WCF" on a "IIS", kill me first)
In the end I was thinking of using FSharpChart on Silverlight.
Is that possible and/ or the best option ?
Thanks for your suggestions
update
I see that system.drawing which fsharpchart relies on is not silverlight supported..
Try Dynamic Data Display instead of FSharpChart. It runs on Silverlight: http://research.microsoft.com/en-us/um/cambridge/groups/science/tools/d3/dynamicdatadisplay.htm
It's not as F# Interactive friendly as FSharpChart, but you can easily wrap it in a handful of functions to make it more usable

Alternatives to WebBrowser control in WPF?

We are working on a WPF app with the web browser control. When the user drags the window, the web browser lags behind the window as it drags.
Does anyone know how to solve this issue? Failing that, does anyone know an alternative to the web browser control itself?
Thanks!
Yes, as long as you don't require IE specific features you can use Awesomium which basically gives the same browser engine used by Google Chrome except for everything is rendered in pure WPF. For a while it was open source but I believe it is becoming a commercial product.
I haven't heard about any Native WPF WebBrowser Control. The only options I know are based on Win32 controls which are wrapped into WPF controls in order to displayed. (See more details at http://msdn.microsoft.com/en-us/library/ms752055.aspx )
Recently I have to use the WPF wrapper for the WebBrowser control, and it's very limited regarding the options available for the developer. During my research I found that you are able to inject scripts or html content in order to modify the page behavior. Also, you can call .NET code (e.g. CSharp function from Javascript).
However tasks such as accessing the cache, modifying cookies are difficult task or changing the web browser behavior are very difficult. Here is when you will have to use DLL Imports in order to invoke unmanaged routines (see http://msdn.microsoft.com/en-us/library/aa984739(v=vs.71).aspx )
It's possible to look for an alternative WebBrowser control such as:
http://code.google.com/p/csexwb2/
http://wpfchromium.codeplex.com/
I hope this helps
You can try CefSharp.Wpf which uses Chromium as a base browser. You can find it on NuGet

Silverlight control with code hightlighting?

Is there a Silverlight control out there that will allow you to type in text and have it highlighted as code?
For example:
foreach (client in Clients)
{
client.Save();
}
would become
foreach (client in Clients)
{
client.Save();
}
I need to write a web app to screen non-programming programmers without wasting time on them one by one. I am thinking of a Silverlight app that will ask a few simple programming questions with a time limit. After the limit is up, it will send what they have via a web service.
Most of that is quite doable for me, but I would like to be able offer my candidates code highlighting. I am not up to (nor interested in) writing a Silverlight code highlighter.
Any suggestions?
Actipro Software has a syntax highlighter component for Silverlight, WPF, and Winforms:
http://www.actiprosoftware.com/
In Silverlight4 you could use the RichTextArea control.
The link below has some info on this control:
http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-richtextarea.aspx
Still in Silverlight 4 you can also use the HTML brush.
In Silverlight 3 you can also show HTML but using a third party control. The one below is free.
http://www.divelements.co.uk/silverlight/tools.aspx
There are also those articles on syntax highlighting:
http://www.sharpgis.net/post/2010/06/06/Code-Syntax-Highlighting-in-Silverlight.aspx
http://www.jeff.wilcox.name/2010/03/syntax-highlighting-text-block/
http://community.devexpress.com/blogs/theprogressbar/archive/2010/05/12/silverlight-rich-text-edit-control-custom-syntax-highlighting.aspx

Starting out Silverlight 4 design

I come from mainly a web development background (ASP.NET, ASP.NET MVC, XHTML, CSS etc) but have been tasked with creating/designing a Silverlight application. The application is utilising Bing Maps control for Silverlight, this will be contained in a user control and will be the 'main' screen in the system.
There will be numerous other user controls on the form that will be used to choose/filter/sort/order the data on the map. I think of it like Visual Studio: the Bing Maps will be like the code editor window and the other controls will be like Solutions Explorer, Find Results etc. (although a lot less of them!)
I have read up and I'm comfortable with the data side (RIA-Services) of the application. I've (kinda) got my head around databinding and using a view model to present data and keep the code behind file lite.
What I do need some help on is UI design/navigation framework, specifically 2 aspects:
How do I best implement a fluid design so that the various user controls which filter the map data can be resized/pinned/unpinned (for example, like the Solution Explorer in VS)? I made a test using a Grid with a GridSplitter control, is this the best way? Would it be best to create a Grid/Gridsplitter with Navigation Frames inside the grid to load the content?
Since I have multiple user controls that basically use the same set of data, should I set the dataContext at the highest possible level (e.g. if using a grid with multiple frames, at the Grid level?).
Any help, tips, links etc. will be very much appreciated!
Microsoft has created a great community site for helping people get started with both design and Silverlight here: http://www.microsoft.com/design/toolbox/
It may be far more than what you need for your current project, but it definitely will give you the training you need to master Design with Silverlight.

How to run Google Earth Inside a WPF Control

I’m trying to run Google earth inside WPF but I don’t know how. Basically I have managed to run Google Earth in a Windows Form Control inside a Windows Form, everything was OK.
Trying to do the same thing in WPF, well, give strange result a small Google Earth screen placed anywhere in the form an not inside the User Control I have created, and there is now way to make this Google Earth Control grow, or shrink, when I grow or shrink the WPF Form.
Any help would be appreciated, I really mean any!
If you have a Windows Forms control that already works exactly as you want, you could always use WindowsFormsHost to put that control on your WPF form. That might be the easiest thing to do... or is that what you're already doing that isn't working?
I also wrote an application that placed Google Earth inside a WinForms WebBrowserControl that was based on the more-or-less official example hosted by Google. It worked fine. I struggled to recreate the same application inside a WPF WebBrowserControl. My experience confirms what appears to be the general consensus that the WPF WebBrowserControl is harder to use because it provides less control. (e.g. With the WinForms WebBrowserControl you can use the properties to remove the scroll bar and eliminate the IE security question on startup, but with WPF WebBrowserControl you have to use kludges inside to HTML file loaded to get the same effect.) If you are following the Google GE plugin WinForms example, you have to move the JavaScript callback functions into a separate class because of WPF window cant be a parent of the .Net-COM interop between JavaScript and C#. Maybe the other artifacts you described are due to how you resolved this latter limitation. Before finding this solution, I was tempted to put the WinForms WebBrowser control inside the WPF window, but others have posted of unpleasing side-effects of doing this.

Resources