From b429e4bc53879ec030d58300a07c5e15f39dc22e Mon Sep 17 00:00:00 2001 From: Drew Tingen Date: Sun, 27 Jan 2019 22:55:24 -0800 Subject: [PATCH] feat: OnConsolePrint event and better VC-4 console support --- CHANGELOG.md | 5 +++++ ICD.Common.Utils/IcdConsole.cs | 30 +++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5adbe94..c150ebf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added + - IcdConsole.OnConsolePrint event + +### Changed + - Better VC-4 support for IcdConsole ## [8.3.0] - 2019-01-25 ### Added diff --git a/ICD.Common.Utils/IcdConsole.cs b/ICD.Common.Utils/IcdConsole.cs index fe00a64..1f58b6b 100644 --- a/ICD.Common.Utils/IcdConsole.cs +++ b/ICD.Common.Utils/IcdConsole.cs @@ -1,6 +1,8 @@ using System; using System.Linq; using ICD.Common.Properties; +using ICD.Common.Utils.EventArguments; +using ICD.Common.Utils.Extensions; #if SIMPLSHARP using Crestron.SimplSharp; #else @@ -18,6 +20,8 @@ namespace ICD.Common.Utils Administrator = 2 } + public static event EventHandler OnConsolePrint; + /// /// Wraps CrestronConsole.ConsoleCommandResponse for S+ compatibility. /// @@ -41,17 +45,23 @@ namespace ICD.Common.Utils message = string.Format(message, args); #if SIMPLSHARP - try + if (IcdEnvironment.RuntimeEnvironment == IcdEnvironment.eRuntimeEnvironment.SimplSharpPro) { - CrestronConsole.ConsoleCommandResponse(message); + try + { + + CrestronConsole.ConsoleCommandResponse(message); + + } + catch (NotSupportedException) + { + Print(message); + } + return; } - catch (NotSupportedException) - { - Print(message); - } -#else - Print(message); #endif + + Print(message); } public static void PrintLine(string message) @@ -90,10 +100,12 @@ namespace ICD.Common.Utils public static void Print(string message) { #if SIMPLSHARP - CrestronConsole.Print(message); + if (IcdEnvironment.RuntimeEnvironment != IcdEnvironment.eRuntimeEnvironment.SimplSharpProMono) + CrestronConsole.Print(message); #else Console.Write(message); #endif + OnConsolePrint.Raise(null, new StringEventArgs(message)); } public static void Print(string message, params object[] args)