Skip to content

Commit

Permalink
merge fix
Browse files Browse the repository at this point in the history
  • Loading branch information
anti79 committed Jul 23, 2022
1 parent a9481de commit 034b965
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 29 deletions.
30 changes: 15 additions & 15 deletions GoogleMapsApi.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32408.312
# Visual Studio Version 16
VisualStudioVersion = 16.0.30804.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GoogleMapsApi.Test", "GoogleMapsApi.Test\GoogleMapsApi.Test.csproj", "{AD9AD8E9-0E2C-470E-9004-373679F9D954}"
EndProject
Expand All @@ -19,7 +19,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GoogleMapsApi", "GoogleMaps
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{C2FD166C-D375-4C75-A0BB-1C26FEAA0F65}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UI", "google-maps-api\UI.csproj", "{B05104DC-E752-4484-AFE0-75B0EE203F82}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UI", "google-maps-api\UI.csproj", "{8E3B3E61-EEA4-45A9-A1AF-B584CDCEC566}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -66,18 +66,18 @@ Global
{C2FD166C-D375-4C75-A0BB-1C26FEAA0F65}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{C2FD166C-D375-4C75-A0BB-1C26FEAA0F65}.Release|x86.ActiveCfg = Release|Any CPU
{C2FD166C-D375-4C75-A0BB-1C26FEAA0F65}.Release|x86.Build.0 = Release|Any CPU
{B05104DC-E752-4484-AFE0-75B0EE203F82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B05104DC-E752-4484-AFE0-75B0EE203F82}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B05104DC-E752-4484-AFE0-75B0EE203F82}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{B05104DC-E752-4484-AFE0-75B0EE203F82}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{B05104DC-E752-4484-AFE0-75B0EE203F82}.Debug|x86.ActiveCfg = Debug|Any CPU
{B05104DC-E752-4484-AFE0-75B0EE203F82}.Debug|x86.Build.0 = Debug|Any CPU
{B05104DC-E752-4484-AFE0-75B0EE203F82}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B05104DC-E752-4484-AFE0-75B0EE203F82}.Release|Any CPU.Build.0 = Release|Any CPU
{B05104DC-E752-4484-AFE0-75B0EE203F82}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{B05104DC-E752-4484-AFE0-75B0EE203F82}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{B05104DC-E752-4484-AFE0-75B0EE203F82}.Release|x86.ActiveCfg = Release|Any CPU
{B05104DC-E752-4484-AFE0-75B0EE203F82}.Release|x86.Build.0 = Release|Any CPU
{8E3B3E61-EEA4-45A9-A1AF-B584CDCEC566}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8E3B3E61-EEA4-45A9-A1AF-B584CDCEC566}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E3B3E61-EEA4-45A9-A1AF-B584CDCEC566}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{8E3B3E61-EEA4-45A9-A1AF-B584CDCEC566}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{8E3B3E61-EEA4-45A9-A1AF-B584CDCEC566}.Debug|x86.ActiveCfg = Debug|Any CPU
{8E3B3E61-EEA4-45A9-A1AF-B584CDCEC566}.Debug|x86.Build.0 = Debug|Any CPU
{8E3B3E61-EEA4-45A9-A1AF-B584CDCEC566}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E3B3E61-EEA4-45A9-A1AF-B584CDCEC566}.Release|Any CPU.Build.0 = Release|Any CPU
{8E3B3E61-EEA4-45A9-A1AF-B584CDCEC566}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{8E3B3E61-EEA4-45A9-A1AF-B584CDCEC566}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{8E3B3E61-EEA4-45A9-A1AF-B584CDCEC566}.Release|x86.ActiveCfg = Release|Any CPU
{8E3B3E61-EEA4-45A9-A1AF-B584CDCEC566}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
75 changes: 68 additions & 7 deletions google-maps-api/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using GoogleMapsApi.Entities.Common;
using GoogleMapsApi;
using GoogleMapsApi.Entities.Common;
using GoogleMapsApi.Entities.PlaceAutocomplete.Request;
using GoogleMapsApi.Entities.PlaceAutocomplete.Response;
using GoogleMapsApi.StaticMaps;
using GoogleMapsApi.StaticMaps.Entities;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
Expand All @@ -11,10 +15,11 @@

