diff --git a/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/Controls/DocumentTypeSelector.cs b/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/Controls/DocumentTypeSelector.cs index db39648d..4753c91d 100644 --- a/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/Controls/DocumentTypeSelector.cs +++ b/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/Controls/DocumentTypeSelector.cs @@ -17,8 +17,8 @@ namespace UniversalEditor.UserInterface.WindowsForms.Controls { InitializeComponent(); - IconMethods.PopulateSystemIcons(ref imlLargeIcons); - IconMethods.PopulateSystemIcons(ref imlSmallIcons); + imlLargeIcons.PopulateSystemIcons(); + imlSmallIcons.PopulateSystemIcons(); } protected override void OnCreateControl() diff --git a/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/Controls/LocalFileSystemExplorer.cs b/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/Controls/LocalFileSystemExplorer.cs index 5e30fbc8..660ebc0c 100644 --- a/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/Controls/LocalFileSystemExplorer.cs +++ b/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/Controls/LocalFileSystemExplorer.cs @@ -17,8 +17,8 @@ namespace UniversalEditor.UserInterface.WindowsForms.Controls { InitializeComponent(); - IconMethods.PopulateSystemIcons(ref imlSmallIcons); - IconMethods.PopulateSystemIcons(ref imlLargeIcons); + imlSmallIcons.PopulateSystemIcons(); + imlLargeIcons.PopulateSystemIcons(); } public bool ShowFavorites diff --git a/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/Editor.cs b/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/Editor.cs index 6c643d2d..c22a66bb 100644 --- a/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/Editor.cs +++ b/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/Editor.cs @@ -104,7 +104,7 @@ namespace UniversalEditor.UserInterface.WindowsForms mvarLargeImageList.ColorDepth = ColorDepth.Depth32Bit; mvarLargeImageList.ImageSize = new System.Drawing.Size(32, 32); - IconMethods.PopulateSystemIcons(ref mvarLargeImageList); + mvarLargeImageList.PopulateSystemIcons(); string largeImageListPath = String.Join(System.IO.Path.DirectorySeparatorChar.ToString(), new string[] { @@ -131,7 +131,7 @@ namespace UniversalEditor.UserInterface.WindowsForms mvarSmallImageList.ColorDepth = ColorDepth.Depth32Bit; mvarSmallImageList.ImageSize = new System.Drawing.Size(16, 16); - IconMethods.PopulateSystemIcons(ref mvarSmallImageList); + mvarSmallImageList.PopulateSystemIcons(); string smallImageListPath = String.Join(System.IO.Path.DirectorySeparatorChar.ToString(), new string[] { diff --git a/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/Editors/FileSystemEditor.cs b/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/Editors/FileSystemEditor.cs index a5736578..a074dc53 100644 --- a/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/Editors/FileSystemEditor.cs +++ b/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/Editors/FileSystemEditor.cs @@ -31,8 +31,8 @@ namespace UniversalEditor.UserInterface.WindowsForms.Editors ImageList large = base.LargeImageList; ImageList small = base.SmallImageList; - IconMethods.PopulateSystemIcons(ref large); - IconMethods.PopulateSystemIcons(ref small); + large.PopulateSystemIcons(); + small.PopulateSystemIcons(); lv.LargeImageList = base.LargeImageList; lv.SmallImageList = base.SmallImageList; diff --git a/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/IconMethods.cs b/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/IconMethods.cs index 563d35da..61921219 100644 --- a/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/IconMethods.cs +++ b/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/IconMethods.cs @@ -201,50 +201,4 @@ internal static class IconMethods } return icon; } - - - public static void PopulateSystemIcons(ref System.Windows.Forms.ImageList iml) - { - switch (Environment.OSVersion.Platform) - { - case PlatformID.MacOSX: - break; - case PlatformID.Unix: - break; - case PlatformID.Win32NT: - case PlatformID.Win32S: - case PlatformID.Win32Windows: - case PlatformID.WinCE: - { - if (iml.ImageSize.Width == 16 && iml.ImageSize.Height == 16) - { - Icon iconFile = ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 0, IconSize.Small); - iml.Images.Add("generic-file", iconFile); - Icon iconDocument = ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 1, IconSize.Small); - iml.Images.Add("generic-document", iconDocument); - Icon iconApplication = ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 2, IconSize.Small); - iml.Images.Add("generic-application", iconApplication); - Icon iconFolderClosed = ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 3, IconSize.Small); - iml.Images.Add("generic-folder-closed", iconFolderClosed); - Icon iconFolderOpen = ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 4, IconSize.Small); - iml.Images.Add("generic-folder-open", iconFolderOpen); - } - else - { - Icon iconFile = ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 0, IconSize.Large); - iml.Images.Add("generic-file", iconFile); - Icon iconDocument = ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 1, IconSize.Large); - iml.Images.Add("generic-document", iconDocument); - Icon iconApplication = ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 2, IconSize.Large); - iml.Images.Add("generic-application", iconApplication); - Icon iconFolderClosed = ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 3, IconSize.Large); - iml.Images.Add("generic-folder-closed", iconFolderClosed); - Icon iconFolderOpen = ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 4, IconSize.Large); - iml.Images.Add("generic-folder-open", iconFolderOpen); - } - return; - } - } - // throw new PlatformNotSupportedException(); - } } \ No newline at end of file diff --git a/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/ImageListExtensionMethods.cs b/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/ImageListExtensionMethods.cs new file mode 100644 index 00000000..31b78422 --- /dev/null +++ b/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/ImageListExtensionMethods.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; + +namespace UniversalEditor +{ + public static class ImageListExtensionMethods + { + public static void PopulateSystemIcons(this System.Windows.Forms.TreeView tv) + { + System.Windows.Forms.ImageList iml = new System.Windows.Forms.ImageList(); + iml.ImageSize = new Size(16, 16); + iml.PopulateSystemIcons(); + + tv.ImageList = iml; + } + public static void PopulateSystemIcons(this System.Windows.Forms.ListView lv) + { + System.Windows.Forms.ImageList imlSmallIcons = new System.Windows.Forms.ImageList(); + imlSmallIcons.ImageSize = new Size(16, 16); + System.Windows.Forms.ImageList imlLargeIcons = new System.Windows.Forms.ImageList(); + imlLargeIcons.ImageSize = new Size(32, 32); + + lv.LargeImageList = imlLargeIcons; + lv.SmallImageList = imlSmallIcons; + } + public static void PopulateSystemIcons(this System.Windows.Forms.ImageList iml) + { + switch (Environment.OSVersion.Platform) + { + case PlatformID.MacOSX: + break; + case PlatformID.Unix: + break; + case PlatformID.Win32NT: + case PlatformID.Win32S: + case PlatformID.Win32Windows: + case PlatformID.WinCE: + { + if (iml.ImageSize.Width == 16 && iml.ImageSize.Height == 16) + { + Icon iconFile = IconMethods.ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 0, IconMethods.IconSize.Small); + iml.Images.Add("generic-file", iconFile); + Icon iconDocument = IconMethods.ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 1, IconMethods.IconSize.Small); + iml.Images.Add("generic-document", iconDocument); + Icon iconApplication = IconMethods.ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 2, IconMethods.IconSize.Small); + iml.Images.Add("generic-application", iconApplication); + Icon iconFolderClosed = IconMethods.ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 3, IconMethods.IconSize.Small); + iml.Images.Add("generic-folder-closed", iconFolderClosed); + Icon iconFolderOpen = IconMethods.ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 4, IconMethods.IconSize.Small); + iml.Images.Add("generic-folder-open", iconFolderOpen); + } + else + { + Icon iconFile = IconMethods.ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 0, IconMethods.IconSize.Large); + iml.Images.Add("generic-file", iconFile); + Icon iconDocument = IconMethods.ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 1, IconMethods.IconSize.Large); + iml.Images.Add("generic-document", iconDocument); + Icon iconApplication = IconMethods.ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 2, IconMethods.IconSize.Large); + iml.Images.Add("generic-application", iconApplication); + Icon iconFolderClosed = IconMethods.ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 3, IconMethods.IconSize.Large); + iml.Images.Add("generic-folder-closed", iconFolderClosed); + Icon iconFolderOpen = IconMethods.ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 4, IconMethods.IconSize.Large); + iml.Images.Add("generic-folder-open", iconFolderOpen); + } + return; + } + } + // throw new PlatformNotSupportedException(); + } + } +} diff --git a/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/UniversalEditor.UserInterface.WindowsForms.csproj b/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/UniversalEditor.UserInterface.WindowsForms.csproj index 3a8811b9..434f8a1e 100644 --- a/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/UniversalEditor.UserInterface.WindowsForms.csproj +++ b/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/UniversalEditor.UserInterface.WindowsForms.csproj @@ -128,6 +128,7 @@ + UserControl