From 494c2b6d82587cd02dde2ea3271d43ff6dcd2046 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Fri, 15 Dec 2017 14:55:10 -0800 Subject: [PATCH] Remove redundant helper method --- ApplicationView/ApplicationController.cs | 16 ++++++++-------- Library/ContentProviders/MeshContentProvider.cs | 2 +- Library/Providers/LibraryProviderHelpers.cs | 6 ------ Library/Providers/SDCard/SDCardContainer.cs | 4 +++- Library/Providers/Zip/LocalZipContainerLink.cs | 3 ++- Library/Widgets/ListView/ListViewItemBase.cs | 7 ++++--- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index fb4df1281..ee8ff2c8a 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -386,7 +386,7 @@ namespace MatterHackers.MatterControl this.Library.RegisterRootProvider( new DynamicContainerLink( () => "Downloads".Localize(), - LibraryProviderHelpers.LoadInvertIcon("FileDialog", "download_folder.png"), + AggContext.StaticData.LoadIcon(Path.Combine("FileDialog", "download_folder.png")), () => new FileSystemContainer(ApplicationDataStorage.Instance.DownloadsDirectory) { UseIncrementedNameDuringTypeChange = true @@ -396,7 +396,7 @@ namespace MatterHackers.MatterControl this.Library.RegisterRootProvider( new DynamicContainerLink( () => "Calibration Parts".Localize(), - LibraryProviderHelpers.LoadInvertIcon("FileDialog", "folder.png"), + AggContext.StaticData.LoadIcon(Path.Combine("FileDialog", "folder.png")), () => new CalibrationPartsContainer()) { IsReadOnly = true @@ -405,7 +405,7 @@ namespace MatterHackers.MatterControl this.Library.RegisterRootProvider( new DynamicContainerLink( () => "Print Queue".Localize(), - LibraryProviderHelpers.LoadInvertIcon("FileDialog", "queue_folder.png"), + AggContext.StaticData.LoadIcon(Path.Combine("FileDialog", "queue_folder.png")), () => new PrintQueueContainer())); var rootLibraryCollection = Datastore.Instance.dbSQLite.Table().Where(v => v.Name == "_library").Take(1).FirstOrDefault(); @@ -414,7 +414,7 @@ namespace MatterHackers.MatterControl this.Library.RegisterRootProvider( new DynamicContainerLink( () => "Local Library".Localize(), - LibraryProviderHelpers.LoadInvertIcon("FileDialog", "library_folder.png"), + AggContext.StaticData.LoadIcon(Path.Combine("FileDialog", "library_folder.png")), () => new SqliteLibraryContainer(rootLibraryCollection.Id))); } @@ -422,7 +422,7 @@ namespace MatterHackers.MatterControl this.Library.RegisterRootProvider( new DynamicContainerLink( () => "Print History".Localize(), - LibraryProviderHelpers.LoadInvertIcon("FileDialog", "folder.png"), + AggContext.StaticData.LoadIcon(Path.Combine("FileDialog", "folder.png")), () => new PrintHistoryContainer()) { IsReadOnly = true @@ -433,7 +433,7 @@ namespace MatterHackers.MatterControl // Add each path defined in the CustomLibraryFolders file as a new FileSystemContainerItem foreach (string directory in File.ReadLines(ApplicationDataStorage.Instance.CustomLibraryFoldersPath)) { - if (Directory.Exists(directory)) + //if (Directory.Exists(directory)) { this.Library.RegisterRootProvider( new FileSystemContainer.DirectoryContainerLink(directory) @@ -447,7 +447,7 @@ namespace MatterHackers.MatterControl this.Library.RegisterRootProvider( new DynamicContainerLink( () => "SD Card".Localize(), - LibraryProviderHelpers.LoadInvertIcon("FileDialog", "sd_folder.png"), + AggContext.StaticData.LoadIcon(Path.Combine("FileDialog", "sd_folder.png")), () => new SDCardContainer(), () => { @@ -466,7 +466,7 @@ namespace MatterHackers.MatterControl this.Library.RegisterRootProvider( new DynamicContainerLink( () => "Plating History".Localize(), - LibraryProviderHelpers.LoadInvertIcon("FileDialog", "folder.png"), + AggContext.StaticData.LoadIcon(Path.Combine("FileDialog", "folder.png")), () => ApplicationController.Instance.Library.PlatingHistory)); } diff --git a/Library/ContentProviders/MeshContentProvider.cs b/Library/ContentProviders/MeshContentProvider.cs index 294a786bc..460b6d1e7 100644 --- a/Library/ContentProviders/MeshContentProvider.cs +++ b/Library/ContentProviders/MeshContentProvider.cs @@ -150,7 +150,7 @@ namespace MatterHackers.MatterControl } } - public ImageBuffer DefaultImage => LibraryProviderHelpers.LoadInvertIcon("mesh.png"); + public ImageBuffer DefaultImage => AggContext.StaticData.LoadIcon("mesh.png"); private static bool MeshIsTooBigToLoad(string fileLocation) { diff --git a/Library/Providers/LibraryProviderHelpers.cs b/Library/Providers/LibraryProviderHelpers.cs index 307921137..1ea9540f0 100644 --- a/Library/Providers/LibraryProviderHelpers.cs +++ b/Library/Providers/LibraryProviderHelpers.cs @@ -39,12 +39,6 @@ namespace MatterHackers.MatterControl.Library { public static class LibraryProviderHelpers { - - public static ImageBuffer LoadInvertIcon(params string[] pathSegments) - { - return AggContext.StaticData.LoadIcon(Path.Combine(pathSegments)); //.InvertLightness(); - } - public static void RenderCentered(this Graphics2D graphics2D, ImageBuffer imageBuffer, double width, double height) { int targetWidth = graphics2D.DestImage.Width; diff --git a/Library/Providers/SDCard/SDCardContainer.cs b/Library/Providers/SDCard/SDCardContainer.cs index b5713932a..5744a5ed2 100644 --- a/Library/Providers/SDCard/SDCardContainer.cs +++ b/Library/Providers/SDCard/SDCardContainer.cs @@ -29,10 +29,12 @@ either expressed or implied, of the FreeBSD Project. using System; using System.Collections.Generic; +using System.IO; using System.Threading; using System.Threading.Tasks; using MatterHackers.Agg; using MatterHackers.Agg.Image; +using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; using MatterHackers.Localizations; @@ -78,7 +80,7 @@ namespace MatterHackers.MatterControl.Library public override Task GetThumbnail(ILibraryItem item, int width, int height) { bool largeIcon = width > 50 || height > 50; - var thumbnail = LibraryProviderHelpers.LoadInvertIcon(largeIcon ? "icon_sd_card_115x115.png" : "icon_sd_card_50x50.png"); + var thumbnail = AggContext.StaticData.LoadIcon(Path.Combine(largeIcon ? "icon_sd_card_115x115.png" : "icon_sd_card_50x50.png")); return Task.FromResult(thumbnail); } diff --git a/Library/Providers/Zip/LocalZipContainerLink.cs b/Library/Providers/Zip/LocalZipContainerLink.cs index e2ee5e652..06a527520 100644 --- a/Library/Providers/Zip/LocalZipContainerLink.cs +++ b/Library/Providers/Zip/LocalZipContainerLink.cs @@ -32,6 +32,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; using MatterHackers.Agg.Image; +using MatterHackers.Agg.Platform; namespace MatterHackers.MatterControl.Library { @@ -41,7 +42,7 @@ namespace MatterHackers.MatterControl.Library static LocalZipContainerLink() { - thumbnail = LibraryProviderHelpers.LoadInvertIcon("FileDialog", "folder_zip.png"); + thumbnail = AggContext.StaticData.LoadIcon(System.IO.Path.Combine("FileDialog", "folder_zip.png")); } public bool IsReadOnly { get; } = false; diff --git a/Library/Widgets/ListView/ListViewItemBase.cs b/Library/Widgets/ListView/ListViewItemBase.cs index 0674aaa2a..02442f592 100644 --- a/Library/Widgets/ListView/ListViewItemBase.cs +++ b/Library/Widgets/ListView/ListViewItemBase.cs @@ -32,6 +32,7 @@ using System.IO; using System.Threading.Tasks; using MatterHackers.Agg; using MatterHackers.Agg.Image; +using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; using MatterHackers.Agg.VertexSource; using MatterHackers.MatterControl.Library; @@ -42,9 +43,9 @@ namespace MatterHackers.MatterControl.CustomWidgets { public class ListViewItemBase : GuiWidget { - private static ImageBuffer defaultFolderIcon = LibraryProviderHelpers.LoadInvertIcon("FileDialog", "folder.png"); - private static ImageBuffer defaultItemIcon = LibraryProviderHelpers.LoadInvertIcon("FileDialog", "file.png"); - private static ImageBuffer generatingThumbnailIcon = LibraryProviderHelpers.LoadInvertIcon("building_thumbnail_40x40.png"); + private static ImageBuffer defaultFolderIcon = AggContext.StaticData.LoadIcon(Path.Combine("FileDialog", "folder.png")); + private static ImageBuffer defaultItemIcon = AggContext.StaticData.LoadIcon(Path.Combine("FileDialog", "file.png")); + private static ImageBuffer generatingThumbnailIcon = AggContext.StaticData.LoadIcon(Path.Combine("building_thumbnail_40x40.png")); protected ListViewItem listViewItem; protected View3DWidget view3DWidget;