Fix a bug that causes message sending from Client.cs to not be shown

Brian [2016-08-01 01:16:53]
Fix a bug that causes message sending from Client.cs to not be shown

Now recycling items message, using item (e.g use pokeball) message and
other messages send from Client.cs will show in the console
Filename
PokemonGo/RocketAPI/Client.cs
PokemonGo/RocketAPI/PokemonGo.RocketAPI.csproj
PokemonGo/RocketAPI/Window/MainForm.cs
diff --git a/PokemonGo/RocketAPI/Client.cs b/PokemonGo/RocketAPI/Client.cs
index 5c4ae6c..3a1444e 100644
--- a/PokemonGo/RocketAPI/Client.cs
+++ b/PokemonGo/RocketAPI/Client.cs
@@ -40,6 +40,9 @@ namespace PokemonGo.RocketAPI

         private readonly ILoginType login;

+        public delegate void ConsoleWriteDelegate(ConsoleColor color, string message);
+        public static event ConsoleWriteDelegate OnConsoleWrite;
+
         public Client(ISettings settings)
         {
             _settings = settings;
@@ -254,14 +257,12 @@ namespace PokemonGo.RocketAPI
         {
             ConsoleColor originalColor = System.Console.ForegroundColor;
             System.Console.ForegroundColor = color;
-            System.Console.WriteLine("[" + DateTime.Now.ToString("HH:mm:ss tt") + "] " + text);
-
-            var dir = AppDomain.CurrentDomain.BaseDirectory + @"\Logs";
-            if (!Directory.Exists(dir))
-                Directory.CreateDirectory(dir);
-            File.AppendAllText(dir + @"\" + DateTime.Today.ToString("yyyyMMdd") + ".txt", "[" + DateTime.Now.ToString("HH:mm:ss tt") + "] " + text + "\r\n");
-
+            System.Console.WriteLine(text);
             System.Console.ForegroundColor = originalColor;
+            if (OnConsoleWrite != null)
+            {
+                OnConsoleWrite(color, text);
+            }
         }

         public async Task<FortDetailsResponse> GetFort(string fortId, double fortLat, double fortLng)
diff --git a/PokemonGo/RocketAPI/PokemonGo.RocketAPI.csproj b/PokemonGo/RocketAPI/PokemonGo.RocketAPI.csproj
index 8a6404d..3dc6681 100644
--- a/PokemonGo/RocketAPI/PokemonGo.RocketAPI.csproj
+++ b/PokemonGo/RocketAPI/PokemonGo.RocketAPI.csproj
@@ -50,6 +50,7 @@
     <Reference Include="System" />
     <Reference Include="System.Configuration" />
     <Reference Include="System.Core" />
+    <Reference Include="System.Drawing" />
     <Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
       <HintPath>..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
       <Private>True</Private>
@@ -106,7 +107,6 @@
     <None Include="Proto\Response.proto" />
     <None Include="Proto\Request.proto" />
   </ItemGroup>
-  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
        Other similar extension points exist, see Microsoft.Common.targets.
diff --git a/PokemonGo/RocketAPI/Window/MainForm.cs b/PokemonGo/RocketAPI/Window/MainForm.cs
index 8443137..f1be82a 100644
--- a/PokemonGo/RocketAPI/Window/MainForm.cs
+++ b/PokemonGo/RocketAPI/Window/MainForm.cs
@@ -50,6 +50,7 @@ namespace PokemonGo.RocketAPI.Window
             synchronizationContext = SynchronizationContext.Current;
             InitializeComponent();
             ClientSettings = Settings.Instance;
+            Client.OnConsoleWrite += Client_OnConsoleWrite;
             Instance = this;
         }
You may download the files in Public Git.