Clean up code

Brian [2016-08-15 16:39:24]
Clean up code
Filename
PokemonGo.RocketBot.Window/App.config
PokemonGo.RocketBot.Window/Forms/MainForm.cs
PokemonGo.RocketBot.Window/Forms/SettingsForm.cs
PokemonGo.RocketBot.Window/Helpers/DeviceHelper.cs
PokemonGo.RocketBot.Window/Helpers/S2GMapDrawer.cs
PokemonGo.RocketBot.Window/PokemomObject.cs
PokemonGo.RocketBot.Window/WebSocketInterface.cs
RocketBot.sln
diff --git a/PokemonGo.RocketBot.Window/App.config b/PokemonGo.RocketBot.Window/App.config
index 7dc6eeb..d1e0a4c 100644
--- a/PokemonGo.RocketBot.Window/App.config
+++ b/PokemonGo.RocketBot.Window/App.config
@@ -2,9 +2,14 @@

 <configuration>
   <configSections>
-    <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-      <section name="PokemonGo.RocketBot.Window.UserSettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
-      <section name="PokemonGo.RocketBot.Window.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
+    <sectionGroup name="userSettings"
+                  type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+      <section name="PokemonGo.RocketBot.Window.UserSettings"
+               type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
+               allowExeDefinition="MachineToLocalUser" requirePermission="false" />
+      <section name="PokemonGo.RocketBot.Window.Settings"
+               type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
+               allowExeDefinition="MachineToLocalUser" requirePermission="false" />
     </sectionGroup>
   </configSections>
   <startup>
@@ -27,6 +32,7 @@
     </assemblyBinding>
   </runtime>
   <connectionStrings>
-    <add name="Pogo" connectionString="DatasetId = YOUR_DATASET_ID; CertificateFilePath = C:\Path\To\Your\Certificate\File-privatekey.p12; ServiceAccountId = your-service-account-email@developer.gserviceaccount.com; CertificatePassword = notasecret" />
+    <add name="Pogo"
+         connectionString="DatasetId = YOUR_DATASET_ID; CertificateFilePath = C:\Path\To\Your\Certificate\File-privatekey.p12; ServiceAccountId = your-service-account-email@developer.gserviceaccount.com; CertificatePassword = notasecret" />
   </connectionStrings>
 </configuration>
\ No newline at end of file
diff --git a/PokemonGo.RocketBot.Window/Forms/MainForm.cs b/PokemonGo.RocketBot.Window/Forms/MainForm.cs
index 58517b0..d0d63d3 100644
--- a/PokemonGo.RocketBot.Window/Forms/MainForm.cs
+++ b/PokemonGo.RocketBot.Window/Forms/MainForm.cs
@@ -14,6 +14,7 @@ using System.Threading.Tasks;
 using System.Windows.Forms;
 using BrightIdeasSoftware;
 using GMap.NET;
+using GMap.NET.MapProviders;
 using GMap.NET.WindowsForms;
 using GMap.NET.WindowsForms.Markers;
 using PokemonGo.RocketAPI.Helpers;
@@ -25,14 +26,13 @@ using PokemonGo.RocketBot.Logic.PoGoUtils;
 using PokemonGo.RocketBot.Logic.Service;
 using PokemonGo.RocketBot.Logic.State;
 using PokemonGo.RocketBot.Logic.Utils;
+using PokemonGo.RocketBot.Window.Helpers;
 using PokemonGo.RocketBot.Window.Plugin;
 using POGOProtos.Data;
 using POGOProtos.Inventory;
 using POGOProtos.Inventory.Item;
-using POGOProtos.Networking.Responses;
 using POGOProtos.Map.Fort;
