Clean up code

Brian [2016-08-16 15:23:49]
Clean up code
Filename
PokemonGo.RocketBot.Window/App.config
PokemonGo.RocketBot.Window/Forms/MainForm.cs
PokemonGo.RocketBot.Window/Models/GMapMarkerPokestops.cs
PokemonGo.RocketBot.Window/Models/GMapMarkerTrainer.cs
PokemonGo.RocketBot.Window/packages.config
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 842a373..f7dc5ee 100644
--- a/PokemonGo.RocketBot.Window/Forms/MainForm.cs
+++ b/PokemonGo.RocketBot.Window/Forms/MainForm.cs
@@ -17,7 +17,6 @@ using BrightIdeasSoftware;
 using GMap.NET;
 using GMap.NET.MapProviders;
 using GMap.NET.WindowsForms;
-using GMap.NET.WindowsForms.Markers;
 using PokemonGo.RocketAPI.Helpers;
 using PokemonGo.RocketBot.Logic;
 using PokemonGo.RocketBot.Logic.Common;
@@ -28,14 +27,13 @@ using PokemonGo.RocketBot.Logic.Service;
 using PokemonGo.RocketBot.Logic.State;
 using PokemonGo.RocketBot.Logic.Utils;
 using PokemonGo.RocketBot.Window.Helpers;
+using PokemonGo.RocketBot.Window.Models;
 using PokemonGo.RocketBot.Window.Plugin;
 using POGOProtos.Data;
 using POGOProtos.Inventory;
 using POGOProtos.Inventory.Item;
 using POGOProtos.Map.Fort;
 using POGOProtos.Networking.Responses;
-using PokemonGo.RocketAPI.Extensions;
-using PokemonGo.RocketBot.Window.Models;

 namespace PokemonGo.RocketBot.Window.Forms
 {
@@ -99,7 +97,8 @@ namespace PokemonGo.RocketBot.Window.Forms
             gMapControl1.Overlays.Add(_pokemonsOverlay);
             gMapControl1.Overlays.Add(_playerOverlay);

-            _playerMarker = new GMapMarkerTrainer(new PointLatLng(lat, lng), (Image)Properties.Resources.ResourceManager.GetObject("Trainer"));
+            _playerMarker = new GMapMarkerTrainer(new PointLatLng(lat, lng),
+                (Image) Properties.Resources.ResourceManager.GetObject("Trainer"));
             _playerOverlay.Markers.Add(_playerMarker);
             _playerMarker.Position = new PointLatLng(lat, lng);
             _searchAreaOverlay.Polygons.Clear();
@@ -210,12 +209,12 @@ 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 });
+                    _session.EventDispatcher.Send(new OptimizeRouteEvent {OptimizedRoute = optimizedroute});
             RouteOptimizeUtil.RouteOptimizeEvent += Visualize;
         }

@@ -243,8 +242,8 @@ 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();
                 var route = new GMapRoute(routePoint, "Walking Path");
                 route.Stroke = new Pen(Color.FromArgb(128, 0, 179, 253), 4);
@@ -261,7 +260,8 @@ namespace PokemonGo.RocketBot.Window.Forms
                 foreach (var pokeStop in _pokeStops)
                 {
                     var pokeStopLoc = new PointLatLng(pokeStop.Latitude, pokeStop.Longitude);
-                    var pokestopMarker = new GMapMarkerPokestops(pokeStopLoc, (Image)Properties.Resources.ResourceManager.GetObject("Pokestop_Inrange"));
+                    var pokestopMarker = new GMapMarkerPokestops(pokeStopLoc,
+                        (Image) Properties.Resources.ResourceManager.GetObject("Pokestop_Inrange"));
                     //pokestopMarker.ToolTipMode = MarkerTooltipMode.OnMouseOver;
                     //pokestopMarker.ToolTip = new GMapBaloonToolTip(pokestopMarker);
                     _pokestopsOverlay.Markers.Add(pokestopMarker);
@@ -274,7 +274,6 @@ namespace PokemonGo.RocketBot.Window.Forms
                 _playerOverlay.Routes.Clear();
                 _playerOverlay.Routes.Add(route);
             }, null);
-
         }

         private async void Navigation_UpdatePositionEvent(double lat, double lng)
