Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BookmarksViewSample fixes #543

Merged
merged 7 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
<Button Text="Map/Scene" Grid.Row="3" Grid.Column="2" Clicked="AddToMapScene_Click" />
<Button Text="Red fore" Grid.Row="4" Grid.Column="1" Clicked="SetItemTemplateOne_Click" />
<Button Text="Red back" Grid.Row="4" Grid.Column="2" Clicked="SetItemTemplateTwo_Click" />
<Button Text="Add" Grid.Row="5" Grid.Column="1" Clicked="AddSelectionListener_Click" />
<Button Text="Remove" Grid.Row="5" Grid.Column="2" Clicked="RemoveSelectionListener_Click" />
<Switch x:Name="BookmarkListenerSwitch" Grid.Row="5" Grid.Column="1" HorizontalOptions="Start"
Toggled="BookmarkListenerSwitch_Toggled"/>
</Grid>
</Grid>
</ScrollView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial class BookmarksViewSample : ContentPage
private const string webMapOneUrl = "https://arcgisruntime.maps.arcgis.com/home/item.html?id=e50fafe008ac4ce4ad2236de7fd149c3";
private const string webMapTwoUrl = "https://arcgisruntime.maps.arcgis.com/home/item.html?id=16f1b8ba37b44dc3884afc8d5f454dd2";
private const string webSceneOne = "https://arcgisruntime.maps.arcgis.com/home/item.html?id=6b6588041965408e84ba319e12d9d7ad";
private const string webSceneTwo = "https://www.arcgis.com/home/webscene/viewer.html?webscene=b9ad8372ff884bc4a4e78d936b170f7d";
private const string webSceneTwo = "https://arcgisruntime.maps.arcgis.com/home/item.html?id=b3e2230e170d4f91aa3d47f88821743d";
private MapView MyMapView;
private SceneView MySceneView;
private Random _randomizer = new Random();
Expand Down Expand Up @@ -48,6 +48,8 @@ private void SetMapViewBinding_Click(object? sender, EventArgs e)
BookmarksView.SetBinding(Esri.ArcGISRuntime.Toolkit.Maui.BookmarksView.GeoViewProperty, geoviewBinding);
}

// Note that the Web Scene Specification does not use bookmarks.
// As such, the BookmarksView will initially be empty, so click the "Set list" button to generate bookmarks.
private void SetSceneViewBinding_Click(object? sender, EventArgs e)
{
if (_viewContainer.Children.Contains(MySceneView) == false)
Expand Down Expand Up @@ -128,14 +130,16 @@ private void SetItemTemplateTwo_Click(object? sender, EventArgs e)
BookmarksView.ItemTemplate = template;
}

private void AddSelectionListener_Click(object? sender, EventArgs e)
private void BookmarkListenerSwitch_Toggled(object sender, ToggledEventArgs e)
{
BookmarksView.BookmarkSelected += BookmarkSelected;
}

private void RemoveSelectionListener_Click(object? sender, EventArgs e)
{
BookmarksView.BookmarkSelected -= BookmarkSelected;
if (BookmarkListenerSwitch.IsToggled)
{
BookmarksView.BookmarkSelected += BookmarkSelected;
}
else
{
BookmarksView.BookmarkSelected -= BookmarkSelected;
}
}

private void BookmarkSelected(object? sender, Bookmark bookmark)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
</Setter.Value>
</Setter>
</Style>
<Grid x:Name="Dialog" />
</Page.Resources>
<Grid>
<Grid.ColumnDefinitions>
Expand Down Expand Up @@ -143,8 +144,8 @@
<Button Content="Map/Scene" Grid.Row="3" Grid.Column="2" Click="AddToMapScene_Click" />
<Button Content="Red fore" Grid.Row="4" Grid.Column="1" Click="SetItemTemplateOne_Click" />
<Button Content="Red back" Grid.Row="4" Grid.Column="2" Click="SetItemTemplateTwo_Click" />
<Button Content="Add" Grid.Row="5" Grid.Column="1" Click="AddSelectionListener_Click" />
<Button Content="Remove" Grid.Row="5" Grid.Column="2" Click="RemoveSelectionListener_Click" />
<ToggleButton x:Name="BookmarkListenerToggle" Content="Add listener" Grid.Row="5" Grid.Column="1"
Grid.ColumnSpan="2" Click="SelectionListenerToggle_Click" HorizontalAlignment="Stretch" Margin="5" />
<Button Content="Default" Grid.Row="6" Grid.Column="1" Click="SelectDefaultItemContainer_Click" />
<Button Content="Custom" Grid.Row="6" Grid.Column="2" Click="SelectCustomItemContainer_Click" />
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public sealed partial class BookmarksViewSample : Page
private const string webMapOneUrl = "https://arcgisruntime.maps.arcgis.com/home/item.html?id=e50fafe008ac4ce4ad2236de7fd149c3";
private const string webMapTwoUrl = "https://arcgisruntime.maps.arcgis.com/home/item.html?id=16f1b8ba37b44dc3884afc8d5f454dd2";
private const string webSceneOne = "https://arcgisruntime.maps.arcgis.com/home/item.html?id=6b6588041965408e84ba319e12d9d7ad";
private const string webSceneTwo = "https://www.arcgis.com/home/webscene/viewer.html?webscene=b9ad8372ff884bc4a4e78d936b170f7d";
private const string webSceneTwo = "https://arcgisruntime.maps.arcgis.com/home/item.html?id=b3e2230e170d4f91aa3d47f88821743d";

