private void RegisterStatusIcon(Icon icon) { if (icon != Icon.None) { this.ResourceManager.RegisterClientStyleBlock(icon.ToString() + "-sbar", this.GetIconClass(icon)); } }
/// <include file='doc\IconConverter.uex' path='docs/doc[@for="IconConverter.ConvertTo"]/*' /> /// <devdoc> /// Converts the given object to another type. The most common types to convert /// are to and from a string object. The default implementation will make a call /// to ToString on the object if the object is valid and if the destination /// type is string. If this cannot convert to the desitnation type, this will /// throw a NotSupportedException. /// </devdoc> public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(string)) { if (value != null) { // should do something besides ToString() the image...go get // the filename Icon image = (Icon)value; return(image.ToString()); } else { return(SR.GetString(SR.toStringNone)); } } else if (destinationType == typeof(byte[])) { if (value != null) { MemoryStream ms = new MemoryStream(); Icon icon = (Icon)value; icon.Save(ms); ms.Close(); return(ms.ToArray()); } else { return(new byte[0]); } } return(base.ConvertTo(context, culture, value, destinationType)); }
public void SetUp () { icon = new Icon (TestBitmap.getInFile ("bitmaps/VisualPng.ico")); iconStr = icon.ToString (); icoConv = new IconConverter(); icoConvFrmTD = (IconConverter) TypeDescriptor.GetConverter (icon); Stream stream = new FileStream (TestBitmap.getInFile ("bitmaps/VisualPng1.ico"), FileMode.Open); int length = (int) stream.Length; iconBytes = new byte [length]; try { if (stream.Read (iconBytes, 0, length) != length) Assert.Fail ("SU#1: Read Failure"); } catch (Exception e) { Assert.Fail ("SU#2 Exception thrown while reading. Exception is: "+e.Message); } finally { stream.Close (); } stream.Close (); }
public static string GetIconClassName(Icon icon) { return (icon != Icon.None) ? string.Format("icon-{0}-sbar", icon.ToString().ToLowerInvariant()) : ""; }
/// <summary> /// Sets the CSS class that provides a background image to use as the button's icon. This method also changes the value of the iconCls config internally. /// </summary> protected virtual void SetIconClass(Icon icon) { if (this.Icon != Icon.None) { this.SetIconClass("#" + icon.ToString()); } else { this.SetIconClass(""); } }
/// <summary> /// Sets the CSS class that provides a background image to use as the button's icon. This method also changes the value of the iconCls config internally. /// </summary> /// <param name="icon">New icon</param> protected virtual void SetIconCls(Icon icon) { this.SetIconCls(this.Icon != Icon.None ? "#" + icon.ToString() : ""); }