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 -
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);
Related
<--------------EDIT:-------------->
I can't use Windows.System
That assembly (and associated classes and namespaces) are for Windows Store apps only.
You cannot use them in a standard C# project.
Reference on MSDN.
Also, the first part of the question has been answered:
If it sounds simple, it is.
Process.Start("ms-settings:SomePage");
So, now the question is, how do you get that to launch inside the WPF Page/Window?
<--------------/EDIT-------------->
I am using Visual Studio 2015 to develop a WPF application. I'd prefer to use C# to launch the ms-settings:whatever page.
Ok, so I'm trying to follow the directions listed HERE on msdn.microsoft, but the assembly they reference "Windows.System" doesn't seem to exist. 0.o
"System.Windows" exists, but it doesn't contain Launcher.LaunchUriAsync...
Below is the snippet of code on that page:
using Windows.System;
...
bool result = await Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-webcam"));
So the question is, what am I missing? I'm pretty sure something is flying way over my head and I can't seem to see what is.
Bonus points if you know how to get the ms-settings app to open inside the WPF page, although I'm pretty sure that isn't reasonably feasible.
It seems that Windows treats the ms-settings:... syntax as URI. So, you should be able to open it in the default browser just as you would open any other URI from within C# code:
System.Diagnostics.Process.Start("ms-settings:privacy-webcam");
However, I'm not sure how older versions of Windows (which don't know the ms-settings:... syntax) react to that...
Damn, well I found why I can't use Windows.System
That assembly (and associated classes and namespaces) are for Windows Store apps only.
You cannot use them in a standard C# project.
Reference on MSDN.
Is there a way in VS2013 to compile a C# file without a project or solution?
This is useful, e.g. in editing some C# code quickly while preparing a Stack Overflow answer while scrubbing corporate IP from the file (without risking any harm to the "real project").
The build toolbar is grayed-out.
I know one can occasionally see squiggles for errors.
Any other simple ideas?
You can use https://dotnetfiddle.net/
You can specify different things in it. It is best for writing fast answers, also you can post link with your saved work. It is similar to jsfiddle if you aware of it.
You can use Snippet Compiler. You can download it from below URL.
http://www.sliver.com/dotnet/SnippetCompiler/
Its a stand alone light weight small application.
If you have Mono C# installed then C# REPL is awesome tool to execute small chunk of c# code.
http://www.mono-project.com/docs/tools+libraries/tools/repl/
Alright so this may be a total n00b question but I'm using the WatiN 2.1 library with Visual Studio 2013 and I'm trying to automate a mostly javascript-based webpage. I've done this task already using VBA but I wanted to redo it in C#. The webpage has multiple AND elements and some necessary fields are contained in lower levels of each. In VBA, I was able to navigate the page by simple doing something like this:
ie.Document.frames("frameID1").Document.frames("frameID2").Document.getElementByID("target").Click
This line of code would work whether frameID1 or frameID2 were frames or iframes. It didn't seem to matter to VBA. I tried a similar approach in C# using WatiN but it seems like the Frame feature in WatiN only recognizes as frame elements and simply recognizes a element as a simple HTML element.
That being said, I have read the question regarding this found here
but this is where my questoin arises. They say the solution is to alter the code for the AllFramesProcessor method and that fixes it. But how exactly do you access and modify this code? This code is contained in a .dll which I've tried to modify using .NET Reflector. I've export the source code, opened it in Visual Studio, found the code to modify and did so, but when I tried to build a new release, it threw multiple errors. Any suggestions on how to modify this block of code properly and get a version of WatiN that can handle elements?
When I open the Chrome's Task Manager, I can see something like this?
Now, programatically, is it somehow possible to target the Chrome instance that is being used to run the Flash Plug-In? Maybe using System.Diagnostics.Process class or native API calls?
I was able to do this with native api calls. My solution worked perfectly on my machine. Here is what I did:
First, get Microsoft Process Explorer. Using this tool, I was able to get the flash plugin dll's name that chrome uses which is called pepflashplayer.dll in my case.
Next, a little search on Bing got me this article. It's C code so I converted to C# and after some coding I was able to retrieve the correct Chrome process ID that uses flash plug-in.
I have uploaded my solution to SkyDrive for you to check here. Note that I am not closing any handles in my sample so you'll have to add that for a real project.
There might be better solutions out there but this one should work. Hope it helps.
Can I communicate to Google Chrome in C#?
For writing a chrome plugin for example.
<Spoilers>
Quick short answer: No, because Extensions require JSON, JavaScript, and HTML.
</Spoilers>
Hi Tony,
There are multiple templates on the internet that you can download to build a chrome extension project using Visual Studio.
Downloading one of these templates just gives you the files and folders that you need which I call "the setup".
That won't let you build a Google extension using C#.
Andrey mentioned that there are libraries like Bridge.NET that will compile your code into HTML/JavaScript. That will help you write HTML and JavaScript using C#. You still need a manifest.json file.
I don't recommend that. That library is not designed for Chrome Extensions. Also, you will have to compile the code into JavaScript and store that JavaScript code in a JavaScript file. I recommend using HTML/JavaScript with no compilers when building your Chrome Extension.
You need to keep in mind that there are 3 main parts in a chrome extension. These are:
manifest.json
A JavaScript file
HTML file
There are multiple steps and it's not hard to build a google chrome extension. This link will give you the complete tutorial on developing a chrome extension with detailed explanation. This tutorial installs a template so that you can develop it in Visual Studio just like I mentioned before.
What I have done to address is use Simple Message Host, it will trigger an executable on the local machine that you code in c#, sending stdin messages and listening to stdout messages so you can build this host to use as a bridge, but like I said, it needs to be on your local network at least, and you have to do some editing in the windows registry, so it has its limitations.
But for the system I am working with, this solution worked perfectly because I have a controlled environment that I can set up all these prerequisites.
So, just to clarify, what I did here is:
Create a chrome extension with background.js opening up the listener to the website's javascript.
Add a registry in windows registry pointing to the path of the executable.
Create the executable in C# doing all your logic.
Send a response from the executable to the extension and then back to the website.
There are several guides on how to do this, so I won't detail these steps here so I don't replicate it.
But for the moment, it is the best way to do what you want, if you have control of your environment that is.
So, if your plugin (extension or chrome app) will work on a controlled environment, this is the way to go, otherwise, I would consider something related to ClickOnce perhaps or WebAssembly but that's not fully released yet.
Chrome own extension manager supports extensions written in js and html.
that said, to execute c# code within the extension you have two options:
Compile c# code to javascript code which then can be added as a normal javascript extension to chrome (take a look at scriptsharp)
Use c# as a back-end system. just like most of download managers:
for case 2 you need a c# application installed in client device(or in the cloud) listing to a specific port (using httplistener or self hosted webapi (you can use netcore) which do these steps
Listing to incoming requests
parse request data eg. json and do something with it
return the result to javascript extension which can display it to user or do other things with it.
The topic is quite old, but I'd like to share that sample:
https://github.com/Retyped/Demos/tree/master/ChromeDemo
In a few words, the sample is implemented in C#. The Retyped.chrome NuGet package provides bindings (Chrome API) for Bridge.NET projects. So yes, now you can implement your logic in C#, then C# code will be transparently compiled into JavaScript by Bridge.NET compiler.
With that approach you can build your Chrome extension on top of .NET Framework as well as utilize thousands of JavaScript libraries.