Beispiel #1
0
 /// <summary>
 /// On exiting the app, a message pops up asking, if the user really wants to close the app. On tapping "yes", this method is executed.
 /// </summary>
 /// <param name="command"></param>
 private void CommandInvokedHandler(Windows.UI.Popups.IUICommand command)
 {
     // Display message showing the label of the command that was invoked
     if (command.Label.Equals("Close app"))
     {
         Application.Current.Exit();
     }
 }
Beispiel #2
0
 public static async void DisplayMsg(String title, String content)
 {
     // Create the message dialog and set its content; it will get a default "Close" button since there aren't any other buttons being added
     Windows.UI.Popups.MessageDialog msg = new Windows.UI.Popups.MessageDialog("Welcome");
     msg.Title   = title;
     msg.Content = content;
     try
     {
         Windows.UI.Popups.IUICommand result = await msg.ShowAsync();
     }
     catch
     { }
 }
Beispiel #3
0
        private async void HelpCommand(Windows.UI.Popups.IUICommand command)
        {
            try
            {
                Windows.Storage.StorageFile file =
                    await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"Assets\OTWBHelp.pdf");

                await Windows.System.Launcher.LaunchFileAsync(file);
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);
            }
        }
        /// <summary>
        ///  ロック画面の更新に関する設定のポップアップを表示する.
        /// </summary>
        /// <param name="command"></param>
        private void OnSettingCommandUpdateSetting(Windows.UI.Popups.IUICommand command)
        {
            if (SettingsPane.Edge == SettingsEdgeLocation.Right)
            {
                this.UpdateSettingPopup.HorizontalOffset  = this.ActualWidth;
                this.UpdateSettingPopup.VerticalAlignment = 0;
            }
            else if (SettingsPane.Edge == SettingsEdgeLocation.Left)
            {
                this.UpdateSettingPopup.HorizontalOffset  = 0;
                this.UpdateSettingPopup.VerticalAlignment = 0;
                (this.UpdateSettingPopup.ChildTransitions[0] as Windows.UI.Xaml.Media.Animation.EdgeUIThemeTransition).Edge = EdgeTransitionLocation.Left;
            }

            (this.UpdateSettingPopup.Child as UserControl).Height = this.ActualHeight;
            this.UpdateSettingPopup.IsOpen = true;
        }
Beispiel #5
0
        private void TriggerLogin(Windows.UI.Popups.IUICommand command)
        {
            var flyout = new SettingsFlyout();

            flyout.Content    = new LoginView();
            flyout.HeaderText = "Login";
            flyout.IsOpen     = true;
            flyout.Closed    += (e, sender) =>
            {
                Messenger.Default.Unregister <CloseSettingsMessage>(this);
                SetSearchKeyboard(_isTypeToSearch);
            };
            Messenger.Default.Register <CloseSettingsMessage>(this, (message) =>
            {
                flyout.IsOpen = false;
                SetSearchKeyboard(_isTypeToSearch);
            });

            _isTypeToSearch = GetSearchKeyboard();
            App.SetSearchKeyboard(false);
        }
Beispiel #6
0
        private void TriggerContentPreferences(Windows.UI.Popups.IUICommand command)
        {
            var flyout = new SettingsFlyout();

            flyout.Content    = new ContentPreferencesView();
            flyout.HeaderText = "Content Preferences";
            flyout.IsOpen     = true;
            flyout.Closed    += async(e, sender) =>
            {
                Messenger.Default.Unregister <CloseSettingsMessage>(this);
                SetSearchKeyboard(_isTypeToSearch);
                await _baconProvider.GetService <ISettingsService>().Persist();
            };
            Messenger.Default.Register <CloseSettingsMessage>(this, async(message) =>
            {
                flyout.IsOpen = false;
                SetSearchKeyboard(_isTypeToSearch);
                await _baconProvider.GetService <ISettingsService>().Persist();
            });

            _isTypeToSearch = GetSearchKeyboard();
            App.SetSearchKeyboard(false);
        }
Beispiel #7
0
 private async void GetPrivacyPolicyAsync(Windows.UI.Popups.IUICommand command)
 {
     await Windows.System.Launcher.LaunchUriAsync(new Uri("http://www.microsoft.com/privacystatement/zh-cn/core/default.aspx"));
 }
Beispiel #8
0
 private async void privacy_Handler(Windows.UI.Popups.IUICommand command)
 {
     Uri uri = new Uri(PrivacyLink);
     await Launcher.LaunchUriAsync(uri);
 }
