Skip to content

Commit 938755f

Browse files
committed
fix UI errors
1 parent 6e13be3 commit 938755f

File tree

7 files changed

+361
-14
lines changed

7 files changed

+361
-14
lines changed

J4JMapWinLibrary/credential-dialogs/BingCredentialsDialog.xaml.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
11
// Copyright (c) Microsoft Corporation and Contributors.
22
// Licensed under the MIT License.
33

4-
using Microsoft.UI.Xaml;
5-
using Microsoft.UI.Xaml.Controls;
6-
using Microsoft.UI.Xaml.Controls.Primitives;
7-
using Microsoft.UI.Xaml.Data;
8-
using Microsoft.UI.Xaml.Input;
9-
using Microsoft.UI.Xaml.Media;
10-
using Microsoft.UI.Xaml.Navigation;
114
using System;
12-
using System.Collections.Generic;
13-
using System.IO;
14-
using System.Linq;
15-
using System.Runtime.InteropServices.WindowsRuntime;
16-
using Windows.Foundation;
17-
using Windows.Foundation.Collections;
185
using J4JSoftware.J4JMapLibrary;
196

207
// To learn more about WinUI, the WinUI project structure,
@@ -23,7 +10,7 @@
2310
namespace J4JSoftware.J4JMapWinLibrary;
2411

