示例#1
0
        public DialogTextViewModel(string title, string content, DialogButtons buttons, bool showCheckbox)
        {
            Title   = title;
            Content = content;

            OkButtonVisibility     = buttons.HasFlag(DialogButtons.Ok) ? Visibility.Visible : Visibility.Collapsed;
            NoButtonVisibility     = buttons.HasFlag(DialogButtons.No) ? Visibility.Visible : Visibility.Collapsed;
            CancelButtonVisibility = buttons.HasFlag(DialogButtons.Cancel) ? Visibility.Visible : Visibility.Collapsed;
            CheckboxVisibility     = showCheckbox ? Visibility.Visible : Visibility.Collapsed;
        }
示例#2
0
        /// <summary>
        /// Gets the <see cref="ButtonConfiguration"/>s for the specified <paramref name="buttons"/>.
        /// </summary>
        /// <param name="buttons"> The <see cref="DialogButtons"/> that should be displayed. </param>
        /// <returns> A collection of <see cref="ButtonConfiguration"/>. </returns>
        /// <remarks> To have no buttons the only flag has to be <see cref="DialogButtons.None"/>. If other flags are set, then the respective buttons will be shown. </remarks>
        internal static IEnumerable <ButtonConfiguration> GetConfiguration(DialogButtons buttons)
        {
            if (buttons.Equals(DialogButtons.None))
            {
                yield break;
            }

            if (buttons.HasFlag(DialogButtons.Ok))
            {
                yield return(DefaultButtonConfigurations.OkButtonConfiguration);
            }
            if (buttons.HasFlag(DialogButtons.Cancel))
            {
                yield return(DefaultButtonConfigurations.CancelButtonConfiguration);
            }
            if (buttons.HasFlag(DialogButtons.Yes))
            {
                yield return(DefaultButtonConfigurations.YesButtonConfiguration);
            }
            if (buttons.HasFlag(DialogButtons.No))
            {
                yield return(DefaultButtonConfigurations.NoButtonConfiguration);
            }
            if (buttons.HasFlag(DialogButtons.Save))
            {
                yield return(DefaultButtonConfigurations.SaveButtonConfiguration);
            }
            if (buttons.HasFlag(DialogButtons.Close))
            {
                yield return(DefaultButtonConfigurations.CloseButtonConfiguration);
            }
        }
        public MessageDialogViewModel(string caption, string message, DialogButtons buttons = DialogButtons.OK)
        {
            base.DisplayName = caption;
            _message         = message;


            foreach (var b in Enum.GetValues(typeof(DialogButtons)).Cast <DialogButtons>())
            {
                if (b != DialogButtons.None && buttons.HasFlag(b))
                {
                    _dialogButtons.Add(new DialogButtonViewModel(b, this));
                }
            }
        }