/// <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.GameDetailView"/> class. /// </summary> /// <param name="gameDetailViewModel">Game detail view model.</param> public GameDetailView(GameDetailViewModel gameDetailViewModel) : base() { BindingContext = gameDetailViewModel; App.GameNavigation.ShowBackButton = true; this.SetBinding(GameDetailView.TitleProperty, GameDetailViewModel.NamePropertyName); // Set binding for direction this.DirectionLayout.SetBinding(StackLayout.IsVisibleProperty, GameDetailViewModel.HasDirectionPropertyName); this.DirectionSpaceLayout.SetBinding(BoxView.IsVisibleProperty, GameDetailViewModel.HasDirectionPropertyName); this.DirectionView.SetBinding(DirectionArrow.DirectionProperty, GameDetailViewModel.DirectionPropertyName); this.DistanceView.SetBinding(Label.TextProperty, GameDetailViewModel.DistancePropertyName, BindingMode.OneWay, new ConverterToDistance()); #if __HTML__ var webView = new CustomWebView() { BackgroundColor = App.Colors.Background, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; webView.SetBinding(WebView.SourceProperty, GameDetailViewModel.HtmlSourcePropertyName); ((StackLayout)ContentLayout).Children.Add(webView); #else var scrollLayout = new PinchScrollView() { Orientation = ScrollOrientation.Vertical, Padding = new Thickness(0, 0), HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; var layout = new StackLayout() { BackgroundColor = App.Colors.Background, Orientation = StackOrientation.Vertical, Padding = 10, Spacing = 10, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; var image = new ExtendedImage() { Aspect = Aspect.AspectFit, HorizontalOptions = Settings.ImageAlignment.ToLayoutOptions(), }; image.SetBinding(Image.SourceProperty, GameDetailViewModel.ImageSourcePropertyName); image.SetBinding(VisualElement.IsVisibleProperty, GameDetailViewModel.HasImagePropertyName); layout.Children.Add(image); var description = new ExtendedLabel() { TextColor = App.Colors.Text, FontSize = Settings.FontSize, FontFamily = Settings.FontFamily, XAlign = Settings.TextAlignment, UseMarkdown = App.Game.UseMarkdown, }; description.SetBinding(Label.TextProperty, GameDetailViewModel.DescriptionPropertyName); description.SetBinding(VisualElement.IsVisibleProperty, GameDetailViewModel.HasDescriptionPropertyName); layout.Children.Add(description); scrollLayout.Content = layout; ((StackLayout)ContentLayout).Children.Add(scrollLayout); #endif }
/// <summary> /// Initializes a new instance of the <see cref="WF.Player.GameInputView"/> class. /// </summary> /// <param name="gameInputViewModel">Game input view model.</param> public GameInputView(GameInputViewModel gameInputViewModel) : base() { BindingContext = gameInputViewModel; NavigationPage.SetHasBackButton(this, false); App.GameNavigation.ShowBackButton = false; #if __HTML__ var webView = new CustomWebView () { BackgroundColor = App.Colors.Background, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; webView.SetBinding (WebView.SourceProperty, GameDetailViewModel.HtmlSourcePropertyName); webView.SizeChanged += (object sender, EventArgs e) => { webView.HeightRequest = 1; }; ((StackLayout)ContentLayout).Children.Add(webView); #else ScrollLayout = new PinchScrollView() { Orientation = ScrollOrientation.Vertical, Padding = 0, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; var layout = new StackLayout() { Orientation = StackOrientation.Vertical, Padding = 10, Spacing = 10, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; var image = new ExtendedImage() { Aspect = Aspect.AspectFit, HorizontalOptions = Settings.ImageAlignment.ToLayoutOptions(), }; image.SetBinding(Image.SourceProperty, GameInputViewModel.ImageSourcePropertyName); image.SetBinding(VisualElement.IsVisibleProperty, GameInputViewModel.HasImagePropertyName); layout.Children.Add(image); var description = new ExtendedLabel() { TextColor = App.Colors.Text, FontSize = Settings.FontSize, FontFamily = Settings.FontFamily, XAlign = Settings.TextAlignment, UseMarkdown = App.Game.UseMarkdown, }; description.SetBinding(Label.TextProperty, GameInputViewModel.TextPropertyName); description.SetBinding(VisualElement.IsVisibleProperty, GameInputViewModel.HasTextPropertyName); layout.Children.Add(description); ScrollLayout.Content = layout; ((StackLayout)ContentLayout).Children.Add(ScrollLayout); #endif var scanner = new Image { BackgroundColor = Color.Transparent, Source = "IconScan.png", Aspect = Aspect.AspectFit, #if __IOS__ // WidthRequest = 42, // FontSize = 20, // FontFamily = Settings.FontFamily, #endif HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, }; var tapRecognizer = new TapGestureRecognizer { Command = ((GameInputViewModel)BindingContext).ScannerClicked, NumberOfTapsRequired = 1 }; scanner.GestureRecognizers.Add(tapRecognizer); var entry = new Entry { #if __IOS__ BackgroundColor = Color.FromRgb(223, 223, 223), TextColor = App.Colors.Tint, #endif HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Fill, }; entry.SetBinding(Entry.TextProperty, GameInputViewModel.InputTextPropertyName, BindingMode.TwoWay); entry.SetBinding(Entry.PlaceholderProperty, GameInputViewModel.PlaceholderPropertyName); entry.SetBinding(VisualElement.IsVisibleProperty, GameInputViewModel.HasEntryPropertyName); var button = new Button { BackgroundColor = Color.Transparent, Text = Catalog.GetString("Ok"), TextColor = App.Colors.Tint, #if __IOS__ FontSize = 20, FontFamily = Settings.FontFamily, #endif HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, }; button.SetBinding(Button.CommandProperty, GameInputViewModel.ButtonClickedPropertyName); // BottomEntry.Children.Add(button); BottomEntry = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = Device.OnPlatform(new Thickness(6, 6, 6, 6), new Thickness(6, 2, 2, 2), 2), Children = {scanner, entry, button }, }; }
/// <summary> /// Initializes a new instance of the <see cref="WF.Player.GameMessageboxView"/> class. /// </summary> /// <param name="gameMessageboxViewModel">Game messagebox view model.</param> public GameMessageboxView(GameMessageboxViewModel gameMessageboxViewModel) { BindingContext = gameMessageboxViewModel; NavigationPage.SetHasBackButton(this, false); App.GameNavigation.ShowBackButton = false; #if __HTML__ var webView = new CustomWebView() { BackgroundColor = App.Colors.Background, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; webView.SetBinding(WebView.SourceProperty, GameMessageboxViewModel.HtmlSourcePropertyName); ((StackLayout)ContentLayout).Children.Add(webView); #else var scrollLayout = new PinchScrollView() { Orientation = ScrollOrientation.Vertical, Padding = new Thickness(0, 0), HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; var layout = new StackLayout() { Orientation = StackOrientation.Vertical, Padding = 10, Spacing = 10, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; var image = new ExtendedImage() { Aspect = Aspect.AspectFit, HorizontalOptions = Settings.ImageAlignment.ToLayoutOptions(), }; image.SetBinding(Image.SourceProperty, GameMessageboxViewModel.ImageSourcePropertyName); image.SetBinding(VisualElement.IsVisibleProperty, GameMessageboxViewModel.HasImagePropertyName); layout.Children.Add(image); var description = new ExtendedLabel() { TextColor = App.Colors.Text, FontSize = Settings.FontSize, FontFamily = Settings.FontFamily, XAlign = Settings.TextAlignment, UseMarkdown = App.Game.UseMarkdown, VerticalOptions = LayoutOptions.StartAndExpand, }; description.SetBinding(Label.TextProperty, GameMessageboxViewModel.TextPropertyName); description.SetBinding(VisualElement.IsVisibleProperty, GameMessageboxViewModel.HasTextPropertyName); layout.Children.Add(description); scrollLayout.Content = layout; ((StackLayout)ContentLayout).Children.Add(scrollLayout); #endif }