I want a attribute in my Hero class to have a Portrait attribute for his/her image. What object type should I use in this case?
public class Hero
{
public string Name { get; set; }
public string HeroType { get; set; }
public int StartingHP { get; set; }
public int StartingMana { get; set; }
public Dictionary<string, string> Spells { get; set; }
public Dictionary<string, string> Items { get; set; }
}
In WPF, you should use the
ImageSourceclass, like this:You can read an image from a file like this:
You can use theImageclass from System.Drawing.dll. For example:To load the image, call
Image.FromFile(path). If you have an image in a stream (eg, from a database or web service, you can callImage.FromStream(stream).If you have all of the images at compile time, you can put them in a ResX file; you can get an image from the designer-generated code file like this:
myHero.Portrait = SomeResXFile.Portrait1.