Example #1
0
        public static async Task <bool> ChangeBillboard(int id, BookListChangeType changeType,
                                                        int?alteredId = null, string alteredText = null)
        {
            var admin = new AdminObject("ChangeBillboard")
            {
                BillboardId   = id,
                ChangeType    = (int)changeType,
                AlteredBookId = alteredId,
                AlteredText   = alteredText
            };

            if (Storage.Test)
            {
                return(true);
            }

            var recv = await Connection.SendAdminAndReceive.GlobalLock(admin);

            var obj = JsonConvert.DeserializeObject(recv, typeof(ReceiveObject)) as ReceiveObject;

            if (obj != null && obj.Message != null && obj.Message.Trim().Length > 0)
            {
                var dialog = new Windows.UI.Xaml.Controls.ContentDialog()
                {
                    Content = obj.Message.Trim(),
                    Title   = "Edit Billboard Result",
                    IsSecondaryButtonEnabled = false,
                    PrimaryButtonText        = "OK"
                };
                await dialog.ShowAsync();
            }
            return(obj != null && obj.Success);
        }
Example #2
0
        private async void OnDeleteDirectoryCommandExecute()
        {
            // Rückfrage
            // https://docs.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/dialogs-and-flyouts/dialogs
            Windows.UI.Xaml.Controls.ContentDialog locationPromptDialog = new Windows.UI.Xaml.Controls.ContentDialog
            {
                Title             = "Bestätigung",
                Content           = "Möchten Sie den gesamten Ordner löschen?",
                CloseButtonText   = "Abbrechen",
                PrimaryButtonText = "Löschen"
            };

            Windows.UI.Xaml.Controls.ContentDialogResult result = await locationPromptDialog.ShowAsync();

            // wenn löschen bestätigt
            if (result == Windows.UI.Xaml.Controls.ContentDialogResult.Primary)
            {
                // Ordner lokal löschen
                StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
                StorageFolder currentFolder = await storageFolder.GetFolderAsync(SelectedDirName);

                await currentFolder.DeleteAsync();

                // Ordner in Dropbox löschen
                DropboxCommunication dropbox = new DropboxCommunication(AppSettings.Default.DropBoxAppToken);
                dropbox.DeleteFolderAsync(SelectedDirName);
                UpdateDirNamesAsync();
            }
        }
 void newPlayerContentDialog_Closing(Windows.UI.Xaml.Controls.ContentDialog sender, Windows.UI.Xaml.Controls.ContentDialogClosingEventArgs args)
 {
     if (newPlayerContentDialog.NewPlayer == null)
     {
         return;
     }
     newPlayerContentDialog.Closing -= newPlayerContentDialog_Closing;
     PlayersViewModel.Instance.InsertPlayer(newPlayerContentDialog.NewPlayer);
 }
Example #4
0
        private static void OnPrimaryButtonClick(Windows.UI.Xaml.Controls.ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var contentDialog = sender as Windows.UI.Xaml.Controls.ContentDialog;

            if (contentDialog != null)
            {
                var command = GetCancelableCommand(contentDialog);
                command?.Execute(GetCancelableCommandParameter(contentDialog));
                args.Cancel = GetDialogCancel(contentDialog);
            }
        }
Example #5
0
        public override void showErrorDialog(string message)
        {
            var dlg = new Windows.UI.Xaml.Controls.ContentDialog()
            {
                Title               = "ERROR",
                Content             = message,
                SecondaryButtonText = "OK"
            };

            dlg.ShowAsync();
        }
        async void choseTeamDialog_Closing(Windows.UI.Xaml.Controls.ContentDialog sender, Windows.UI.Xaml.Controls.ContentDialogClosingEventArgs args)
        {
            await choseTeamDialog.ProgresIndicator.HideAsync();

            if (choseTeamDialog.SelectedTeam == null)
            {
                return;
            }

            selectedTeam           = choseTeamDialog.SelectedTeam;
            TeamNameTextBlock.Text = selectedTeam.TeamName;
        }
        void addTeamDialog_Closing(Windows.UI.Xaml.Controls.ContentDialog sender, Windows.UI.Xaml.Controls.ContentDialogClosingEventArgs args)
        {
            if (addTeamDialog.NewTeam == null)
            {
                return;
            }

            TeamsViewModel.Instance.InsertTeam(addTeamDialog.NewTeam);

            selectedTeam           = addTeamDialog.NewTeam;
            TeamNameTextBlock.Text = selectedTeam.TeamName;
        }
