Пример #1
0
		private void ButtonTypePressed(object o)
		{
			App.Click();

			var cfg = new ActionSheetConfig();
			cfg.SetTitle(Vernacular.Catalog.GetString("Maptype"));
			cfg.Add(Vernacular.Catalog.GetString("Street"), () => HandleMapTypeSelection(MapType.Street));
			cfg.Add(Vernacular.Catalog.GetString("Satellite"), () => HandleMapTypeSelection(MapType.Satellite));
			cfg.Add(Vernacular.Catalog.GetString("Hybrid"), () => HandleMapTypeSelection(MapType.Hybrid));
			cfg.Cancel = new ActionSheetOption(Vernacular.Catalog.GetString("Cancel"), App.Click);

			UserDialogs.Instance.ActionSheet(cfg);
		}
Пример #2
0
		/// <summary>
		/// Initializes a new instance of the <see cref="WF.Player.CartridgeListPage"/> class.
		/// </summary>
		/// <param name="cartridges">Cartridges to show.</param>
		public CartridgeListPage(CartridgeStore store)
		{
			this.cartridges = store;

			this.cartridges.CollectionChanged += HandleCartridgesCollectionChanged;

			// If the store is empty, than update it
			if (this.cartridges.Count == 0)
			{
				UpdateCartridges();
			}

			this.BindingContext = this;

			Title = Catalog.GetString("Cartridges");

			NavigationPage.SetTitleIcon(this, "HomeIcon.png");
			NavigationPage.SetBackButtonTitle(this, string.Empty);

			// Only show settings, if device is Android
			#if __ANDROID__

			this.ToolbarItems.Add(new ToolbarItem(Catalog.GetString("Settings"), null, () =>
				{
					App.Navigation.Popped += HandleSettingsClosed;
					App.Navigation.Navigation.PushAsync(new SettingsPage.SettingsPage());
				}, ToolbarItemOrder.Secondary));
			this.ToolbarItems.Add(new ToolbarItem(Catalog.GetString("Feedback"), null, () =>
				HockeyApp.FeedbackManager.ShowFeedbackActivity(Forms.Context), 
				ToolbarItemOrder.Secondary));
			this.ToolbarItems.Add(new ToolbarItem(Catalog.GetString("About"), null, () =>
				{
					App.Navigation.Navigation.PushAsync(new SettingsPage.AboutPage());
				}, ToolbarItemOrder.Secondary));
			this.ToolbarItems.Add(new ToolbarItem(Catalog.GetString("Quit"), null, () =>
				{
					DependencyService.Get<IExit>().ExitApp(0);
				}, ToolbarItemOrder.Secondary));

			#endif

			#if __IOS__

			var toolbarMenu = new ToolbarItem(Catalog.GetString("Menu"), null, () => { //"IconMenu.png", () => {
				App.Click();
				App.Navigation.Popped += HandleSettingsClosed;
				var cfg = new WF.Player.Services.UserDialogs.ActionSheetConfig().SetTitle(Catalog.GetString("Main Menu"));
				cfg.Add(Catalog.GetString("Settings"), () => App.Navigation.Navigation.PushAsync(new SettingsPage.SettingsPage()));
				cfg.Add(Catalog.GetString("Feedback"), () => HockeyApp.BITHockeyManager.SharedHockeyManager.FeedbackManager.ShowFeedbackListView());
				cfg.Add(Catalog.GetString("About"), () => App.Navigation.Navigation.PushAsync(new SettingsPage.AboutPage()));
				cfg.Cancel = new WF.Player.Services.UserDialogs.ActionSheetOption(Catalog.GetString("Cancel"), App.Click);
				UserDialogs.Instance.ActionSheet(cfg);
			});
			this.ToolbarItems.Add (toolbarMenu);

			#endif

			layout = new StackLayout() 
				{
					BackgroundColor = App.Colors.Background,
					VerticalOptions = LayoutOptions.FillAndExpand,
				};

			var listCellHeight = (int)(((DependencyService.Get<IScreen>().Width * 0.25) - 20) * 1.25 + 30);

			list = new ListView() 
				{
					BackgroundColor = App.Colors.Background,
					RowHeight = Device.OnPlatform<int>(110, 120, 120),
					HasUnevenRows = false,
					SeparatorColor = App.Colors.SeparatorLine,
					ItemsSource = cartridges,
					ItemTemplate = new DataTemplate(typeof(CartridgeListCell)),
					IsPullToRefreshEnabled = true,
					RefreshCommand = this.RefreshCommand,
			};

//			list.SetBinding<CartridgeListPage> (ListView.IsRefreshingProperty, vm => vm.IsBusy);
			list.ItemSelected += async (sender, e) =>
			{
				if (e.SelectedItem == null)
				{
					return;
				}

				App.Click();

				var cartridgeTag = (CartridgeTag)e.SelectedItem;
				var cartridgeDetailPage = new CartridgeDetailPage(new CartridgeDetailViewModel(cartridgeTag));

				await App.Navigation.PushAsync(cartridgeDetailPage, true);

				// Clear selection, so it is possible later select the same item
				list.SelectedItem = null;
			};

			layout.Children.Add(list);

			Content = layout;
		}
