GitXplorerGitXplorer
G

MaterialMessageBox

public
5 stars
3 forks
2 issues

Commits

List of commits on branch master.
Verified
214a19cd8785f0cac5a2f3078cdc4594fbe987bb

Merge pull request #92 from Gigas002/dependabot/add-v2-config-file

GGigas002 committed 3 years ago
Verified
75495ce3c4245dca9aec5f63d39ea047345be926

Merge pull request #95 from sucrose0413/master

GGigas002 committed 3 years ago
Unverified
da2cdfc821ebe1c3dc22bcd1d544094c561a6e71

Fix version conflicts caused by PR#93

ssucrose0413 committed 3 years ago
Verified
4991da68eaeb5d5d18b549758f1f1b83f0550707

Upgrade to GitHub-native Dependabot

ddependabot-preview[bot] committed 4 years ago
Unverified
a663e7482b8c28b3acc94d581c4e9d9485d2a48e

Update dependencies

committed 5 years ago
Unverified
f56c2505cd68a823d320094e5c038365715347c8

Update license and readme

committed 5 years ago

README

The README file for this repository.

MaterialMessageBox

Library on .NET Core 3.1 implementing material design message box in WPF.

Original idea and some code is written by denpalrius, but I’ve changed some major stuff and decided to make it different repository. Text for message boxes in Demo is taken from here. Icon is taken from here.

You can build project in VS2019 (16.4.1+) or in VSCode (1.40.2+) with omnisharp-vscode extension (1.21.8+).

Icon

Build status Actions Status

Current version

Get latest version on releases page: Release, or on NuGet:

Windows x86: NuGet

Windows x64: NuGet

Information about changes since previous releases can be found in changelog. This project supports SemVer 2.0.0 (template is {MAJOR}.{MINOR}.{PATCH}.{BUILD}).

Previous versions can be found on releases and branches pages.

Requirements

  • Windows 7 or newer;
  • .NET Core 3.1;

Dependencies

API

Library implements two different kinds of message boxes: Window and UserControl. See screenshots below to see the difference in design.

To use API, add using MaterialMessageBox directive to your classes.

MaterialMessageBoxWindow

Contains three slightly different static Show(...) methods:

public static MessageBoxResult Show(string message, bool isCancelButtonVisible = false, bool isRightToLeft = false) {...}

public static MessageBoxResult ShowError(string message, bool isCancelButtonVisible = false, bool isRightToLeft = false) {...}

public static MessageBoxResult ShowWarning(string message, bool isCancelButtonVisible = false, bool isRightToLeft = false) {...}

Which you can call in your code like this:

MaterialMessageBoxWindow.Show(MessageBoxMessage);
MaterialMessageBoxWindow.ShowError(MessageBoxMessage, true, true);
MaterialMessageBoxWindow.ShowWarning(MessageBoxMessage, true);

But also you can create MaterialMessageBoxWindow object and rewrite some stuff for yourself:

MaterialMessageBoxWindow materialMessageBoxWindow = new MaterialMessageBoxWindow
{
    MessageTextBlock = { Text = MessageBoxMessage, Foreground = Brushes.Yellow },
    CopyToClipboardButton = { Visibility = Visibility.Hidden },
    OkButton = { Content = "Good", Foreground = Brushes.Yellow, Background = Brushes.LightCoral},
    CancelButton = { Content = "Bad", Foreground = Brushes.Blue, Background = Brushes.LightBlue},
    BordersGrid = { Background = Brushes.IndianRed },
    MainGrid = { Background = Brushes.Red }, BorderBrush = Brushes.DarkRed,
    BorderThickness = new Thickness(4, 4, 4, 4)
};
materialMessageBoxWindow.ShowDialog();

MaterialMessageBoxUserControl

To use this, you must specify DialogHost in your .xaml file.

Code is mostly the same, as in MaterialMessageBoxWindow, but there’s also implemented both Async and non-Async methods:

public static async ValueTask<MessageBoxResult> ShowAsync(string message, bool isCancelButtonVisible = false, bool isRightToLeft = false) {...}

public static async ValueTask<MessageBoxResult> ShowErrorAsync(string message, bool isCancelButtonVisible = false, bool isRightToLeft = false) {...}

public static async ValueTask<MessageBoxResult> ShowWarningAsync(string message, bool isCancelButtonVisible = false, bool isRightToLeft = false) {...}

public static MessageBoxResult Show(string message, bool isCancelButtonVisible = false, bool isRightToLeft = false) {...}

public static MessageBoxResult ShowError(string message, bool isCancelButtonVisible = false, bool isRightToLeft = false) {...}

public static MessageBoxResult ShowWarning(string message, bool isCancelButtonVisible = false, bool isRightToLeft = false) {...}

Ways to call it are pretty much the same (don’t forget to make your methods async and use ConfigureAwait):

await MaterialMessageBoxUserControl.ShowAsync(MessageBoxMessage);
await MaterialMessageBoxUserControl.ShowErrorAsync(MessageBoxMessage, true, true);
await MaterialMessageBoxUserControl.ShowWarningAsync(MessageBoxMessage, true)

And of course you can also create MaterialMessageBoxUserControl object, but note, that there’s a bit different way to call Show() method:

MaterialMessageBoxUserControl materialMessageBoxUserControl = new MaterialMessageBoxUserControl
{
    MessageTextBlock = { Text = MessageBoxMessage, Foreground = Brushes.Yellow },
    CopyToClipboardButton = { Visibility = Visibility.Hidden },
    OkButton = { Content = "Good", Foreground = Brushes.Yellow, Background = Brushes.LightCoral },
    CancelButton = { Content = "Bad", Foreground = Brushes.Blue, Background = Brushes.LightBlue },
    BordersGrid = { Background = Brushes.IndianRed },
    MainGrid = { Background = Brushes.Red },
    BorderBrush = Brushes.DarkRed,
    BorderThickness = new Thickness(4, 4, 4, 4)
};
await DialogHost.Show(materialMessageBoxUserControl);

Screenshots

Usual Window

UsualWindow

Usual UserControl

UsualUserControl

Custom Window

CustomWindow

Custom UserControl

CustomUserControl

Error Window

ErrorWindow

Error UserControl

ErrorUserControl

Warning Window

WarningWindow

Warning UserControl

WarningUserControl

Contributing

Feel free to contribute, make forks, change some code, add issues, etc.