简体   繁体   中英

Displaying HTML with Mono on Mac OS X

I gather from this question and others like it, as well as a thorough web search, that libgluezilla is not available for OS X so it is not possible to use the WebBrowser control.

If that is still the case, is there any other way of displaying HTML within a mono application on a Mac?

EDIT: I have tried open-webkit-sharp but get a run time error like 'cannot find file ......\\English.ini', which is odd as it exists in the place that is being searched. Following Lex Li's suggestion I tried with MonoMac, but evidently I need to do more than add in some name spaces and a couple of lines of initialisation code to get the program working as it compiles okay but does not actually open a window when run. I think that MonoMac is probably not the way I want to go anyway as it will prevent the code from being cross platform which is why I am going down the mono route.

I have implemented in my application displaying HTML using mono. I use monobjc(http://www.monobjc.net/) and mono 2.8.10. Monobjc 4.0 has webkit dlls in it. You can use it.

There are two ways -

  1. Recommended approach - Using Webkit - Examples available on monobjc site - http://www.monobjc.net/index.php?page=simplewebbrowser . If you download the project you will see the sample code.

Documentation at the site is self explanatory.

2 Not recommended - Using textView -SubClass NSTextView and hook it up with your project. Now add the following code to the Setter of your subclass . I am pasting the code that can be used with monobjc.

 NSString str = new NSString(value);

 NSData data = str.DataUsingEncoding(NSStringEncoding.NSUnicodeStringEncoding);

var attributedString1 = new NSMutableAttributedString();

NSDictionary dict;

_htmlString = attributedString1.InitWithHTMLDocumentAttributes(data, out dict).CastAs();

TextStorage.SetAttributedString(_htmlString);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM