- taskmanager.zip
- TaskManager
- Core
- AppRestartRecovery
- Core.csproj
- Dialogs
- Common
- TaskDialogs
- Interop
- NetworkList
- PowerManagement
- Properties
- PropertySystem
- SafeHandles
- Shell
- Common
- CommonFileDialogs
- Controls
- Design
- ShellObjects.cd
- ShellThumbnailClassDiagram.cd
- DesktopWindowManager
- ExplorerBrowser
- Interop
- Common
- Dialogs
- ExplorerBrowser
- KnownFolders
- PropertySystem
- StockIcons
- Taskbar
- KnownFolders
- Properties
- PropertySystem
- Shell.csproj
- StockIcons
- Taskbar
- TaskManager.sln
- TaskManager
- taskmanagersimple.zip
- TaskManagerSimple
|
//Copyright (c) Microsoft Corporation. All rights reserved.
using System;
namespace Microsoft.WindowsAPICodePack.Shell
{
/// <summary>
/// A refence to an icon resource
/// </summary>
public struct IconReference
{
#region Private members
private string moduleName;
private int resourceId;
private string referencePath;
static private char[] commaSeparator = new char[] { ',' };
#endregion
/// <summary>
/// Overloaded constructor takes in the module name and resource id for the icon reference.
/// </summary>
/// <param name="moduleName">String specifying the name of an executable file, DLL, or icon file</param>
/// <param name="resourceId">Zero-based index of the icon</param>
public IconReference(string moduleName, int resourceId)
{
if (string.IsNullOrEmpty(moduleName))
throw new ArgumentNullException("moduleName", "Module name cannot be null or empty string");
this.moduleName = moduleName;
this.resourceId = resourceId;
referencePath = moduleName + "," + resourceId;
}
/// <summary>
/// Overloaded constructor takes in the module name and resource id separated by a comma.
/// </summary>
/// <param name="refPath">Reference path for the icon consiting of the module name and resource id.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.Int32.Parse(System.String)", Justification = "We are not currently handling globalization or localization")]
public IconReference(string refPath)
{
if (string.IsNullOrEmpty(refPath))
throw new ArgumentNullException("refPath", "Reference path cannot be null or empty string");
string[] refParams = refPath.Split(commaSeparator);
if (refParams.Length != 2 || string.IsNullOrEmpty(refParams[0]) || string.IsNullOrEmpty(refParams[1]))
throw new ArgumentException("Reference path is invalid.");
moduleName = refParams[0];
resourceId = int.Parse(refParams[1]);
this.referencePath = refPath;
}
/// <summary>
/// String specifying the name of an executable file, DLL, or icon file
/// </summary>
public string ModuleName
{
get
{
return moduleName;
}
set
{
if (string.IsNullOrEmpty(value))
throw new ArgumentNullException("value", "Module name cannot be null or empty string");
moduleName = value;
}
}
/// <summary>
/// Zero-based index of the icon
/// </summary>
public int ResourceId
{
get
{
return resourceId;
}
set
{
resourceId = value;
}
}
/// <summary>
/// Reference to a specific icon within a EXE, DLL or icon file.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.Int32.Parse(System.String)", Justification = "We are not currently handling globalization or localization")]
public string ReferencePath
{
get
{
return referencePath;
}
set
{
if (string.IsNullOrEmpty(value))
throw new ArgumentNullException("value", "Reference path cannot be null or empty string");
string[] refParams = value.Split(commaSeparator);
if (refParams.Length != 2 || string.IsNullOrEmpty(refParams[0]) || string.IsNullOrEmpty(refParams[1]))
throw new ArgumentException("Reference path is invalid.");
ModuleName = refParams[0];
ResourceId = int.Parse(refParams[1]);
referencePath = value;
}
}
}
}
|
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.