GeckoFx version 22 GeckoWebBrowser.DrawToBitmap in windows 7 64bit Environment - geckofx

I am a developers from China, when I use GeckoFx, I encountered a problem.
I use GeckoFx version 22, when I use GeckoWebBrowser.DrawToBitmap method in Windows 7 64 bit environment, I can not get the snapshot,on get a gray box. If I use the normal WinForm control, there is no problem.

Hopefully someone will give you an answer for GeckoFX 22. There are two issues related to capturing images at the bitbucket site. Neither were resolved. It's possible that it just didn't work.
In case it is helpful, here's how we do it using GeckoFX 29:
private Image CreateImage(GeckoWebBrowser browser)
{
var creator = new ImageCreator(browser);
byte[] imageBytes = creator.CanvasGetPngImage((uint)browser.Width, (uint)browser.Height);
using (var stream = new MemoryStream(imageBytes))
{
return Image.FromStream(stream);
}
}
Looking at the source of ImageCreator class , I see there are now calls that would be simpler, like
ImageCreator.CapturePng(browser);

Related

Can we get fluid design with Xamarin.Forms for UWP?

Can we get the fluid design in Windows 10 UWP app with Xamarin.Forms?
https://learn.microsoft.com/en-us/windows/uwp/style/acrylic
Jason is technically right since the feature isn't publically released yet. However, you should be able to try it already if you're in the Windows Insider Preview program. This is what you need:
Latest version of Visual Studio (2017, 15.3)
Latest Windows 10 Insider Preview SDK (probably 16267)
Latest version of the .NET UWP NuGet Package
You can check that you have the correct version if Windows.UI.Xaml.Media.AcrylicBrush is accessible.
Using with Xamarin.Forms: I haven't tried this myself but technically it should be possible. You'll need to roll out a custom renderer for the UWP platform where you define the Acrylic brush and add it to a control (Grid in this example). You also need to make sure to check that the XamlCompositionBrushBase is present and have a fallback for the case where it's not.
if(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.XamlCompositionBrushBase"))
{
Windows.UI.Xaml.Media.AcrylicBrush myBrush = new
Windows.UI.Xaml.Media.AcrylicBrush();
myBrush.BackgroundSource =
Windows.UI.Xaml.Media.AcrylicBackgroundSource.HostBackdrop;
myBrush.TintColor = Color.FromArgb(255, 202, 24, 37);
myBrush.FallbackColor = Color.FromArgb(255, 202, 24, 37);
myBrush.TintOpacity = 0.6;
grid.Fill = myBrush;
}
else
{
SolidColorBrush myBrush = new SolidColorBrush(Color.FromArgb(255, 202, 24, 37));
grid.Fill = myBrush;
}
This code is taken straight from the article you linked to but it should work as is in the custom renderer.
Please notice, that even if you get it to work, there might be major changes to the API and you'll have to rework your solution again and again.

Cordova AngularJS Windows 8 App Fails on ui-bootstrap Templates with "directive must have exactly one root element"

I am using Cordova 4.0.0 with AngularJS 1.2.26, Angular-Bootstrap 0.11.2, and UI Router 0.2.11 to create apps for Android and Windows (8.0 and 8.1). I am having an issue only when running the application in Windows with ui-bootstrap templates. The same error keeps popping up for standard templates for typeahead, datepicker, and the modal dialog, "Template for directive { whatever } must have exactly one root element."
Looking at the DOM inspector within Visual Studio, it seems that every node that has the ui-view directive is getting populated with its own set of head and body tags (which wraps around the template in question). I'm guessing that this is the issue, but am having trouble pinning down where these extra nodes are being inserted, and thus, having trouble proving out the theory.
The same code works as desired in the latest Chrome, FireFox, and IE desktop browsers, as well as within Android.
Does anyone have any insight on this behavior? It might also be worthwhile to note that ngCsp is being used to alleviate dyanmic content insertion restrictions on Metro applications.
Thanks in advance!
I found that the problem was in the shim winstore-jscompat.js
The method used to add the new tags has a bug.
My version of that method is:
cleansePropertySetter("innerHTML", function (propertyDescriptor, target, elements) {
empty(target);
for (var elementIndex = 0, elementsLength = elements.length; elementIndex < elementsLength; elementIndex++) {
if (elements[elementIndex].nodeName == 'BODY') {
for (var childIndex = 0, amountOfChildren = elements[elementIndex].childNodes.length; childIndex < amountOfChildren; childIndex++) {
target.appendChild(elements[elementIndex].childNodes[0]);
}
}
}
});
This did the trick for me. I have not yet tested all variations of directives.
The fix above didn't work for me, but I found a Fork that fixes the issue:
https://github.com/ClemMakesApps/winstore-jscompat/blob/master/winstore-jscompat.js
Note that this will probably be pulled into the main project at some point so this issue should go away "soon".
Also here is the original issue:
https://github.com/MSOpenTech/winstore-jscompat/issues/8

Clearing CacheMemory of WebBrowser

I want to clear the Cache of a WebBrowser control dynamically in Windows Phone 7.1 using C#. Previously selected images are loading again in my WebBrowser, has anyone ran into this before?
Clearing Cache in WP7.1 is not possible.
The workaround can be to force the browser to load fresh page each time. This can be accomplished in many ways such as:
- Using False Query i.e. Passing a random parameter in location of web page like /page.html?q=5
- Using tags based methods to prevent caching (google it)
- passing no-cache headers from server itself
On Windows Phone 8 you can use the extension method ClearInternetCacheAsync.
This won't work on WP7.1 however. See another StackOverflow question that deals with that.
For clearing images this code can be helpfull to you.
BitmapImage bitmapImage = image.Source as BitmapImage;
bitmapImage.UriSource = null;
image.Source = null;
This works. happy coding

ABCPDF6 issue: "HTML render is blank" but web page output is fine

Like the title says, we are using ABCPdf6 to render PDFs from XSLT. Everything was working fine, but now we are getting an error that states "HTML render is blank". Using a browser (tested on IE/Firefox/Chrome) I am able to browse to the generated HTML (formatted XSL) and it displays perfectly fine in the browser. ABCPDF6 is not able to convert the file. I have tried giving control to the page that outputs the XSL, but I am still getting this error.
Does anyone have experience with ABCPdf and have encountered this before? The code was working fine before without a problem, and another page that uses the exact same generating code (even pointing to the same placeholder page that spits out the HTML!) is working fine.
I know what the problem was in my case now.
When i ran Windows update on my 2008 server, Internet Explorer 9 was installed.
IE 9 has a different way of rendering HTML which brakes abcPDF.
Updating to the latest version (8) solved all my problems. In this version you can also try another HTML engine called Gecko.
Even though you have resolved your problem, if anyone else gets this error, I would suggest that you install the trial version and try this out with the latest version.
I had same error on windows 7 machine with AbcPdf4.0. During MS updates IE8 was upgraded to IE10. Issue got fixed by uninstalling IE10.
Note: Abcpdf4.0 does not work with IE9 onwards. Either upgrade Abcpdf or uninstall latest IE.
I had a similar issue this morning with AbcPdf9. I added code to test the engine types and GECKO worked, then I swapped it back to MSHTML, and it still worked. So it was a temporary issue.
This is how you specify the engine type:
using (var document = new Doc())
{
document.HtmlOptions.Engine = EngineType.Gecko;
...
...
}
This code calls the method that converts the html to PDF, but calls it twice if necessary, since it will only fail once:
try
{
return GeneratePdfFromHtml(html, width, EngineType.MSHtml);
}
catch (Exception ex)
{
/* detect this known issue, swapping the rendering engine once seems to fix it */
if (ex.Message.ToUpper().Contains("BLANK"))
{
return GeneratePdfFromHtml(html, width, EngineType.Gecko);
}
throw;
}
Then you can add a parameter to the method that does the conversion:
public byte[] GeneratePdfFromHtml(string html, int width, EngineType engineType)
{
if (string.IsNullOrWhiteSpace(html)) throw new ArgumentNullException("html");
if (width < 100) throw new ArgumentOutOfRangeException("width");
try
{
using (var document = new Doc())
{
document.HtmlOptions.Engine = engineType;
...
...
If you have a suggestion or different solution, please leave a comment.
In regedit use the following steps
1)HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node
2)Create a key DWORD 32 Bit
3) Rename it "w3wp.exe"
4) Set Value Date = 1

