Simplify GetIcon function.
authorStephaneLenclud
Thu, 21 Jan 2016 15:00:05 +0100
changeset 1789eb93d079a3e
parent 177 c24dc0c6b64b
child 179 533eb8a80d56
Simplify GetIcon function.
Server/MainForm.cs
     1.1 --- a/Server/MainForm.cs	Fri Jan 01 00:45:18 2016 +0100
     1.2 +++ b/Server/MainForm.cs	Thu Jan 21 15:00:05 2016 +0100
     1.3 @@ -578,23 +578,20 @@
     1.4  			iNotifyIcon.ContextMenu = contextMenu;
     1.5  		}
     1.6  
     1.7 -		/// <summary>
     1.8 -		/// Access icons from embedded resources.
     1.9 -		/// </summary>
    1.10 -		/// <param name="name"></param>
    1.11 -		/// <returns></returns>
    1.12 -		public static Icon GetIcon(string name)
    1.13 +        /// <summary>
    1.14 +        /// Access icons from embedded resources.
    1.15 +        /// </summary>
    1.16 +        /// <param name="aName"></param>
    1.17 +        /// <returns></returns>
    1.18 +        public static Icon GetIcon(string aName)
    1.19  		{
    1.20 -			name = "SharpDisplayManager.Resources." + name;
    1.21 -
    1.22 -			string[] names =
    1.23 -			  Assembly.GetExecutingAssembly().GetManifestResourceNames();
    1.24 -			for (int i = 0; i < names.Length; i++)
    1.25 +			string[] names =  Assembly.GetExecutingAssembly().GetManifestResourceNames();
    1.26 +			foreach (string name in names)
    1.27  			{
    1.28 -				if (names[i].Replace('\\', '.') == name)
    1.29 +                //Find a resource name that ends with the given name
    1.30 +				if (name.EndsWith(aName))
    1.31  				{
    1.32 -					using (Stream stream = Assembly.GetExecutingAssembly().
    1.33 -					  GetManifestResourceStream(names[i]))
    1.34 +					using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name))
    1.35  					{
    1.36  						return new Icon(stream);
    1.37  					}