From f8488cad8e39cd09de1eb5ed774657cf8d04efec Mon Sep 17 00:00:00 2001 From: John Lewin Date: Sun, 29 Apr 2018 10:58:41 -0700 Subject: [PATCH] Extract PlatingHistory functionality for reuse in Part History --- .../MatterControl/PlatingHistoryContainer.cs | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Library/Providers/MatterControl/PlatingHistoryContainer.cs b/Library/Providers/MatterControl/PlatingHistoryContainer.cs index ac6430ff5..f701feca6 100644 --- a/Library/Providers/MatterControl/PlatingHistoryContainer.cs +++ b/Library/Providers/MatterControl/PlatingHistoryContainer.cs @@ -32,21 +32,34 @@ using System.Collections.Generic; using System.IO; using System.Linq; using MatterHackers.Agg.Image; +using MatterHackers.Agg.Platform; using MatterHackers.DataConverters3D; using MatterHackers.Localizations; using MatterHackers.MatterControl.DataStorage; namespace MatterHackers.MatterControl.Library { - public class PlatingHistoryContainer : LibraryContainer, ILibraryWritableContainer + public class PlatingHistoryContainer : HistoryContainerBase { public PlatingHistoryContainer() + { + this.Name = "Plating History".Localize(); + this.FullPath = ApplicationDataStorage.Instance.PlatingDirectory; + } + } + + public class HistoryContainerBase : LibraryContainer, ILibraryWritableContainer + { + public HistoryContainerBase() { this.ChildContainers = new List(); this.Items = new List(); - this.Name = "Plating History".Localize(); } + public string FullPath { get; protected set; } + + public int PageSize { get; set; } = 25; + public event EventHandler ItemContentChanged; public void Add(IEnumerable items) @@ -74,8 +87,8 @@ namespace MatterHackers.MatterControl.Library public override void Load() { // Select the 25 most recent files and project onto FileSystemItems - var recentFiles = new DirectoryInfo(ApplicationDataStorage.Instance.PlatingDirectory).GetFiles("*.mcx").OrderByDescending(f => f.LastWriteTime); - Items = recentFiles.Take(25).Select(f => new SceneReplacementFileItem(f.FullName)).ToList(); + var recentFiles = new DirectoryInfo(this.FullPath).GetFiles("*.mcx").OrderByDescending(f => f.LastWriteTime); + Items = recentFiles.Take(this.PageSize).Select(f => new SceneReplacementFileItem(f.FullName)).ToList(); } public void Move(IEnumerable items, ILibraryWritableContainer targetContainer)