示例#1
0
		/// <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
		}
示例#2
0
		/// <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 },
				};
			}
示例#3
0
		/// <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);
		}
示例#4
0
		/// <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
		}