Habanero.Faces.Win.FormWin.SetIcon C# (CSharp) Method

SetIcon() public method

public SetIcon ( string resourceName ) : void
resourceName string
return void
        public void SetIcon(string resourceName)
        {
            var form = this as Form;
            if (form == null) return;
            var s = ResourceStreamer.GetResourceStreamByName(resourceName);
            if (s == null) return;

            try
            {
                var bmp = new Bitmap(Image.FromStream(s));
                var resized = ImageUtil.ResizeBitmap(bmp, 32);

                form.Icon = Icon.FromHandle(resized.GetHicon());
            }
            catch (Exception ex)
            {
                Trace.WriteLine(String.Join("", new string[] 
                    { "Unable to load resource by name for form icon: ", resourceName, "\n", ex.Message, "\n", ex.StackTrace}));
            }
        }
    }