Пример #3
0
		private void ButtonCenterPressed(object o)
		{
			App.Click();

			var cfg = new WF.Player.Services.UserDialogs.ActionSheetConfig().SetTitle(Catalog.GetString("Focus on"));

			if (App.Game != null)
			{
				// Center menu for inside of game
				cfg.Add(Catalog.GetString("Current Location"), () => HandleCenterLocation());
				cfg.Add(Catalog.GetString("Gamefield"), () => HandleCenterGamefield());
				cfg.Add(Catalog.GetString("Both"), () => HandleCenterBoth());
			}
			else
			{
				if (StartingLocation != null)
				{
					// Show in case we have a StartingLocation the center menu for outside of game
					cfg.Add(Catalog.GetString("Current Location"), () => HandleCenterLocation());
					cfg.Add(Catalog.GetString("Starting Location"), () => HandleCenterGamefield());
					cfg.Add(Catalog.GetString("Both"), () => HandleCenterBoth());
				}
				else
				{
					HandleCenterLocation();

					return;
				}
			}

			cfg.Cancel = new WF.Player.Services.UserDialogs.ActionSheetOption(Catalog.GetString("Cancel"), App.Click);

			UserDialogs.Instance.ActionSheet(cfg);
		}
Пример #4
0
		/// <summary>
		/// Executes the selected command.
		/// </summary>
		/// <param name="command">Command to execute.</param>
		private async void ExecuteCommand(WF.Player.Core.Command command)
		{
			if (command == null)
			{
				return;
			}

			// Notify user
			App.Click();

			if (command.CmdWith) 
			{
				if (command.TargetObjects.Count > 0) 
				{
					// There are one or more targets for this command
					var cfg = new ActionSheetConfig().SetTitle(command.Text);

					foreach (Thing t in command.TargetObjects)
					{
						cfg.Add(
							t.Name, 
							() => 
							{
								App.Click();
								command.Execute(t);
							});
					}

					cfg.Cancel = new ActionSheetOption(Catalog.GetString("Cancel"), App.Click);

					UserDialogs.Instance.ActionSheet(cfg);
				} 
				else 
				{
					// There are no target for this command
					await UserDialogs.Instance.AlertAsync(command.EmptyTargetListText, command.Text, Catalog.GetString("Ok"));
					App.Click();
				}
			} 
			else 
			{
				command.Execute();
			}
		}
Пример #5
0
		/// <summary>
		/// Handles the click of toolbar button, if there are more than one command active.
		/// </summary>
		/// <param name="obj">Object, which is clicked.</param>
		private void HandleCommandsClicked(object obj)
		{
			// Now show a list with all active commands
			var cfg = new ActionSheetConfig().SetTitle(Catalog.GetString("Actions"));

			foreach (WF.Player.Core.Command c in ((Thing)this.activeObject).ActiveCommands)
			{
				cfg.Add(
					c.Text, 
					() => 
					{
						ExecuteCommand(c);
					});
			}

			cfg.Cancel = new ActionSheetOption(Catalog.GetString("Cancel"), App.Click);

			UserDialogs.Instance.ActionSheet(cfg);
		}
Пример #6
0
		/// <summary>
		/// Handles the click of the button.
		/// </summary>
		/// <param name="sender">Sender of event.</param>
		private void HandleButtonClicked(object sender)
		{
			// Get active view
			var view = (GameInputView)App.GameNavigation.CurrentPage;

			if (this.input.InputType == WF.Player.Core.InputType.Unknown)
			{
				App.Game.ShowScreen(ScreenType.Last, null);
				this.input.GiveResult(null);
			}

			if (this.input.InputType == WF.Player.Core.InputType.Text)
			{
				// Click for button
				App.Click();

				// Remove the input screen
				App.Game.ShowScreen(ScreenType.Last, null);

				// Handle input of dialog
				this.input.GiveResult(inputText);
			}

			if (this.input.InputType == WF.Player.Core.InputType.MultipleChoice)
			{
				var cfg = new ActionSheetConfig().SetTitle(Catalog.GetString("Choose"));

				foreach (var c in this.input.Choices)
				{
					cfg.Add(
						c, 
						() =>
						{
							MultipleChoiceSelected(c);
						});
				}

				cfg.Cancel = new ActionSheetOption(Catalog.GetString("Cancel"), App.Click);

				UserDialogs.Instance.ActionSheet(cfg);
			}
		}
Пример #7
0
		/// <summary>
		/// Clicked on button.
		/// </summary>
		/// <param name="command">Command to execute.</param>
		/// <param name="parameter">Parameter for command.</param>
		private void HandleOverflowMenuClick(object parameter)
		{
			// Play any sound, if allowed
			App.Click();

			// Create overflow menu
			// Now show a list with all active commands
			var cfg = new ActionSheetConfig().SetTitle(OverflowMenuText);

			foreach (var b in buttons)
			{
				cfg.Add(b.Button.Text, () => KeyClick(b.Command, b.Button.Text));
			}

			cfg.Cancel = new ActionSheetOption(Catalog.GetString("Cancel"), App.Click);

			UserDialogs.Instance.ActionSheet(cfg);
		}