コード例 #1
0
 private async void AddCommands(CauldronUICommandCollection commands)
 {
     await this.Dispatcher.RunAsync(() =>
     {
         foreach (var item in commands.Where(x => x != null))
         {
             this.Buttons.Add(new MessageDialogCommandViewModel
             {
                 Text          = item.Label,
                 ButtonCommand = new RelayCommand(() =>
                 {
                     item.Invoke();
                     this.Navigator.TryClose(this);
                 })
             });
         }
     });
 }
コード例 #2
0
        public MessageDialogViewModel(string title, string message, int messageBoxImage, uint defaultCommandIndex, uint cancelCommandIndex, CauldronUICommandCollection commands)
        {
            var locale = Locale.Current;

            this.defaultCommandIndex = defaultCommandIndex;
            this.cancelCommandIndex  = cancelCommandIndex;

            if (string.IsNullOrEmpty(title))
            {
                this.Title = ApplicationInfo.ApplicationName;
            }
            else if (locale.Contains(title))
            {
                this.Title = locale[title];
            }
            else
            {
                this.Title = title;
            }

            if (string.IsNullOrEmpty(message))
            {
                this.Message = ApplicationInfo.ApplicationName;
            }
            else if (locale.Contains(message))
            {
                this.Message = locale[message];
            }
            else
            {
                this.Message = message;
            }

            this.LoadIconAsync((MessageBoxImage)messageBoxImage);

            this.HorizontalAlignment = HorizontalAlignment.Left;

            this.Buttons       = new ObservableCollection <MessageDialogCommandViewModel>();
            this.CancelCommand = new RelayCommand(this.CancelAction);
            this.EnterCommand  = new RelayCommand(this.EnterAction);

            this.AddCommands(commands);
        }
コード例 #3
0
 /// <summary>
 /// Begins an asynchronous operation showing a dialog.
 /// </summary>
 /// <param name="title">The title to display on the dialog, if any.</param>
 /// <param name="content">The message to be displayed to the user.</param>
 /// <param name="defaultCommandIndex">
 /// The index of the command you want to use as the default. This is the command that fires
 /// by default when users press the ENTER key.
 /// </param>
 /// <param name="cancelCommandIndex">
 /// The index of the command you want to use as the cancel command. This is the command that
 /// fires when users press the ESC key.
 /// </param>
 /// <param name="messageBoxImage">The icon to show on the dialog</param>
 /// <param name="commands">
 /// An array of commands that appear in the command bar of the message dialog. These commands
 /// makes the dialog actionable.
 /// </param>
 /// <returns>An object that represents the asynchronous operation.</returns>
 public Task ShowAsync(string title, string content, uint defaultCommandIndex, uint cancelCommandIndex, MessageBoxImage messageBoxImage, CauldronUICommandCollection commands)
 {
     return(this.Dispatcher.RunAsync(async() => await this.navigator.NavigateAsync <MessageDialogViewModel>(new Func <Task>(() => Task.FromResult(0)), title, content, (int)messageBoxImage, defaultCommandIndex, cancelCommandIndex, commands)));
 }
コード例 #4
0
 /// <summary>
 /// Begins an asynchronous operation showing a dialog.
 /// </summary>
 /// <param name="title">The title to display on the dialog, if any.</param>
 /// <param name="content">The message to be displayed to the user.</param>
 /// <param name="defaultCommandIndex">
 /// The index of the command you want to use as the default. This is the command that fires
 /// by default when users press the ENTER key.
 /// </param>
 /// <param name="cancelCommandIndex">
 /// The index of the command you want to use as the cancel command. This is the command that
 /// fires when users press the ESC key.
 /// </param>
 /// <param name="commands">
 /// An array of commands that appear in the command bar of the message dialog. These commands
 /// makes the dialog actionable.
 /// </param>
 /// <returns>An object that represents the asynchronous operation.</returns>
 public async Task ShowAsync(string title, string content, uint defaultCommandIndex, uint cancelCommandIndex, CauldronUICommandCollection commands) =>
 await this.ShowAsync(title, content, defaultCommandIndex, cancelCommandIndex, MessageBoxImage.None, commands);
コード例 #5
0
        public MessageDialogViewModel(string title, string message, int messageBoxImage /* The serializer can only serialize primitives */, uint defaultCommandIndex, uint cancelCommandIndex, CauldronUICommandCollection commands)
        {
            var locale = Locale.Current;

            this.defaultCommandIndex = defaultCommandIndex;
            this.cancelCommandIndex  = cancelCommandIndex;

            this.Title   = string.IsNullOrEmpty(title) ? ApplicationInfo.ApplicationName : locale[title];
            this.Message = locale[message];

            this.LoadIconAsync((MessageBoxImage)messageBoxImage);

            this.HorizontalAlignment = HorizontalAlignment.Left;

            this.Buttons       = new ObservableCollection <MessageDialogCommandViewModel>();
            this.CancelCommand = new RelayCommand(this.CancelAction);
            this.EnterCommand  = new RelayCommand(this.EnterAction);

            this.AddCommands(commands);
        }