Default ForegroundColor of StatusBar depending on Theme - windows-runtime

I am looking for the default ForegroundColor (or resource key) of the StatusBar in the Light or Dark Theme. I need to set the ForegroundColor manually because it seems to be not updated according to the RequestedTheme.
If I set the RequestedTheme in my app to Light and the SystemTheme is Dark, the StatusBar will be displayed with white ForegroundColor. I expected that the ForegroundColor of the StatusBar depends on the App's RequestedTheme.

The only known way to change the StatusBar colors so far is by doing it in C#. No XAML resources to override unfortunately.
You can change the StatusBar colors like so:
Windows.UI.ViewManagement.StatusBar.GetForCurrentView().ForegroundColor = Colors.Black;
Windows.UI.ViewManagement.StatusBar.GetForCurrentView().BackgroundColor = Colors.White;
Windows.UI.ViewManagement.StatusBar.GetForCurrentView() has more properties btw.
If you want to be able to change the colors depending on which theme is requested, you could check for the requested theme:
if( Application.Current.RequestedTheme == ApplicationTheme.Light )
{
Windows.UI.ViewManagement.StatusBar.GetForCurrentView().ForegroundColor = Colors.Black;
Windows.UI.ViewManagement.StatusBar.GetForCurrentView().BackgroundColor = Colors.White;
}

Related

Set transparent for specific element

I want set transparent for specific element, i follow this code:
var instanceTree = this.viewer.model.getInstanceTree();
var fragList = this.viewer.model.getFragmentList();
this.listElement.forEach(element => {
instanceTree.enumNodeFragments(element, (fragId) => {
console.log(element.material)
var material = fragList.getMaterial(fragId)
if (material) {
material.opacity = value;
material.transparent = true;
material.needsUpdate = true;
}
});
});
this.viewer.impl.invalidate(true, true, true);
but it overide for all elements have that material. How can i set for selected element?
Appreciate any comments.
UPDATE 1:
i found go around way is clone main material than register it with different name:
var newMaterial = material.clone();
const materials = this.viewer.impl.matman();
materials.addMaterial('mymaterial',newMaterial,true);
fragList.setMaterial(fragId,newMaterial);
newMaterial.opacity = value;
newMaterial.transparent = true;
newMaterial.needsUpdate = true;
but effect is not what i want, it has different color and when set transparent i can only see a couple object behind it
You can create your own, custom THREE.js material and assign it to the fragment using fragList.setMaterial(fragId, material).
For more information on using custom materials or shaders, see https://forge.autodesk.com/blog/custom-shader-materials-forge-viewer.
EDIT:
Regarding the visual anomalies (for example, when you only see some of the objects behind something semi-transparent), this is a known problem, unfortunately with no clear solution. When the Forge Model Derivative service creates an SVF file to be viewed in Forge Viewer, the individual scene elements are stored in a data structure optimized for fast traversal, depending on whether they are semi-transparent or fully opaque. This data structure is fixed, and so unfortunately, when you take an object that was originally fully opaque, and you make it semi-transparent, it will most likely be rendered in a wrong order...

Cannot remove default buttons from autodesk-forge viewer panel (Autodesk.Viewing.Private.GuiViewer3D)

