# HG changeset patch
# User StephaneLenclud
# Date 1472078529 -7200
# Node ID 2dae7a163fffffc8cef266ba81f65e177ca04b50
# Parent 59ea5cb46258c104b4d7af6a6849082443e2566e
Published v1.0.0.0
Updating Harmony library to v0.4.0 for keep alive support.
Improved logs mechanism.
diff -r 59ea5cb46258 -r 2dae7a163fff Server/Actions/ActionCecActiveSource.cs
--- a/Server/Actions/ActionCecActiveSource.cs Mon Aug 22 13:20:54 2016 +0200
+++ b/Server/Actions/ActionCecActiveSource.cs Thu Aug 25 00:42:09 2016 +0200
@@ -2,6 +2,7 @@
using SharpLib.Ear;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
@@ -29,7 +30,7 @@
{
if (Cec.Client.Static == null)
{
- Console.WriteLine("WARNING: No CEC client installed.");
+ Trace.WriteLine("WARNING: No CEC client installed.");
return;
}
diff -r 59ea5cb46258 -r 2dae7a163fff Server/Actions/ActionCecClose.cs
--- a/Server/Actions/ActionCecClose.cs Mon Aug 22 13:20:54 2016 +0200
+++ b/Server/Actions/ActionCecClose.cs Thu Aug 25 00:42:09 2016 +0200
@@ -2,6 +2,7 @@
using SharpLib.Ear;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
@@ -17,7 +18,7 @@
{
if (Cec.Client.Static == null)
{
- Console.WriteLine("WARNING: No CEC client installed.");
+ Trace.WriteLine("WARNING: No CEC client installed.");
return;
}
diff -r 59ea5cb46258 -r 2dae7a163fff Server/Actions/ActionCecDevicePowerOn.cs
--- a/Server/Actions/ActionCecDevicePowerOn.cs Mon Aug 22 13:20:54 2016 +0200
+++ b/Server/Actions/ActionCecDevicePowerOn.cs Thu Aug 25 00:42:09 2016 +0200
@@ -2,6 +2,7 @@
using SharpLib.Ear;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
@@ -30,7 +31,7 @@
{
if (Cec.Client.Static == null)
{
- Console.WriteLine("WARNING: No CEC client installed.");
+ Trace.WriteLine("WARNING: No CEC client installed.");
return;
}
diff -r 59ea5cb46258 -r 2dae7a163fff Server/Actions/ActionCecDeviceStandby.cs
--- a/Server/Actions/ActionCecDeviceStandby.cs Mon Aug 22 13:20:54 2016 +0200
+++ b/Server/Actions/ActionCecDeviceStandby.cs Thu Aug 25 00:42:09 2016 +0200
@@ -2,6 +2,7 @@
using SharpLib.Ear;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
@@ -30,7 +31,7 @@
{
if (Cec.Client.Static == null)
{
- Console.WriteLine("WARNING: No CEC client installed.");
+ Trace.WriteLine("WARNING: No CEC client installed.");
return;
}
diff -r 59ea5cb46258 -r 2dae7a163fff Server/Actions/ActionCecInactiveSource.cs
--- a/Server/Actions/ActionCecInactiveSource.cs Mon Aug 22 13:20:54 2016 +0200
+++ b/Server/Actions/ActionCecInactiveSource.cs Thu Aug 25 00:42:09 2016 +0200
@@ -2,6 +2,7 @@
using SharpLib.Ear;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
@@ -17,7 +18,7 @@
{
if (Cec.Client.Static == null)
{
- Console.WriteLine("WARNING: No CEC client installed.");
+ Trace.WriteLine("WARNING: No CEC client installed.");
return;
}
diff -r 59ea5cb46258 -r 2dae7a163fff Server/Actions/ActionCecOpen.cs
--- a/Server/Actions/ActionCecOpen.cs Mon Aug 22 13:20:54 2016 +0200
+++ b/Server/Actions/ActionCecOpen.cs Thu Aug 25 00:42:09 2016 +0200
@@ -2,6 +2,7 @@
using SharpLib.Ear;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
@@ -17,7 +18,7 @@
{
if (Cec.Client.Static == null)
{
- Console.WriteLine("WARNING: No CEC client installed.");
+ Trace.WriteLine("WARNING: No CEC client installed.");
return;
}
diff -r 59ea5cb46258 -r 2dae7a163fff Server/Actions/ActionCecScan.cs
--- a/Server/Actions/ActionCecScan.cs Mon Aug 22 13:20:54 2016 +0200
+++ b/Server/Actions/ActionCecScan.cs Thu Aug 25 00:42:09 2016 +0200
@@ -2,6 +2,7 @@
using SharpLib.Ear;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
@@ -18,7 +19,7 @@
{
if (Cec.Client.Static == null)
{
- Console.WriteLine("WARNING: No CEC client installed.");
+ Trace.WriteLine("WARNING: No CEC client installed.");
return;
}
diff -r 59ea5cb46258 -r 2dae7a163fff Server/Actions/ActionCecUserControlPressed.cs
--- a/Server/Actions/ActionCecUserControlPressed.cs Mon Aug 22 13:20:54 2016 +0200
+++ b/Server/Actions/ActionCecUserControlPressed.cs Thu Aug 25 00:42:09 2016 +0200
@@ -2,6 +2,7 @@
using SharpLib.Ear;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
@@ -60,7 +61,7 @@
{
if (Cec.Client.Static == null)
{
- Console.WriteLine("WARNING: No CEC client installed.");
+ Trace.WriteLine("WARNING: No CEC client installed.");
return;
}
diff -r 59ea5cb46258 -r 2dae7a163fff Server/Actions/ActionCecUserControlReleased.cs
--- a/Server/Actions/ActionCecUserControlReleased.cs Mon Aug 22 13:20:54 2016 +0200
+++ b/Server/Actions/ActionCecUserControlReleased.cs Thu Aug 25 00:42:09 2016 +0200
@@ -2,6 +2,7 @@
using SharpLib.Ear;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
@@ -52,7 +53,7 @@
{
if (Cec.Client.Static == null)
{
- Console.WriteLine("WARNING: No CEC client installed.");
+ Trace.WriteLine("WARNING: No CEC client installed.");
return;
}
diff -r 59ea5cb46258 -r 2dae7a163fff Server/Actions/ActionHarmonyCommand.cs
--- a/Server/Actions/ActionHarmonyCommand.cs Mon Aug 22 13:20:54 2016 +0200
+++ b/Server/Actions/ActionHarmonyCommand.cs Thu Aug 25 00:42:09 2016 +0200
@@ -2,6 +2,7 @@
using SharpLib.Ear;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -77,7 +78,7 @@
}
else
{
- Console.WriteLine("WARNING: No Harmony client connection.");
+ Trace.WriteLine("WARNING: No Harmony client connection.");
}
}
diff -r 59ea5cb46258 -r 2dae7a163fff Server/CecClient.cs
--- a/Server/CecClient.cs Mon Aug 22 13:20:54 2016 +0200
+++ b/Server/CecClient.cs Thu Aug 25 00:42:09 2016 +0200
@@ -34,6 +34,7 @@
using System.Text;
using CecSharp;
using System.Threading;
+using System.Diagnostics;
namespace Cec
{
@@ -98,7 +99,7 @@
if (Static != null)
{
- Console.WriteLine("WARNING: CEC client static already exists");
+ Trace.WriteLine("WARNING: CEC client static already exists");
}
else
{
@@ -106,8 +107,8 @@
}
- //Console.WriteLine("CEC Parser created - libCEC version " + Lib.VersionToString(Config.ServerVersion));
- Console.WriteLine("INFO: CEC Parser created - libCEC version " + Config.ServerVersion);
+ //Trace.WriteLine("CEC Parser created - libCEC version " + Lib.VersionToString(Config.ServerVersion));
+ Trace.WriteLine("INFO: CEC Parser created - libCEC version " + Config.ServerVersion);
}
@@ -125,7 +126,7 @@
log += " " + data.Data;
}
- Console.WriteLine(log);
+ Trace.WriteLine(log);
Close();
//Try reconnect
@@ -140,7 +141,7 @@
///
public override int ReceiveMenuStateChange(CecMenuState newVal)
{
- Console.WriteLine("CEC menu state changed to: " + iLib.ToString(newVal));
+ Trace.WriteLine("CEC menu state changed to: " + iLib.ToString(newVal));
return 1;
}
@@ -151,13 +152,13 @@
///
public override void SourceActivated(CecLogicalAddress logicalAddress, bool activated)
{
- Console.WriteLine("CEC source activated: " + iLib.ToString(logicalAddress) + "/" + activated.ToString() );
+ Trace.WriteLine("CEC source activated: " + iLib.ToString(logicalAddress) + "/" + activated.ToString() );
return;
}
public override int ReceiveCommand(CecCommand command)
{
- Console.WriteLine(string.Format("CEC command '{5}' from {0} to {1} - Ack: {2} Eom: {3} OpcodeSet: {4} Timeout: {6}",
+ Trace.WriteLine(string.Format("CEC command '{5}' from {0} to {1} - Ack: {2} Eom: {3} OpcodeSet: {4} Timeout: {6}",
iLib.ToString(command.Initiator),
iLib.ToString(command.Destination),
command.Ack.ToString(),
@@ -171,7 +172,7 @@
public override int ReceiveKeypress(CecKeypress key)
{
- Console.WriteLine(string.Format("CEC keypress: {0} Duration:{1} Empty: {2}",
+ Trace.WriteLine(string.Format("CEC keypress: {0} Duration:{1} Empty: {2}",
key.Keycode.ToString(), key.Duration.ToString(), key.Empty.ToString()));
return 1;
}
@@ -207,7 +208,7 @@
break;
}
string strLog = string.Format("{0} {1} {2}", strLevel, message.Time, message.Message);
- Console.WriteLine(strLog);
+ Trace.WriteLine(strLog);
}
return 1;
@@ -228,7 +229,7 @@
}
else
{
- Console.WriteLine("CEC did not find any adapters");
+ Trace.WriteLine("CEC did not find any adapters");
}
return iConnected;
@@ -280,7 +281,7 @@
break;
default:
- Console.WriteLine(i.ToString());
+ Trace.WriteLine(i.ToString());
Thread.Sleep(1000);
iLib.SendKeypress(CecLogicalAddress.Tv, (CecUserControlCode)i, true);
@@ -343,7 +344,7 @@
scanRes += "===================" + "\n";
}
- Console.Write(scanRes);
+ Trace.Write(scanRes);
}
public void ListAdapters()
@@ -351,214 +352,9 @@
int iAdapter = 0;
foreach (CecAdapter adapter in iLib.FindAdapters(string.Empty))
{
- Console.WriteLine("Adapter: " + iAdapter++);
- Console.WriteLine("Path: " + adapter.Path);
- Console.WriteLine("Com port: " + adapter.ComPort);
- }
- }
-
- void ShowConsoleHelp()
- {
- Console.WriteLine(
- "================================================================================" + Environment.NewLine +
- "Available commands:" + Environment.NewLine +
- Environment.NewLine +
- "[tx] {bytes} transfer bytes over the CEC line." + Environment.NewLine +
- "[txn] {bytes} transfer bytes but don't wait for transmission ACK." + Environment.NewLine +
- "[on] {address} power on the device with the given logical address." + Environment.NewLine +
- "[standby] {address} put the device with the given address in standby mode." + Environment.NewLine +
- "[la] {logical_address} change the logical address of the CEC adapter." + Environment.NewLine +
- "[pa] {physical_address} change the physical address of the CEC adapter." + Environment.NewLine +
- "[osd] {addr} {string} set OSD message on the specified device." + Environment.NewLine +
- "[ver] {addr} get the CEC version of the specified device." + Environment.NewLine +
- "[ven] {addr} get the vendor ID of the specified device." + Environment.NewLine +
- "[lang] {addr} get the menu language of the specified device." + Environment.NewLine +
- "[pow] {addr} get the power status of the specified device." + Environment.NewLine +
- "[poll] {addr} poll the specified device." + Environment.NewLine +
- "[scan] scan the CEC bus and display device info" + Environment.NewLine +
- "[mon] {1|0} enable or disable CEC bus monitoring." + Environment.NewLine +
- "[log] {1 - 31} change the log level. see cectypes.h for values." + Environment.NewLine +
- "[ping] send a ping command to the CEC adapter." + Environment.NewLine +
- "[bl] to let the adapter enter the bootloader, to upgrade" + Environment.NewLine +
- " the flash rom." + Environment.NewLine +
- "[r] reconnect to the CEC adapter." + Environment.NewLine +
- "[h] or [help] show this help." + Environment.NewLine +
- "[q] or [quit] to quit the CEC test client and switch off all" + Environment.NewLine +
- " connected CEC devices." + Environment.NewLine +
- "================================================================================");
- }
-
- public void MainLoop()
- {
- bool bContinue = true;
- string command;
- while (bContinue)
- {
- Console.WriteLine("waiting for input");
-
- command = Console.ReadLine();
- if (command != null && command.Length == 0)
- continue;
- string[] splitCommand = command.Split(' ');
- if (splitCommand[0] == "tx" || splitCommand[0] == "txn")
- {
- CecCommand bytes = new CecCommand();
- for (int iPtr = 1; iPtr < splitCommand.Length; iPtr++)
- {
- bytes.PushBack(byte.Parse(splitCommand[iPtr], System.Globalization.NumberStyles.HexNumber));
- }
-
- if (command == "txn")
- bytes.TransmitTimeout = 0;
-
- iLib.Transmit(bytes);
- }
- else if (splitCommand[0] == "on")
- {
- if (splitCommand.Length > 1)
- iLib.PowerOnDevices((CecLogicalAddress)byte.Parse(splitCommand[1], System.Globalization.NumberStyles.HexNumber));
- else
- iLib.PowerOnDevices(CecLogicalAddress.Broadcast);
- }
- else if (splitCommand[0] == "standby")
- {
- if (splitCommand.Length > 1)
- iLib.StandbyDevices((CecLogicalAddress)byte.Parse(splitCommand[1], System.Globalization.NumberStyles.HexNumber));
- else
- iLib.StandbyDevices(CecLogicalAddress.Broadcast);
- }
- else if (splitCommand[0] == "poll")
- {
- bool bSent = false;
- if (splitCommand.Length > 1)
- bSent = iLib.PollDevice((CecLogicalAddress)byte.Parse(splitCommand[1], System.Globalization.NumberStyles.HexNumber));
- else
- bSent = iLib.PollDevice(CecLogicalAddress.Broadcast);
- if (bSent)
- Console.WriteLine("POLL message sent");
- else
- Console.WriteLine("POLL message not sent");
- }
- else if (splitCommand[0] == "la")
- {
- if (splitCommand.Length > 1)
- iLib.SetLogicalAddress((CecLogicalAddress)byte.Parse(splitCommand[1], System.Globalization.NumberStyles.HexNumber));
- }
- else if (splitCommand[0] == "pa")
- {
- if (splitCommand.Length > 1)
- iLib.SetPhysicalAddress(ushort.Parse(splitCommand[1], System.Globalization.NumberStyles.HexNumber));
- }
- else if (splitCommand[0] == "osd")
- {
- if (splitCommand.Length > 2)
- {
- StringBuilder osdString = new StringBuilder();
- for (int iPtr = 1; iPtr < splitCommand.Length; iPtr++)
- {
- osdString.Append(splitCommand[iPtr]);
- if (iPtr != splitCommand.Length - 1)
- osdString.Append(" ");
- }
- iLib.SetOSDString((CecLogicalAddress)byte.Parse(splitCommand[1], System.Globalization.NumberStyles.HexNumber), CecDisplayControl.DisplayForDefaultTime, osdString.ToString());
- }
- }
- else if (splitCommand[0] == "ping")
- {
- iLib.PingAdapter();
- }
- else if (splitCommand[0] == "mon")
- {
- bool enable = splitCommand.Length > 1 ? splitCommand[1] == "1" : false;
- iLib.SwitchMonitoring(enable);
- }
- else if (splitCommand[0] == "bl")
- {
- iLib.StartBootloader();
- }
- else if (splitCommand[0] == "lang")
- {
- if (splitCommand.Length > 1)
- {
- string language = iLib.GetDeviceMenuLanguage((CecLogicalAddress)byte.Parse(splitCommand[1], System.Globalization.NumberStyles.HexNumber));
- Console.WriteLine("Menu language: " + language);
- }
- }
- else if (splitCommand[0] == "ven")
- {
- if (splitCommand.Length > 1)
- {
- CecVendorId vendor = iLib.GetDeviceVendorId((CecLogicalAddress)byte.Parse(splitCommand[1], System.Globalization.NumberStyles.HexNumber));
- Console.WriteLine("Vendor ID: " + iLib.ToString(vendor));
- }
- }
- else if (splitCommand[0] == "ver")
- {
- if (splitCommand.Length > 1)
- {
- CecVersion version = iLib.GetDeviceCecVersion((CecLogicalAddress)byte.Parse(splitCommand[1], System.Globalization.NumberStyles.HexNumber));
- Console.WriteLine("CEC version: " + iLib.ToString(version));
- }
- }
- else if (splitCommand[0] == "pow")
- {
- if (splitCommand.Length > 1)
- {
- CecPowerStatus power = iLib.GetDevicePowerStatus((CecLogicalAddress)byte.Parse(splitCommand[1], System.Globalization.NumberStyles.HexNumber));
- Console.WriteLine("power status: " + iLib.ToString(power));
- }
- }
- else if (splitCommand[0] == "r")
- {
- Console.WriteLine("closing the connection");
- iLib.Close();
-
- Console.WriteLine("opening a new connection");
- Open(10000);
-
- Console.WriteLine("setting active source");
- iLib.SetActiveSource(CecDeviceType.PlaybackDevice);
- }
- else if (splitCommand[0] == "scan")
- {
- StringBuilder output = new StringBuilder();
- output.AppendLine("CEC bus information");
- output.AppendLine("===================");
- CecLogicalAddresses addresses = iLib.GetActiveDevices();
- for (int iPtr = 0; iPtr < addresses.Addresses.Length; iPtr++)
- {
- CecLogicalAddress address = (CecLogicalAddress)iPtr;
- if (!addresses.IsSet(address))
- continue;
-
- CecVendorId iVendorId = iLib.GetDeviceVendorId(address);
- bool bActive = iLib.IsActiveDevice(address);
- ushort iPhysicalAddress = iLib.GetDevicePhysicalAddress(address);
- string strAddr = "todo: fixme"; //Lib.PhysicalAddressToString(iPhysicalAddress);
- CecVersion iCecVersion = iLib.GetDeviceCecVersion(address);
- CecPowerStatus power = iLib.GetDevicePowerStatus(address);
- string osdName = iLib.GetDeviceOSDName(address);
- string lang = iLib.GetDeviceMenuLanguage(address);
-
- output.AppendLine("device #" + iPtr + ": " + iLib.ToString(address));
- output.AppendLine("address: " + strAddr);
- output.AppendLine("active source: " + (bActive ? "yes" : "no"));
- output.AppendLine("vendor: " + iLib.ToString(iVendorId));
- output.AppendLine("osd string: " + osdName);
- output.AppendLine("CEC version: " + iLib.ToString(iCecVersion));
- output.AppendLine("power status: " + iLib.ToString(power));
- if (!string.IsNullOrEmpty(lang))
- output.AppendLine("language: " + lang);
- output.AppendLine("");
- }
- Console.WriteLine(output.ToString());
- }
- else if (splitCommand[0] == "h" || splitCommand[0] == "help")
- ShowConsoleHelp();
- else if (splitCommand[0] == "q" || splitCommand[0] == "quit")
- bContinue = false;
- else if (splitCommand[0] == "log" && splitCommand.Length > 1)
- LogLevel = int.Parse(splitCommand[1]);
+ Trace.WriteLine("Adapter: " + iAdapter++);
+ Trace.WriteLine("Path: " + adapter.Path);
+ Trace.WriteLine("Com port: " + adapter.ComPort);
}
}
diff -r 59ea5cb46258 -r 2dae7a163fff Server/FormMain.cs
--- a/Server/FormMain.cs Mon Aug 22 13:20:54 2016 +0200
+++ b/Server/FormMain.cs Thu Aug 25 00:42:09 2016 +0200
@@ -131,7 +131,7 @@
///
///
///
- RichTextBoxTextWriter iWriter;
+ RichTextBoxTraceListener iWriter;
///
@@ -172,8 +172,8 @@
InitializeComponent();
//Redirect console output
- iWriter = new RichTextBoxTextWriter(richTextBoxLogs);
- Console.SetOut(iWriter);
+ iWriter = new RichTextBoxTraceListener(richTextBoxLogs);
+ Trace.Listeners.Add(iWriter);
//Populate device types
PopulateDeviceTypes();
@@ -993,9 +993,6 @@
//This is our timer tick responsible to perform our render
private void timer_Tick(object sender, EventArgs e)
{
- //Not ideal cause this has nothing to do with display render
- LogsUpdate();
-
//Update our animations
DateTime NewTickTime = DateTime.Now;
@@ -2498,25 +2495,11 @@
}
///
- ///
- ///
- private void LogsUpdate()
- {
- if (iWriter != null)
- {
- iWriter.Flush();
- }
-
- }
-
- ///
/// Broadcast messages to subscribers.
///
///
protected override void WndProc(ref Message aMessage)
{
- LogsUpdate();
-
if (OnWndProc != null)
{
OnWndProc(ref aMessage);
@@ -2577,8 +2560,8 @@
}
catch (Exception ex)
{
- Console.WriteLine("Exception thrown by ConnectHarmonyAsync");
- Console.WriteLine(ex.ToString());
+ Trace.WriteLine("Exception thrown by ConnectHarmonyAsync");
+ Trace.WriteLine(ex.ToString());
}
}
}
@@ -3008,35 +2991,35 @@
Program.HarmonyClient = null;
Program.HarmonyConfig = null;
- Console.WriteLine("Harmony: Connecting... ");
+ Trace.WriteLine("Harmony: Connecting... ");
Program.HarmonyClient = new HarmonyHub.Client(iTextBoxHarmonyHubAddress.Text);
//First create our client and login
if (File.Exists("SessionToken") && !aForceAuth)
{
var sessionToken = File.ReadAllText("SessionToken");
- Console.WriteLine("Harmony: Reusing token: {0}", sessionToken);
+ Trace.WriteLine("Harmony: Reusing token: {0}", sessionToken);
Program.HarmonyClient.Open(sessionToken);
}
else
{
if (string.IsNullOrEmpty(iTextBoxLogitechPassword.Text))
{
- Console.WriteLine("Harmony: Credentials missing!");
+ Trace.WriteLine("Harmony: Credentials missing!");
return;
}
- Console.WriteLine("Harmony: Authenticating with Logitech servers...");
+ Trace.WriteLine("Harmony: Authenticating with Logitech servers...");
await Program.HarmonyClient.Open(iTextBoxLogitechUserName.Text, iTextBoxLogitechPassword.Text);
File.WriteAllText("SessionToken", Program.HarmonyClient.Token);
}
- Console.WriteLine("Harmony: Fetching Harmony Hub configuration...");
+ Trace.WriteLine("Harmony: Fetching Harmony Hub configuration...");
//Fetch our config
Program.HarmonyConfig = await Program.HarmonyClient.GetConfigAsync();
PopulateTreeViewHarmony(Program.HarmonyConfig);
- Console.WriteLine("Harmony: Ready");
+ Trace.WriteLine("Harmony: Ready");
//Make sure harmony command actions are showing device name instead of device id
PopulateEventsTreeView();
@@ -3080,7 +3063,7 @@
HarmonyHub.Function f = tag;
HarmonyHub.Device d = (HarmonyHub.Device)e.Node.Parent.Parent.Tag;
- Console.WriteLine($"Harmony: Sending {f.Name} to {d.Label}...");
+ Trace.WriteLine($"Harmony: Sending {f.Name} to {d.Label}...");
await Program.HarmonyClient.SendCommandAsync(d.Id, f.Name);
}
diff -r 59ea5cb46258 -r 2dae7a163fff Server/FormSelectHarmonyCommand.cs
--- a/Server/FormSelectHarmonyCommand.cs Mon Aug 22 13:20:54 2016 +0200
+++ b/Server/FormSelectHarmonyCommand.cs Thu Aug 25 00:42:09 2016 +0200
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.ComponentModel;
using System.Data;
using System.Drawing;
@@ -73,7 +74,7 @@
HarmonyHub.Function f = tag;
HarmonyHub.Device d = (HarmonyHub.Device)e.Node.Parent.Parent.Tag;
- Console.WriteLine($"Harmony: Sending {f.Name} to {d.Label}...");
+ Trace.WriteLine($"Harmony: Sending {f.Name} to {d.Label}...");
await Program.HarmonyClient.SendCommandAsync(d.Id, f.Name);
}
diff -r 59ea5cb46258 -r 2dae7a163fff Server/MarqueeLabel.cs
--- a/Server/MarqueeLabel.cs Mon Aug 22 13:20:54 2016 +0200
+++ b/Server/MarqueeLabel.cs Thu Aug 25 00:42:09 2016 +0200
@@ -122,7 +122,7 @@
private double PixelsLeft { get; set; }
//DateTime a = new DateTime(2010, 05, 12, 13, 15, 00);
//DateTime b = new DateTime(2010, 05, 12, 13, 45, 00);
- //Console.WriteLine(b.Subtract(a).TotalMinutes);
+ //Trace.WriteLine(b.Subtract(a).TotalMinutes);
public MarqueeLabel()
{
diff -r 59ea5cb46258 -r 2dae7a163fff Server/RichTextBoxTextWriter.cs
--- a/Server/RichTextBoxTextWriter.cs Mon Aug 22 13:20:54 2016 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-using System;
-using System.Text;
-using System.IO;
-using System.Windows.Forms;
-
-namespace SharpDisplayManager
-{
- public class RichTextBoxTextWriter : TextWriter
- {
- public delegate void WriteDelegate(char aChar);
-
- RichTextBox iRichTextBox = null;
- string iAccumulator = "";
- private char iLastChar='\n';
-
- public RichTextBoxTextWriter(RichTextBox aRichTextBox)
- {
- iRichTextBox = aRichTextBox;
- }
-
- public override void Write(char aChar)
- {
- if (aChar == '\r')
- {
- //Skip
- return;
- }
-
- //Put our time stamp if starting a new line
- char previousChar = iLastChar;
- iLastChar = aChar;
- if (previousChar == '\n')
- {
- //Write(DateTime.Now.ToString("yyyy/MM/dd - HH:mm:ss.fff: "));
- Write(DateTime.Now.ToString("MM/dd HH:mm:ss.fff: "));
- }
-
-
- base.Write(aChar);
- if (iRichTextBox.InvokeRequired)
- {
- lock (iAccumulator)
- {
- iAccumulator += aChar;
- }
-
- //Invoke was not working from here
- //WriteDelegate d = new WriteDelegate(Write);
- //iRichTextBox.Invoke(d, new object[] { aChar });
- }
- else
- {
- Flush();
- iRichTextBox.AppendText(aChar.ToString()); // When character data is written, append it to the text box.
- }
- }
-
- public override Encoding Encoding
- {
- get { return System.Text.Encoding.UTF8; }
- }
-
- ///
- ///
- ///
- public override void Flush()
- {
- base.Flush();
-
- lock (iAccumulator)
- {
- if (!string.IsNullOrEmpty(iAccumulator))
- {
- iRichTextBox.AppendText(iAccumulator); // When character data is written, append it to the text box.
- iAccumulator = "";
- }
- }
-
- }
- }
-}
\ No newline at end of file
diff -r 59ea5cb46258 -r 2dae7a163fff Server/RichTextBoxTraceListener.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/RichTextBoxTraceListener.cs Thu Aug 25 00:42:09 2016 +0200
@@ -0,0 +1,43 @@
+using System;
+using System.Text;
+using System.IO;
+using System.Windows.Forms;
+using System.Diagnostics;
+
+namespace SharpDisplayManager
+{
+ public class RichTextBoxTraceListener : TraceListener
+ {
+ RichTextBox iRichTextBox = null;
+
+ public RichTextBoxTraceListener(RichTextBox aRichTextBox)
+ {
+ iRichTextBox = aRichTextBox;
+ }
+
+ public override void WriteLine(string aString)
+ {
+ //Add time stamp and new line characters
+ Write(DateTime.Now.ToString("MM/dd HH:mm:ss.fff: ") + aString + "\r\n");
+ }
+
+ public override void Write(string aString)
+ {
+ //Allows iRichTextBox to be updated from different thread
+ if (iRichTextBox.InvokeRequired)
+ {
+ // Fire and forget invocation
+ // Using the synchronous variant Invoke tends to result in deadlock here
+ iRichTextBox.BeginInvoke(new MethodInvoker(delegate ()
+ {
+ iRichTextBox.Text += aString;
+ }));
+ }
+ else
+ {
+ iRichTextBox.Text += aString;
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff -r 59ea5cb46258 -r 2dae7a163fff Server/Settings.cs
--- a/Server/Settings.cs Mon Aug 22 13:20:54 2016 +0200
+++ b/Server/Settings.cs Thu Aug 25 00:42:09 2016 +0200
@@ -18,6 +18,7 @@
//
using System;
+using System.Diagnostics;
namespace SharpDisplayManager.Properties {
@@ -43,23 +44,23 @@
private void PropertyChangedEventHandler(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
- Console.WriteLine($"Settings: property changed {e.PropertyName}");
+ Trace.WriteLine($"Settings: property changed {e.PropertyName}");
Default.Save();
}
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
// Add code to handle the SettingChangingEvent event here.
- Console.WriteLine($"Settings: changing {e.SettingKey}.{e.SettingName}");
+ Trace.WriteLine($"Settings: changing {e.SettingKey}.{e.SettingName}");
}
private void SettingsLoadedEventHandler(object sender, System.Configuration.SettingsLoadedEventArgs e)
{
- Console.WriteLine($"Settings: loaded {e.Provider.ApplicationName}");
+ Trace.WriteLine($"Settings: loaded {e.Provider.ApplicationName}");
}
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
// Add code to handle the SettingsSaving event here.
- Console.WriteLine("Settings: saving");
+ Trace.WriteLine("Settings: saving");
}
}
}
diff -r 59ea5cb46258 -r 2dae7a163fff Server/SharpDisplayManager.csproj
--- a/Server/SharpDisplayManager.csproj Mon Aug 22 13:20:54 2016 +0200
+++ b/Server/SharpDisplayManager.csproj Thu Aug 25 00:42:09 2016 +0200
@@ -34,7 +34,7 @@
index.htm
false
0
- 0.12.2.0
+ 1.0.0.0
false
true
true
@@ -112,7 +112,7 @@
True
- ..\packages\SharpLibHarmony.0.3.0\lib\net451\HarmonyHub.dll
+ ..\packages\SharpLibHarmony.0.4.0\lib\net451\HarmonyHub.dll
True
@@ -219,7 +219,7 @@
ProgressForm.cs
-
+
diff -r 59ea5cb46258 -r 2dae7a163fff Server/packages.config
--- a/Server/packages.config Mon Aug 22 13:20:54 2016 +0200
+++ b/Server/packages.config Thu Aug 25 00:42:09 2016 +0200
@@ -4,7 +4,7 @@
-
+
diff -r 59ea5cb46258 -r 2dae7a163fff SharpLibEar/Action.cs
--- a/SharpLibEar/Action.cs Mon Aug 22 13:20:54 2016 +0200
+++ b/SharpLibEar/Action.cs Thu Aug 25 00:42:09 2016 +0200
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Runtime.Serialization;
using System.Threading;
@@ -18,16 +19,16 @@
///
public void Test()
{
- Console.WriteLine("Action test");
+ Trace.WriteLine("Action test");
Execute();
}
public void Execute()
{
- Console.WriteLine("Action executing: " + Brief());
+ Trace.WriteLine("Action executing: " + Brief());
if (!IsValid())
{
- Console.WriteLine($"WARNING: action invalid, aborting execution.");
+ Trace.WriteLine($"WARNING: action invalid, aborting execution.");
return;
}
diff -r 59ea5cb46258 -r 2dae7a163fff SharpLibEar/Event.cs
--- a/SharpLibEar/Event.cs Mon Aug 22 13:20:54 2016 +0200
+++ b/SharpLibEar/Event.cs Thu Aug 25 00:42:09 2016 +0200
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Runtime.Serialization;
namespace SharpLib.Ear
@@ -42,14 +43,14 @@
///
public void Test()
{
- Console.WriteLine("Event test");
+ Trace.WriteLine("Event test");
Trigger();
}
public void Trigger()
{
- Console.WriteLine("Event triggered: " + Name);
+ Trace.WriteLine("Event triggered: " + Name);
foreach (Action action in Actions)
{
action.Execute();
diff -r 59ea5cb46258 -r 2dae7a163fff SharpLibUtils/TypeConverterJson.cs
--- a/SharpLibUtils/TypeConverterJson.cs Mon Aug 22 13:20:54 2016 +0200
+++ b/SharpLibUtils/TypeConverterJson.cs Thu Aug 25 00:42:09 2016 +0200
@@ -60,7 +60,7 @@
//catch (Exception ex)
//{
//That's not helping with partial loading
- // Console.WriteLine("WARNING: Internalize exception -" + ex.ToString() );
+ // Trace.WriteLine("WARNING: Internalize exception -" + ex.ToString() );
// return null;
//}
}