using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; namespace OwnForms { class Icons { /// /// Control the possible icons. /// public Icons() { SetIcon(Icon.Information); //Initialisiere ein Icon } //Die vorhandenen Icons public enum Icon { Construction, Email, Error, FatalError, Information, Instruction, Question, Telephon, Tips, Warning } /// /// Stores the current icon. /// public Icon CurrentIcon { private set; get; } /// /// Stores the current icon image. /// public Bitmap CurrentIconImage { private set; get; } /// /// Sets the used icon. /// /// A valid icon. Possible options are: 'Construction', 'Email', 'Error', 'FatalError', 'Information', 'Instruction', 'Question', 'Telephone', 'Tips', 'Warning'. /// Returns the image name. public Bitmap SetIcon(Icon icon) { switch (icon) { case Icon.Construction: CurrentIconImage = GetIconImage("Test_Form.Resources.Construction.png"); break; case Icon.Email: CurrentIconImage = GetIconImage("Test_Form.Resources.Email.png"); break; case Icon.Error: CurrentIconImage = GetIconImage("Test_Form.Resources.Error.png"); break; case Icon.FatalError: CurrentIconImage = GetIconImage("Test_Form.Resources.FatalError.png"); break; case Icon.Instruction: CurrentIconImage = GetIconImage("Test_Form.Resources.Instruction.png"); break; case Icon.Question: CurrentIconImage = GetIconImage("Test_Form.Resources.Question.png"); break; case Icon.Telephon: CurrentIconImage = GetIconImage("Test_Form.Resources.Telephon.png"); break; case Icon.Tips: CurrentIconImage = GetIconImage("Test_Form.Resources.Tips.png"); break; case Icon.Warning: CurrentIconImage = GetIconImage("Test_Form.Resources.Warning.png"); break; default: CurrentIconImage = GetIconImage("Test_Form.Resources.Information.png"); break; } CurrentIcon = icon; return CurrentIconImage; } private Bitmap GetIconImage(string icon) { Assembly myAssembly = Assembly.GetExecutingAssembly(); Stream myStream = myAssembly.GetManifestResourceStream(icon); Bitmap bmp = new Bitmap(myStream); return bmp; } } }