Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 02, 2016, 12:11:46 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: C# Help Pls :)  (Read 2298 times)

Stephen66515

  • Animated Giffer in Chief
  • Honorary Member
  • Joined in 2010
  • **
  • Posts: 3,129
    • View Profile
    • Donate to Member
C# Help Pls :)
« on: August 05, 2011, 03:25:21 PM »
Anybody got any clue how to do the following in Visual C# 2010

When working with richTextBox I would like to be able to output a live preview into a popup form, or same-form object.

This should initially be able to handle HTML code from the 'RTB' and coded to refresh after every statement is closed (IE: <br />)

Obviously manual refresh and such buttons would be required.

The second option around this is to simply have a webBrowser object load a requested .html/.php etc. file.

To do it this way, I would be having a form open, and using onLoad I would be calling an openFileDialog so the user can select the file. 

Not asking for anybody to completely code either, just maybe a push in the right direction, or even an MSDN link :P  This is one of the major functions of the NANY project ive been working on for some time now, and would like to be able to have it come to life in time for NANY!

It would be a massive advantage if the live preview window handled mouseover events and highlighted the code in the 'RTB' for the object the user is hovered over ((IE, if a user hovers over a navigation link called 'Home' the 'RTB' window will automatically navigate to the correct segment in the code, and highlight '<a href="index.html">Home</a>')) <---- Not a massivly required function for the moment and I could probably figure this part out myself after a while!  Although, a little hint wouldnt hurt! ^_^

Thanks in advance,

Stephen

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,029
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: C# Help Pls :)
« Reply #1 on: August 05, 2011, 06:01:49 PM »
- carpe noctem

Renegade

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 13,220
  • Tell me something you don't know...
    • View Profile
    • Renegade Minds
    • Donate to Member
Re: C# Help Pls :)
« Reply #2 on: August 05, 2011, 10:21:34 PM »
I'm not sure I understand what you're trying to do...

Does this help?

http://www.codeproje...n_windows_forms.aspx

http://www.codeproje...edit/HtmlEditor.aspx

http://www.codeproje...ctrl/HtmlEditor.aspx

Checking in there, they're using the MSHTML library... Ahem... If you've ever used shdocvw.dll and MSHTML, you know it's horrible.

I've got a basic tutorial written up here for some aspects of it:

http://renegademinds...abid/82/Default.aspx

The WebBrowser control in Visual Studio is just those two ruffians wrapped up. For highly controlled situations inside of your application, they're good. However, if you actually need to do HTML that will be used outside of your application, or consume HTML from outside of your application, then you have a potential problem.

Since it's basically just IE 6, you have all kinds of baggage there. If a web page is using hacks like PIE, you could be in big trouble. The hacks that PIE uses are IE6 filters (I think they started in 5.x though, not sure), which are highly CPU intensive. If there's much going on there, then it will grind IE6 to a halt. Not good. Besides, IE6 is just plain slow anyways.

You might want to look into those links above that f0dder posted. Check out MozNet for sure. I've used the old GeckoFX control, and it's wonderful. I bought a MozNet license but haven't had time to use it quite yet. It's dirt cheap too. (I bought early, so I got a small discount, but it's still cheap.)

I checked out this quickly:

http://awesomium.com/

And it does look awesome. :)

If you can post a bit more about what you're trying to do, maybe I can help some more.

Opening and loading HTML into the browser is pretty simple though.

WebBrowser.Navigate(fullPathToHtmlFile);

For loading in memory, use wbr.DocumentText > http://stackoverflow...o-webbrowser-control

However, keep in mind that the DocumentCompleted event fires 3x per page, and isn't predictable/reliable. So you'll need to use the Navigated event, but some things will only work in DocumentCompleted... Welcome to Hell.


Does any of that help or is it relevant?




Slow Down Music - Where I commit thought crimes...

Freedom is the right to be wrong, not the right to do wrong. - John Diefenbaker