-using PokemonGo.RocketBot.Window.Helpers;
-using GMap.NET.MapProviders;
+using POGOProtos.Networking.Responses;

 namespace PokemonGo.RocketBot.Window.Forms
 {
@@ -41,17 +41,17 @@ namespace PokemonGo.RocketBot.Window.Forms
         public static MainForm Instance;
         private static readonly ManualResetEvent QuitEvent = new ManualResetEvent(false);
         private static readonly string subPath = "";
-        private GlobalSettings _settings;
         private static Session _session;
-        private ConsoleLogger _logger;
         public static bool BoolNeedsSetup;
-        private StateMachine _machine;

         private readonly GMapOverlay _playerOverlay = new GMapOverlay("players");
         private readonly GMapOverlay _pokemonsOverlay = new GMapOverlay("pokemons");
         private readonly GMapOverlay _pokestopsOverlay = new GMapOverlay("pokestops");
         private readonly GMapOverlay _searchAreaOverlay = new GMapOverlay("areas");
+        private ConsoleLogger _logger;
+        private StateMachine _machine;
         private GMarkerGoogle _playerMarker;
+        private GlobalSettings _settings;

         public MainForm()
         {
@@ -204,12 +204,15 @@ namespace PokemonGo.RocketBot.Window.Forms
             Logger.SetLoggerContext(_session);

             _session.Navigation.UpdatePositionEvent +=
-                (lat, lng) => _session.EventDispatcher.Send(new UpdatePositionEvent { Latitude = lat, Longitude = lng });
+                (lat, lng) => _session.EventDispatcher.Send(new UpdatePositionEvent {Latitude = lat, Longitude = lng});
             _session.Navigation.UpdatePositionEvent += Navigation_UpdatePositionEvent;

-            RouteOptimizeUtil.RouteOptimizeEvent += (optimizedroute) => _session.EventDispatcher.Send(new OptimizeRouteEvent { OptimizedRoute = optimizedroute });
+            RouteOptimizeUtil.RouteOptimizeEvent +=
+                optimizedroute =>
+                    _session.EventDispatcher.Send(new OptimizeRouteEvent {OptimizedRoute = optimizedroute});
             RouteOptimizeUtil.RouteOptimizeEvent += Visualize;
         }
+
         private async Task StartBot()
         {
             _machine.AsyncStart(new VersionCheckState(), _session);
@@ -231,13 +234,11 @@ namespace PokemonGo.RocketBot.Window.Forms
                 _pokestopsOverlay.Markers.Clear();
                 var routePoint =
                     (from pokeStop in pokeStops
-                     where pokeStop != null
-                     select new PointLatLng(pokeStop.Latitude, pokeStop.Longitude)).ToList();
+                        where pokeStop != null
+                        select new PointLatLng(pokeStop.Latitude, pokeStop.Longitude)).ToList();
                 _pokestopsOverlay.Routes.Clear();
                 _pokestopsOverlay.Routes.Add(new GMapRoute(routePoint, "Walking Path"));
             }
-
-
         }

         private static void Navigation_UpdatePositionEvent(double lat, double lng)
