Use Telerik converter service through WebBrowser? - c#

I'm trying to visit the webpage http://converter.telerik.com/ using a WebBrowser control in a WinForms application but the page contains script errors.
After ScriptErrorsSuppressed to True the main controls of the webpage are unable to load at this point i'm lost about using the WebBrowser control to this task so I've search other alternatives.
I've tried with the latest build of GeckoFX (29.0.X) from here: https://bitbucket.org/geckofx/
With the GeckoWebBrowser control the Telerik page loads perfectly but after pressing the "Convert" button from my GeckoWebBrowser the second "Textbox" gets crazy and is not properly displayed, so again I'm lost but I don't know what more alternatives I have.
In the past i've tried to use some builds of chrome for .Net but I was unable to compile them.
What I need to do to use the Telerik converter service using any kind of webbrowser from my app?
PS: Dependencies are not a problem for me, I just want to develop a personal application for my only usage to load/save snippets that I converted using the Telerik service accessing to its converter webpage from my app.

Personally I would take a look at SharpDevelop's NRefactory Library and see if I could utilize this in my application instead of using someone else's webservice which more than likely uses NRefactory as it's underlying engine.
The online version of the code converter is available at http://codeconverter.sharpdevelop.net/.
https://github.com/icsharpcode/SharpDevelop/wiki/Code-Converter
https://github.com/icsharpcode/SharpDevelop/wiki/NRefactory
About NRefactory:
ICSharpCode.NRefactory is freely available as a part of SharpDevelop IDE.
It is parser library for C# and VB.
It consists of a single Abstract Syntax Tree (AST) that can represent all constructs that are available in C# or VB (unlike System.CodeDom, which only represents constructs common to C# and VB).
By using the C# parser and a VB output visitor (or vice versa), you can do a code converter.
After parsing to AST, you can analyze and/or transform the AST and re-create source code from the (modified) AST, then re-insert the comments we saved from the parser into the output
For more info about NRefactory please see: sharpdevelop.net and NRefactory wiki.
You may try samples\NRefactoryDemo in the SharpDevelop source code to take a look how the AST parse source code.
Source: http://www.codeproject.com/Articles/262950/CodeConverter

Related

Using Silverlight with HTML?

I usually C++ applications. The only web-application development I've done is writing Java Applets. There it's all pretty simple stuff. Just write the entire applet in Java, and embed it into an html page with the:
<applet></applet> or <object></object>
tag.
Now, I am trying to find my way to Silverlight. Now Visual Web-Developer Express or Visual Studio is awesome. It eases all problems, creating a new Silverlight project automatically generates an aspx website and does all the embedding & deployment.
However, I don't want to depend on the IDE. Though I use IDEs quite often, what I hate is depending on it. So my questions are,
Is it possible to write a silverlight app with a simple programmer's editor?
How do I embed my silverlight XAML code and C-Sharp compiled *.dlls in an HTML file?
Some basic tutorial or documentation for people like me who know absolutely nothing about Silverlight?
How do I embed my silverlight XAML code and C-Sharp compiled *.dlls in an HTML file?
You can add a silverlight app to a html file simply by using the <object> tag (here is an example taken from MSDN):
<object width="300" height="300"
data="data:application/x-silverlight-2,"
type="application/x-silverlight-2" >
<param name="source" value="SilverlightApplication1.xap"/>
</object>
Is it possible to write a silverlight app with a simple programmer's editor?
It is possible to write all of your code for a silverlight app using nothing but notepad, but because of the somewhat verbose nature of XAML, i think this would be a fairly tedious task. If anything, i would suggest you go in the other direction and use Expression Blend to craft your XAML and then Visual Studio for your C# needs - the two IDE's work together very effectively and allow you to easily switch from one to the other with ease.
Some basic tutorial or documentation for people like me who know absolutely nothing about Silverlight?
If your looking for good tutorials, head over to the official silverlight site where you will find lots of tutorials, videos and hands on labs to help you through the learning process.
Here are some other good resources:
There were lots of good presentations on Silverlight at MIX10
Channel9 in general has lots of good vids. This is their Silverlight section
A list of great Silverlight resources from SmashingApps
Tekpub do a free video course on Silverlight 4
The *.xap file generated from compiling a Silverlight application is simply a zip file with a different extension. You can check out the contents of a XAP file by renaming it with a ZIP extension, then browsing through it.

Display HTML in a silverlight application

