private void EnsureShortcutUtility() { if (ShortcutUtility == null) { ShortcutUtility = new ShortcutUtility(); } }
///// <summary> ///// The height of the image in piexels. ///// </summary> //public int Height { get; private set; } ///// <summary> ///// The width of the image in pixels. ///// </summary> //public int Width { get; private set; } ///// <summary> ///// The image aspect ratio: width / height. ///// </summary> //public double AspectRatio { get; private set; } ///// <summary> ///// True if the image's height is greater than or equal to the width. ///// </summary> //public bool IsTall { get; private set; } ///// <summary> ///// True if the image's width is greater than or equal to the height. ///// </summary> //public bool IsWide { get; private set; } /// <summary> /// Constructs an instance of the class. Can be used with image or .lnk files. /// </summary> /// <param name="file">The image file or .lnk file.</param> /// <param name="shortcutUtility">An instance of ShortcutUtility for resolving shortcuts.</param> public ImageItem(FileInfo file, ShortcutUtility shortcutUtility = null) { FileInfo = file; FileExists = file.Exists; if (FileExists) { IsLink = file.Extension.ToLower() == ".lnk"; if (IsLink) { if (shortcutUtility == null) { throw new Exception("You must specify a ShortcutUtility when passing in a link."); } TargetFileInfo = shortcutUtility.ResolveShortcut(file); TargetExists = TargetFileInfo.Exists; if (TargetExists) { SetImageProperties(TargetFileInfo); } } else { SetImageProperties(FileInfo); } } }