Watin 2.1 error with Firefox 3.6 ContainsText and jssh

I have had problems using Firefox with Watin 2.0 and the recent 2.1 release.
FireFox: 3.6.17
Watin: 2.1.0.1196
Gallio / mbUnit: 3.2.601
Windows Server 2008 32 bit
.NET 4.0 assemblies
Visual Studio 2010
I went over these instructions repeatedly:
http://watin.org/documentation/setting-up-firefox/
I went to Firefox, File->Open, navigated to the file: jssh-3.6-WINNT.xpi
Installed the XPI in Firefox without any problem.
A few things do work fine in FF with Watin. Finding text fields, TypeText, Click, all that works. But this line of code blows up:
Assert.IsTrue(theBrowser.ContainsText(validationText), "Listing '{0}' was not found in the results.", validationText);
See below for the error. Any idea what I did wrong?
WatiN.Core.Native.Mozilla.FireFoxException: Error sending last message to jssh server: SyntaxError: missing ) after argument list
C:\QEDev\tools\WatiN\source\src\Core\Native\Mozilla\FireFoxClientPort.cs(422,0): at WatiN.Core.Native.Mozilla.FireFoxClientPort.CheckForError(String response)
Another user here on StackOverflow answered this question in a separate thread. Here is one workaround:
Sub-class based off of Watin's Firefox class
Override the ContainsText method
Use the HTML Agility Pack to load the document and call the Contains method.
This seemed to work fine for a while. On other computers I saw the same JSSH error as before.
public override bool ContainsText(string text)
{
WaitForComplete();
var htmldoc = new HtmlDocument();
htmldoc.LoadHtml(Html);
bool result = htmldoc.DocumentNode.InnerText.Contains(text);
return result;
}

Resources