Added GitHub Version check on StartUp
Added GitHub Version check on StartUp
Added "Save last coordination function"
diff --git a/PokemonGo.RocketAPI.Logic/Logic.cs b/PokemonGo.RocketAPI.Logic/Logic.cs
index 1583bb0..a8326c9 100644
--- a/PokemonGo.RocketAPI.Logic/Logic.cs
+++ b/PokemonGo.RocketAPI.Logic/Logic.cs
@@ -33,7 +33,7 @@ namespace PokemonGo.RocketAPI.Logic
public async Task Execute()
{
- CheckAndDownloadVersion.CheckVersion();
+ Git.CheckVersion();
if (_clientSettings.DefaultLatitude == 0 || _clientSettings.DefaultLongitude == 0)
{
diff --git a/PokemonGo.RocketAPI.Logic/PokemonGo.RocketAPI.Logic.csproj b/PokemonGo.RocketAPI.Logic/PokemonGo.RocketAPI.Logic.csproj
index 8346c44..9f081bd 100644
--- a/PokemonGo.RocketAPI.Logic/PokemonGo.RocketAPI.Logic.csproj
+++ b/PokemonGo.RocketAPI.Logic/PokemonGo.RocketAPI.Logic.csproj
@@ -48,7 +48,7 @@
<Compile Include="Logic.cs" />
<Compile Include="Navigation.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Utils\CheckAndDownloadVersion.cs" />
+ <Compile Include="Utils\Git.cs" />
<Compile Include="Utils\LocationUtils.cs" />
<Compile Include="Utils\Statistics.cs" />
<Compile Include="Utils\StringUtils.cs" />
diff --git a/PokemonGo.RocketAPI.Logic/Utils/CheckAndDownloadVersion.cs b/PokemonGo.RocketAPI.Logic/Utils/Git.cs
similarity index 52%
rename from PokemonGo.RocketAPI.Logic/Utils/CheckAndDownloadVersion.cs
rename to PokemonGo.RocketAPI.Logic/Utils/Git.cs
index c172f64..c80863e 100644
--- a/PokemonGo.RocketAPI.Logic/Utils/CheckAndDownloadVersion.cs
+++ b/PokemonGo.RocketAPI.Logic/Utils/Git.cs
@@ -1,13 +1,13 @@
using System;
-using System.Diagnostics;
using System.Net;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading;
+using System.Threading.Tasks;
-namespace PokemonGo.RocketAPI.Logic.Utils
+namespace PokemonGo.RocketAPI.Helpers
{
- class CheckAndDownloadVersion
+ public static class Git
{
public static void CheckVersion()
{
@@ -21,26 +21,23 @@ namespace PokemonGo.RocketAPI.Logic.Utils
if (!match.Success) return;
var gitVersion =
new Version(
- string.Format(
- "{0}.{1}.{2}.{3}",
- match.Groups[1],
- match.Groups[2],
- match.Groups[3],
- match.Groups[4]));
+ $"{match.Groups[1]}.{match.Groups[2]}.{match.Groups[3]}.{match.Groups[4]}");
if (gitVersion <= Assembly.GetExecutingAssembly().GetName().Version)
{
- Logger.Normal(ConsoleColor.Green, "Awesome! You have already got the newest version! " + Assembly.GetExecutingAssembly().GetName().Version);
+ Logger.Normal(
+ "Awesome! You have already got the newest version! " +
+ Assembly.GetExecutingAssembly().GetName().Version);
return;
}
- ;
- Logger.Normal(ConsoleColor.Red, "There is a new Version available: " + gitVersion + " downloading.. ");
+
+ Logger.Normal(
+ "There is a new Version available: https://github.com/Spegeli/Pokemon-Go-Rocket-API");
Thread.Sleep(1000);
- Process.Start("https://github.com/Spegeli/Pokemon-Go-Rocket-API");
}
catch (Exception)
{
- Logger.Error($"Unable to check for updates now...");
+ // ignored
}
}
@@ -49,7 +46,7 @@ namespace PokemonGo.RocketAPI.Logic.Utils
using (var wC = new WebClient())
return
wC.DownloadString(
- "https://raw.githubusercontent.com/Spegeli/Pokemon-Go-Rocket-API/master/PokemonGo/RocketAPI/Console/Properties/AssemblyInfo.cs");
+ "https://raw.githubusercontent.com/Spegeli/Pokemon-Go-Rocket-API/master/PokemonGo.RocketAPI/Properties/AssemblyInfo.cs");
}
}
-}
+}
\ No newline at end of file
diff --git a/PokemonGo.RocketAPI/Client.cs b/PokemonGo.RocketAPI/Client.cs
index 507c525..416d6b6 100644
--- a/PokemonGo.RocketAPI/Client.cs
+++ b/PokemonGo.RocketAPI/Client.cs
@@ -1,4 +1,5 @@
using System;
+using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
@@ -32,7 +33,17 @@ namespace PokemonGo.RocketAPI
public Client(ISettings settings)
{
Settings = settings;
- SetCoordinates(Settings.DefaultLatitude, Settings.DefaultLongitude, Settings.DefaultAltitude);
+ //SetCoordinates(Settings.DefaultLatitude, Settings.DefaultLongitude, Settings.DefaultAltitude);
+ if (File.Exists(Directory.GetCurrentDirectory() + "\\Coords.txt"))
+ {
+ string latlngFromFile = File.ReadAllText(Directory.GetCurrentDirectory() + "\\Coords.txt");
+ String[] latlng = latlngFromFile.Split(':');
+ SetCoordinates(Convert.ToDouble(latlng[0]), Convert.ToDouble(latlng[1]), Settings.DefaultAltitude);
+ }
+ else
+ {
+ SetCoordinates(Settings.DefaultLatitude, Settings.DefaultLongitude, Settings.DefaultAltitude);
+ }
//Setup HttpClient and create default headers
HttpClientHandler handler = new HttpClientHandler()
@@ -50,11 +61,18 @@ namespace PokemonGo.RocketAPI
"application/x-www-form-urlencoded");
}
+ public void SaveLatLng(double lat, double lng)
+ {
+ string latlng = lat.ToString() + ":" + lng.ToString();
+ File.WriteAllText(Directory.GetCurrentDirectory() + "\\Coords.txt", latlng);
+ }
+
private void SetCoordinates(double lat, double lng, double altitude)
{
CurrentLat = lat;
CurrentLng = lng;
CurrentAltitude = altitude;
+ SaveLatLng(lat, lng);
}
public async Task DoGoogleLogin()
diff --git a/PokemonGo.RocketAPI/Logger.cs b/PokemonGo.RocketAPI/Logger.cs
deleted file mode 100644
index 301c303..0000000
--- a/PokemonGo.RocketAPI/Logger.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-using PokemonGo.RocketAPI.Logging;
-using System;
-
-namespace PokemonGo.RocketAPI
-{
- public static class LogColor
- {
- public static ConsoleColor Black = ConsoleColor.Black;
- public static ConsoleColor Blue = ConsoleColor.Blue;
- public static ConsoleColor Cyan = ConsoleColor.Cyan;
- public static ConsoleColor DarkBlue = ConsoleColor.DarkBlue;
- public static ConsoleColor DarkCyan = ConsoleColor.DarkCyan;
- public static ConsoleColor DarkGray = ConsoleColor.DarkGray;
- public static ConsoleColor DarkGreen = ConsoleColor.DarkGreen;
- public static ConsoleColor DarkMagenta = ConsoleColor.DarkMagenta;
- public static ConsoleColor DarkRed = ConsoleColor.DarkRed;
- public static ConsoleColor DarkYellow = ConsoleColor.DarkYellow;
-
- public static ConsoleColor Gray = ConsoleColor.Gray;
- public static ConsoleColor Green = ConsoleColor.Green;
- public static ConsoleColor Magenta = ConsoleColor.Magenta;
- public static ConsoleColor Error = ConsoleColor.Red;
- public static ConsoleColor White = ConsoleColor.White;
- public static ConsoleColor Yellow = ConsoleColor.Yellow;
- }
-
- /// <summary>
- /// Generic logger which can be used across the projects.
- /// Logger should be set to properly log.
- /// </summary>
- public static class Logger
- {
- private static ILogger logger;
-
- /// <summary>
- /// Set the logger. All future requests to <see cref="Write(string, LogLevel)"/> will use that logger, any old will be unset.
- /// </summary>
- /// <param name="logger"></param>
- public static void SetLogger(ILogger logger)
- {
- Logger.logger = logger;
- }
-
- /// <summary>
- /// write message to log window and file
- /// </summary>
- /// <param name="message">message text</param>
- public static void Normal(string message)
- {
- logger.Write(message);
- }
-
- /// <summary>
- /// Log a specific message to the logger setup by <see cref="SetLogger(ILogger)"/> .
- /// </summary>
- /// <param name="message">The message to log.</param>
- /// <param name="level">Optional level to log. Default <see cref="LogLevel.Info"/>.</param>
- public static void Normal(ConsoleColor color, string message)
- {
- if (logger == null)
- return;
- ConsoleColor originalColor = System.Console.ForegroundColor;
- System.Console.ForegroundColor = color;
- logger.Write(message);
- System.Console.ForegroundColor = originalColor;
- }
-
- /// <summary>
- /// Log a specific message to the logger setup by <see cref="SetLogger(ILogger)"/> .
- /// </summary>
- /// <param name="message">The message to log.</param>
- /// <param name="level">Optional level to log. Default <see cref="LogLevel.Info"/>.</param>
- public static void Error(string message)
- {
- if (logger == null)
- return;
- ConsoleColor originalColor = System.Console.ForegroundColor;
- System.Console.ForegroundColor = ConsoleColor.Red;
- logger.Write(message);
- System.Console.ForegroundColor = originalColor;
- }
-
- }
-
- public enum LogLevel
- {
- None = 0,
- Error = 1,
- Warning = 2,
- Info = 3,
- Debug = 4
- }
-}
\ No newline at end of file
You may download the files in Public Git.