I need to display HTML in my silverlight application and cannot find a way of doing it. I cannot use the web browser control as it needs to be able to run in or out of a browser.
Does anyone know of a good way to do this, because all I can think of doing at the moment is running replace methods on the text to just replace the tags with C# equivalents eg(<br /> to \n).
The way I do it is to check if the application is running inside the browser and change the means of display accordingly. If running inside the browser, I overlay the application with an IFrame, as I describe in this article: http://www.silverlightshow.net/items/Building-a-Silverlight-Line-Of-Business-Application-Part-6.aspx. Otherwise, I use the WebBrowser control. I have a control which does this all for you in the source code that accompanies my book, which is downloadable from the Apress website here: http://www.apress.com/book/downloadfile/4638.
Hope this helps...
Chris
I believe what you are looking for is HTML Bridge.
Edit I'm am actually now unsure if you'll still have access to javascript if you're running this OOB. I'm going to look into this some more and will further update. I'll still leave the answer up though for reference.
Second Edit Here is what I've found. HTML Bridge is disabled when you run silverlight out of browser. This disables access to the HTML DOM as well as Javascript. However, according to a comment on this site:
HTML Bridge is not available when you first install a OOB app. But you CAN force it if you modify the index.html in the folder where the app is installed just adding the enablehtmlaccess parameter.
It works!
You can even create dynamic HTML elements using the well-known methods of the HtmlPage class. You can even open a new browser window with the Navigate() method and its "_blank" parameter.
Keep in mind this information was posted about SL 3. Its possible that this may have changed, but I doubt it. So it seems that what you may want to do is build a script into the startup of your SL app that detects whether or not your app is running out of browser. If it is then you may want to have some script to call that can modify this file for you.
There recently was a similar question.
I posted a link there to an implementation that parses and displays HTML inline in Silverlight. Of course, it will work only with simple HTML, but maybe you can expand it to your needs.

C# autocomplete not working for Script# in visual studio

I'm using the fantastic project Script# (http://projects.nikhilk.net/ScriptSharp)
I can't seem to get the autocomplete feature in VisualStudio 2008 working
the .scriptlet files appear as plain text with no code formatting at all
the version of Script# I am using is 0.5.6
I am opening the samples project and looking at HelloWorld.scriptlet
Cheers
Sam
Yes, currently .scriptlet files don't have a custom editor, and as such are treated as regular text files.
In the next version of script#, the Scriptlet server control is going to work slightly differently. Two changes:
Its not going to support inline code. All code must be in a .scriptlet file if you want script code-behind.
The scriptlet server control will look for a .scriptlet file instead, and open it up when you choose to Edit Code from the script in design-view. At that point you'll get intellisense.
Of course over the long-term I actually want an editor experience for these. That is the desired implementation...

How do I convert a windows forms app from C# to VB?

I've been converting all kinds of other things, classes, interfaces, ASP.NET MVC apps, and WPF applications, but I am stumped as to how to convert a windows forms application, as the whole structure seems to be different. Does anyone have any advice on how to tackle this problem?
I see essentially that you have two files, Form1.cs and Form1.Designer.cs. Literally translating them from C# to VB doesn't work because of some intricacies or other of how Visual Basic works. I think you /might/ be able to convert Form1.cs in this way, as it's just a constructor plus event handlers, but the designer contains the references to the controls etc. and I am not sure how to go about doing that.
I am using Visual Studio 2010 Beta 2.
My approach would be to create a new form in VB do add some forms and add events and look at the VB generated from there you will be able to see how each element [control/event/propertyset] is done in both C# and VB. From there it should be trival to conver from c# to VB.net. This would give me more confidance the designer could cope with the converted class as well as the runtime.
What I did is to manually create a new form in VB with the same name as the form in C#, then opened the C# form in design view, made sure that I selected all controls on the form, copied and pasted them onto the empty new form in VB. Then just translated the code-behind with the telerik free converter at:converter.telerik.com. I'm sure it becomes cumbersome if you have a huge solution that you need to convert, but in my case it was a small solution and the results were great.
Redgate.NET Reflector does a great job.
The two files each contain a part of the Form1 class, in the form of partial classes. As partial classes are also supported in VB.Net, I don't see a problem here.
The designer file contains all of the code generated by the windows forms designer, the Form1.cs file is the place where all custom code goes (event handling, etc).
So after converting both files you should check if all references made to controls in the Forms1.cs file are available in the designer.cs file.

Using jQuery in WinForms desktop app?

We have a WinForms desktop application that uses the .NET 2.0 framework WebBrowser control quite extensively for displaying HTML. The HTML may be simple, or quite complicated. It may reside on disk, or it may be written directly to the document property at runtime.
I was wondering if anyone had any experience with using jQuery as a library for such desktop applications. Can i just reference the jquery.js file on disk, and use it just as if it were a web app? Are there any pitfalls that I need to be aware of?
At the end of the day, it's just HTML markup in a browser, treat it as you would if you were working with a page to be viewed in any web browser. jQuery will work just fine assuming you can reference the library from the markup. This would require injecting a script reference into the markup at runtime.
You say that the source may reside on disk or be dynamically generated, I would introduce a pre-loaded step which either loads the file from disk, or generates the markup in memory, then (using string or XML manipulation), inject the jQuery reference and any associated scripts into the markup before populating the WebBrowser document. From there, just let the WebBrowser control do its job.

Categories

Resources