From 31de3f985797381e310221dfe6c5db8fc050b896 Mon Sep 17 00:00:00 2001 From: Chris Winland Date: Mon, 28 Feb 2022 11:06:11 -0500 Subject: [PATCH] Fix namespace syntax for compatibility. --- src/Dialogs/DialogBase.cs | 561 +++++++++++++++++++------------------- 1 file changed, 281 insertions(+), 280 deletions(-) diff --git a/src/Dialogs/DialogBase.cs b/src/Dialogs/DialogBase.cs index 07a3b89..9efbc1e 100644 --- a/src/Dialogs/DialogBase.cs +++ b/src/Dialogs/DialogBase.cs @@ -14,346 +14,347 @@ using wpf_material_dialogs.Interfaces; using HorizontalAlignment = System.Windows.HorizontalAlignment; -namespace wpf_material_dialogs.Dialogs; - -/// -/// Class DialogBase. -/// Implements the -/// -/// -public abstract class DialogBase : IDialog +namespace wpf_material_dialogs.Dialogs { - private readonly object buttonLock = new(); - private readonly List buttonTypes = new(); - private HorizontalAlignment buttonAlignment = HorizontalAlignment.Right; - private IButtons buttons = new OkButtons(); - private DialogButton dialogButtons = DialogButton.OkButtons; - private FontWeight fontWeight = FontWeights.Normal; - private double height = double.NaN; - private Brush iconBrush; - private PackIconKind iconKind; - private bool showIcon; - private string text; - private double textFontSize = 14; - private string title; - private double titleFontSize = 16; - private FontWeight titleFontWeight = FontWeights.Bold; - private double width = double.NaN; - /// - /// Gets the selected buttons based on the selection. + /// Class DialogBase. + /// Implements the /// - /// . - public IButtons SelectedButtons => DialogButtons == DialogButton.Custom - ? Buttons - : GetButtons(DialogButtons); - - public FontWeight TitleFontWeight + /// + public abstract class DialogBase : IDialog { - get => titleFontWeight; - set + private readonly object buttonLock = new(); + private readonly List buttonTypes = new(); + private HorizontalAlignment buttonAlignment = HorizontalAlignment.Right; + private IButtons buttons = new OkButtons(); + private DialogButton dialogButtons = DialogButton.OkButtons; + private FontWeight fontWeight = FontWeights.Normal; + private double height = double.NaN; + private Brush iconBrush; + private PackIconKind iconKind; + private bool showIcon; + private string text; + private double textFontSize = 14; + private string title; + private double titleFontSize = 16; + private FontWeight titleFontWeight = FontWeights.Bold; + private double width = double.NaN; + + /// + /// Gets the selected buttons based on the selection. + /// + /// . + public IButtons SelectedButtons => DialogButtons == DialogButton.Custom + ? Buttons + : GetButtons(DialogButtons); + + public FontWeight TitleFontWeight { - titleFontWeight = value; - NotifyOfPropertyChanged(); + get => titleFontWeight; + set + { + titleFontWeight = value; + NotifyOfPropertyChanged(); + } } - } - public FontWeight FontWeight - { - get => fontWeight; - set + public FontWeight FontWeight { - fontWeight = value; - NotifyOfPropertyChanged(); + get => fontWeight; + set + { + fontWeight = value; + NotifyOfPropertyChanged(); + } } - } - public double Width - { - get => width; - set + public double Width { - width = value; - NotifyOfPropertyChanged(); + get => width; + set + { + width = value; + NotifyOfPropertyChanged(); + } } - } - public double Height - { - get => height; - set + public double Height { - height = value; - NotifyOfPropertyChanged(); + get => height; + set + { + height = value; + NotifyOfPropertyChanged(); + } } - } - /// - /// Gets or sets the button alignment. - /// - /// . - public HorizontalAlignment ButtonAlignment - { - get => buttonAlignment; - set + /// + /// Gets or sets the button alignment. + /// + /// . + public HorizontalAlignment ButtonAlignment { - buttonAlignment = value; - NotifyOfPropertyChanged(); + get => buttonAlignment; + set + { + buttonAlignment = value; + NotifyOfPropertyChanged(); + } } - } - /// - /// Gets or sets the custom buttons to be used. must set to custom for this property to - /// apply. - /// - /// . - public IButtons Buttons - { - get => buttons; - set + /// + /// Gets or sets the custom buttons to be used. must set to custom for this property to + /// apply. + /// + /// . + public IButtons Buttons { - buttons = value; - NotifyOfPropertyChanged(); + get => buttons; + set + { + buttons = value; + NotifyOfPropertyChanged(); + } } - } - /// - /// Gets or sets the buttons to use in the dialog. - /// - /// . - public DialogButton DialogButtons - { - get => dialogButtons; - set + /// + /// Gets or sets the buttons to use in the dialog. + /// + /// . + public DialogButton DialogButtons { - dialogButtons = value; - NotifyOfPropertyChanged(); + get => dialogButtons; + set + { + dialogButtons = value; + NotifyOfPropertyChanged(); + } } - } - /// - /// Gets the buttons. - /// - /// The button enum to convert to an IButton. - /// IButtons. - /// button - /// button - /// button - public IButtons GetButtons(DialogButton button) - { - lock (buttonLock) + /// + /// Gets the buttons. + /// + /// The button enum to convert to an IButton. + /// IButtons. + /// button + /// button + /// button + public IButtons GetButtons(DialogButton button) { - var assembly = Assembly.GetExecutingAssembly(); - - if (!buttonTypes?.Any() ?? false) + lock (buttonLock) { - buttonTypes.AddRange(assembly - .GetTypes() - .Where(mytype => mytype.GetInterfaces().Contains(typeof(IButtons)))); - } + var assembly = Assembly.GetExecutingAssembly(); + + if (!buttonTypes?.Any() ?? false) + { + buttonTypes.AddRange(assembly + .GetTypes() + .Where(mytype => mytype.GetInterfaces().Contains(typeof(IButtons)))); + } - var buttons = buttonTypes - ?.First(mytype => mytype.Name.Equals(button.ToString(), StringComparison.CurrentCultureIgnoreCase)); + var buttons = buttonTypes + ?.First(mytype => mytype.Name.Equals(button.ToString(), StringComparison.CurrentCultureIgnoreCase)); - return buttons?.FullName != null - ? assembly.CreateInstance(buttons.FullName) as IButtons - : throw new ArgumentOutOfRangeException(nameof(button)); + return buttons?.FullName != null + ? assembly.CreateInstance(buttons.FullName) as IButtons + : throw new ArgumentOutOfRangeException(nameof(button)); + } } - } - /// - /// Gets or sets the icon brush. - /// - /// The icon brush. - public Brush IconBrush - { - get => iconBrush; - set + /// + /// Gets or sets the icon brush. + /// + /// The icon brush. + public Brush IconBrush { - iconBrush = value; - NotifyOfPropertyChanged(); + get => iconBrush; + set + { + iconBrush = value; + NotifyOfPropertyChanged(); + } } - } - /// - /// Gets or sets the kind of the icon. - /// - /// The kind of the icon. - public PackIconKind IconKind - { - get => iconKind; - set + /// + /// Gets or sets the kind of the icon. + /// + /// The kind of the icon. + public PackIconKind IconKind { - iconKind = value; - NotifyOfPropertyChanged(); + get => iconKind; + set + { + iconKind = value; + NotifyOfPropertyChanged(); + } } - } - /// - /// Notifies the of property changed. - /// - /// Name of the property. - public void NotifyOfPropertyChanged([CallerMemberName] string propertyName = "") - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - } + /// + /// Notifies the of property changed. + /// + /// Name of the property. + public void NotifyOfPropertyChanged([CallerMemberName] string propertyName = "") + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } - /// - /// Shows the dialog with given configuration. - /// - /// The dialog hos identifier. - /// The opened action. - /// The closing action. - /// containing and . - public async Task ShowDialog(object dialogHosId = null, - DialogOpenedEventHandler openedAction = null, - DialogClosingEventHandler closingAction = null) - { - return await DialogHost.Show(this, dialogHosId, openedAction, closingAction) as DialogResult? ?? - DialogResult.None; - } + /// + /// Shows the dialog with given configuration. + /// + /// The dialog hos identifier. + /// The opened action. + /// The closing action. + /// containing and . + public async Task ShowDialog(object dialogHosId = null, + DialogOpenedEventHandler openedAction = null, + DialogClosingEventHandler closingAction = null) + { + return await DialogHost.Show(this, dialogHosId, openedAction, closingAction) as DialogResult? ?? + DialogResult.None; + } - /// - /// Shows the dialog with given configuration. - /// - /// The dialog hos identifier. - /// The opened action. - /// The closing action. - /// containing and . - public async Task ShowDialogObject(object dialogHosId = null, - DialogOpenedEventHandler openedAction = null, - DialogClosingEventHandler closingAction = null) - { - return await DialogHost.Show(this, dialogHosId, openedAction, closingAction); - } + /// + /// Shows the dialog with given configuration. + /// + /// The dialog hos identifier. + /// The opened action. + /// The closing action. + /// containing and . + public async Task ShowDialogObject(object dialogHosId = null, + DialogOpenedEventHandler openedAction = null, + DialogClosingEventHandler closingAction = null) + { + return await DialogHost.Show(this, dialogHosId, openedAction, closingAction); + } - /// - /// Gets or sets a value indicating whether to show the icon. - /// - /// true if [show icon]; otherwise, false. - public bool ShowIcon - { - get => showIcon; - set + /// + /// Gets or sets a value indicating whether to show the icon. + /// + /// true if [show icon]; otherwise, false. + public bool ShowIcon { - showIcon = value; - NotifyOfPropertyChanged(); + get => showIcon; + set + { + showIcon = value; + NotifyOfPropertyChanged(); + } } - } - /// - /// Gets or sets the dialog primary text. - /// - /// The primary text of the dialog. - public string Text - { - get => text; - set + /// + /// Gets or sets the dialog primary text. + /// + /// The primary text of the dialog. + public string Text { - text = value; - NotifyOfPropertyChanged(); + get => text; + set + { + text = value; + NotifyOfPropertyChanged(); + } } - } - /// - /// Gets or sets the size of the text font. - /// - /// The size of the text font. - public double TextFontSize - { - get => textFontSize; - set + /// + /// Gets or sets the size of the text font. + /// + /// The size of the text font. + public double TextFontSize { - textFontSize = value; - NotifyOfPropertyChanged(); + get => textFontSize; + set + { + textFontSize = value; + NotifyOfPropertyChanged(); + } } - } - /// - /// Gets or sets the dialog title. - /// - /// The title of the dialog. - public string Title - { - get => title; - set + /// + /// Gets or sets the dialog title. + /// + /// The title of the dialog. + public string Title { - title = value; - NotifyOfPropertyChanged(); + get => title; + set + { + title = value; + NotifyOfPropertyChanged(); + } } - } - /// - /// Gets or sets the size of the title font. - /// - /// The size of the title font. - public double TitleFontSize - { - get => titleFontSize; - set + /// + /// Gets or sets the size of the title font. + /// + /// The size of the title font. + public double TitleFontSize { - titleFontSize = value; - NotifyOfPropertyChanged(); + get => titleFontSize; + set + { + titleFontSize = value; + NotifyOfPropertyChanged(); + } } - } - /// - /// Occurs when [property changed]. - /// - public event PropertyChangedEventHandler PropertyChanged; + /// + /// Occurs when [property changed]. + /// + public event PropertyChangedEventHandler PropertyChanged; - /// - /// Shows the destroy alert dialog. - /// - /// The text. - /// The buttons. - /// true if , false otherwise. - public static async Task ShowAlertDialog(string text, DialogButton buttons) - { - return await new AlertDialog + /// + /// Shows the destroy alert dialog. + /// + /// The text. + /// The buttons. + /// true if , false otherwise. + public static async Task ShowAlertDialog(string text, DialogButton buttons) { - Title = "Alert", - IconBrush = Brushes.Red, - Text = text, - DialogButtons = buttons - }.ShowDialog(); - } + return await new AlertDialog + { + Title = "Alert", + IconBrush = Brushes.Red, + Text = text, + DialogButtons = buttons + }.ShowDialog(); + } - /// - /// Shows the dialog with a few customizable options. - /// - /// The dialog text. - /// The footer dialog buttons. - /// The dialog title. - /// The dialog identifier. - /// . - public async Task ShowDialog(string dialogText, DialogButton buttons, string title, - object dialogHosId = null) - { - Title = title; - Text = dialogText; - DialogButtons = buttons; + /// + /// Shows the dialog with a few customizable options. + /// + /// The dialog text. + /// The footer dialog buttons. + /// The dialog title. + /// The dialog identifier. + /// . + public async Task ShowDialog(string dialogText, DialogButton buttons, string title, + object dialogHosId = null) + { + Title = title; + Text = dialogText; + DialogButtons = buttons; - return await ShowDialog(dialogHosId); - } + return await ShowDialog(dialogHosId); + } - /// - /// Shows the dialog with a few customizable options. - /// - /// The dialog text. - /// The footer dialog buttons. - /// Kind of the icon. - /// The icon brush. - /// The dialog title. - /// The dialog identifier. - /// . - public async Task ShowDialog(string dialogText, DialogButton buttons, PackIconKind iconKind, - Brush iconBrush, string title, object dialogHosId = null) - { - IconKind = iconKind; - ShowIcon = true; - IconBrush = iconBrush; + /// + /// Shows the dialog with a few customizable options. + /// + /// The dialog text. + /// The footer dialog buttons. + /// Kind of the icon. + /// The icon brush. + /// The dialog title. + /// The dialog identifier. + /// . + public async Task ShowDialog(string dialogText, DialogButton buttons, PackIconKind iconKind, + Brush iconBrush, string title, object dialogHosId = null) + { + IconKind = iconKind; + ShowIcon = true; + IconBrush = iconBrush; - return await ShowDialog(dialogText, buttons, title, dialogHosId); + return await ShowDialog(dialogText, buttons, title, dialogHosId); + } } } \ No newline at end of file