Office RibbonUI ApplicationMenu Icon - c#

I'm having weird issues with the LargeImageSource for the Application menu (using Office2007Blue theme)
My image is 48x48 but it appears to be scaling down to 10x10. It's not using SmallImageSource at all.
<r:Ribbon.ApplicationMenu>
<r:RibbonApplicationMenu>
<r:RibbonApplicationMenu.Command>
<r:RibbonCommand
SmallImageSource="images/icon.png"
LargeImageSource="images/icon.png"
ToolTipTitle="Application Menu"
ToolTipDescription="Click here to open files or close the application." />
</r:RibbonApplicationMenu.Command>
<r:RibbonApplicationMenuItem>
<r:RibbonApplicationMenuItem.Command>
<r:RibbonCommand
LabelTitle="_Close"
LabelDescription="Close the Application"
/>
</r:RibbonApplicationMenuItem.Command>
</r:RibbonApplicationMenuItem>
</r:RibbonApplicationMenu>
</r:Ribbon.ApplicationMenu>

Changing the image's printed dimensions fixed it. The button doesn't look at the pixel dimensions.

The WPF Ribbon is full of bugs. This one in particular is because the SmallImageSource Image is hardcoded to 16x16 in the RibbonApplicationMenu's control template. LargeImageSource isn't even used anywhere in the default theme.

Related

how can I give an image an octagonal shape?

I'm creating a mobile App. In this app there is the user's profile and i would like give an an octagonal shape to the user's profile. For the moment I have just an image:
<Image x:Name="ProfilePicture" HeightRequest="100" HorizontalOptions="Center" Source="Profile.png" TranslationY="50" VerticalOptions="End"/>
how can I shape this image?
The result I would like to achieve is this:
a yellow outline and instead of the gift the user image
Xaml doesn't support drawing shapes directly. You have several options:
Simple. Use shape image as resource. Put it all together with with grid or absolute layout.
Smart. Use Font Awesome icons in your XF. You can reuse other icons to reduce bitmaps in your app. Unfortunately octagonal shape is available only in PRO edition.
Heavy artillery. You can use Skiasharp or similar library to draw octagonal image with user image inside.
Hope it helps.

Adding an icon to right-to-left ListView items causes the icons to flip in C# WinForms

I have a ListView. Its RightToLeft property is set to Yes and its RightToLeftLayout is set to True. The ListView is populated with files in a directory.
In my code, I get the appropriate icon of a file using System.Drawing.Icon.ExtractAssociatedIcon(string filePath) and assign it to the file. This means that the icon come directly from the operating system. I do not have a directory with custom icons.
So the result is this:
As you can see, the PowerPoint file icon is flipped. When I change the layout to LeftToRight it is shown perfectly. How can I fix it?
Thanks.
If you only need the icon to be reversed, I suggest putting it into a Bitmap then using the Bitmap.RotateFlip you can flip it horizontally.
Bitmap bm = System.Drawing.Icon.ExtractAssociatedIcon(string filePath).ToBitmap();
bm.RotateFlip(RotateFlipType.RotateNoneFlipX);

Xamarin Android - Gif in WebView is displayed blank

I got an issue while trying to display a gif for my UI.
When the app is launched, the .gif file is correctly loaded (if i change the path, a loading error occure) but the webView is displayed blank.
Android version : marshmallow 6.0 API lvl 23
the "ship_sea.gif" is currently located in Assets Folder, with "Android Asset" in build action.
the axml:
<WebView
android:id="#+id/myWebGIF"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginTop="50dp"
android:layout_marginLeft="50dp" />
the .cs :
WebView webGif = FindViewById<WebView>(Resource.Id.myWebGIF);
webGif.LoadUrl(string.Format("file:///android_asset/ship_sea.gif"));
Why is this not working? It is really simple and I can't figure out what is the problem.
Could it be the device as this post suggests (NVIDIA Shield Tablet K1)?
Ok guys, here is the answer :
Be sure that your canvas is the same size as your gif.
In my case, i had a particular large gif, and the only part rendered in my canvas was the top-left (a blank part).
The default background color for a webView is white, so it resulted in a blank view.
Problem solved : there was no error, just wrong interpretation of the problem.

