From 4d300a9b685212c473e2acb24a35e8c284856269 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Fri, 14 Feb 2020 14:28:40 -0700 Subject: [PATCH] Closes #26. If specified SGD file isnt' found in User/sgd directory, we look in application/SGD directory for embedded resource file. Updates PD.Core to latest. --- PepperDashEssentials/ControlSystem.cs | 2 +- .../UI/EssentialsTouchpanelController.cs | 14 ++++++++++---- .../PepperDashEssentialsBase/Global/Global.cs | 11 +++++++++++ essentials-framework/pepperdashcore-builds | 2 +- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index e003cd54..62aee267 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -96,7 +96,7 @@ namespace PepperDash.Essentials string directoryPrefix; directoryPrefix = Crestron.SimplSharp.CrestronIO.Directory.GetApplicationRootDirectory(); - + var version = Crestron.SimplSharp.Reflection.Assembly.GetExecutingAssembly().GetName().Version; Global.SetAssemblyVersion(string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build)); diff --git a/PepperDashEssentials/UI/EssentialsTouchpanelController.cs b/PepperDashEssentials/UI/EssentialsTouchpanelController.cs index 11f720a3..df1ecdce 100644 --- a/PepperDashEssentials/UI/EssentialsTouchpanelController.cs +++ b/PepperDashEssentials/UI/EssentialsTouchpanelController.cs @@ -106,12 +106,18 @@ namespace PepperDash.Essentials Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "WARNING: Registration failed. Continuing, but panel may not function: {0}", Panel.RegistrationFailureReason); // Give up cleanly if SGD is not present. - var sgdName = Global.FilePathPrefix - + Global.DirectorySeparator + "sgd" + Global.DirectorySeparator + props.SgdFile; + var sgdName = Global.FilePathPrefix + "sgd" + Global.DirectorySeparator + props.SgdFile; if (!File.Exists(sgdName)) { - Debug.Console(0, this, "ERROR: Smart object file '{0}' not present. Exiting TSW load", sgdName); - return; + Debug.Console(0, this, "Smart object file '{0}' not present in User folder. Looking for embedded file", sgdName); + + sgdName = Global.ApplicationDirectoryPathPrefix + Global.DirectorySeparator + "SGD" + Global.DirectorySeparator + props.SgdFile; + + if (!File.Exists(sgdName)) + { + Debug.Console(0, this, "Unable to find SGD file '{0}' in User sgd or application SGD folder. Exiting touchpanel load.", sgdName); + return; + } } Panel.LoadSmartObjects(sgdName); diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs index 999191ea..4ef68066 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs @@ -26,6 +26,17 @@ namespace PepperDash.Essentials.Core /// public static string FilePathPrefix { get; private set; } + /// + /// The file path prefix to the applciation directory + /// + public static string ApplicationDirectoryPathPrefix + { + get + { + return Crestron.SimplSharp.CrestronIO.Directory.GetApplicationDirectory(); + } + } + /// /// Returns the directory separator character based on the running OS /// diff --git a/essentials-framework/pepperdashcore-builds b/essentials-framework/pepperdashcore-builds index acebe6b4..27a665b6 160000 --- a/essentials-framework/pepperdashcore-builds +++ b/essentials-framework/pepperdashcore-builds @@ -1 +1 @@ -Subproject commit acebe6b43b28cc3a93f899e9714292a0cc1ab2cc +Subproject commit 27a665b68a0725729bb09138bb85f575833df4b2