private Random _randomizer = new Random();

Expand Down Expand Up @@ -46,6 +46,8 @@ private void SetMapViewBinding_Click(object sender, RoutedEventArgs e)
BookmarksView.SetBinding(UI.Controls.BookmarksView.GeoViewProperty, geoviewBinding);
}

// Note that the Web Scene Specification does not use bookmarks.
// As such, the BookmarksView will initially be empty, so click the "Set list" button to generate bookmarks.
private void SetSceneViewBinding_Click(object sender, RoutedEventArgs e)
{
MyMapView.Visibility = Visibility.Collapsed;
Expand Down Expand Up @@ -124,19 +126,30 @@ private void SetItemTemplateTwo_Click(object sender, RoutedEventArgs e)
BookmarksView.ItemTemplate = template;
}

private void AddSelectionListener_Click(object sender, RoutedEventArgs e)
private void SelectionListenerToggle_Click(object sender, RoutedEventArgs e)
{
BookmarksView.BookmarkSelected += BookmarkSelected;
}

private void RemoveSelectionListener_Click(object sender, RoutedEventArgs e)
{
BookmarksView.BookmarkSelected -= BookmarkSelected;
if (BookmarkListenerToggle.IsChecked == true)
{
BookmarksView.BookmarkSelected += BookmarkSelected;
BookmarkListenerToggle.Content = "Remove";
}
else
{
BookmarksView.BookmarkSelected -= BookmarkSelected;
BookmarkListenerToggle.Content = "Add";
}
}

private async void BookmarkSelected(object sender, Bookmark bookmark)
{
await new MessageDialog($"{bookmark.Name} Selected!").ShowAsync();
await new ContentDialog
{
XamlRoot = Dialog.XamlRoot,
Title = "Bookmark Selected",
Content = bookmark.Name,
CloseButtonText = "Ok"
}
.ShowAsync();
}

private void SelectDefaultItemContainer_Click(object sender, RoutedEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@
<Button Content="Map/Scene" Grid.Row="3" Grid.Column="2" Click="AddToMapScene_Click" />
<Button Content="Red fore" Grid.Row="4" Grid.Column="1" Click="SetItemTemplateOne_Click" />
<Button Content="Red back" Grid.Row="4" Grid.Column="2" Click="SetItemTemplateTwo_Click" />
<Button Content="Add" Grid.Row="5" Grid.Column="1" Click="AddSelectionListener_Click" />
<Button Content="Remove" Grid.Row="5" Grid.Column="2" Click="RemoveSelectionListener_Click" />
<ToggleButton x:Name="SelectionListenerToggle" Content="Add listener" Grid.Row="5" Grid.Column="1"
Grid.ColumnSpan="2" Click="SelectionListenerToggle_Click" />
<Button Content="Default" Grid.Row="6" Grid.Column="1" Click="SelectDefaultItemContainer_Click" />
<Button Content="Custom" Grid.Row="6" Grid.Column="2" Click="SelectCustomItemContainer_Click" />
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public partial class BookmarksViewSample : UserControl
private const string webMapOneUrl = "https://arcgisruntime.maps.arcgis.com/home/item.html?id=e50fafe008ac4ce4ad2236de7fd149c3";
private const string webMapTwoUrl = "https://arcgisruntime.maps.arcgis.com/home/item.html?id=16f1b8ba37b44dc3884afc8d5f454dd2";
private const string webSceneOne = "https://arcgisruntime.maps.arcgis.com/home/item.html?id=6b6588041965408e84ba319e12d9d7ad";
private const string webSceneTwo = "https://www.arcgis.com/home/webscene/viewer.html?webscene=b9ad8372ff884bc4a4e78d936b170f7d";
private const string webSceneTwo = "https://arcgisruntime.maps.arcgis.com/home/item.html?id=b3e2230e170d4f91aa3d47f88821743d";

private Random _randomizer = new Random();

Expand Down Expand Up @@ -57,6 +57,8 @@ private void SetMapViewBinding_Click(object sender, RoutedEventArgs e)
BookmarksView.SetBinding(UI.Controls.BookmarksView.GeoViewProperty, geoviewBinding);
}

// Note that the Web Scene specification does not use bookmarks.
// As such, the BookmarksView will initially be empty, so click the "Set list" button to generate bookmarks.
private void SetSceneViewBinding_Click(object sender, RoutedEventArgs e)
{
MyMapView.Visibility = Visibility.Collapsed;
Expand Down Expand Up @@ -135,14 +137,18 @@ private void SetItemTemplateTwo_Click(object sender, RoutedEventArgs e)
BookmarksView.ItemTemplate = template;
}

private void AddSelectionListener_Click(object sender, RoutedEventArgs e)
private void SelectionListenerToggle_Click(object sender, RoutedEventArgs e)
{
BookmarksView.BookmarkSelected += BookmarkSelected;
}

private void RemoveSelectionListener_Click(object sender, RoutedEventArgs e)
{
BookmarksView.BookmarkSelected -= BookmarkSelected;
if (SelectionListenerToggle.IsChecked == true)
{
BookmarksView.BookmarkSelected += BookmarkSelected;
SelectionListenerToggle.Content = "Remove";
}
else
{
BookmarksView.BookmarkSelected -= BookmarkSelected;
SelectionListenerToggle.Content = "Add";
}
}

private void BookmarkSelected(object sender, Bookmark bookmark)
Expand Down
Loading