2512
[CredentialsDialog(typeof(BingCredentials))]
26-
public sealed partial class BingCredentialsDialog : ContentDialog, ICredentialsDialog
13+
public sealed partial class BingCredentialsDialog : ICredentialsDialog
2714
{
2815
private readonly BingCredentials _credentials;
2916

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<!-- Copyright (c) Microsoft Corporation and Contributors. -->
2+
<!-- Licensed under the MIT License. -->
3+
4+
<ContentDialog
5+
x:Class="J4JSoftware.J4JMapWinLibrary.GoogleCredentialsDialog"
6+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
7+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
8+
xmlns:local="using:J4JSoftware.J4JMapWinLibrary"
9+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
10+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
11+
mc:Ignorable="d"
12+
PrimaryButtonText="Submit"
13+
SecondaryButtonText="Cancel">
14+
15+
<ContentDialog.TitleTemplate>
16+
<DataTemplate>
17+
<TextBlock Text="Google Maps Credentials"
18+
HorizontalAlignment="Center"
19+
Margin="5"
20+
FontWeight="Bold"/>
21+
</DataTemplate>
22+
</ContentDialog.TitleTemplate>
23+
24+
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
25+
Margin="0,20">
26+
27+
<Grid.ColumnDefinitions>
28+
<ColumnDefinition Width="Auto"/>
29+
<ColumnDefinition Width="*"/>
30+
</Grid.ColumnDefinitions>
31+
32+
<Grid.RowDefinitions>
33+
<RowDefinition Height="Auto"/>
34+
<RowDefinition Height="Auto"/>
35+
<RowDefinition Height="Auto"/>
36+
<RowDefinition Height="Auto"/>
37+
<RowDefinition Height="Auto"/>
38+
</Grid.RowDefinitions>
39+
40+
<TextBlock Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"
41+
Margin="5"
42+
VerticalAlignment="Top">
43+
You need an API key and Signature Secret to use the Google Maps service.
44+
</TextBlock>
45+
46+
<TextBlock Grid.Column="0" Grid.Row="1"
47+
Margin="5"
48+
VerticalAlignment="Center"
49+
Text="API Key"/>
50+
51+
<TextBox Grid.Column="1" Grid.Row="1"
52+
Margin="5"
53+
VerticalAlignment="Center"
54+
Text="{x:Bind ApiKey, Mode=TwoWay}"/>
55+
56+
<TextBlock Grid.Column="0" Grid.Row="2"
57+
Margin="5"
58+
VerticalAlignment="Center"
59+
Text="Signature Secret"/>
60+
61+
<TextBox Grid.Column="1" Grid.Row="2"
62+
Margin="5"
63+
VerticalAlignment="Center"
64+
Text="{x:Bind SignatureSecret, Mode=TwoWay}"/>
65+
66+
<CheckBox Grid.Column="1" Grid.Row="3"
67+
Margin="5"
68+
VerticalAlignment="Center"
69+
IsChecked="{x:Bind CancelOnFailure, Mode=TwoWay}">
70+
Submit but cancel if authentication fails
71+
</CheckBox>
72+
73+
<TextBlock Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="2"
74+
Margin="5"
75+
VerticalAlignment="Top"
76+
TextWrapping="WrapWholeWords">
77+
Instructions on how to obtain a Google Maps API key and signature secret can
78+
be found at
79+
<Hyperlink NavigateUri="https://developers.google.com/maps/documentation/maps-static/get-api-key">
80+
https://developers.google.com/maps/documentation/maps-static/get-api-key
81+
</Hyperlink>
82+
</TextBlock>
83+
84+
</Grid>
85+
</ContentDialog>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright (c) Microsoft Corporation and Contributors.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
using J4JSoftware.J4JMapLibrary;
6+
using Microsoft.UI.Xaml.Controls;
7+
8+
// To learn more about WinUI, the WinUI project structure,
9+
// and more about our project templates, see: http://aka.ms/winui-project-info.
10+
11+
namespace J4JSoftware.J4JMapWinLibrary;
12+
13+
[CredentialsDialog(typeof(GoogleCredentials))]
14+
public sealed partial class GoogleCredentialsDialog : ICredentialsDialog
15+
{
16+
private readonly GoogleCredentials _credentials;
17+
18+
public GoogleCredentialsDialog()
19+
{
20+
if (MapControlViewModelLocator.Instance == null)
21+
throw new NullReferenceException($"{typeof(MapControlViewModelLocator)} was not initialized");
22+
23+
var temp = MapControlViewModelLocator.Instance.CredentialsFactory[ typeof( GoogleMapsProjection ), false ];
24+
if( temp is not GoogleCredentials credentials )
25+
throw new NullReferenceException($"{typeof(GoogleCredentials)} could not be created");
26+
27+
_credentials = credentials;
28+
29+
this.InitializeComponent();
30+
}
31+
32+
public string ApiKey
33+
{
34+
get => _credentials.ApiKey;
35+
set => _credentials.ApiKey = value;
36+
}
37+
38+
public string SignatureSecret
39+
{
40+
get => _credentials.SignatureSecret;
41+
set => _credentials.SignatureSecret = value;
42+
}
43+
44+
public ICredentials Credentials => _credentials;
45+
46+
public bool CancelOnFailure { get; set; }
47+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<!-- Copyright (c) Microsoft Corporation and Contributors. -->
2+
<!-- Licensed under the MIT License. -->
3+
4+
<ContentDialog
5+
x:Class="J4JSoftware.J4JMapWinLibrary.OpenStreetCredentialsDialog"
6+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
7+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
8+
xmlns:local="using:J4JSoftware.J4JMapWinLibrary"
9+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
10+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
11+
mc:Ignorable="d"
12+
PrimaryButtonText="Submit"
13+
SecondaryButtonText="Cancel">
14+
15+
<ContentDialog.TitleTemplate>
16+
<DataTemplate>
17+
<TextBlock Text="Open Street Maps Credentials"
18+
HorizontalAlignment="Center"
19+
Margin="5"
20+
FontWeight="Bold"/>
21+
</DataTemplate>
22+
</ContentDialog.TitleTemplate>
23+
24+
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
25+
Margin="0,20">
26+
27+
<Grid.ColumnDefinitions>
28+
<ColumnDefinition Width="Auto"/>
29+
<ColumnDefinition Width="*"/>
30+
</Grid.ColumnDefinitions>
31+
32+
<Grid.RowDefinitions>
33+
<RowDefinition Height="Auto"/>
34+
<RowDefinition Height="Auto"/>
35+
<RowDefinition Height="Auto"/>
36+
<RowDefinition Height="Auto"/>
37+
</Grid.RowDefinitions>
38+
39+
<TextBlock Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"
40+
Margin="5"
41+
VerticalAlignment="Top">
42+
You need to define a unique identifying user agent value for your app to use the Open Street Maps service.
43+
</TextBlock>
44+
45+
<TextBlock Grid.Column="0" Grid.Row="1"
46+
Margin="5"
47+
VerticalAlignment="Center"
48+
Text="User Agent"/>
49+
50+
<TextBox Grid.Column="1" Grid.Row="1"
51+
Margin="5"
52+
VerticalAlignment="Center"
53+
Text="{x:Bind UserAgent, Mode=TwoWay}"/>
54+
55+
<CheckBox Grid.Column="1" Grid.Row="2"
56+
Margin="5"
57+
VerticalAlignment="Center"
58+
IsChecked="{x:Bind CancelOnFailure, Mode=TwoWay}">
59+
Submit but cancel if authentication fails
60+
</CheckBox>
61+
62+
<TextBlock Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2"
63+
Margin="5"
64+
VerticalAlignment="Top"
65+
TextWrapping="WrapWholeWords">
66+
Instructions on how to define a valid user agent value can
67+
be found at
68+
<Hyperlink NavigateUri="https://operations.osmfoundation.org/policies/tiles/">
69+
https://operations.osmfoundation.org/policies/tiles/
70+
</Hyperlink>
71+
</TextBlock>
72+
73+
</Grid>
74+
</ContentDialog>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright (c) Microsoft Corporation and Contributors.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
using J4JSoftware.J4JMapLibrary;
6+
7+
// To learn more about WinUI, the WinUI project structure,
8+
// and more about our project templates, see: http://aka.ms/winui-project-info.
9+
10+
namespace J4JSoftware.J4JMapWinLibrary;
11+
12+
[CredentialsDialog(typeof(OpenStreetCredentials))]
13+
public sealed partial class OpenStreetCredentialsDialog : ICredentialsDialog
14+
{
15+
private readonly OpenStreetCredentials _credentials;
16+
17+
public OpenStreetCredentialsDialog()
18+
{
19+
if (MapControlViewModelLocator.Instance == null)
20+
throw new NullReferenceException($"{typeof(MapControlViewModelLocator)} was not initialized");
21+
22+
var temp = MapControlViewModelLocator.Instance.CredentialsFactory[ typeof( OpenStreetMapsProjection ), false ];
23+
if( temp is not OpenStreetCredentials credentials )
24+
throw new NullReferenceException($"{typeof(OpenStreetCredentials)} could not be created");
25+
26+
_credentials = credentials;
27+
28+
this.InitializeComponent();
29+
}
30+
31+
public string UserAgent
32+
{
33+
get => _credentials.UserAgent;
34+
set => _credentials.UserAgent = value;
35+
}
36+
37+
public ICredentials Credentials => _credentials;
38+
39+
public bool CancelOnFailure { get; set; }
40+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<!-- Copyright (c) Microsoft Corporation and Contributors. -->
2+
<!-- Licensed under the MIT License. -->
3+
4+
<ContentDialog
5+
x:Class="J4JSoftware.J4JMapWinLibrary.OpenTopoCredentialsDialog"
6+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
7+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
8+
xmlns:local="using:J4JSoftware.J4JMapWinLibrary"
9+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
10+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
11+
mc:Ignorable="d"
12+
PrimaryButtonText="Submit"
13+
SecondaryButtonText="Cancel">
14+
15+
<ContentDialog.TitleTemplate>
16+
<DataTemplate>
17+
<TextBlock Text="Open Topo Maps Credentials"
18+
HorizontalAlignment="Center"
19+
Margin="5"
20+
FontWeight="Bold"/>
21+
</DataTemplate>
22+
</ContentDialog.TitleTemplate>
23+
24+
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
25+
Margin="0,20">
26+
27+
<Grid.ColumnDefinitions>
28+
<ColumnDefinition Width="Auto"/>
29+
<ColumnDefinition Width="*"/>
30+
</Grid.ColumnDefinitions>
31+
32+
<Grid.RowDefinitions>
33+
<RowDefinition Height="Auto"/>
34+
<RowDefinition Height="Auto"/>
35+
<RowDefinition Height="Auto"/>
36+
<RowDefinition Height="Auto"/>
37+
</Grid.RowDefinitions>
38+
39+
<TextBlock Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"
40+
Margin="5"
41+
VerticalAlignment="Top">
42+
You need to define a unique identifying user agent value for your app to use the Open Street Maps service.
43+
</TextBlock>
44+
45+
<TextBlock Grid.Column="0" Grid.Row="1"
46+
Margin="5"
47+
VerticalAlignment="Center"
48+
Text="User Agent"/>
49+
50+
<TextBox Grid.Column="1" Grid.Row="1"
51+
Margin="5"
52+
VerticalAlignment="Center"
53+
Text="{x:Bind UserAgent, Mode=TwoWay}"/>
54+
55+
<CheckBox Grid.Column="1" Grid.Row="2"
56+
Margin="5"
57+
VerticalAlignment="Center"
58+
IsChecked="{x:Bind CancelOnFailure, Mode=TwoWay}">
59+
Submit but cancel if authentication fails
60+
</CheckBox>
61+
62+
<TextBlock Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2"
63+
Margin="5"
64+
VerticalAlignment="Top"
65+
TextWrapping="WrapWholeWords">
66+
Instructions on how to define a valid user agent value can
67+
be found at
68+
<Hyperlink NavigateUri="https://operations.osmfoundation.org/policies/tiles/">
69+
https://operations.osmfoundation.org/policies/tiles/
70+
</Hyperlink>
71+
</TextBlock>
72+
73+
</Grid>
74+
</ContentDialog>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright (c) Microsoft Corporation and Contributors.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
using J4JSoftware.J4JMapLibrary;
6+
7+
// To learn more about WinUI, the WinUI project structure,
8+
// and more about our project templates, see: http://aka.ms/winui-project-info.
9+
10+
namespace J4JSoftware.J4JMapWinLibrary;
11+
12+
[CredentialsDialog(typeof(OpenTopoCredentials))]
13+
public sealed partial class OpenTopoCredentialsDialog : ICredentialsDialog
14+
{
15+
private readonly OpenTopoCredentials _credentials;
16+
17+
public OpenTopoCredentialsDialog()
18+
{
19+
if (MapControlViewModelLocator.Instance == null)
20+
throw new NullReferenceException($"{typeof(MapControlViewModelLocator)} was not initialized");
21+
22+
var temp = MapControlViewModelLocator.Instance.CredentialsFactory[ typeof( OpenTopoMapsProjection ), false ];
23+
if( temp is not OpenTopoCredentials credentials )
24+
throw new NullReferenceException($"{typeof(OpenTopoCredentials)} could not be created");
25+
26+
_credentials = credentials;
27+
28+
this.InitializeComponent();
29+
}
30+
31+
public string UserAgent
32+
{
33+
get => _credentials.UserAgent;
34+
set => _credentials.UserAgent = value;
35+
}
36+
37+
public ICredentials Credentials => _credentials;
38+
39+
public bool CancelOnFailure { get; set; }
40+
}

0 commit comments

Comments
 (0)