|
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
namespace AssociatedIcons.Controls
{
[ToolboxData("<{0}:AssociatedIcon runat=server></{0}:AssociatedIcon>")]
public class AssociatedIcon : Image
{
/*****
* This control accepts a file name or file extension,
* determines the associated icon, and displays it on the page
* ***/
/// <summary>
/// Gets or sets a file name or extension (including the dot)
/// to display the associated icon
/// </summary>
public string ExtensionOrFile
{
get
{
string s = (string)ViewState["ExtensionOrFile"];
if(s == null) return "";
return s;
}
set{ ViewState["ExtensionOrFile"] = value; }
}
/// <summary>
/// Determines if the icon size will be 16x16 or 32x32 pixels
/// </summary>
public bool LargeIcon
{
get
{
object obj = ViewState["LargeIcon"];
if(obj == null) return false;
return (bool)obj;
}
set
{
ViewState["LargeIcon"] = value;
}
}
public override string ImageUrl
{
get{ return base.ImageUrl;}
set{ throw new InvalidOperationException("The ImageUrl cannot be set.");}
}
protected override void OnLoad(EventArgs e)
{
if(!Page.IsPostBack)
base.ImageUrl = IconExtractor.GetUrlToIcon(ExtensionOrFile, LargeIcon);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Sergio Pereira is a senior software developer and architect. He currently makes his services available throughout Chicago and suburbs. Sergio has always made himself proficient in mainstream Microsoft technologies and has a deep interest in emerging technologies and the software life cycle aspect of development.
Feel free to contact Sergio at sergio_pereira(AT)msn(dot)com.