Beispiel #1
0
        /// <summary>
        /// Close the <see cref="MessageDialog"/>
        /// </summary>
        ///
        /// <param name="window">Window to remove the dialog</param>
        ///
        /// <returns>
        /// </returns>
        public static async Task CloseDialog(this XUiWindow window)
        {
            await dialogLoaded.ExitAnimation();

            ((Grid)window.Template.FindName("DialogContainer", window)).Children.Remove(dialogLoaded as UIElement);
            dialogLoaded = null;
        }
Beispiel #2
0
        /// <summary>
        /// Show a <see cref="ProgressDialog"/>
        /// </summary>
        ///
        /// <param name="window">Window to use</param>
        /// <param name="text">Text to show</param>
        /// <param name="keepAlive">If the dialog is reusable</param>
        ///
        /// <returns>
        /// <see cref="ProgressDialog"/> to interact with him
        /// </returns>
        public static async Task <ProgressDialog> ShowProgressDialog(this XUiWindow window, string text = "", bool keepAlive = false)
        {
            if (dialogLoaded != null && keepAlive)
            {
                // Get the progress dialog
                Grid           grid           = window.Template.FindName("DialogContainer", window) as Grid;
                ProgressDialog progressDialog = grid.Children[0] as ProgressDialog;

                // Reset the text
                progressDialog.SetText(text);
                return(progressDialog);
            }
            else
            {
                // Create the message dialog
                ProgressDialog progressDialog = new ProgressDialog(text);
                dialogLoaded = progressDialog;
                Grid grid = window.Template.FindName("DialogContainer", window) as Grid;
                grid.Children.Add(progressDialog);

                // Return the progress dialog
                await Task.Delay(500);

                return(progressDialog);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Show a <see cref="CustomDialog"/>
        /// The dialog is defined by the UIElement sended to this method
        /// Can take any controls
        /// </summary>
        ///
        /// <param name="window">XUiWindow to use</param>
        /// <param name="dialog">Dialog to load</param>
        ///
        /// <returns>
        /// <see cref="CustomDialog"/> to interact with him
        /// </returns>
        ///
        /// <remarks>
        /// Useful to create a dialog with some specific actions
        /// </remarks>
        public static async Task <IDialog> ShowCustomDialog(this XUiWindow window, IDialog dialog)
        {
            dialogLoaded = dialog;
            Grid grid = window.Template.FindName("DialogContainer", window) as Grid;

            grid.Children.Add((UIElement)dialog);

            // Return the progress dialog
            await Task.Delay(500);

            return(dialog);
        }
Beispiel #4
0
 /// <summary>
 /// Check if a dialog is already opened
 /// </summary>
 public static bool IsDialogOpen(this XUiWindow window)
 {
     // Check if a dialog is already loaded
     if (dialogLoaded != null)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #5
0
        /// <summary>
        /// Show a <see cref="MessageDialog"/>
        /// </summary>
        ///
        /// <param name="window">Window to use</param>
        /// <param name="dialogSettings"><see cref="DialogSettings"/> of the <see cref="MessageDialog"/></param>
        ///
        /// <returns>
        /// <see cref="MessageResult"/> which depend of the button clicked by the user
        /// </returns>
        public static async Task <MessageResult> ShowMessageDialog(this XUiWindow window, DialogSettings dialogSettings)
        {
            // Create the message dialog
            MessageDialog messageDialog = new MessageDialog(dialogSettings);

            dialogLoaded = messageDialog;
            Grid grid = window.Template.FindName("DialogContainer", window) as Grid;

            grid.Children.Add(messageDialog);

            // Wait the message result and return it
            MessageResult messageResult = await messageDialog.WaitMessageResult();

            return(messageResult);
        }
Beispiel #6
0
        /// <summary>
        /// Show a <see cref="MessageDialog"/>
        /// </summary>
        ///
        /// <param name="window">Window to use </param>
        /// <param name="dialogSettings">Dialog settings to use</param>
        ///
        /// <returns>
        /// <see cref="ProgressDialog"/> to interact with him
        /// </returns>
        public static async Task <InputDialog> ShowInputDialog(this XUiWindow window, DialogSettings dialogSettings)
        {
            // Create the message dialog
            InputDialog inputDialog = new InputDialog(dialogSettings);

            dialogLoaded = inputDialog;
            Grid grid = window.Template.FindName("DialogContainer", window) as Grid;

            grid.Children.Add(inputDialog);

            // Wait the animation is finished
            await Task.Delay(500);

            // Return the dialog
            return(inputDialog);
        }
Beispiel #7
0
        /// <summary>
        /// Show a <see cref="MessageDialog"/>
        /// </summary>
        ///
        /// <param name="window">Window to use</param>
        /// <param name="dialogSettings"><see cref="DialogSettings"/> of the <see cref="MessageDialog"/></param>
        /// <param name="itemSource">Item to set in the combo box</param>
        ///
        /// <returns>
        /// <see cref="object"/> which depend of the seleccted item
        /// </returns>
        public static async Task <object> ShowSelectDialog(this XUiWindow window, DialogSettings dialogSettings, IEnumerable itemSource)
        {
            // Create the message dialog
            SelectDialog selectDialog = new SelectDialog(dialogSettings);

            dialogLoaded = selectDialog;
            Grid grid = window.Template.FindName("DialogContainer", window) as Grid;

            grid.Children.Add(selectDialog);

            // Set the item source
            selectDialog.SelectComboBox.ItemsSource   = itemSource;
            selectDialog.SelectComboBox.SelectedIndex = 0;

            // Wait the message result and return it
            await selectDialog.WaitMessageResult();

            return(selectDialog.SelectComboBox.SelectedItem);
        }