using System.ComponentModel; namespace Vanara.Windows.Shell { /// Wraps a resource reference used by some Shell classes. public abstract class IndirectResource { /// Initializes a new instance of the class. public IndirectResource() { } /// Initializes a new instance of the class. /// The module file name. /// /// If this number is positive, this is the index of the resource in the module file. If negative, the absolute value of the number /// is the resource ID of the resource in the module file. /// public IndirectResource(string module, int resourceIdOrIndex) { ModuleFileName = module; ResourceId = resourceIdOrIndex; } /// Returns true if this location is valid. /// true if this location is valid; otherwise, false. [Browsable(false)] public virtual bool IsValid => ResourceId != 0 && System.IO.File.Exists(ModuleFileName); /// Gets or sets the module file name. /// The module file name. public string ModuleFileName { get; set; } /// Gets or sets the resource index or resource ID. /// /// If this number is positive, this is the index of the resource in the module file. If negative, the absolute value of the number /// is the resource ID of the icon in the module file. /// public int ResourceId { get; set; } /// Returns a that represents this instance. /// A that represents this instance. public override string ToString() => IsValid ? $"@{ModuleFileName},{ResourceId}" : string.Empty; } }