namespace google_maps_api
{
public class MainViewModel:INotifyPropertyChanged
public class MainViewModel : INotifyPropertyChanged
{
private RouteMapRequest _routemaprequest;
private readonly string apikey = "AIzaSyDikeBAymgSWrWz-9Y7Danr2mNewZV_MwI";
public string apikey { get => "AIzaSyDikeBAymgSWrWz-9Y7Danr2mNewZV_MwI"; }

private RelayCommand _drawcommand;
public RelayCommand DrawCommand
{
Expand Down Expand Up @@ -46,6 +51,31 @@ public RelayCommand ZoomOutCommand
}
}

private RelayCommand _origincommand;
public RelayCommand OriginCommand
{
get => _origincommand;
set
{
_origincommand = value;
NotifyPropertyChanged();
}
}

private RelayCommand _destinationcommand;
public RelayCommand DestinationCommand
{
get => _destinationcommand;
set
{
_destinationcommand = value;
NotifyPropertyChanged();
}
}

public ObservableCollection<string> OriginSource { get; set; }
public ObservableCollection<string> DestinationSource { get; set; }

private string _imageSource;
public string ImageSource
{
Expand Down Expand Up @@ -88,6 +118,8 @@ public string Destination

public MainViewModel()
{
OriginSource = new ObservableCollection<string>();
DestinationSource = new ObservableCollection<string>();
ImageSource = "https://media.discordapp.net/attachments/917760526094856212/1000076529226752072/unknown.png";
DrawCommand = new RelayCommand((_) => {

Expand Down Expand Up @@ -123,8 +155,6 @@ public MainViewModel()
{
MessageBox.Show(ex.Message);
}


});
ZoomOutCommand = new RelayCommand((_) =>
{
Expand All @@ -142,9 +172,40 @@ public MainViewModel()

});

OriginCommand = new RelayCommand((_) =>
{
try
{
var request = new PlaceAutocompleteRequest
{
ApiKey = apikey,
Input = Origin,
};
OriginSource = new ObservableCollection<string>(GetAutocompleteResponse(request).Result.Results.Select(x => x.Description));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
});
DestinationCommand = new RelayCommand((_) =>
{
try
{

}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
});


}


private async Task<PlaceAutocompleteResponse> GetAutocompleteResponse(PlaceAutocompleteRequest? request)
{
return await GoogleMaps.PlaceAutocomplete.QueryAsync(request);
}

}
}
11 changes: 9 additions & 2 deletions google-maps-api/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:materialDesign="https://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:local="clr-namespace:google_maps_api" xmlns:controls="clr-namespace:System.Windows.Controls;assembly=DotNetProjects.Input.Toolkit"
mc:Ignorable="d"
ResizeMode="CanMinimize"
Expand Down Expand Up @@ -92,11 +94,16 @@
</Grid>
</Border>
<StackPanel Orientation='Vertical' Margin="19,59,460,270">
<controls:AutoCompleteBox Text="{Binding Origin, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextChanged="tb_TextChanged" x:Name='tb_origin'>
<controls:AutoCompleteBox ItemsSource="{Binding OriginSource}" TextChanged="tb_origin_TextChanged" Text="{Binding Origin, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" x:Name='tb_origin'>
<!--<i:Interaction.Triggers>
<i:EventTrigger EventName="TextChanged">
<i:InvokeCommandAction Command="{Binding OriginCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>-->
</controls:AutoCompleteBox>
</StackPanel>
<StackPanel Orientation='Vertical' Margin="297,59,182,270">
<controls:AutoCompleteBox Text="{Binding Destination, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextChanged="tb_TextChanged" x:Name='tb_destination'>
<controls:AutoCompleteBox TextChanged="tb_destination_TextChanged" Text="{Binding Destination, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" x:Name='tb_destination'>
</controls:AutoCompleteBox>
</StackPanel>
<Button Command="{Binding DrawCommand}" Click="btn_drawroute" Content="Draw route" Margin="574,55,19,471"/>
Expand Down
29 changes: 24 additions & 5 deletions google-maps-api/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -18,6 +19,7 @@
using GoogleMapsApi.Entities.Directions.Response;
using GoogleMapsApi.Entities.Geocoding.Request;
using GoogleMapsApi.Entities.Geocoding.Response;
using GoogleMapsApi.Entities.PlaceAutocomplete.Request;
using GoogleMapsApi.StaticMaps;
using GoogleMapsApi.StaticMaps.Entities;

Expand All @@ -35,7 +37,7 @@ public MainWindow()
tb_origin.FilterMode = AutoCompleteFilterMode.Contains;
tb_origin.ItemsSource = new string[] { "New York", "Ukraine", "Odesa" };
tb_destination.FilterMode = AutoCompleteFilterMode.Contains;
tb_destination.ItemsSource = new string[] { "New York", "Kyiv", "Odesa" };
//tb_destination.ItemsSource = new string[] { "New York", "Kyiv", "Odesa" };
}

private void TitleBar_MouseDown(object sender, MouseButtonEventArgs e)
Expand All @@ -62,9 +64,26 @@ private void btn_drawroute(object sender, RoutedEventArgs e)
//((MainViewModel)this.DataContext).ImageSource = result;
}

private void tb_TextChanged(object sender, RoutedEventArgs e)
{
private async void tb_origin_TextChanged(object sender, RoutedEventArgs e)
{
var request = new PlaceAutocompleteRequest
{
ApiKey = ((MainViewModel)DataContext).apikey,
Input = $"{tb_origin.Text}",
};

tb_origin.ItemsSource = (await GoogleMaps.PlaceAutocomplete.QueryAsync(request)).Results.Select(x => x.Description);
}

private async void tb_destination_TextChanged(object sender, RoutedEventArgs e)
{
var request = new PlaceAutocompleteRequest
{
ApiKey = ((MainViewModel)DataContext).apikey,
Input = $"{tb_destination.Text}",
};

}
}
tb_destination.ItemsSource = (await GoogleMaps.PlaceAutocomplete.QueryAsync(request)).Results.Select(x => x.Description);
}
}
}
1 change: 1 addition & 0 deletions google-maps-api/UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<ItemGroup>
<PackageReference Include="DotNetProjects.WpfToolkit.Input" Version="6.1.94" />
<PackageReference Include="Expression.Blend.Sdk" Version="1.0.2" />
<PackageReference Include="GoogleMapsApi" Version="1.2.0" />
<PackageReference Include="MaterialDesignColors" Version="2.0.7-ci246" />
<PackageReference Include="MaterialDesignExtensions" Version="3.3.0" />
Expand Down

0 comments on commit 034b965

Please sign in to comment.