/// <summary> /// Initializes a new instance of the <see cref="WF.Player.CartridgeDetailDescriptionView"/> class. /// </summary> /// <param name="viewModel">View model.</param> public CartridgeDetailMapView(CartridgeDetailViewModel viewModel) : base(viewModel) { Title = Catalog.GetString("Map"); this.DirectionView.SetBinding(DirectionArrow.DirectionProperty, CartridgeDetailViewModel.DirectionPropertyName); this.DistanceView.SetBinding(Label.TextProperty, CartridgeDetailViewModel.DistanceTextPropertyName, BindingMode.OneWay); mapViewModel = new MapViewModel(); mapViewModel.Position = App.GPS.LastKnownPosition; var mapView = new MapView(mapViewModel) { Padding = 0, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, BindingContext = mapViewModel, }; ((StackLayout)ContentLayout).Children.Add(mapView); }
/// <summary> /// Initializes a new instance of the <see cref="WF.Player.CartridgeDetailDescriptionView"/> class. /// </summary> /// <param name="viewModel">View model.</param> public CartridgeDetailDescriptionView(CartridgeDetailViewModel viewModel) : base(viewModel) { Title = Catalog.GetString("Description"); this.DirectionView.SetBinding(DirectionArrow.DirectionProperty, CartridgeDetailViewModel.DirectionPropertyName); this.DistanceView.SetBinding(Label.TextProperty, CartridgeDetailViewModel.DistanceTextPropertyName, BindingMode.OneWay); var layoutScroll = new PinchScrollView() { Orientation = ScrollOrientation.Vertical, Padding = 0, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, }; // Used for padding around the label var layout = new StackLayout() { Padding = 10, }; var label = new Label() { XAlign = Settings.TextAlignment, FontSize = Settings.FontSize, FontFamily = Settings.FontFamily, TextColor = App.Colors.Text, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, }; label.SetBinding(Label.TextProperty, CartridgeDetailViewModel.DescriptionPropertyName); layout.Children.Add(label); layoutScroll.Content = layout; ((StackLayout)ContentLayout).Children.Add(layoutScroll); }
/// <summary> /// Initializes a new instance of the <see cref="WF.Player.CartridgeDetailBasePage"/> class. /// </summary> /// <param name="viewModel">View model.</param> public CartridgeDetailBasePage(CartridgeDetailViewModel viewModel) { this.BindingContext = viewModel; // Show empty string as back button title (default "Back" would be null as string) NavigationPage.SetBackButtonTitle(this, string.Empty); buttonResume = new ToolIconButton("IconResume.png", viewModel.ResumeCommand, false); var buttonStart = new ToolIconButton("IconPlay.png", viewModel.StartCommand); // Activate bottom items if it isn't a play anywhere cartridge if (viewModel.IsPlayAnywhere) { Buttons.Add(buttonResume); buttonResume.Button.IsVisible = ((CartridgeDetailViewModel)BindingContext).HasSaveFile; Buttons.Add(buttonStart); DirectionLayout.IsVisible = false; DirectionSpaceLayout.IsVisible = false; } else { Buttons.Add(new ToolIconButton("IconRouting.png", viewModel.RoutingCommand)); Buttons.Add(buttonResume); buttonResume.Button.IsVisible = ((CartridgeDetailViewModel)BindingContext).HasSaveFile; Buttons.Add(buttonStart); DirectionLayout.IsVisible = true; DirectionSpaceLayout.IsVisible = true; } }
/// <summary> /// Initializes a new instance of the <see cref="WF.Player.CartridgeDetailPage"/> class. /// </summary> /// <param name="viewModel">View model.</param> public CartridgeDetailPage(CartridgeDetailViewModel viewModel) : base(viewModel) { this.SetBinding(ContentPage.TitleProperty, CartridgeDetailViewModel.NamePropertyName); this.DirectionView.SetBinding(DirectionArrow.DirectionProperty, CartridgeDetailViewModel.DirectionPropertyName); this.DistanceView.SetBinding(Label.TextProperty, CartridgeDetailViewModel.DistanceTextPropertyName, BindingMode.OneWay); var layoutScroll = new ScrollView() { Orientation = ScrollOrientation.Vertical, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, }; var layout = new StackLayout() { Orientation = StackOrientation.Vertical, Padding = 10, Spacing = 10, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, }; // Header var label = new Label { XAlign = Settings.TextAlignment, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.CenterAndExpand, FontSize = Settings.FontSize * 1.5, FontFamily = Settings.FontFamily, FontAttributes = FontAttributes.Bold, TextColor = App.Colors.Text, }; label.SetBinding(Label.TextProperty, CartridgeDetailViewModel.NamePropertyName); layout.Children.Add(label); // Author label = new Label { XAlign = Settings.Current.GetValueOrDefault<TextAlignment>(Settings.TextAlignmentKey, TextAlignment.Start), VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.CenterAndExpand, FontSize = Settings.FontSize * 1.2, FontFamily = Settings.FontFamily, FontAttributes = FontAttributes.Bold, TextColor = App.Colors.Text, }; label.SetBinding(Label.TextProperty, CartridgeDetailViewModel.AuthorPropertyName); layout.Children.Add(label); // Poster var poster = new ExtendedImage { Aspect = Aspect.AspectFit, }; poster.SetBinding(Image.SourceProperty, CartridgeDetailViewModel.PosterSourcePropertyName); poster.SetBinding(Image.IsVisibleProperty, CartridgeDetailViewModel.HasPosterPropertyName); layout.Children.Add(poster); var listSource = new List<MenuEntry>(); listSource.Add(new MenuEntry(Catalog.GetString("Description"), App.Colors.Text, HandleDescriptionClicked)); // listSource.Add(new MenuEntry(Catalog.GetString("Details"), App.Colors.Text, HandleDetailsClicked)); // listSource.Add(new MenuEntry(Catalog.GetString("Attributes"), App.Colors.Text, HandleAttributesClicked)); if (!viewModel.IsPlayAnywhere) { listSource.Add(new MenuEntry(Catalog.GetString("Map"), App.Colors.Text, HandleMapClicked)); } // listSource.Add(new MenuEntry(Catalog.GetString("History"), App.Colors.Text, HandleHistoryClicked)); // listSource.Add(new MenuEntry(Catalog.GetString("Logs"), App.Colors.Text, HandleLogsClicked)); var list = new ListView() { BackgroundColor = App.Colors.Background, ItemsSource = listSource, HeightRequest = listSource.Count * 44, SeparatorVisibility = SeparatorVisibility.None, }; var cell = new DataTemplate(typeof(AccessoryCell)); cell.SetBinding(AccessoryCell.TextProperty, "Text"); cell.SetBinding(AccessoryCell.TextColorProperty, "TextColor"); list.ItemTemplate = cell; list.ItemTapped += (object sender, ItemTappedEventArgs e) => { // Get selected MenuEntry MenuEntry me = (MenuEntry)e.Item; // If MenuEntry is null (unselected item), than leave if (me == null) { return; } // Call handler of this MenuEntry me.Handler(sender, e); // Deselect MenuEntry list.SelectedItem = null; }; layout.Children.Add(list); layoutScroll.Content = layout; ((StackLayout)ContentLayout).Children.Add(layoutScroll); }