I would like to remove measure, text format and properties buttons. See image.
I can only remove "toolbar-settingsTool" but not able remove above three buttons.
onExtensionLoaded = (e) => {
if (e.extensionId === 'Autodesk.DefaultTools.NavTools') {
// Remove settings tools
const settingsTools = viewer.toolbar.getControl('settingsTools');
settingsTools.removeControl('toolbar-settingsTool');
//settingsTools.removeControl('toolbar-fullscreenTool');
// Remove settings tools
const navTools = viewer.toolbar.getControl('navTools');
navTools.removeControl('toolbar-propertiesTool');
// Remove model tools
const modelTools = viewer.toolbar.getControl('modelTools');
modelTools.removeControl('toolbar-modelStructureTool');
}
}
viewer.addEventListener(
Autodesk.Viewing.EXTENSION_LOADED_EVENT,
this.onExtensionLoaded);
Can you please help me? Thank you.
viewer
Here is my code.
Some toolbars are initialized when loading the corresponding extension such as measurement ('Autodesk.Measure'). If you still need to use these functionalities in the workflow, yet only need to put the button to your own toolbars, or no button, you will need to check the corresponding extension if it supports removing the button only. e.g. in 'Autodesk.Measure' extension, it has the method measurementToolbarButton.removeFromParent, by which, the default button will be removed, while the functionalities of measurement still exists. The code could be:
ext = NOP_VIEWER.getExtension('Autodesk.Measure')
ext.measurementToolbarButton.removeFromParent()
When you need to switch to measure mode by your own button, call the method below:
NOP_VIEWER.setActiveNavigationTool('measure')
If you do not need the functionalities at all, just unload the extension. The default button will also be removed.
Thank you Xiaodong Liang. That works. I was able to remove measure and properties icons using following code:
onExtensionLoaded = (e) => {
// Remove "Settings" icon
if (e.extensionId === 'Autodesk.DefaultTools.NavTools') {
// Remove settings tools
const settingsTools = viewer.toolbar.getControl('settingsTools');
settingsTools.removeControl('toolbar-settingsTool');
//settingsTools.removeControl('toolbar-fullscreenTool');
}
// Remove measurement icon
else if (e.extensionId === 'Autodesk.Measure') {
var ext = viewer.getExtension('Autodesk.Measure');
ext.measurementToolbarButton.removeFromParent();
}
// Remove "Text" icon
else if (e.extensionId === 'Autodesk.Hyperlink') {
var ext = viewer.getExtension('Autodesk.Hyperlink');
ext.tool.removeFromParent();
}
// Remove properties icon
else if (e.extensionId === 'Autodesk.PropertiesManager') {
var ext = viewer.getExtension('Autodesk.PropertiesManager');
ext._toolbarButton.removeFromParent();
}
}
Is there any way to remove "Select Text" (T) icon? Following code is not working:
var ext = viewer.getExtension('Autodesk.Hyperlink');
ext.tool.removeFromParent();
Thank you.

'Pin To Start' custom tile

When a user 'Pins To Start' on their wp8 / wp8.1 phone, how can I change the image that is saved as the live tile? Can I modify this?
I am guessing there is some sort of meta-tag or something that I am not aware of.
EDIT Sorry, i really should have clarified, this is for when you pin to start a web-page and it appears in the start menu. I was sure there was a meta tag that went into the section that solved it. Or is it something to do with Favicon?
May be you can try this ,This is for pinning a secondary tile.I am unsure of the possibility for changing the image in primary tile
StandardTileData standardTileData = new StandardTileData();
standardTileData.BackgroundImage = new Uri("ApplicationIcon.png", UriKind.Relative);
standardTileData.Title = "Your title";
standardTileData.Count = 26;
standardTileData.BackTitle = "Pinned";
standardTileData.BackContent = "Tile";
standardTileData.BackBackgroundImage = "Your image URL";
ShellTile tiletopin = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("MainPage.xaml"));
if (tiletopin == null)
{
ShellTile.Create(new Uri("/MainPage.xaml", UriKind.Relative), standardTileData);
}
else
{
MessageBox.Show("Already Pinned");
}
To change the Images on the pinned tile you need to update the images in the WMAppManifest.xml file.
Open the WMAppManifest.xml file present in Properties in Solution Explorer:
Once you Open the file Go to Application UI Tab and update the icons for small, Medium and Large size. The Icon that comes up when you pin the Application icon is The Medium Icon. So that will come up:

AS3: Using embedded font