Beispiel #9
0
 private async void TriggerPrivacyPolicy(Windows.UI.Popups.IUICommand command)
 {
     await Windows.System.Launcher.LaunchUriAsync(new Uri("https://github.com/Synergex/Baconography/wiki/PrivacyPolicy"));
 }
 private void CommandInvokedHandler(Windows.UI.Popups.IUICommand command)
 {
     //Application.Current.Exit();
 }
Beispiel #11
0
 private async void LaunchPrivacyPolicyUrl(Windows.UI.Popups.IUICommand command)
 {
     Uri privacyPolicyUri = new Uri("http://kiewic.com/privacypolicy");
     var result           = await Windows.System.Launcher.LaunchUriAsync(privacyPolicyUri);
 }
Beispiel #12
0
        /// <summary>
        /// Begins an asynchronous operation showing a dialog.
        /// </summary>
        /// <returns>An object that represents the asynchronous operation.
        /// For more on the async pattern, see Asynchronous programming in the Windows Runtime.</returns>
        /// <remarks>In some cases, such as when the dialog is closed by the system out of your control, your result can be an empty command.
        /// Returns either the command selected which destroyed the dialog, or an empty command.
        /// For example, a dialog hosted in a charms window will return an empty command if the charms window has been dismissed.</remarks>
        public Task <IUICommand> ShowAsync()
        {
            if (Commands.Count > MaxCommands)
            {
                throw new InvalidOperationException();
            }

#if __ANDROID__
            Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity);
            Android.App.AlertDialog         dialog  = builder.Create();
            dialog.SetTitle(Title);
            dialog.SetMessage(Content);
            if (Commands.Count == 0)
            {
                dialog.SetButton(-1, Resources.System.GetString(Android.Resource.String.Cancel), new EventHandler <Android.Content.DialogClickEventArgs>(Clicked));
            }
            else
            {
                for (int i = 0; i < Commands.Count; i++)
                {
                    dialog.SetButton(-1 - i, Commands[i].Label, new EventHandler <Android.Content.DialogClickEventArgs>(Clicked));
                }
            }
            dialog.Show();

            return(Task.Run <IUICommand>(() =>
            {
                _handle.WaitOne();
                return _selectedCommand;
            }));
#elif __IOS__ || __TVOS__
            uac = UIAlertController.Create(Title, Content, UIAlertControllerStyle.Alert);
            if (Commands.Count == 0)
            {
                uac.AddAction(UIAlertAction.Create("Close", UIAlertActionStyle.Cancel | UIAlertActionStyle.Default, ActionClicked));
            }
            else
            {
                for (int i = 0; i < Commands.Count; i++)
                {
                    UIAlertAction action = UIAlertAction.Create(Commands[i].Label, CancelCommandIndex == i ? UIAlertActionStyle.Cancel : UIAlertActionStyle.Default, ActionClicked);
                    uac.AddAction(action);
                }
            }
            UIViewController currentController = UIApplication.SharedApplication.KeyWindow.RootViewController;
            while (currentController.PresentedViewController != null)
            {
                currentController = currentController.PresentedViewController;
            }

            currentController.PresentViewController(uac, true, null);

            return(Task.Run <IUICommand>(() =>
            {
                _handle.WaitOne();
                return _selectedCommand;
            }));
#elif __MAC__
            NSAlert alert = new NSAlert();
            alert.AlertStyle      = NSAlertStyle.Informational;
            alert.InformativeText = Content;
            alert.MessageText     = Title;

            foreach (IUICommand command in Commands)
            {
                var button = alert.AddButton(command.Label);
            }

            alert.BeginSheetForResponse(NSApplication.SharedApplication.MainWindow, NSAlert_onEnded);

            return(Task.Run <IUICommand>(() =>
            {
                _handle.WaitOne();
                return _selectedCommand;
            }));
#elif WINDOWS_PHONE
            List <string> buttons = new List <string>();
            foreach (IUICommand uic in Commands)
            {
                buttons.Add(uic.Label);
            }

            if (buttons.Count == 0)
            {
                buttons.Add("Close");
            }

            MessageDialogAsyncOperation asyncOperation = new MessageDialogAsyncOperation(this);

            string contentText = Content;

            // trim message body to 255 chars
            if (contentText.Length > 255)
            {
                contentText = contentText.Substring(0, 255);
            }

            while (Microsoft.Xna.Framework.GamerServices.Guide.IsVisible)
            {
                Thread.Sleep(100);
            }

            Microsoft.Xna.Framework.GamerServices.Guide.BeginShowMessageBox(
                string.IsNullOrEmpty(Title) ? " " : Title,
                contentText,
                buttons,
                DefaultCommandIndex == uint.MaxValue ? 0 : (int)DefaultCommandIndex, // can choose which button has the focus
                Microsoft.Xna.Framework.GamerServices.MessageBoxIcon.None,           // can play sounds
                result =>
            {
                int?returned = Microsoft.Xna.Framework.GamerServices.Guide.EndShowMessageBox(result);

                // process and fire the required handler
                if (returned.HasValue)
                {
                    if (Commands.Count > returned.Value)
                    {
                        IUICommand theCommand = Commands[returned.Value];
                        asyncOperation.SetResults(theCommand);
                        if (theCommand.Invoked != null)
                        {
                            theCommand.Invoked(theCommand);
                        }
                    }
                    else
                    {
                        asyncOperation.SetResults(null);
                    }
                }
                else
                {
                    asyncOperation.SetResults(null);
                }
            }, null);

            return(asyncOperation.AsTask <IUICommand>());