Stephen66515

  • Animated Giffer in Chief
  • Honorary Member
  • Joined in 2010
  • **
  • Posts: 3,129
    • View Profile
    • Donate to Member
Re: C# Help Pls :)
« Reply #3 on: August 06, 2011, 08:47:15 AM »
Quote
If you can post a bit more about what you're trying to do, maybe I can help some more.

It just basically needs to be a live preview of code written in a richTextBox

Quote
WebBrowser.Navigate(fullPathToHtmlFile);

I understand this part as that very basic but what it needs to do is navigate to the loaded HTML file selected from a openFileDialog so I figured the code would be more along the lines of:

webBrowser1.Navigate(selectedFile);


Quote
Two relevant SO questions:

Cant check links right now, but will look ASAP! Thanks

Quote
Check out MozNet for sure. I've used the old GeckoFX control, and it's wonderful. I bought a MozNet license but haven't had time to use it quite yet. It's dirt cheap too. (I bought early, so I got a small discount, but it's still cheap.)

Im not dead set on using the standard IE engine that comes with visual c# but im somewhat stuck with it right now as im using a machine with no internet connection, so figured I would try at least get the basic functions down.

In the project im doing, im using Syntax Highlighting, (Smart)AutoCompletion and a selection of other features that I feel will make it run a lot better and be a lot more usefull in the future.

Im also sort of re-inventing the wheel with the project in itself as theres no real shortage of software to do some of the things im adding into mine, but I have yet to find one that actually offers them all in one simple window, without having to download 6 seperate suites to do it!  Its an adaptation of several earlier projects of mine that I was using as a starting point to learn about the things I needed for this.  Still want to bang my face on the desk  :wallbash: when implementing (Smart)AutoComplete but its getting there.


Renegade

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 13,220
  • Tell me something you don't know...
    • View Profile
    • Renegade Minds
    • Donate to Member
Re: C# Help Pls :)
« Reply #4 on: August 06, 2011, 11:16:55 AM »
Quote
webBrowser1.Navigate(selectedFile);

webBrowser1.Navigate(openFileBrowser1.FileName);

Is that what you need?

For live updates, you can use the change events... but it might get ugly. Especially with the IE engine. It's just slow.

Do you really need a live update? You might want to go the MSHTML route then as you can set it to edit mode and do LIVE edits right in the browser. There's code out there to show you how to do it. Search for "html editor mshtml" and you should find something that does something like what you're looking for, if not exactly.

Slow Down Music - Where I commit thought crimes...

Freedom is the right to be wrong, not the right to do wrong. - John Diefenbaker

Stephen66515

  • Animated Giffer in Chief
  • Honorary Member
  • Joined in 2010
  • **
  • Posts: 3,129
    • View Profile
    • Donate to Member
Re: C# Help Pls :)
« Reply #5 on: August 19, 2011, 09:57:48 AM »
Cheers for the help guys.  For the moment, I have put this project on hold as I am somewhat in-love with the new CryENGINE SDK and wanna learn more about it!

Renegade

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 13,220
  • Tell me something you don't know...
    • View Profile
    • Renegade Minds
    • Donate to Member
Re: C# Help Pls :)
« Reply #6 on: August 19, 2011, 10:30:17 AM »
Cheers for the help guys.  For the moment, I have put this project on hold as I am somewhat in-love with the new CryENGINE SDK and wanna learn more about it!

Make sure to post about it! Are you using C# with it?
Slow Down Music - Where I commit thought crimes...

Freedom is the right to be wrong, not the right to do wrong. - John Diefenbaker

Stephen66515

  • Animated Giffer in Chief
  • Honorary Member
  • Joined in 2010
  • **
  • Posts: 3,129
    • View Profile
    • Donate to Member
Re: C# Help Pls :)
« Reply #7 on: August 19, 2011, 11:47:39 AM »
I havn't got around to the scripting part, but I think its C++.

Theres already a post about it :)

http://www.donationc....msg258744#msg258744