@@ -352,20 +353,20 @@ namespace PokemonGo.RocketBot.Window.Forms
         {
             //olvPokemonList.ButtonClick += PokemonListButton_Click;

-            pkmnName.ImageGetter = delegate (object rowObject)
+            pkmnName.ImageGetter = delegate(object rowObject)
             {
                 var pokemon = rowObject as PokemonObject;

                 var key = pokemon.PokemonId.ToString();
                 if (!olvPokemonList.SmallImageList.Images.ContainsKey(key))
                 {
-                    var img = GetPokemonImage((int)pokemon.PokemonId);
+                    var img = GetPokemonImage((int) pokemon.PokemonId);
                     olvPokemonList.SmallImageList.Images.Add(key, img);
                 }
                 return key;
             };

-            olvPokemonList.FormatRow += delegate (object sender, FormatRowEventArgs e)
+            olvPokemonList.FormatRow += delegate(object sender, FormatRowEventArgs e)
             {
                 var pok = e.Model as PokemonObject;
                 if (olvPokemonList.Objects.Cast<PokemonObject>()
@@ -383,7 +384,7 @@ namespace PokemonGo.RocketBot.Window.Forms
                 }
             };

-            cmsPokemonList.Opening += delegate (object sender, CancelEventArgs e)
+            cmsPokemonList.Opening += delegate(object sender, CancelEventArgs e)
             {
                 e.Cancel = false;
                 cmsPokemonList.Items.Clear();
@@ -639,7 +640,7 @@ namespace PokemonGo.RocketBot.Window.Forms

         private Image GetPokemonImage(int pokemonId)
         {
-            return (Image)Properties.Resources.ResourceManager.GetObject("Pokemon_" + pokemonId);
+            return (Image) Properties.Resources.ResourceManager.GetObject("Pokemon_" + pokemonId);
         }

         private async Task ReloadPokemonList()
@@ -684,7 +685,7 @@ namespace PokemonGo.RocketBot.Window.Forms
                 {
                     var pokemonObject = new PokemonObject(pokemon);
                     var family =
-                        _families.Where(i => (int)i.FamilyId <= (int)pokemon.PokemonId)
+                        _families.Where(i => (int) i.FamilyId <= (int) pokemon.PokemonId)
                             .First();
                     pokemonObject.Candy = family.Candy_;
                     pokemonObjects.Add(pokemonObject);
@@ -738,7 +739,7 @@ namespace PokemonGo.RocketBot.Window.Forms

         private async void ItemBox_ItemClick(object sender, EventArgs e)
         {
-            var item = (ItemData)sender;
+            var item = (ItemData) sender;

             using (var form = new ItemForm(item))
             {
@@ -829,6 +830,5 @@ namespace PokemonGo.RocketBot.Window.Forms
         }

         #endregion POKEMON LIST
-
     }
 }
\ No newline at end of file
diff --git a/PokemonGo.RocketBot.Window/Forms/SettingsForm.cs b/PokemonGo.RocketBot.Window/Forms/SettingsForm.cs
index f79d1b5..c39816d 100644
--- a/PokemonGo.RocketBot.Window/Forms/SettingsForm.cs
+++ b/PokemonGo.RocketBot.Window/Forms/SettingsForm.cs
@@ -18,7 +18,8 @@ namespace PokemonGo.RocketBot.Window.Forms
         private List<DeviceInfo> _deviceInfos;
         private bool _doNotPopulate;

-        private List<ItemId> itemSettings = new List<ItemId> {
+        private List<ItemId> itemSettings = new List<ItemId>
+        {
             ItemId.ItemPokeBall,
             ItemId.ItemGreatBall,
             ItemId.ItemUltraBall,
@@ -28,7 +29,7 @@ namespace PokemonGo.RocketBot.Window.Forms
             ItemId.ItemHyperPotion,
             ItemId.ItemMaxPotion,
             ItemId.ItemRevive,
-            ItemId.ItemMaxRevive,
+            ItemId.ItemMaxRevive
         };

         public SettingsForm()
@@ -58,7 +59,7 @@ namespace PokemonGo.RocketBot.Window.Forms
         private void SettingsForm_Load(object sender, EventArgs e)
         {
             GlobalSettings.Load("");
-            GlobalSettings settings = new GlobalSettings();
+            var settings = new GlobalSettings();

             authTypeCb.Text = settings.Auth.AuthType.ToString();
             if (authTypeCb.Text.ToLower().Equals("google"))
@@ -113,7 +114,7 @@ namespace PokemonGo.RocketBot.Window.Forms
             {
                 for (var i = 0; i < clbCatch.Items.Count; i++)
                 {
-                    var pokemonId = (PokemonId)clbCatch.Items[i];
+                    var pokemonId = (PokemonId) clbCatch.Items[i];
                     if (pokemonIdSetting == pokemonId)
                     {
                         clbCatch.SetItemChecked(i, true);
@@ -125,7 +126,7 @@ namespace PokemonGo.RocketBot.Window.Forms
             {
                 for (var i = 0; i < clbTransfer.Items.Count; i++)
                 {
-                    var pokemonId = (PokemonId)clbTransfer.Items[i];
+                    var pokemonId = (PokemonId) clbTransfer.Items[i];
                     if (pokemonIdSetting == pokemonId)
                     {
                         clbTransfer.SetItemChecked(i, true);
@@ -133,7 +134,7 @@ namespace PokemonGo.RocketBot.Window.Forms
                 }
             }

-          /**  foreach (var pokemonIdSetting in Settings.Instance.ExcludedPokemonEvolve)
+            /**  foreach (var pokemonIdSetting in Settings.Instance.ExcludedPokemonEvolve)
             {
                 for (var i = 0; i < clbEvolve.Items.Count; i++)
                 {
@@ -145,7 +146,7 @@ namespace PokemonGo.RocketBot.Window.Forms
                 }
             } **/

-           /** var itemCounts = Settings.Instance.ItemCounts;
+            /** var itemCounts = Settings.Instance.ItemCounts;
             foreach (ItemSetting itemSetting in flpItems.Controls)
             {
                 foreach (var itemCount in itemCounts)
@@ -186,7 +187,7 @@ namespace PokemonGo.RocketBot.Window.Forms

         private void saveBtn_Click(object sender, EventArgs e)
         {
-           /** Settings.Instance.SetSetting(authTypeCb.Text, "AuthType");
+            /** Settings.Instance.SetSetting(authTypeCb.Text, "AuthType");
             if (authTypeCb.Text.ToLower().Equals("google"))
             {
                 Settings.Instance.SetSetting(UserLoginBox.Text, "GoogleUsername");
diff --git a/PokemonGo.RocketBot.Window/Helpers/DeviceHelper.cs b/PokemonGo.RocketBot.Window/Helpers/DeviceHelper.cs
index dc21afd..d852dbf 100644
--- a/PokemonGo.RocketBot.Window/Helpers/DeviceHelper.cs
+++ b/PokemonGo.RocketBot.Window/Helpers/DeviceHelper.cs
@@ -52,7 +52,7 @@ namespace PokemonGo.RocketBot.Window.Helpers

         public string RandomString(int length, string alphabet = "abcdefghijklmnopqrstuvwxyz0123456789")
         {
-            var outOfRange = byte.MaxValue + 1 - (byte.MaxValue + 1) % alphabet.Length;
+            var outOfRange = byte.MaxValue + 1 - (byte.MaxValue + 1)%alphabet.Length;

             return string.Concat(
                 Enumerable
@@ -60,7 +60,7 @@ namespace PokemonGo.RocketBot.Window.Helpers
                     .Select(e => RandomByte())
                     .Where(randomByte => randomByte < outOfRange)
                     .Take(length)
-                    .Select(randomByte => alphabet[randomByte % alphabet.Length])
+                    .Select(randomByte => alphabet[randomByte%alphabet.Length])
                 );
         }

diff --git a/PokemonGo.RocketBot.Window/Helpers/S2GMapDrawer.cs b/PokemonGo.RocketBot.Window/Helpers/S2GMapDrawer.cs
index 488536e..24a9050 100644
--- a/PokemonGo.RocketBot.Window/Helpers/S2GMapDrawer.cs
+++ b/PokemonGo.RocketBot.Window/Helpers/S2GMapDrawer.cs
@@ -12,7 +12,7 @@ namespace PokemonGo.RocketBot.Window.Helpers
         {
             for (var i = 0; i < cellsIds.Count; i++)
             {
-                var cellId = new S2CellId((ulong)i);
+                var cellId = new S2CellId((ulong) i);
                 var cell = new S2Cell(cellId);

                 var points = new List<PointLatLng>();
diff --git a/PokemonGo.RocketBot.Window/PokemomObject.cs b/PokemonGo.RocketBot.Window/PokemomObject.cs
index 132d8f6..aaf8eba 100644
--- a/PokemonGo.RocketBot.Window/PokemomObject.cs
+++ b/PokemonGo.RocketBot.Window/PokemomObject.cs
@@ -1,8 +1,8 @@
 using System;
 using System.Collections.Generic;
 using PokemonGo.RocketBot.Logic.PoGoUtils;
-using POGOProtos.Enums;
 using POGOProtos.Data;
+using POGOProtos.Enums;
 using POGOProtos.Networking.Responses;

 namespace PokemonGo.RocketBot.Window
diff --git a/PokemonGo.RocketBot.Window/WebSocketInterface.cs b/PokemonGo.RocketBot.Window/WebSocketInterface.cs
index ab0bbba..f86ea2d 100644
--- a/PokemonGo.RocketBot.Window/WebSocketInterface.cs
+++ b/PokemonGo.RocketBot.Window/WebSocketInterface.cs
@@ -22,9 +22,9 @@ namespace PokemonGo.RocketBot.Window
     {
         private readonly WebSocketServer _server;
         private readonly Session _session;
+        private readonly WebSocketEventManager _websocketHandler;
         private PokeStopListEvent _lastPokeStopList;
         private ProfileEvent _lastProfile;
-        private readonly WebSocketEventManager _websocketHandler;

         public WebSocketInterface(int port, Session session)
         {
diff --git a/RocketBot.sln b/RocketBot.sln
index 5f8f53f..c3c9b91 100644
--- a/RocketBot.sln
+++ b/RocketBot.sln
@@ -22,8 +22,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PokemonGo.RocketAPI", "Poke
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "POGOProtos", "POGOProtos\POGOProtos.csproj", "{A03A7BB2-4F0B-467B-84B2-9A76E6AAE6FB}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dijitest", "dijitest\dijitest.csproj", "{87CC2B4F-7303-419E-BB92-63778B1F7384}"
-EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -64,14 +62,6 @@ Global
 		{A03A7BB2-4F0B-467B-84B2-9A76E6AAE6FB}.Release|Any CPU.Build.0 = Release|Any CPU
 		{A03A7BB2-4F0B-467B-84B2-9A76E6AAE6FB}.Release|x86.ActiveCfg = Release|x86
 		{A03A7BB2-4F0B-467B-84B2-9A76E6AAE6FB}.Release|x86.Build.0 = Release|x86
-		{87CC2B4F-7303-419E-BB92-63778B1F7384}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{87CC2B4F-7303-419E-BB92-63778B1F7384}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{87CC2B4F-7303-419E-BB92-63778B1F7384}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{87CC2B4F-7303-419E-BB92-63778B1F7384}.Debug|x86.Build.0 = Debug|Any CPU
-		{87CC2B4F-7303-419E-BB92-63778B1F7384}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{87CC2B4F-7303-419E-BB92-63778B1F7384}.Release|Any CPU.Build.0 = Release|Any CPU
-		{87CC2B4F-7303-419E-BB92-63778B1F7384}.Release|x86.ActiveCfg = Release|Any CPU
-		{87CC2B4F-7303-419E-BB92-63778B1F7384}.Release|x86.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
You may download the files in Public Git.