I'm trying to reference WindowManger so I can get the default screen's dimensions but I can't seem to find reference to it. (this is API 8, froyo 2.2). I even tried:
dynamic wm = Android.App.Application.Context.GetSystemService(Android.Content.Context.WindowService);
Display display = wm.getDefaultDisplay();
But got an error indicating that Object doesn't respond to getDefaultDisplay.
Also I tried:
var wm = (IWindowManager)Android.App.Application.Context.GetSystemService(Android.Content.Context.WindowService);
Display display = wm.DefaultDisplay;
But I get an invalid cast exception.
Saw this post, but I can't resolve WindowManager. Any ideas what's going on here?
WindowManager is the IWindowManager interface. Instead of the cast, try using the .JavaCast<T>() extension method:
var wm = context.GetSystemService(Android.Content.Context.WindowService)
.JavaCast<IWindowManager>();
var d = wm.DefaultDisplay;
You can also check out the AccelerometerPlay sample.
Another simpler way is
Display display = this.WindowManager.DefaultDisplay;
You can get the Width and Height properties from the display object.
using Android.Runtime; //for JavaCast
var windowManager = Android.App.Application.Context.GetSystemService(Android.Content.Context.WindowService).JavaCast<IWindowManager>();
Related
Im using playwright with C# and a trying to do the following:
I have two elements with the same locator.
I want to be able to locate one of them by position, i.e 1st or 2nd found.
when do the following:
var nameField = page.Locator("div[data-key='Name']");
await nameField.FillAsync("");
I get the error:
Microsoft.Playwright.PlaywrightException : Error: strict mode violation: "div[data-ph-key='Name']" resolved to 2 elements:
Ive tried the following based on the playwright documentation:
var nameField = page.Locator("div[data-ph-key='Name'] >> nth=0");
this results in the element resolved to 2 elements error:
also tried this
var nameField = page.Locator("div[data-key='Name']");
await nameField.First.FillAsync("");
which returns the same error
How can do a simple select the nth element found and interact with it?
Is there something similar to selenium's IWebelements where I would put all the matching elements in a collection and interact with the desired one based on its index position?
Okay, so this works:
var nameField = page.Locator("div[data-key='Name']")
await nameField.Nth(0).FillAsync("");
We are using the Autodesk Forge Viewer DiffTool extension, but we need to change one of the texts:
Every tutorial shows how add localization to your own extension, but I couldn't find how to change a translation in an existing extension you are using.
Moreover, without knowing what the translation key is, I would have "guess" it, which isn't really great either.
So, how do I change the translation for this text?
There is no supported way to hook into the translation service of the Viewer to change the text. If the translation is wrong, please let us know, and we can fix that on our side.
If you want to change the text for some other reasons, then one thing you could do is wait for the initialization of the extension's UI and change the button's content using DOM APIs:
let extensionConfig = {}
extensionConfig['mimeType'] = 'application/vnd.autodesk.revit'
extensionConfig['primaryModels'] = [model1]
extensionConfig['diffModels'] = [model2]
extensionConfig['diffMode'] = 'overlay'
extensionConfig['versionA'] = '2'
extensionConfig['versionB'] = '1'
extensionConfig['onInitialized'] = () => {
let button = document.getElementById("diffFacetsRemovedButton");
let label = button.nextSibling;
label.innerHTML = label.innerHTML.replace("Odebrat", "Něco jiného");
}
viewer.loadExtension('Autodesk.DiffTool', extensionConfig);
final html.IFrameElement iframe = rootDemoElement.querySelector("iframe");
final int contentHeight = <???>.scrollHeight;
this works in JS:
var contentHeight = iframe.contentDocument.documentElement.scrollHeight;
contentDocument is not available in Dart.
Is it really possible that contentDocument is missing in Dart?
Here is my solution:
var jsIFrame = new JsObject.fromBrowserObject(iframe);
var contentHeight = jsIFrame["contentDocument"]["documentElement"]["scrollHeight"];
As far as I know there was an attempt to make Dart in the browser more secure than JavaScript and this led to a model where cross-window communication was limited (to postMessage). I assume an Iframe suffers from the same limitations. There was a comment on an issue that they want to leave this strategy because this is usually circumnavigated by using dart-js-interop anyway.
I think the main culprit is that you get a _DOMWindowCrossFrame instead of a Window instance.
See
http://dartbug.com/17936#c2
probably also related
http://dartbub.com/20146
http://dartbug.com/20143
http://dartbug.com/20173
http://dartbug.com/21219
http://dartbug.com/20216
http://dartbug.com/19610
http://dartbug.com/16814
http://dartbug.com/12788
http://dartbug.com/2312
How can I get/set the bonding box of a Google map? I know how to create map using center and zoom, but I need a way to save the view of map based on its boxing and the recreate the same view later using the map bonds (NE and SW of map)
Any idea how I can do this?
I am using MVC 3.
You want to use the map.getBounds() function which returns a LatLngBounds object. From this you can then use getNorthEast() and getSouthWest() to get the coordinates you want.
var bounds = map.getBounds();
var NE = bounds.getNorthEast();
var SW = bounds.getSouthWest();
If you need those LatLng objects to then be strings (for inserting to your DB or writing to a cookie or whatever), just use the toString() function on them.
strNE = NE.toString();
strSW = SW.toString();
So let's assume you write these to a cookie or use Ajax to write these to your DB. Once you get them out of the cookie/DB later, you can then just use those for setting the center of the map:
bounds = new google.maps.LatLngBounds(SW, NE);
map.fitBounds(bounds); // or maybe try panToBounds()
All these functions are documented here: https://developers.google.com/maps/documentation/javascript/reference
while trying to overlay an image in blackberry i am getting this error
Image outerFrame = Image.createImage("/outerFrame.png");
Image innerFrame = Image.createImage("/innerFrame.png");
OverlayControl overlay = myMediaProcessor.getControl ("javax.microedition.media.control.imageeffect.OverlayControl");
overlay.insertImage(innerFrame, 0,0,1); // order = 1
overlay.insertImage(outerFrame, 0,0,0); // order = 0
I can’t get to create “myMediaProcessor”.
You do not show a lot of context, so it's hard to understand what you're actually asking for.
myMediaProcessor should be an object of a class that implements the
javax.microedition.media.Controllable
interface. See the Controllabale javadoc for a list of classes that implement it.
Alternatively, look at the javadoc for the MediaProcessor interface, and the GlobalManager docs. These have the information you seem to be looking for.