Skip to content

Commit

Permalink
flip direction of route
Browse files Browse the repository at this point in the history
close #1
  • Loading branch information
MannusEtten committed Jul 1, 2016
1 parent 42379a8 commit b8a67d9
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 10 deletions.
57 changes: 48 additions & 9 deletions TripPreparationApp/BicycleTripsPreparationApp/MainScreen.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ xmlns:s="clr-namespace:System;assembly=mscorlib"
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Image Width="150" Height="99" Source="bike touring gis splash screen.png" Stretch="Fill" Grid.Column="0"/>
Expand All @@ -53,6 +54,51 @@ xmlns:s="clr-namespace:System;assembly=mscorlib"
<TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="Load any gpx-file with routes" Foreground="LightGray" VerticalAlignment="Bottom"/>
</Grid>

<Grid Margin="25,5,5,5">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid Grid.Row="0" Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Row="1" Grid.Column="0" Content="Flip direction" Margin="5" Width="125" Style="{DynamicResource AccentedSquareButtonStyle}" BorderBrush="DarkGreen" Command="{Binding FlipDirectionCommand}" Click="Button_Click_1"/>
</Grid>
</Grid>

<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Margin="5" Content="Save GPX-track" Grid.Row="0" Grid.Column="1" Width="125" Style="{DynamicResource AccentedSquareButtonStyle}" BorderBrush="DarkGreen" Click="Button_Click_2"/>
<TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="Save the original gpx" Foreground="LightGray" VerticalAlignment="Bottom"/>
</Grid>


<Grid Margin="25,5,5,5">
<Button Content="Add POI" Command="{Binding AddPOICommand}"/>
</Grid>
<Grid Margin="25,5,5,5">
<Button Content="Clear POI's" Command="{Binding ClearPOIsCommand}"/>
</Grid>
</StackPanel>
</Border>
<Border BorderBrush="DarkGreen" BorderThickness="1" Margin="5" Grid.Column="2" HorizontalAlignment="Center">
<StackPanel Orientation="Horizontal">
<Grid Margin="25,5,5,5">
<Grid.RowDefinitions>
<RowDefinition/>
Expand All @@ -78,7 +124,6 @@ xmlns:s="clr-namespace:System;assembly=mscorlib"
<Button Margin="5" Content="Create split points" Click="CreateSplitPoints_Click" Grid.Row="0" Grid.Column="1" Width="125" Style="{DynamicResource AccentedSquareButtonStyle}" BorderBrush="DarkGreen"/>
<TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="Split route into smaller routes" Foreground="LightGray" VerticalAlignment="Bottom"/>
</Grid>

<Grid Margin="25,5,5,5">
<Grid.RowDefinitions>
<RowDefinition/>
Expand All @@ -100,19 +145,13 @@ xmlns:s="clr-namespace:System;assembly=mscorlib"
<TextBox x:Name="prefix" Grid.Row="1" Grid.Column="0" Controls:TextBoxHelper.Watermark="Bike tour" Controls:TextBoxHelper.ClearTextButton="True"/>
</Grid>

<Button Margin="5" Content="Save GPX-tracks" Click="SaveGPSTracks_Click" Grid.Row="0" Grid.Column="1" Width="125" Style="{DynamicResource AccentedSquareButtonStyle}" BorderBrush="DarkGreen"/>
<Button Margin="5" Content="Save splitted GPX-tracks" Click="SaveGPSTracks_Click" Grid.Row="0" Grid.Column="1" Width="125" Style="{DynamicResource AccentedSquareButtonStyle}" BorderBrush="DarkGreen"/>
<TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="Save smaller routes" Foreground="LightGray" VerticalAlignment="Bottom"/>
</Grid>

