From 97722fbe9d474adffbba0b92e9727c48a8205234 Mon Sep 17 00:00:00 2001 From: John T Date: Sat, 11 Nov 2017 08:53:55 -0500 Subject: Only 1/4 broken ShiftFS and WIP File Skimmer --- ShiftOS.Engine/Misc/Tools.cs | 75 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 4 deletions(-) (limited to 'ShiftOS.Engine/Misc/Tools.cs') diff --git a/ShiftOS.Engine/Misc/Tools.cs b/ShiftOS.Engine/Misc/Tools.cs index 6430084..11f4761 100644 --- a/ShiftOS.Engine/Misc/Tools.cs +++ b/ShiftOS.Engine/Misc/Tools.cs @@ -1,18 +1,25 @@ using System; +using System.Diagnostics; using System.Drawing; +using System.Linq; using System.Runtime.InteropServices; +using System.Windows.Forms; +using ShiftOS.Engine.Properties; +using ShiftOS.Engine.ShiftFS; +using ShiftOS.Engine.WindowManager; namespace ShiftOS.Engine.Misc { /// - /// Random class full of unassorted [but also uncategorizable] tools. + /// Random class full of unassorted [but also uncategorizable] tools. /// public static class Tools { public static Random Rnd = new Random(); - [DllImport("user32.dll", CharSet = CharSet.Auto)] - public static extern bool DestroyIcon(IntPtr handle); + //I wanna DESTROY this method + [DllImport("user32.dll")] + static extern bool DestroyIcon(IntPtr handle); public static Icon ToIcon(this Bitmap bm) { @@ -22,8 +29,68 @@ namespace ShiftOS.Engine.Misc //for some reason this exists DestroyIcon(tempicon.Handle); - + tempicon.Dispose(); + return newIcon; } + + public static void DisplayShiftFolder(this ListView list, ShiftDirectory dir) + { + var dirs = dir.OfType().ToArray(); + for (var i = 0; i < dirs.Length; i++) + { + list.Items.Add( + new ListViewItem + { + Text = dirs[i].Name, + ImageIndex = i, + StateImageIndex = i, + ImageKey = dirs[i].Guid.ToString(), + Tag = dirs[i] + }); + + list.StateImageList.Images.Add(dirs[i].Guid.ToString(), Resources.iconFileOpener_fw); + } + + var items = dir.OfType().ToArray(); + for (var i = 0; i < items.Length; i++) + { + list.Items.Add( + new ListViewItem + { + Text = items[i].Name, + ImageIndex = i, + StateImageIndex = i, + ImageKey = items[i].Guid.ToString(), + Tag = items[i], + }); + + list.StateImageList.Images.Add(items[i].Guid.ToString(), items[i].Icon ?? Resources.iconFileOpener_fw); + } + } + + public static void ShowDrivesList(this ListView list, ShiftWindow window = null) + { + var imageList = new ImageList(); + list.SmallImageList = imageList; + list.LargeImageList = imageList; + list.StateImageList = imageList; + + for (var i = 0; i < ShiftFS.ShiftFS.Drives.Count; i++) + { + list.Items.Add( + new ListViewItem + { + Text = $"{ShiftFS.ShiftFS.Drives[i].Name} ({ShiftFS.ShiftFS.Drives[i].Letter})", + ImageIndex = i, + StateImageIndex = i, + ImageKey= ShiftFS.ShiftFS.Drives[i].Guid.ToString(), + Tag = ShiftFS.ShiftFS.Drives[i] + }); + + list.StateImageList.Images.Add(ShiftFS.ShiftFS.Drives[i].Guid.ToString(), window?.Icon.ToBitmap() ?? Resources.ArtPadsave); + } + } + } } \ No newline at end of file -- cgit v1.2.3