diff --git a/GoogleMapsApi.sln b/GoogleMapsApi.sln
index 1e9b9e3..aec9da9 100644
--- a/GoogleMapsApi.sln
+++ b/GoogleMapsApi.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.0.31808.319
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31129.286
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GoogleMapsApi.Test", "GoogleMapsApi.Test\GoogleMapsApi.Test.csproj", "{AD9AD8E9-0E2C-470E-9004-373679F9D954}"
EndProject
@@ -17,6 +17,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "artifacts", "artifacts", "{
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GoogleMapsApi", "GoogleMapsApi\GoogleMapsApi.csproj", "{61E9FC82-47B0-43C3-8749-95D3A9967060}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GoogleMapsWPF", "GoogleMapsWPF\GoogleMapsWPF.csproj", "{F81C2FF9-8C3F-4654-ADE1-C93EFA03CB43}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -50,6 +52,18 @@ Global
{61E9FC82-47B0-43C3-8749-95D3A9967060}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{61E9FC82-47B0-43C3-8749-95D3A9967060}.Release|x86.ActiveCfg = Release|Any CPU
{61E9FC82-47B0-43C3-8749-95D3A9967060}.Release|x86.Build.0 = Release|Any CPU
+ {F81C2FF9-8C3F-4654-ADE1-C93EFA03CB43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F81C2FF9-8C3F-4654-ADE1-C93EFA03CB43}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F81C2FF9-8C3F-4654-ADE1-C93EFA03CB43}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {F81C2FF9-8C3F-4654-ADE1-C93EFA03CB43}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {F81C2FF9-8C3F-4654-ADE1-C93EFA03CB43}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {F81C2FF9-8C3F-4654-ADE1-C93EFA03CB43}.Debug|x86.Build.0 = Debug|Any CPU
+ {F81C2FF9-8C3F-4654-ADE1-C93EFA03CB43}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F81C2FF9-8C3F-4654-ADE1-C93EFA03CB43}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F81C2FF9-8C3F-4654-ADE1-C93EFA03CB43}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {F81C2FF9-8C3F-4654-ADE1-C93EFA03CB43}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {F81C2FF9-8C3F-4654-ADE1-C93EFA03CB43}.Release|x86.ActiveCfg = Release|Any CPU
+ {F81C2FF9-8C3F-4654-ADE1-C93EFA03CB43}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/GoogleMapsApi/GoogleMapsApi.csproj b/GoogleMapsApi/GoogleMapsApi.csproj
index a764014..8947408 100644
--- a/GoogleMapsApi/GoogleMapsApi.csproj
+++ b/GoogleMapsApi/GoogleMapsApi.csproj
@@ -35,4 +35,8 @@
+
+
+
+
diff --git a/GoogleMapsWPF/App.xaml b/GoogleMapsWPF/App.xaml
new file mode 100644
index 0000000..bef698c
--- /dev/null
+++ b/GoogleMapsWPF/App.xaml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GoogleMapsWPF/App.xaml.cs b/GoogleMapsWPF/App.xaml.cs
new file mode 100644
index 0000000..7120122
--- /dev/null
+++ b/GoogleMapsWPF/App.xaml.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace GoogleMapsWPF
+{
+ ///
+ /// Interaction logic for App.xaml
+ ///
+ public partial class App : Application
+ {
+ }
+}
diff --git a/GoogleMapsWPF/AssemblyInfo.cs b/GoogleMapsWPF/AssemblyInfo.cs
new file mode 100644
index 0000000..8b5504e
--- /dev/null
+++ b/GoogleMapsWPF/AssemblyInfo.cs
@@ -0,0 +1,10 @@
+using System.Windows;
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
diff --git a/GoogleMapsWPF/GoogleMapsWPF.csproj b/GoogleMapsWPF/GoogleMapsWPF.csproj
new file mode 100644
index 0000000..c3f86d7
--- /dev/null
+++ b/GoogleMapsWPF/GoogleMapsWPF.csproj
@@ -0,0 +1,23 @@
+
+
+
+ WinExe
+ netcoreapp3.1
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GoogleMapsWPF/GoogleMapsWPF.sln b/GoogleMapsWPF/GoogleMapsWPF.sln
new file mode 100644
index 0000000..fa88b24
--- /dev/null
+++ b/GoogleMapsWPF/GoogleMapsWPF.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31129.286
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoogleMapsWPF", "GoogleMapsWPF.csproj", "{2841EEDA-D859-46DB-B2C4-6827D09775CB}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {2841EEDA-D859-46DB-B2C4-6827D09775CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2841EEDA-D859-46DB-B2C4-6827D09775CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2841EEDA-D859-46DB-B2C4-6827D09775CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2841EEDA-D859-46DB-B2C4-6827D09775CB}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {F4B6628F-98BB-409C-A09C-9489B1479D25}
+ EndGlobalSection
+EndGlobal
diff --git a/GoogleMapsWPF/MainWindow.xaml b/GoogleMapsWPF/MainWindow.xaml
new file mode 100644
index 0000000..4103890
--- /dev/null
+++ b/GoogleMapsWPF/MainWindow.xaml
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GoogleMapsWPF/MainWindow.xaml.cs b/GoogleMapsWPF/MainWindow.xaml.cs
new file mode 100644
index 0000000..c24f8d9
--- /dev/null
+++ b/GoogleMapsWPF/MainWindow.xaml.cs
@@ -0,0 +1,184 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using GoogleMapsApi;
+using GoogleMapsApi.Entities.Common;
+using GoogleMapsApi.Entities.Directions.Request;
+using GoogleMapsApi.Entities.Directions.Response;
+using GoogleMapsApi.Entities.Geocoding.Request;
+using GoogleMapsApi.Entities.Geocoding.Response;
+using GoogleMapsApi.StaticMaps;
+using GoogleMapsApi.StaticMaps.Entities;
+using MaterialDesignThemes.Wpf;
+
+namespace GoogleMapsWPF
+{
+ ///
+ /// Interaction logic for MainWindow.xaml
+ ///
+ public partial class MainWindow : Window
+ {
+ public MainWindow()
+ {
+ InitializeComponent();
+
+ }
+
+ public BitmapImage ToBitmapImage(Bitmap bitmap)
+ {
+ using (var memory = new MemoryStream())
+ {
+ bitmap.Save(memory, System.Drawing.Imaging.ImageFormat.Png);
+ memory.Position = 0;
+
+ var bitmapImage = new BitmapImage();
+ bitmapImage.BeginInit();
+ bitmapImage.StreamSource = memory;
+ bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
+ bitmapImage.EndInit();
+
+ return bitmapImage;
+ }
+ }
+
+ private async void search_Click(object sender, RoutedEventArgs e)
+ {
+ if (String.IsNullOrEmpty(origin.Text) || String.IsNullOrEmpty(destination.Text))
+ return;
+
+ string[] waypoints = new string[destinations.Children.Count - 2];
+ for (int i = 1; i < destinations.Children.Count - 1; i++)
+ {
+ waypoints[i - 1] = ((destinations.Children[i] as StackPanel).Children[0] as TextBox).Text;
+ }
+
+ DirectionsRequest directionsRequest = new DirectionsRequest()
+ {
+ Origin = origin.Text,
+ Destination = destination.Text,
+ Waypoints = waypoints,
+ TravelMode = (TravelMode)RadioButtonGroup.SelectedIndex,
+ ApiKey = "AIzaSyDikeBAymgSWrWz-9Y7Danr2mNewZV_MwI"
+ };
+
+ DirectionsResponse directions = await GoogleMaps.Directions.QueryAsync(directionsRequest);
+
+ // Static maps API - get static map of with the path of the directions request
+ StaticMapsEngine staticMapGenerator = new StaticMapsEngine();
+
+ //Path from previos directions request
+ if (directions.Status == DirectionsStatusCodes.OK)
+ {
+ List steps = new List();
+
+ foreach (Route route in directions.Routes)
+ {
+ foreach (Leg leg in route.Legs)
+ {
+ steps.AddRange(leg.Steps);
+ }
+ }
+
+ // All start locations
+ IList path = steps.Select(step => step.StartLocation).ToList();
+ // also the end location of the last step
+ path.Add(steps.Last().EndLocation);
+
+ // Choose Map center
+ int mid = path.Count / 2;
+
+ int sum = steps.Sum(step => step.Distance.Value);
+ int zoom = sum > 45000 ? (45000 / sum) : 15; //needs to be completed
+ string url = staticMapGenerator.GenerateStaticMapURL(new StaticMapRequest(path[mid], zoom, new ImageSize(800, 400))
+ {
+ Pathes = new List(){ new GoogleMapsApi.StaticMaps.Entities.Path()
+ {
+ Style = new PathStyle()
+ {
+ Color = "red"
+ },
+ Locations = path
+
+ }},
+ ApiKey = "AIzaSyDikeBAymgSWrWz-9Y7Danr2mNewZV_MwI"
+ });
+ if (url != null)
+ {
+ Uri uri = new Uri(url);
+ HttpWebRequest httpRequest = (HttpWebRequest)HttpWebRequest.Create(uri);
+
+ HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse();
+ Stream imageStream = httpResponse.GetResponseStream();
+ Bitmap buddyIcon = new Bitmap(imageStream);
+ httpResponse.Close();
+ imageStream.Close();
+
+ image.Source = ToBitmapImage(buddyIcon);
+ }
+ }
+ else MessageBox.Show("Нажаль, маршрут не знайдено");
+ }
+
+ private void swap_Click(object sender, RoutedEventArgs e)
+ {
+ origin.Text = origin.Text + destination.Text;
+ destination.Text = origin.Text.Substring(0, origin.Text.Length - destination.Text.Length);
+ origin.Text = origin.Text.Substring(destination.Text.Length);
+ }
+
+ private void addDestination_Click(object sender, MouseButtonEventArgs e)
+ {
+ if (destinations.Children.Count < 9)
+ {
+ swap.Visibility = Visibility.Collapsed;
+
+ StackPanel sp = new StackPanel();
+ sp.Orientation = Orientation.Horizontal;
+
+ TextBox destinationTB = new TextBox();
+ destinationTB.Margin = new Thickness(5);
+ destinationTB.Width = 170;
+ destinationTB.Padding = new Thickness(10);
+ HintAssist.SetHint(destinationTB, "Пункт призначення");
+
+ PackIcon packIcon = new PackIcon();
+ packIcon.Kind = PackIconKind.DeleteCircleOutline;
+ packIcon.Width = 20;
+ packIcon.Height = 20;
+ packIcon.VerticalAlignment = VerticalAlignment.Center;
+ packIcon.Cursor = Cursors.Hand;
+ packIcon.MouseLeftButtonUp += delete_Click;
+
+ sp.Children.Add(destinationTB);
+ sp.Children.Add(packIcon);
+
+ destinations.Children.Insert(destinations.Children.Count - 1, sp);
+ }
+ else
+ {
+ addDestination.Visibility = Visibility.Collapsed;
+ }
+ }
+
+ private void delete_Click(object sender, MouseButtonEventArgs e)
+ {
+ StackPanel sp = (sender as PackIcon).Parent as StackPanel;
+ destinations.Children.Remove(sp);
+ }
+
+ }
+}
diff --git a/GoogleMapsWPF/google_maps_new_logo_icon_159147.png b/GoogleMapsWPF/google_maps_new_logo_icon_159147.png
new file mode 100644
index 0000000..f000a76
Binary files /dev/null and b/GoogleMapsWPF/google_maps_new_logo_icon_159147.png differ