#elif WINDOWS_UWP
            if (Commands.Count < 3 && Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.UI.ApplicationSettings.ApplicationsSettingsContract", 1))
            {
                Windows.UI.Xaml.Controls.ContentDialog cd = new Windows.UI.Xaml.Controls.ContentDialog();
                cd.Title   = Title;
                cd.Content = Content;
                if (Commands.Count == 0)
                {
                    cd.PrimaryButtonText = "Close";
                }
                else
                {
                    cd.PrimaryButtonText   = Commands[0].Label;
                    cd.PrimaryButtonClick += Cd_PrimaryButtonClick;
                    if (Commands.Count > 1)
                    {
                        cd.SecondaryButtonText   = Commands[1].Label;
                        cd.SecondaryButtonClick += Cd_SecondaryButtonClick;
                    }
                }

                return(Task.Run <IUICommand>(async() =>
                {
                    ManualResetEvent mre = new ManualResetEvent(false);
                    IUICommand command = null;

                    await cd.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                    {
                        ContentDialogResult dr = await cd.ShowAsync();
                        if (Commands.Count > 0)
                        {
                            switch (dr)
                            {
                            case ContentDialogResult.Primary:
                                command = Commands[0];
                                if (Commands[0].Invoked != null)
                                {
                                    Commands[0].Invoked.Invoke(Commands[0]);
                                }
                                break;

                            case ContentDialogResult.Secondary:
                                command = Commands[1];
                                if (Commands[1].Invoked != null)
                                {
                                    Commands[1].Invoked.Invoke(Commands[1]);
                                }
                                break;
                            }
                        }
                    });

                    mre.WaitOne();

                    return command;
                }));
            }
            else
            {
                Windows.UI.Popups.MessageDialog dialog = new Windows.UI.Popups.MessageDialog(Content, Title);
                foreach (IUICommand command in Commands)
                {
                    dialog.Commands.Add(new Windows.UI.Popups.UICommand(command.Label, (c) => { command.Invoked(command); }, command.Id));
                }
                return(Task.Run <IUICommand>(async() => {
                    Windows.UI.Popups.IUICommand command = await dialog.ShowAsync();
                    if (command != null)
                    {
                        int i = 0;
                        foreach (Windows.UI.Popups.IUICommand c in dialog.Commands)
                        {
                            if (command == c)
                            {
                                break;
                            }

                            i++;
                        }

                        return Commands[i];
                    }
                    return null;
                }));
            }
#elif WIN32
            return(Task.Run <IUICommand>(() =>
            {
                IUICommand cmd = ShowTaskDialog();
                if (cmd != null)
                {
                    cmd.Invoked?.Invoke(cmd);
                }

                return cmd;
            }));
#else
            throw new PlatformNotSupportedException();
#endif
        }
 private void CommandInvokedHandler(Windows.UI.Popups.IUICommand command)
 {
     //throw new NotImplementedException();
 }
 /// <summary>
 ///  [設定チャーム]->[Store].
 /// </summary>
 /// <param name="command"></param>
 private async void OnSettingCommandOpenStore(Windows.UI.Popups.IUICommand command)
 {
     Uri uri = new Uri(@"ms-windows-store:PDP?PFN=17787zakii.64709012E2351_pd7rzaxsjxxq8");
     await Windows.System.Launcher.LaunchUriAsync(uri);
 }
 /// <summary>
 ///  [設定チャーム]->[Privacy Policy].
 /// </summary>
 /// <param name="command"></param>
 private void OnSettingCommandPrivacyPolicy(Windows.UI.Popups.IUICommand command)
 {
     ShowAppHelpPopup(new Uri(HelpPagePrivacyPolcyUriString));
 }
 /// <summary>
 ///  [設定チャーム]->[Help].
 /// </summary>
 /// <param name="command"></param>
 private void OnSettingCommandHelp(Windows.UI.Popups.IUICommand command)
 {
     ShowAppHelpPopup(new Uri(HelpPageUriString));
 }