<Grid Margin="25,5,5,5">
<Button Content="Add POI" Command="{Binding AddPOICommand}"/>
</Grid>
<Grid Margin="25,5,5,5">
<Button Content="Clear POI's" Command="{Binding ClearPOIsCommand}"/>
</Grid>
</StackPanel>
</Border>
<Border BorderBrush="DarkGreen" BorderThickness="1" Margin="5" MinWidth="150" Grid.Column="2">
<Border BorderBrush="DarkGreen" BorderThickness="1" Margin="5" MinWidth="150" Grid.Column="3">
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition/>
Expand Down
24 changes: 23 additions & 1 deletion TripPreparationApp/BicycleTripsPreparationApp/MainScreen.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public partial class MainScreen : UserControl
private GraphicsLayer _splitLayer;
private List<wptType> _wayPoints;
private DistanceAnalyzer _distanceAnalyzer;
private string _originalFile;
public MainScreen()
{
InitializeComponent();
Expand All @@ -57,7 +58,8 @@ private void Button_Click(object sender, RoutedEventArgs e)
_routelayer.Graphics.Clear();
_splitLayer.Graphics.Clear();
_poiLayer.Graphics.Clear();
_lastUsedFolder = Path.GetDirectoryName(openFileDialog.FileName);
_originalFile = openFileDialog.FileName;
_lastUsedFolder = Path.GetDirectoryName(_originalFile);
GetWayPoints(openFileDialog.FileName);
}
}
Expand Down Expand Up @@ -135,6 +137,7 @@ private void GetStartAndEndPoint(SimpleMarkerSymbol startSymbol, SimpleMarkerSym
var geometry = CreateGeometryFromWayPoints(wayPoints);
var track = new Graphic(geometry, grid.Resources["TotalRoute"] as SimpleLineSymbol);
track.Attributes["routename"] = "mannus";
_routelayer.Graphics.Clear();
_routelayer.Graphics.Add(track);
var startPoint = new Graphic(new MapPoint((double)wayPoints.First().lon, (double)wayPoints.First().lat, new SpatialReference(4326)), startSymbol);
var endPoint = new Graphic(new MapPoint((double)wayPoints.Last().lon, (double)wayPoints.Last().lat, new SpatialReference(4326)), endSymbol);
Expand Down Expand Up @@ -273,6 +276,25 @@ private void CheckBox_Checked(object sender, RoutedEventArgs e)
Map.Layers[2].IsVisible = !Map.Layers[2].IsVisible;
}

private void Button_Click_1(object sender, RoutedEventArgs e)
{
_wayPoints.Reverse();
SetRoute();
}

private void Button_Click_2(object sender, RoutedEventArgs e)
{
var pois = GetPOIs();
var filename = _originalFile;
var gpxFile = new GPXFile();
var gpx = new gpxType();
var rte = new rteType();
rte.rtept = _wayPoints.ToArray();
gpx.rte = new List<rteType>() { rte }.ToArray();
gpx.wpt = pois;
gpxFile.Save(filename, gpx);
}

private async void UserControl_Loaded(object sender, RoutedEventArgs e)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class MainScreenViewModel : ViewModelBase
public RelayCommand<int> SwitchBaseMapCommand { get; private set; }
public RelayCommand SaveSplittedRoute { get; private set; }
public RelayCommand AddPOICommand { get; private set; }
public RelayCommand FlipDirectionCommand { get; private set; }

public MainScreenViewModel()
{
Expand All @@ -38,10 +39,15 @@ public MainScreenViewModel()
ShowOpenStreetMap = false;
SwitchBaseMapCommand = new RelayCommand<int>(x => SwitchBaseMap(x));
AddPOICommand = new RelayCommand(AddPOI);
FlipDirectionCommand = new RelayCommand(FlipDirection);
MapDoubleClickCommand = new RelayCommand<MapPoint>(x => MapDoubleClick(x));
ClearPOIsCommand = new RelayCommand(ClearPOIs);
}

private void FlipDirection()
{
}

// TODO: nog niet volledig mvvm
private void ClearPOIs()
{
Expand Down

0 comments on commit b8a67d9

Please sign in to comment.