notifyicon image looks terrible once image ends up in system tray

I am using Visual Studio 2010, C#, on Windows 7.
I have added a notify control to my project and set it to an icon I have imported to the project. The icon image is really good looking if I just preview it, but once I run my code and see it in the system tray, then it's really terrible, like the sides are dotted instead of straight lines and so on. I have tried 16x16, 24x24, 32x32 and 48x48 of the same file but I am having terrible results.
Have I missed anything?
myNotifyIcon.Icon = SysDir.Properties.Resources.icon2_32_ico_rgba;
The problem with directly using the icon in your resources is that instead of choosing the right icon version in you icon file, the framework simply scales the default icon version to whatever size the notification area needs. That's why you are seeing jagged edges.
To get the best quality, you'll need to choose the right size in your icon by yourself.
First, instead of directly setting your NotifyIcon.Icon to an icon in your resources, create a new Icon instance. Doing so will allow you to choose a specific icon size in your icon resource. Using SystemInformation.SmallIconSize will get you the size the notification area needs.
So :
myNotifyIcon.Icon = new Icon(Properties.Resources.MyIcon, SystemInformation.SmallIconSize);
Now, SystemInformation.SmallIconSize always returns the right icon size, but only if your application is DPI-aware (otherwise, it always returns 16). If your application isn't DPI-aware, and it is used on a system where DPI-scaling is enabled, the line above will select the 16x16 icon in your resource, at it'll be scaled up to whatever size the notification area needs (in other words, ugly icon).
By making your app DPI-aware, SystemInformation.SmallIconSize will return the right size, taking into account DPI-scaling. For instance, if DPI-scaling is at 150%, SystemInformation.SmallIconSize will return 24 (16 × 1.5).
To make your app DPI-aware, simply add this to your app.manifest, inside the <asmv1:assembly> tag:
<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
Edit:
The info I am linking seems to be suspect at this point. Try it out, but if it isn't working, then I suggest you edit your question to post screenshots of all your experiments (each icon size and how it gets scaled).
Original:
32x32x256 is the right size and color depth according to this link:
http://www.hhhh.org/cloister/csharp/icons/
But you have to be very careful when constructing that image:
Take a 16x16x256 image, and get it to look nice
Double it to 32x32 (careful not to blur or resample if doing this in a paint program)
The reason is that Windows will "resize" the 32x32 image to 16x16 by simply throwing away 3/4 of the pixels. The link above demonstrates this phenomenon with a couple screenshots:
Before:
After:
I'm not sure how much of the color-depth pickyness (256 colors only?)/resampling issues are still true on Windows 7, but it certainly seems to be the case on XP.
I use NotifyIcon in a C# WinForms application and no matter what the icon I use contains, after 2 resolution changes it ends up blurry.
My best guess is, that windows doesn't actually rescale the original every time but rescales the (already rescaled) version from the icon cache.
The only solution I found so far was setting the icon again after a resolution/dpi change:
SystemEvents.DisplaySettingsChanged += (sender, eventArgs) => {
trayIcon.Icon = MyIcon;
};
I tried all kind of resolutions and bit depths in the icons but they all got blurred eventually. Now I only use a single 16x16 32b image in the icon and so far it works great on all tested displays.

Image display incorrect on toolstrip

I use a 32-bit image & use it as a value for Image property of ToolStripButton. But I don't know why it displays unlike the original one.
This is the screenshot:
http://img4.imageshack.us/img4/7668/34711163.png http://img4.imageshack.us/img4/7668/34711163.png
And my project:
http://www.mediafire.com/?3mzmf5r5nnx
Please help me to find the reason. Thanks.
I've opened the 'button_9.png' in Paint.NET and it seems like the 'white glass' of the magnifier is semi-transparent.
So you have to edit the image that the magnifier has an opaque backcolor.

Categories