I embed font like this (FlashDevelop):
[ Embed( source = "Ubuntu-R.ttf", embedAsCFF = "false", fontFamily = "Ubuntu" ) ]
private static const Ubuntu : Class;
Then try to use like this:
var textField : TextField = new TextField;
textField.embedFonts = true;
textField.defaultTextFormat = new TextFormat( "Ubuntu", 22 );
textField = "免費旋轉 ПРИВЕТ HELLO";
addChild( textField );
Only russian and english parts of the text visible, but not japanese (my PC is russian). If to comment textField.embedFonts = true; line, then the whole text will be visible, but some other (seems like Arial) font used.
Call to Font.enumerateFonts( false ); returns array with one font called "Ubuntu".
Call to Font.registerFont( Ubuntu ); at any place doesn't help.
Adding parameters fontName, unicodeRange = "U+0000-U+FFFF", mimeType = "application/x-font-truetype", fontWeight, advancedAntiAliasing to the font embed directive with different attributes do not change the behavior.
Seems like dead end, but please help.
The font you use does not contain the required glyphs for Japanese. You might try another font, make sure though it has enough glyphs in there. A hint: if the font isn't as big as 1 megabyte, most likely it has neither japanese nor chinese glyphs, if it's bigger, then try embedding and check with hasGlyphs() if it has enough. Once you'll find the correct font, embed and enjoy. But, I'd say use a font that's widely distributed and has japanese glyphs by design, say Arial.

CycleTile puts a shadow on my images windows phone

I'm trying to make some tasty live tile action for my windows phone 8 app. I've chosen to use the Cycle Tile template for some awesome gliding images but there is a problem: Microsoft seem to have kindly added a grey translucent filter to all the images so that the title text at the bottom is legible even in the case of a white image. This is annoying if the developer intends to make a metro style collage by using WritableBitmap. Whites come out as an off-white grey and the theme colour is a shade darker than all the other tiles:
The code (in a usercontrol in the visual tree):
const double TILE_H = 336;
const double TILE_W = 691;
Size TILE_SIZE = new Size(TILE_W, TILE_H);
const string FILEDIREC = "/Shared/ShellContent";
LayoutRoot.Height = TILE_H;
LayoutRoot.Width = TILE_W;
LayoutRoot.Clip = new RectangleGeometry() { Rect = new Rect(new Point(), TILE_SIZE) };
LayoutRoot.Background = new SolidColorBrush(
((Color)Application.Current.Resources["PhoneAccentColor"]));
TextBlock tb = new TextBlock();
Canvas.SetLeft(tb, 200.0);
tb.Text = "Why is this text grey? + lots more text";
tb.FontSize = 50;
tb.Width = 300;
tb.Foreground = new SolidColorBrush(Colors.White);
tb.TextWrapping = TextWrapping.Wrap;
LayoutRoot.Children.Add(tb);
var bmp = new WriteableBitmap((int)TILE_W, (int)TILE_H);
bmp.Render(LayoutRoot, null);
bmp.Invalidate();
var isf = IsolatedStorageFile.GetUserStoreForApplication();
var filename = FILEDIREC + "/tile.jpg";
if (!isf.DirectoryExists(FILEDIREC))
{
isf.CreateDirectory(FILEDIREC);
}
using (var stream = isf.OpenFile(filename, System.IO.FileMode.OpenOrCreate))
{
bmp.SaveJpeg(stream, (int)TILE_W, (int)TILE_H, 0, 100);
}
imageURIs.Add(new Uri("isostore:" + filename, UriKind.Absolute));
//similar process for other images used by CycleTileData
//these images then added to CycleTileData in the usual way
Any help, explanation, advise or workarounds to get degreying will be greatly appreciated. Thanks. I've tried using the images in different tile types, eg. the front of the flip tile has no issues.
I don't see any obvious issues with the code, but something I would try is to use the Isolated Storage Explorer and download the file and see what it looks like.
When generating custom tiles you may want to consider generating a PNG instead of a JPG. One of the benefits is that you then can generate a transparent image (which means your tile will always have the right theme background color) and PNG also uses a non-lossy compression scheme so there are no compression artifacts introduced.
Take a look at this answer where I describe how I generate tiles in one of my apps. Hopefully that will be of some use to you.