@@ -393,20 +392,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>()
@@ -424,7 +423,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();
@@ -680,7 +679,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()
@@ -725,7 +724,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);
@@ -779,7 +778,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))
             {
diff --git a/PokemonGo.RocketBot.Window/Models/GMapMarkerPokestops.cs b/PokemonGo.RocketBot.Window/Models/GMapMarkerPokestops.cs
index e6c1364..0786ed1 100644
--- a/PokemonGo.RocketBot.Window/Models/GMapMarkerPokestops.cs
+++ b/PokemonGo.RocketBot.Window/Models/GMapMarkerPokestops.cs
@@ -1,42 +1,31 @@
 using System.Drawing;
 using GMap.NET;
+using GMap.NET.WindowsForms;

 namespace PokemonGo.RocketBot.Window.Models
 {
-    public class GMapMarkerPokestops : GMap.NET.WindowsForms.GMapMarker
+    public class GMapMarkerPokestops : GMapMarker
     {
-        private Image img;
-
         /// <summary>
-        /// The image to display as a marker.
-        /// </summary>
-        public Image MarkerImage
-        {
-            get
-            {
-                return img;
-            }
-            set
-            {
-                img = value;
-            }
-        }
-
-        /// <summary>
-        /// Constructor
+        ///     Constructor
         /// </summary>
         /// <param name="p">The position of the marker</param>
         public GMapMarkerPokestops(PointLatLng p, Image image)
             : base(p)
         {
-            img = image;
-            Size = img.Size;
-            Offset = new System.Drawing.Point(-Size.Width / 2, -Size.Height);
+            MarkerImage = image;
+            Size = MarkerImage.Size;
+            Offset = new Point(-Size.Width/2, -Size.Height);
         }

+        /// <summary>
+        ///     The image to display as a marker.
+        /// </summary>
+        public Image MarkerImage { get; set; }
+
         public override void OnRender(Graphics g)
         {
-            g.DrawImage(img, LocalPosition.X, LocalPosition.Y, Size.Width, Size.Height);
+            g.DrawImage(MarkerImage, LocalPosition.X, LocalPosition.Y, Size.Width, Size.Height);
         }
     }
 }
\ No newline at end of file
diff --git a/PokemonGo.RocketBot.Window/Models/GMapMarkerTrainer.cs b/PokemonGo.RocketBot.Window/Models/GMapMarkerTrainer.cs
index f16e9d6..3d9148f 100644
--- a/PokemonGo.RocketBot.Window/Models/GMapMarkerTrainer.cs
+++ b/PokemonGo.RocketBot.Window/Models/GMapMarkerTrainer.cs
@@ -1,42 +1,31 @@
 using System.Drawing;
 using GMap.NET;
+using GMap.NET.WindowsForms;

 namespace PokemonGo.RocketBot.Window.Models
 {
-    public class GMapMarkerTrainer : GMap.NET.WindowsForms.GMapMarker
+    public class GMapMarkerTrainer : GMapMarker
     {
-        private Image img;
-
         /// <summary>
-        /// The image to display as a marker.
-        /// </summary>
-        public Image MarkerImage
-        {
-            get
-            {
-                return img;
-            }
-            set
-            {
-                img = value;
-            }
-        }
-
-        /// <summary>
-        /// Constructor
+        ///     Constructor
         /// </summary>
         /// <param name="p">The position of the marker</param>
         public GMapMarkerTrainer(PointLatLng p, Image image)
             : base(p)
         {
-            img = image;
-            Size = img.Size;
-            Offset = new System.Drawing.Point(-Size.Width / 2, -Size.Height / 2);
+            MarkerImage = image;
+            Size = MarkerImage.Size;
+            Offset = new Point(-Size.Width/2, -Size.Height/2);
         }

+        /// <summary>
+        ///     The image to display as a marker.
+        /// </summary>
+        public Image MarkerImage { get; set; }
+
         public override void OnRender(Graphics g)
         {
-            g.DrawImage(img, LocalPosition.X, LocalPosition.Y, Size.Width, Size.Height);
+            g.DrawImage(MarkerImage, LocalPosition.X, LocalPosition.Y, Size.Width, Size.Height);
         }
     }
 }
\ No newline at end of file
diff --git a/PokemonGo.RocketBot.Window/packages.config b/PokemonGo.RocketBot.Window/packages.config
index 51bda38..7fd6988 100644
--- a/PokemonGo.RocketBot.Window/packages.config
+++ b/PokemonGo.RocketBot.Window/packages.config
@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
+
 <packages>
   <package id="C5" version="2.4.5947.17249" targetFramework="net452" />
   <package id="Costura.Fody" version="1.3.3.0" targetFramework="net45" developmentDependency="true" />
You may download the files in Public Git.