I'd like to make some fancy live tiles. But I am not quite happy with the default options for it. Is there a way in C#/XAML or any site, that shows how to put an own design for a live tile?
the default font size of the Tile cannot be changed. You can only change the text. What you can do is create an image that has text on it and set that to the BackgroundImage or the BackBackgroundImage. You can create an image by using the WriteableBitmap or WriteableBitmapEx.
Related
So I'm trying to add a company logo to the middle of my NavigationPage Title section, and I have tried to use NavigationPage.TitleIcon="companytitleicon.png" inside XAML, but it doesn't display. I'm not certain if it's because the image has to be a certain size, and I cannot find information in the documentation.
I played around with other code as well, like calling NavigationPage.SetTitleIcon which takes a reference to a page and a FileImageSource like so:
NavigationPage.SetTitleIcon(this, "/Assets/dischemtitleicon.png");
I may be using it incorrectly, so I need a bit of advice, in general, with getting the logo to display on the Title section. I'll add a screenshot as well to specify the location and size of the logo. The logo is at least twice as wide as the height, eg. 120 x 50 ...
Any assistance will be truly appreciated. I'm also trying to get the colour of the MasterDetail bar to change, but that's not as crucial of an issue. (I added a global StaticResource that applies a fixed colour to all NavigationPage BarBackgroundColors)
If you are using a Xamarin.Forms app based on Shell then you can easily achieve this using Shell.TitleView without the need of a custom renderer, define your title content, bind it or even style it as you like.
You could refer to my similar answer https://stackoverflow.com/a/65062752/522820
I'm using Ribbon from RibbonControlsLibrary.dll 4.0.0.11019, .NET 4.0, C#, WPF.
It can be downloaded with a free samples here: http://www.microsoft.com/en-us/download/details.aspx?id=11877
The problem comes when a RibbonToggleButton is displayed. Then it's image seems to be a little bit broken, like a part of image is shifted for a few pixels.
EDIT: Thanks to kind people I can post and image now:
Here are some details:
Image is displayed in it's large variant
Image size is 32x32
I set image scaling to none for all the images of Ribbon
Image is broken only when the text in RibbonToggleButton has 1 line
Same image displays correctly in any other kind of button (RibbonButton, RibbonSplitButton etc.)
The image is displayed correctly when I set the font size in Windows to Medium (125%)
My OS is Windows 8
When I set the VerticalContentAlignment for the toggle button to "Bottom", the Image starts to display correctly, but the whole Ribbon starts to look ugly.
I experience this problem for all the toggle buttons, including those which are in a Microsoft's free samples.
I guess that probably the Image doesn't have enough space, so it's compressed from 32x32 to some smaller size.
I use the theme that is made of Microsoft's Generic theme, that is included in the RibbonControlsLibrary.dll. I guess I could fix the RibbonToggleButton template somehow, but I have no idea what to fix there.
Any ideas?
In the xaml declaration of your UserControl / Window put that line:
RenderOptions.BitmapScalingMode="HighQuality"
At the moment I'm using Control DrawToBitmap method to capture my WebBrowser like following.
var bmp = new Bitmap(640,480, PixelFormat::Format32bppArgb)
var web = (System.Windows.Forms.Control)sender;
web.DrawToBitmap(bmp, Rectangle(0, 0, 640,480));
My Bitmap supports Alpha channel but this code doesn't save transparency.
Here is the webpage example :
http://jsfiddle.net/zPtPN/
EDIT 2: opacity on embedded browser
With CEF (Chromium Embedded Framework from Google) you should do as follows. This may or may not apply to the default .NET Internet Explorer control.
body
{
background-color: transparent;
}
To overlay this you have to render to a buffer that was cleared. That buffer IS NOT the final rendered raster but an intermediate in-memory buffer that retains VERY MUCH the alpha channel. As long as the buffer is cleared (filled with transparent pixels), you grab the buffer with the full ARGB32 channels and overlay it correctly, you should get what you want.
Best is, you try as far as you can go, then take a screenshot and post a new question specifying that you are using an embedded browser. Also specify the browser version because it will change from one machine to the other: Options for embedding Chromium instead of IE WebBrowser control with WPF/C#
The Bitmap might contain alpha channel information, but not all file formats support it. You should save the image as a *.PNG with ARGB32 lossless mode. A simple *.BMP file will not suffice.
Look at this answer to know not just how to save as PNG but also how to actually get the transparency right:
c# Bitmap.Save transparancy doesn't save in png
To grab transparency from the web page you can try this UGLY, CUMBERSOME, HORRIBLE technique that has tons of problems:
Use a unique color for the body background, like #ffe000. Render the page, grab it as before.
The transparent parts will show the body's background showing through.
At this point you can filter the image by setting its TransparencyKey to the color of the background -OR- by substituting all pixels of that color with a fully transparent pixel color (just change the alpha channel's value from 255 to 0).
Why this is horrible? Because the results will be ugly:
fonts are smoothed and will have shades of that color, so you can't get them partially transparent, they will retain opacity and look horrible much like gifs looked back in the ole'90 (they are called rendering artifacts).
if you use pretty CSS3 stuff like border-radius or box-shadow the same artifacts as above arise: border pixels with shades (anti-aliasing) will look horrible.
Ugly Example here.
So how can you remove these artifacts? You can't.
I highly recommend a completely different approach to your problem.
By the way, what do you want to achieve? Are you using CEF or other embedded browser technology that you want to overlay somehow?
Maybe there are other ways I can help you with....
EDIT: why the ffff <div> does not show
You set the style to:
background-color: transparent; opacity:0;
Now, the background of the <div> will be transparent and show what is behind (the <body>'s background-color). When you set opacity instead, you say to make the whole <div> (contained images and texts included) transparent. Setting it to 0 means totally invisible.
I would like to know how I can create one image from many. I would like to create a tile in my windows phone application like in this image (specifically, the People tile):
(source: addictivetips.com)
I have nine pictures, and I would create an image, that I will add like tile to background. Does anybody know how can I create an image that looks like the one in that picture?
I have very little experience in this space, but have you considered creating a control that simply displays up to 9 pictures side by side in a grid like that? You then can bind each image independently & change them out however you want. This article touches on how to bind phontos in WP7 nicely:
http://msdn.microsoft.com/en-us/library/hh286418(v=vs.92).aspx
If you're talking about assembling an actual graphic image like a jpeg or bitmap, you'll need to look at the Image Class, Bitmap Class, and Graphics Class. Essentially you'll need to implement the following steps:
Load the relevant images with From method in Image, typically Image.FromFile.
Determine how many rows and columns you'll be using.
Calculate the total width and height for your layout using the widths and heights of the loaded images with appropriate padding added.
Create a new Bitmap of the appropriate size with the correct background color and iamge format.
Have variables for the current drawing location (x & y).
Have variables for the current row and column in your layout.
In a loop, Create your Graphics object.
Use Graphics.DrawImage to add your loaded image to the layout bitmap.
Increment your drawing row and or column as appropriate.
Calculate your new drawing location.
Repeat until done.
One of the options is to use WriteableBitmapEx
Also you can probably find an answer to your question here: How can I merge two images into one?
I'm attempting to display a "LargeIcon" view in a listview control, however the images I specify are blurry. This is what I have so far:
alt text http://img220.imageshack.us/img220/1005/blurryiconsql3.jpg
The .png files are 48x48 and that's what I have it set to display at in the ImageList properties. There's one thing that I've noticed (which is probably the cause) but I don't know how to change it. Inside the "Images Collection Editor" where you choose what images you want for the ImageList control, it looks like it's setting the wrong size for each image.
alt text http://img83.imageshack.us/img83/5218/imagepropertiesmf9.jpg
As you can see the "PhysicalDimension" and the "Size" is set to 16x16 and not abled to be manipulated. Does anyone have any ideas? Many thanks!
Be sure to set ImageList.ImageSize to 48 x 48 too.
When adding a .PNG Icon format size the editor tends to pick the first entry size in that file, so it picks up the 16x16 entry and it's stretching that out. That's why you see the 16x16 in the properties there. As suggested, the support for PNG is poor, I'm often found myself rolling over to another format as well to avoid this.
You can open the file in Paint.Net if you need a free editor or something more fully featured like Photoshop or Fireworks and extract the exact size you want.
I'm not sure if its the problem in this specific case, but Microsoft support for the PNG format is generally poor. Try adding the images in .bmp format and they should display fine.
Check also the ColorDepth setting on your ImageList. I had a similar issue with a TreeView control, but after reading the previous posting regarding the size I found this setting, played around with it a bit and found that it greatly affects the way images from an ImageList are rendered. The higher the depth the better the quality.
Be sure to set the ImageList size to 48x48 px BEFORE you add the images.
If the ImageList is set to 32x32 and you add a 48x48 image, the icon is resized to 32x32. When you change the ImageList to 48x48 afterwards, the image is just resized again, thus losing quality and going blurry.
Also, Paint.NET (or Photoshop) can't open .ico files.
Visual Studio/.NET can handle 32-bit PNG images fine, the built-in image editor in VS is a bit lack-lustre though.