How to convert an Image to Icon? - c#

I need convert the image that is in String or Byte to Icon to show in ToolbarItems.
I need show the photo from user in right side from menu of the app.
My code until now:
this.ToolbarItems.Add(new ToolbarItem("name", "icon", () =>
{
}, ToolbarItemOrder.Primary));
If i set an icon from project, him show me like this:

It seems that ToolbarItem in Xamarin.Forms can only use local files (app resources).
See the API documenation - the property is a FileImageSource, which can only take a local file path.

Related

Why do only some button icons display

I am trying to set a toolbar button image. I have found various ways of defining button images, but none seem to work consistently.
Here are the ways I have found (either in documentation or on SO):
In code (doesn't work at all for me [for toolbar buttons])
public PXAction<DAC> action;
[PXButton(CommitChanges = true, ImageKey = PX.Web.UI.Sprite.Main.ArrowRight)]
[PXUIField(DisplayName = "Action")]
protected virtual void Action()
In ASPX, in Base Properties > Images > Normal of the screen editor
Normal | main#ArrowRight
In ASPX, in Ext Properties > ImageKey and ImageSet of the screen editor
ImageKey | main
ImageSet | ArrowRight
The ASPX options work for the main ArrowRight icon, but there are various other icons in the same sprite that I would like to use that do NOT work. For instance, intellisense in VS suggests that Relation and RelationF are also in the main sprite, but these display as blank images.
What am I doing wrong, and how can I access something other than arrows?
The web font is contained in the fonts folder of the Acumatica web site on the web server. Install a local Acumatica web site if necessary.
Font folder example: C:\AcumaticaSites\YourWebsite\fonts
Open one of the fonts file. The file acumatica-font-v1.svg can be opened in a text editor.
You will notice Relation / RelationF are missing and main-ArrowRight is declared in the file:
<glyph unicode="" glyph-name="main-ArrowRight, ac-arrow_forward" d="M448 134.4l262.4 262.4h-582.4v96h582.4l-262.4 275.2 64 64 384-384-384-384-64 70.4z" />
Check the mapping between the constant and the Unicode icon in Content\font-awesome.css CSS file:
.main-ArrowRight:before {
content: "\e90a";
}
You can also open the true type font ttf from the fonts folder and install it to view the icons in a font viewer.

Dynamically show an image from a resource file in a Windows Forms application

I am working with a Windows Forms application in Visual Studio 2010. I have a resources file, Flags.resx. I have uploaded images to the resource file, and want to show them in an Image control (picFlag). What is funny is THIS is super-easy, because my image files are strongly typed:
picFlag.Image = Flags.AE_Flag
But what I want to do, of course, is not. I want to dynamically provide the name of the image like this pseudo-code:
string strFlag = "AE_Flag";
picFlag.Image = Flags[strFlag]
Any suggestions on the simplest way to do this?
you can use the following
var rm = new System.Resources.ResourceManager("YourProject.Properties.Resources",
typeof(Resources).Assembly);
var image = rm.GetObject("AE_Flag") as System.Drawing.Image;
hope it will help you

Change Background image in WPF using C# [duplicate]

This question already has answers here:
Change WPF window background image in C# code
(7 answers)
Closed 7 years ago.
I'd like to change the background image of my WPF application by a button. I know how to do it using WindowsForms, but in WPF I failed.
I found a solution already, but that solution would copy my background images to the output folder next to the Application.exe
This is not really a solution that I desire. I would like to have the images stored inside my application.
Can somebody explain me detailed what I need to do [how to add the images to the program, especially the resource-properties, how to access them in C#....]. It seems like I am too stupid to set it up correctly :P
Thanks in advance
Firstly, add a Folder to your Solution (Right click -> Add -> Folder), name it something like "Resources" or something useful.
Then, simply add your desired image to the folder (Right click on folder -> Add -> Existing item).
Once it's been added, if you click on the image and open the Properties window (Alt+Enter), you'll see the Build Action is set to Resource and the Copy to Output Directory is set to Do not copy.
You can reference the image in C# using the following code:
this.Background = new BitmapImage(new Uri(#"pack://application:,,,/YourApp;component/YourFolder/YourImage.png"));
Or in XAML:
<Image Source="pack://application:,,,/YourApp;component/YourFolder/YourImage.png" ... />
Or:
<Image Source="/YourApp;component/YourFolder/YourImage.png" ... />
Try this:
this.Background = new ImageBrush(new BitmapImage(new Uri(#"pack://application:,,,/Yourapp;component/yourimage.png")));

Universal App On Phone - How to hide DisplayName?

When I run my Windows Universal App on my Windows 8.1 phone, the LiveTile has additional text (the name of my app) on it that I'm trying to hide. The text seems to be coming from the Package.appxmanifest
<m3:VisualElements DisplayName="This Text Appears" ...
I found a similar question (Is it possible to create a Windows Phone live tile where no title is displayed?) that suggests leaving the value empty. When I do this, Visual Studio complains that it is invalid and I'm not able to compile. Removing the DisplayName entirely also results in an error.
I can see other applications that do not show any text, so it does seem possible.
Can anyone tell me how to hide the DisplayText from my LiveTile, but still have the name of my app appear correctly on the list of installed apps on the phone?
The template I'm using for the live tile (TileWide310x150Image).
The DisplayName attribute inside the Package.appxmanifest file is required and cannot be left blank. It's also the name that will show in the Phone's list of installed Apps. You want that be the proper name of your app.
The name of the app will appear on the LiveTile and, in that context, it's called 'Branding'.
https://msdn.microsoft.com/en-us/library/windows/apps/br212854.aspx
<binding template = tileTemplateNameV2
fallback? = tileTemplateNameV1
lang? = string
baseUri? = anyURI
branding? = "none" | "logo" | "name"
addImageQuery? = boolean
contentId? = string >
It seems to default to 'name', but by setting it to 'none' the text will no longer be displayed on the live tile.
I was able to remove the Wide Tile Display Name in a Windows Phone 8.1 Runtime C# Application with the following code:
XmlDocument squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImage04);
XmlNodeList brandAttribute = squareTileXml.GetElementsByTagName("binding");
((XmlElement)brandAttribute[0]).SetAttribute("branding", "none");
squareTileXml is the name of the XML being configured to the Live Tile while TileWide310x150PeekImage04 is the chosen template.
Basically I specified a tile template (documentation) and I changed the property branding, which is inside the binding in the XML tree, according to this documentation, to none, removing the Display Name.
I'm not sure if this is the right way of configuring that, but at least it worked.

open picture in new tab, same as if do right click - View Image in firefox (WatiN)

I need to open image in new tab exactly as it's being done by clicking right button on it and then selecting View Image in firefox. Copying pic url and using browser.Goto doesn't give me the result i need due to some tricky javascript. Could anyone give me some suggestions? Thanks
Old question, some answer for reference only.
Get the src attribute for the image you are looking for and then open a new instance of IE with that address (you will probably need to append the base website address plus whatever there is in the src attribute for the image you are looking for. Some code for that:
Image btnLogin = Window.Image(Find.ByName("TheImageNameOrAnyOtherAttribute"));
string imageAddress = btnLogin.GetAttributeValue("src");
var newBrowser = new IE();
newBrowser.GoTo("http://www.somesite.com/"+imageAddress);

Categories