Example #8
0
        public override async void showMessageDialog(string title, string message, System.Action callback)
        {
            var dlg = new Windows.UI.Xaml.Controls.ContentDialog()
            {
                Title               = title,
                Content             = message,
                SecondaryButtonText = "OK"
            };
            await dlg.ShowAsync();

            if (callback != null)
            {
                callback();
            }
        }
Example #9
0
        private async void CommunicationService_Packet0008Received(object sender, Packet0008ReceivedEventArgs e)
        {
            if (!e.IsCreated)
            {
                Windows.UI.Xaml.Controls.ContentDialog dialog = new Windows.UI.Xaml.Controls.ContentDialog()
                {
                    Title           = "방만들기 실패",
                    Content         = $"{e.Request.UserID} {Environment.NewLine}{e.Message}",
                    CloseButtonText = "닫기",
                    DefaultButton   = Windows.UI.Xaml.Controls.ContentDialogButton.Close
                };
                switch (await dialog.ShowAsync())
                {
                case Windows.UI.Xaml.Controls.ContentDialogResult.Primary:

                    break;
                }
            }
        }
Example #10
0
        /// <summary>
        /// Displays a <see cref="Windows.UI.Xaml.Controls.ContentDialog"/>.
        /// </summary>
        /// <param name="title">The dialog's title.</param>
        /// <param name="textContent">The dialog's text contents.</param>
        /// <param name="primaryButton">The primary button text.</param>
        /// <param name="secondaryButton">The secondary button text.</param>
        /// <param name="defaultBtn">Which <see cref="Windows.UI.Xaml.Controls.ContentDialogButton"/> will be primary?</param>
        /// <returns>bool? result of displaying.</returns>
        public static bool?ShowDialog
            (string title, string primaryButton, string secondaryButton, string textContent = "",
            Windows.UI.Xaml.Controls.ContentDialogButton?defaultBtn = Windows.UI.Xaml.Controls.ContentDialogButton.Primary)
        {
            Windows.UI.Xaml.Controls.ContentDialog dialog = new Windows.UI.Xaml.Controls.ContentDialog
            {
                Title               = title,
                Content             = textContent,
                PrimaryButtonText   = primaryButton,
                SecondaryButtonText = secondaryButton,
                CloseButtonText     = "Cancel",
                DefaultButton       = (Windows.UI.Xaml.Controls.ContentDialogButton)defaultBtn
            };

            Windows.Foundation.IAsyncOperation <Windows.UI.Xaml.Controls.ContentDialogResult> operation = dialog.ShowAsync(); //run the dialog asynchronously
            if (operation.Status == Windows.Foundation.AsyncStatus.Started)                                                   //check the status
            {
                return(true);
            }
            return(null);
        }
