From 1e4c1bbd8542001d737ddb7f0f0e69e69e12101d Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 23 May 2019 08:21:24 -0700 Subject: [PATCH 1/5] Remove discarded path --- MatterControlLib/DataStorage/ApplicationDataStorage.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/MatterControlLib/DataStorage/ApplicationDataStorage.cs b/MatterControlLib/DataStorage/ApplicationDataStorage.cs index b9a34906a..285b99157 100644 --- a/MatterControlLib/DataStorage/ApplicationDataStorage.cs +++ b/MatterControlLib/DataStorage/ApplicationDataStorage.cs @@ -72,7 +72,6 @@ namespace MatterHackers.MatterControl.DataStorage private static string _applicationLibraryDataPath => Path.Combine(_applicationUserDataPath, "Library"); private static string _libraryAssetPath => Path.Combine(_applicationLibraryDataPath, "Assets"); private static string _platingDirectory => Path.Combine(_applicationLibraryDataPath, "Plating"); - private static string _partHistoryDirectory => Path.Combine(_applicationLibraryDataPath, "PartHistory"); private static string _applicationTempDataPath => Path.Combine(_applicationUserDataPath, "data", "temp"); private static string _gcodeOutputPath => Path.Combine(_applicationTempDataPath, "gcode"); private static string _cacheDirectory => Path.Combine(_applicationTempDataPath, "cache"); @@ -89,8 +88,6 @@ namespace MatterHackers.MatterControl.DataStorage public string PlatingDirectory => EnsurePath(_platingDirectory); - public string PartHistoryDirectory => EnsurePath(_partHistoryDirectory); - public string GCodeOutputPath => EnsurePath(_gcodeOutputPath); public string CacheDirectory => EnsurePath(_cacheDirectory); From 3c15b99d6140edd5575bd654515344fbc2f32b60 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 23 May 2019 08:28:50 -0700 Subject: [PATCH 2/5] Fix warnings --- .../DataStorage/ApplicationDataStorage.cs | 35 +++++++++++++------ MatterControlLib/DataStorage/Datastore.cs | 17 ++++----- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/MatterControlLib/DataStorage/ApplicationDataStorage.cs b/MatterControlLib/DataStorage/ApplicationDataStorage.cs index 285b99157..04b0fd4e9 100644 --- a/MatterControlLib/DataStorage/ApplicationDataStorage.cs +++ b/MatterControlLib/DataStorage/ApplicationDataStorage.cs @@ -28,19 +28,25 @@ either expressed or implied, of the FreeBSD Project. */ using System; +using System.Diagnostics.CodeAnalysis; using System.IO; namespace MatterHackers.MatterControl.DataStorage { + [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Private getters used to enforce presence of directories")] public class ApplicationDataStorage { - public bool FirstRun = false; + // Required by Android + public bool FirstRun { get; set; } = false; - //Describes the location for storing all local application data + // Describes the location for storing all local application data private static ApplicationDataStorage globalInstance; - private const string applicationDataFolderName = "MatterControl"; - private const string datastoreName = "MatterControl.db"; + private const string ApplicationDataFolderName = "MatterControl"; + + private const string DatastoreName = "MatterControl.db"; + + private string _applicationPath; public static ApplicationDataStorage Instance { @@ -50,11 +56,11 @@ namespace MatterHackers.MatterControl.DataStorage { globalInstance = new ApplicationDataStorage(); } + return globalInstance; } } - private string _applicationPath; public string ApplicationPath { get @@ -68,12 +74,18 @@ namespace MatterHackers.MatterControl.DataStorage } } - private static string _applicationUserDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), applicationDataFolderName); + private static string _applicationUserDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), ApplicationDataFolderName); + private static string _applicationLibraryDataPath => Path.Combine(_applicationUserDataPath, "Library"); + private static string _libraryAssetPath => Path.Combine(_applicationLibraryDataPath, "Assets"); + private static string _platingDirectory => Path.Combine(_applicationLibraryDataPath, "Plating"); + private static string _applicationTempDataPath => Path.Combine(_applicationUserDataPath, "data", "temp"); + private static string _gcodeOutputPath => Path.Combine(_applicationTempDataPath, "gcode"); + private static string _cacheDirectory => Path.Combine(_applicationTempDataPath, "cache"); private static string _webCacheDirectory => Path.Combine(_applicationTempDataPath, "WebCache"); @@ -99,20 +111,20 @@ namespace MatterHackers.MatterControl.DataStorage public string CustomLibraryFoldersPath => Path.Combine(_applicationUserDataPath, "LibraryFolders.conf"); /// - /// Returns the path to the sqlite database + /// Gets the path to the Sqlite database /// - /// - public string DatastorePath => Path.Combine(EnsurePath(_applicationUserDataPath), datastoreName); + /// The path toe Sqlite database + public string DatastorePath => Path.Combine(EnsurePath(_applicationUserDataPath), DatastoreName); /// - /// Returns the public storage folder (ex. download folder on Android) + /// Gets or sets the public storage folder (ex. download folder on Android) /// public string PublicDataStoragePath { get; set; } /// /// Invokes CreateDirectory on all paths, creating if missing, before returning /// - /// + /// Returns the path to the given directory private static string EnsurePath(string fullPath) { Directory.CreateDirectory(fullPath); @@ -123,6 +135,7 @@ namespace MatterHackers.MatterControl.DataStorage /// Overrides the AppData location. Used by tests to set a non-standard AppData location /// /// The new AppData path. + /// The Sqlite generator with platform specific bindings internal void OverrideAppDataLocation(string path, Func sqliteBuilder) { Console.WriteLine(" Overriding ApplicationUserDataPath: " + path); diff --git a/MatterControlLib/DataStorage/Datastore.cs b/MatterControlLib/DataStorage/Datastore.cs index b5c89202a..a23bcc116 100644 --- a/MatterControlLib/DataStorage/Datastore.cs +++ b/MatterControlLib/DataStorage/Datastore.cs @@ -31,21 +31,20 @@ using System; using System.Collections.Generic; using System.IO; using System.Threading; -using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; namespace MatterHackers.MatterControl.DataStorage { public class Datastore { - bool wasExited = false; public bool ConnectionError = false; + private bool wasExited = false; public ISQLite dbSQLite; private string datastoreLocation = ApplicationDataStorage.Instance.DatastorePath; private static Datastore globalInstance; private ApplicationSession activeSession; - private List dataStoreTables = new List + private readonly List dataStoreTables = new List { typeof(PrintItemCollection), typeof(PrinterSetting), @@ -76,6 +75,7 @@ namespace MatterHackers.MatterControl.DataStorage { globalInstance = new Datastore(); } + return globalInstance; } @@ -85,6 +85,7 @@ namespace MatterHackers.MatterControl.DataStorage globalInstance = value; } } + public void Exit() { if (wasExited) @@ -94,10 +95,10 @@ namespace MatterHackers.MatterControl.DataStorage wasExited = true; - if (this.activeSession != null) + if (activeSession != null) { - this.activeSession.SessionEnd = DateTime.Now; - this.activeSession.Commit(); + activeSession.SessionEnd = DateTime.Now; + activeSession.Commit(); } // lets wait a bit to make sure the commit has resolved. @@ -122,7 +123,7 @@ namespace MatterHackers.MatterControl.DataStorage } } - //Run initial checks and operations on sqlite datastore + // Run initial checks and operations on sqlite datastore public void Initialize(ISQLite dbSQLite) { this.dbSQLite = dbSQLite; @@ -148,7 +149,7 @@ namespace MatterHackers.MatterControl.DataStorage return Convert.ToInt32(result); } - //Begins new application session record + // Begins new application session record private void StartSession() { activeSession = new ApplicationSession(); From a3700ba8cba7f79d455332cc872c20537401b65d Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 23 May 2019 08:36:11 -0700 Subject: [PATCH 3/5] Remove unused members --- MatterControlLib/DataStorage/Datastore.cs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/MatterControlLib/DataStorage/Datastore.cs b/MatterControlLib/DataStorage/Datastore.cs index a23bcc116..688952461 100644 --- a/MatterControlLib/DataStorage/Datastore.cs +++ b/MatterControlLib/DataStorage/Datastore.cs @@ -37,7 +37,6 @@ namespace MatterHackers.MatterControl.DataStorage { public class Datastore { - public bool ConnectionError = false; private bool wasExited = false; public ISQLite dbSQLite; private string datastoreLocation = ApplicationDataStorage.Instance.DatastorePath; @@ -156,18 +155,6 @@ namespace MatterHackers.MatterControl.DataStorage dbSQLite.Insert(activeSession); } - private void GenerateSampleData() - { - for (int index = 1; index <= 5; index++) - { - Printer printer = new Printer(); - printer.ComPort = string.Format("COM{0}", index); - printer.BaudRate = "250000"; - printer.Name = string.Format("Printer {0}", index); - Datastore.Instance.dbSQLite.Insert(printer); - } - } - // Checks if the datastore contains the appropriate tables - adds them if necessary private void ValidateSchema() { From aeb5f0de24f087d7bea0240a76a051871bf7d8aa Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 23 May 2019 08:39:27 -0700 Subject: [PATCH 4/5] Move PrintHistoryPath to ApplicationDataStorage pattern --- MatterControlLib/ApplicationView/ApplicationController.cs | 6 +----- MatterControlLib/DataStorage/ApplicationDataStorage.cs | 4 ++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index ee5b7a936..063c9cda6 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -2566,12 +2566,8 @@ namespace MatterHackers.MatterControl // Create archive point for printing attempt if (Path.GetExtension(sourcePath).ToUpper() == ".MCX") { - // TODO: We should zip mcx and settings when starting a print - string platingDirectory = Path.Combine(ApplicationDataStorage.Instance.ApplicationLibraryDataPath, "PrintHistory"); - Directory.CreateDirectory(platingDirectory); - string now = "Workspace " + DateTime.Now.ToString("yyyy-MM-dd HH_mm_ss"); - string archivePath = Path.Combine(platingDirectory, now + ".zip"); + string archivePath = Path.Combine(ApplicationDataStorage.Instance.PrintHistoryPath, now + ".zip"); string settingsFilePath = ProfileManager.Instance.ProfilePath(printer.Settings.ID); diff --git a/MatterControlLib/DataStorage/ApplicationDataStorage.cs b/MatterControlLib/DataStorage/ApplicationDataStorage.cs index 04b0fd4e9..c3ba816c9 100644 --- a/MatterControlLib/DataStorage/ApplicationDataStorage.cs +++ b/MatterControlLib/DataStorage/ApplicationDataStorage.cs @@ -88,6 +88,8 @@ namespace MatterHackers.MatterControl.DataStorage private static string _cacheDirectory => Path.Combine(_applicationTempDataPath, "cache"); + private static string _printHistoryPath => Path.Combine(_applicationLibraryDataPath, "PrintHistory"); + private static string _webCacheDirectory => Path.Combine(_applicationTempDataPath, "WebCache"); public static string ApplicationUserDataPath => EnsurePath(_applicationUserDataPath); @@ -104,6 +106,8 @@ namespace MatterHackers.MatterControl.DataStorage public string CacheDirectory => EnsurePath(_cacheDirectory); + public string PrintHistoryPath => EnsurePath(_printHistoryPath); + public string WebCacheDirectory => EnsurePath(_webCacheDirectory); public string DownloadsDirectory { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads"); From 31b460d13e9291f77ae0378050c3c109857a8267 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 23 May 2019 09:46:17 -0700 Subject: [PATCH 5/5] Remove unused return value variable --- MatterControlLib/PartPreviewWindow/View3D/InteractionLayer.cs | 2 +- Submodules/agg-sharp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MatterControlLib/PartPreviewWindow/View3D/InteractionLayer.cs b/MatterControlLib/PartPreviewWindow/View3D/InteractionLayer.cs index 982ed0657..0cec779a2 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/InteractionLayer.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/InteractionLayer.cs @@ -111,7 +111,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow graphics2D.Clear(Color.White); graphics2D.FillRectangle(0, 0, ViewOnlyTexture.Width / 2, ViewOnlyTexture.Height, Color.LightGray); // request the texture so we can set it to repeat - var plugin = ImageGlPlugin.GetImageGlPlugin(ViewOnlyTexture, true, true, false); + ImageGlPlugin.GetImageGlPlugin(ViewOnlyTexture, true, true, false); }); } diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 14a7b7033..f78e55d7e 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 14a7b70331b8001ff55e46363d973ee95e4cac5c +Subproject commit f78e55d7e1f027eafd9c6808bbb3587f3b0abda4