Example #11
0
        private KeyboardService()
        {
            _helper         = new KeyboardHelper();
            _helper.KeyDown = async(e) =>
            {
                e.Handled = true;

                // use this to place focus in search box
                if (e.OnlyControl && e.Character.ToString().ToLower().Equals("e"))
                {
                    DebugWrite("Control+E", caller: nameof(AfterControlEGesture));
                    AfterControlEGesture?.Invoke();
                }

                // use this to nav back
                else if (e.VirtualKey == Windows.System.VirtualKey.GoBack)
                {
                    DebugWrite("GoBack", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.VirtualKey == Windows.System.VirtualKey.NavigationLeft)
                {
                    DebugWrite("NavigationLeft", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadMenu)
                {
                    DebugWrite("GamepadMenu", caller: nameof(AfterMenuGesture));
                    AfterMenuGesture?.Invoke();
                }

                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadLeftShoulder)
                {
                    DebugWrite("GamepadLeftShoulder", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Back)
                {
                    DebugWrite("Alt+Back", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Left)
                {
                    DebugWrite("Alt+Left", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                // use this to nav forward
                else if (e.VirtualKey == Windows.System.VirtualKey.GoForward)
                {
                    DebugWrite("GoForward", caller: nameof(AfterForwardGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.NavigationRight)
                {
                    DebugWrite("NavigationRight", caller: nameof(AfterForwardGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadRightShoulder)
                {
                    DebugWrite("GamepadRightShoulder", caller: nameof(AfterForwardGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Right)
                {
                    DebugWrite("Alt+Right", caller: nameof(AfterForwardGesture));
                    AfterForwardGesture?.Invoke();
                }

                // about
                else if (e.AltKey && e.ControlKey && e.ShiftKey && e.VirtualKey == Windows.System.VirtualKey.F12)
                {
                    var about = new Windows.UI.Xaml.Controls.ContentDialog
                    {
                        Title               = "Template 10",
                        PrimaryButtonText   = "Info",
                        SecondaryButtonText = "Close"
                    };

                    try
                    {
                        var result = await about.ShowAsync();

                        if (result == Windows.UI.Xaml.Controls.ContentDialogResult.Primary)
                        {
                            await Windows.System.Launcher.LaunchUriAsync(new Uri("http://aka.ms/template10"));
                        }
                    }
                    catch (System.Runtime.InteropServices.COMException)
                    {
                        DebugWrite("About dialog already showing");
                    }
                }

                // anything else
                else
                {
                    e.Handled = false;
                }
            };
            _helper.PointerGoBackGestured = () =>
            {
                DebugWrite(caller: nameof(KeyboardHelper.PointerGoBackGestured));
                AfterBackGesture?.Invoke();
            };
            _helper.PointerGoForwardGestured = () =>
            {
                DebugWrite(caller: nameof(KeyboardHelper.PointerGoForwardGestured));
                AfterForwardGesture?.Invoke();
            };
        }
Example #12
0
 private static void Dialog_Closed(Windows.UI.Xaml.Controls.ContentDialog sender, Windows.UI.Xaml.Controls.ContentDialogClosedEventArgs args)
 {
     DialogDisplaySemaphoreSlim.Release();
 }
Example #13
0
        private KeyboardService()
        {
            _helper = new KeyboardHelper();
            _helper.KeyDown = async (e) =>
            {
                e.Handled = true;

                // use this to place focus in search box
                 if (e.OnlyControl && e.Character.ToString().ToLower().Equals("e"))
                {
                    DebugWrite("Control+E", caller: nameof(AfterControlEGesture));
                    AfterControlEGesture?.Invoke();
                }

                // use this to nav back
                else if (e.VirtualKey == Windows.System.VirtualKey.GoBack)
                {
                    DebugWrite("GoBack", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.VirtualKey == Windows.System.VirtualKey.NavigationLeft)
                {
                    DebugWrite("NavigationLeft", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadMenu)
                {
                    DebugWrite("GamepadMenu", caller: nameof(AfterMenuGesture));
                    AfterMenuGesture?.Invoke();
                }

                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadLeftShoulder)
                {
                    DebugWrite("GamepadLeftShoulder", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Back)
                {
                    DebugWrite("Alt+Back", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Left)
                {
                    DebugWrite("Alt+Left", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                // use this to nav forward
                else if (e.VirtualKey == Windows.System.VirtualKey.GoForward)
                {
                    DebugWrite("GoForward", caller: nameof(AfterForwardGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.NavigationRight)
                {
                    DebugWrite("NavigationRight", caller: nameof(AfterForwardGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadRightShoulder)
                {
                    DebugWrite("GamepadRightShoulder", caller: nameof(AfterForwardGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Right)
                {
                    DebugWrite("Alt+Right", caller: nameof(AfterForwardGesture));
                    AfterForwardGesture?.Invoke();
                }

                // about
                else if (e.AltKey && e.ControlKey && e.ShiftKey && e.VirtualKey == Windows.System.VirtualKey.F12)
                {
                    var open = new Action(async () => { await Windows.System.Launcher.LaunchUriAsync(new Uri("http://aka.ms/template10")); });
                    var about = new Windows.UI.Xaml.Controls.ContentDialog
                    {
                        Title = "Template 10",
                        PrimaryButtonText = "Info",
                        PrimaryButtonCommand = new Mvvm.DelegateCommand(open),
                        SecondaryButtonText = "Close"
                    };

                    try
                    {
                        await about.ShowAsync();
                    }
                    catch (System.Runtime.InteropServices.COMException)
                    {
                        DebugWrite("About dialog already showing");
                    }
                }

                // anything else
                else
                    e.Handled = false;
            };
            _helper.PointerGoBackGestured = () =>
            {
                DebugWrite(caller: nameof(KeyboardHelper.PointerGoBackGestured));
                AfterBackGesture?.Invoke();
            };
            _helper.PointerGoForwardGestured = () =>
            {
                DebugWrite(caller: nameof(KeyboardHelper.PointerGoForwardGestured));
                AfterForwardGesture?.Invoke();
            };
        }
Example #14
0
 private void QueueContentDialog_ButtonClick(Windows.UI.Xaml.Controls.ContentDialog sender, Windows.UI.Xaml.Controls.ContentDialogButtonClickEventArgs args)
 {
     Timer.Tick -= Timer_Tick;
     Timer.Stop();
 }
        private void WindowsXamlHost_Loaded(object sender, RoutedEventArgs e)
        {
            windows.UI.Xaml.Controls.StackPanel stackPanel = new windows.UI.Xaml.Controls.StackPanel()
            {
                Background = new windows.UI.Xaml.Media.SolidColorBrush(windows.UI.Colors.Black),
            };

            stackPanel.Children.Add(new windows.UI.Xaml.Shapes.Rectangle()
            {
                Width  = 50,
                Height = 75,
                Fill   = new windows.UI.Xaml.Media.SolidColorBrush(windows.UI.Colors.Blue),
            });

            stackPanel.Children.Add(new windows.UI.Xaml.Shapes.Rectangle()
            {
                Width  = 200,
                Height = 30,
                Fill   = new windows.UI.Xaml.Media.SolidColorBrush(windows.UI.Colors.Red),
            });

            var button = new windows.UI.Xaml.Controls.Button()
            {
                Width  = 160,
                Height = 60,
                HorizontalAlignment = windows.UI.Xaml.HorizontalAlignment.Center,
                Content             = "ContentDialog UWP Button",
            };

            button.Tapped += Button_Tapped;
            stackPanel.Children.Add(button);

            stackPanel.Children.Add(new windows.UI.Xaml.Shapes.Rectangle()
            {
                Width  = 25,
                Height = 100,
                Fill   = new windows.UI.Xaml.Media.SolidColorBrush(windows.UI.Colors.Green),
            });

            windows.UI.Xaml.Controls.Flyout flyout = new windows.UI.Xaml.Controls.Flyout();
            flyout.Content = new windows.UI.Xaml.Controls.TextBlock()
            {
                Text = "Flyout content",
            };

            var button2 = new windows.UI.Xaml.Controls.Button()
            {
                Width  = 300,
                Height = 40,
                HorizontalAlignment = windows.UI.Xaml.HorizontalAlignment.Center,
                Content             = "Long UWP Button with Flyout",
                Flyout = flyout,
            };

            stackPanel.Children.Add(button2);

            var comboBox = new windows.UI.Xaml.Controls.ComboBox()
            {
                HorizontalAlignment = windows.UI.Xaml.HorizontalAlignment.Center,
            };

            comboBox.Items.Add("One");
            comboBox.Items.Add("Two");
            comboBox.Items.Add("Three");
            comboBox.Items.Add("Four");
            stackPanel.Children.Add(comboBox);

            windows.UI.Xaml.Controls.Grid grid = new windows.UI.Xaml.Controls.Grid();
            stackPanel.Children.Add(grid);

            _contentDialog         = new windows.UI.Xaml.Controls.ContentDialog();
            _contentDialog.Content = new windows.UI.Xaml.Controls.TextBlock()
            {
                Text = "ContentDialog content",
            };
            stackPanel.Children.Add(_contentDialog);

            var popup = new windows.UI.Xaml.Controls.Primitives.Popup()
            {
                Width  = 50,
                Height = 50,
                ShouldConstrainToRootBounds = false,
                Child = new windows.UI.Xaml.Controls.TextBlock()
                {
                    Text = "Popup child",
                },
            };

            grid.Children.Add(popup);

            windowsXamlHost.Child = stackPanel;
            popup.IsOpen          = true;
        }
 void ChoseTeamDialog_Closing(Windows.UI.Xaml.Controls.ContentDialog sender, Windows.UI.Xaml.Controls.ContentDialogClosingEventArgs args)
 {
     Loaded -= ChoseTeamDialog_Loaded;
 }
Example #17
0
        private KeyboardService()
        {
            _helper = new KeyboardHelper();
            _helper.KeyDown = async (e) =>
            {
                e.Handled = true;

                // use this to hide and show the menu
                if (e.WindowsKey && e.Character.ToString().ToLower().Equals("z"))
                {
                    DebugWrite("Windows+Z", caller: nameof(AfterWindowZGesture));
                    AfterWindowZGesture?.Invoke();
                }

                // use this to place focus in search box
                else if (e.OnlyControl && e.Character.ToString().ToLower().Equals("e"))
                {
                    DebugWrite("Control+E", caller: nameof(AfterControlEGesture));
                    AfterControlEGesture?.Invoke();
                }

                // use this to nav back
                else if (e.VirtualKey == Windows.System.VirtualKey.GoBack)
                {
                    DebugWrite("GoBack", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.VirtualKey == Windows.System.VirtualKey.NavigationLeft)
                {
                    DebugWrite("NavigationLeft", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadLeftShoulder)
                {
                    DebugWrite("GamepadLeftShoulder", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Back)
                {
                    DebugWrite("Alt+Back", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Left)
                {
                    DebugWrite("Alt+Left", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                // use this to nav forward
                else if (e.VirtualKey == Windows.System.VirtualKey.GoForward)
                {
                    DebugWrite("GoForward", caller: nameof(AfterBackGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.NavigationRight)
                {
                    DebugWrite("NavigationRight", caller: nameof(AfterBackGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadRightShoulder)
                {
                    DebugWrite("GamepadRightShoulder", caller: nameof(AfterBackGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Right)
                {
                    DebugWrite("Alt+Right", caller: nameof(AfterBackGesture));
                    AfterForwardGesture?.Invoke();
                }

                // about
                else if (e.AltKey && e.ControlKey && e.ShiftKey && e.VirtualKey == Windows.System.VirtualKey.A)
                {
                    var open = new Action(async () => { await Windows.System.Launcher.LaunchUriAsync(new Uri("http://aka.ms/template10")); });
                    var about = new Windows.UI.Xaml.Controls.ContentDialog
                    {
                        Title = "Template 10",
                        Content = "Congratulations. This project uses Template 10, an open source framework for Windows 10 apps written against the Universal Windows Platform.",
                        PrimaryButtonText = "Info",
                        PrimaryButtonCommand = new Mvvm.DelegateCommand(open),
                        SecondaryButtonText = "Close"
                    };
                    await about.ShowAsync();
                }

                // anything else
                else
                    e.Handled = false;
            };
            _helper.PointerGoBackGestured = () =>
            {
                DebugWrite(caller: nameof(KeyboardHelper.PointerGoBackGestured));
                AfterBackGesture?.Invoke();
            };
            _helper.PointerGoForwardGestured = () =>
            {
                DebugWrite(caller: nameof(KeyboardHelper.PointerGoForwardGestured));
                AfterForwardGesture?.Invoke();
            };
        }
Example #18
0
        private KeyboardService()
        {
            _helper         = new KeyboardHelper();
            _helper.KeyDown = async(e) =>
            {
                e.Handled = true;

                // use this to hide and show the menu
                if (e.WindowsKey && e.Character.ToString().ToLower().Equals("z"))
                {
                    DebugWrite("Windows+Z", caller: nameof(AfterWindowZGesture));
                    AfterWindowZGesture?.Invoke();
                }

                // use this to place focus in search box
                else if (e.OnlyControl && e.Character.ToString().ToLower().Equals("e"))
                {
                    DebugWrite("Control+E", caller: nameof(AfterControlEGesture));
                    AfterControlEGesture?.Invoke();
                }

                // use this to nav back
                else if (e.VirtualKey == Windows.System.VirtualKey.GoBack)
                {
                    DebugWrite("GoBack", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.VirtualKey == Windows.System.VirtualKey.NavigationLeft)
                {
                    DebugWrite("NavigationLeft", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadLeftShoulder)
                {
                    DebugWrite("GamepadLeftShoulder", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Back)
                {
                    DebugWrite("Alt+Back", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Left)
                {
                    DebugWrite("Alt+Left", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                // use this to nav forward
                else if (e.VirtualKey == Windows.System.VirtualKey.GoForward)
                {
                    DebugWrite("GoForward", caller: nameof(AfterBackGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.NavigationRight)
                {
                    DebugWrite("NavigationRight", caller: nameof(AfterBackGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadRightShoulder)
                {
                    DebugWrite("GamepadRightShoulder", caller: nameof(AfterBackGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Right)
                {
                    DebugWrite("Alt+Right", caller: nameof(AfterBackGesture));
                    AfterForwardGesture?.Invoke();
                }

                // about
                else if (e.AltKey && e.ControlKey && e.ShiftKey && e.VirtualKey == Windows.System.VirtualKey.A)
                {
                    var open  = new Action(async() => { await Windows.System.Launcher.LaunchUriAsync(new Uri("http://aka.ms/template10")); });
                    var about = new Windows.UI.Xaml.Controls.ContentDialog
                    {
                        Title                = "Template 10",
                        Content              = "Congratulations. This project uses Template 10, an open source framework for Windows 10 apps written against the Universal Windows Platform.",
                        PrimaryButtonText    = "Info",
                        PrimaryButtonCommand = new Mvvm.DelegateCommand(open),
                        SecondaryButtonText  = "Close"
                    };
                    await about.ShowAsync();
                }

                // anything else
                else
                {
                    e.Handled = false;
                }
            };
            _helper.PointerGoBackGestured = () =>
            {
                DebugWrite(caller: nameof(KeyboardHelper.PointerGoBackGestured));
                AfterBackGesture?.Invoke();
            };
            _helper.PointerGoForwardGestured = () =>
            {
                DebugWrite(caller: nameof(KeyboardHelper.PointerGoForwardGestured));
                AfterForwardGesture?.Invoke();
            };
        }
Example #19
0
 private void OnContentDialogSecondaryButtonClick(Windows.UI.Xaml.Controls.ContentDialog sender, Windows.UI.Xaml.Controls.ContentDialogButtonClickEventArgs args)
 {
 }
Example #20
0
        public static async void OpenInputDialog(string title, Action <string> callback, int max_length = 0, object[] args = null)
        {
            if (PlatformFunctions.IsDialogOpen)
            {
                return;
            }

            PlatformFunctions.IsDialogOpen = true;
            string result = "";

            Engine.Pause();
#if ANDROID
            var builder = new Android.App.AlertDialog.Builder(NeonPartyGamesControllerGame.AndroidContext);
            var input   = new Android.Widget.EditText(NeonPartyGamesControllerGame.AndroidContext);
            var tcs     = new System.Threading.Tasks.TaskCompletionSource <bool>();

            builder.SetTitle(title);
            if (args != null && args.Length > 0)
            {
                input.InputType = (Android.Text.InputTypes)args[0];
            }
            else
            {
                input.InputType = Android.Text.InputTypes.ClassText;
            }
            if (max_length > 0)
            {
                input.SetFilters(new Android.Text.IInputFilter[] { new Android.Text.InputFilterLengthFilter(max_length) });
            }
            builder.SetView(input);
            builder.SetPositiveButton("OK", (sender_alert, sender_args) => {
                VibrationHelper.Vibrate();
                result = input.Text;
            });
            builder.SetOnDismissListener(new OnDismissListener(() => tcs.TrySetResult(true)));
            builder.Show();
            await tcs.Task;
#elif IOS
            var tcs = new System.Threading.Tasks.TaskCompletionSource <bool>();
            UIKit.UIAlertView alert = new UIKit.UIAlertView();
            alert.Title = title;
            alert.AddButton("OK");
            alert.AlertViewStyle = UIKit.UIAlertViewStyle.PlainTextInput;
            alert.Clicked       += (object s, UIKit.UIButtonEventArgs ev) => {
                if (ev.ButtonIndex == 0)
                {
                    result = alert.GetTextField(0).Text;
                }
            };
            alert.Dismissed += (object s, UIKit.UIButtonEventArgs ev) => {
                tcs.TrySetResult(true);
            };
            alert.Show();
            await tcs.Task;
#elif NETFX_CORE
            await Xamarin.Essentials.MainThread.InvokeOnMainThreadAsync(async() =>
            {
                var input_text_box = new Windows.UI.Xaml.Controls.TextBox
                {
                    AcceptsReturn = false,
                    Height        = 32
                };
                if (max_length > 0)
                {
                    input_text_box.MaxLength = max_length;
                }
                var dialog = new Windows.UI.Xaml.Controls.ContentDialog
                {
                    Content                  = input_text_box,
                    Title                    = title,
                    PrimaryButtonText        = "Ok",
                    IsSecondaryButtonEnabled = true,
                    SecondaryButtonText      = "Cancel",
                    DefaultButton            = Windows.UI.Xaml.Controls.ContentDialogButton.Primary
                };
                if (await dialog.ShowAsync() == Windows.UI.Xaml.Controls.ContentDialogResult.Primary)
                {
                    result = input_text_box.Text;
                }
                else
                {
                    result = "";
                }
            });
#else
        #if DEBUG
            await System.Threading.Tasks.Task.Run(() => {
                var debugger = Engine.GetFirstInstanceByType <DebuggerWithTerminal>();
                debugger?.OpenConsoleWithCustomEvaluator(value => result = value);
                while (debugger != null && debugger.ConsoleOpen)
                {
                    System.Threading.Thread.Sleep(1);
                }
            });
        #endif
#endif
            Engine.Resume();
            PlatformFunctions.IsDialogOpen = false;

            if (!string.IsNullOrWhiteSpace(result))
            {
                callback?.Invoke(result);
            }
        }