public static IMsBoxWindow <string> GetMessageBoxCustomWindow(MessageBoxCustomParams @params) { var window = new CustomWindow(@params.Style); window.DataContext = new MsBoxCustomViewModel(@params, window); return(new MsBoxWindowBase <CustomWindow, string>(window)); }
public async Task <bool> ShowNotification(string message, string title = null, string header = null, Window parentWindow = null, MessageBoxType messageBoxType = MessageBoxType.Ok, bool showInCenter = true, WindowStartupLocation windowStartupLocation = WindowStartupLocation.CenterOwner, Style style = Style.UbuntuLinux, Icon icon = Icon.Info, WindowIcon windowIcon = null, bool canResize = false) { var msgBox = new MessageBoxCustomParams { Icon = icon, Style = style, WindowStartupLocation = windowStartupLocation, ShowInCenter = showInCenter, ContentTitle = title ?? Properties.Resources.notification, ContentHeader = header, CanResize = canResize, ContentMessage = message, }; switch (messageBoxType) { case MessageBoxType.Generate_Cancel: msgBox.ButtonDefinitions = new[] { new ButtonDefinition { Name = Properties.Resources.generateReport }, new ButtonDefinition { Name = Properties.Resources.cancel, Type = ButtonType.Colored } }; break; case MessageBoxType.Yes_No: msgBox.ButtonDefinitions = new[] { new ButtonDefinition { Name = Properties.Resources.yes }, new ButtonDefinition { Name = Properties.Resources.no, Type = ButtonType.Colored } }; break; default: msgBox.ButtonDefinitions = new[] { new ButtonDefinition { Name = Properties.Resources.ok } }; break; } //The feature is temporarily unavailable //if (windowIcon == null) //{ // var assets = AvaloniaLocator.Current.GetService<IAssetLoader>(); // msgBox.WindowIcon = new WindowIcon(assets.Open(new Uri("avares://PertEstimationTool/Assets/main.ico"))); //} var result = await MessageBox.Avalonia.MessageBoxManager.GetMessageBoxCustomWindow(msgBox).ShowDialog(parentWindow); if (result == Properties.Resources.yes || result == Properties.Resources.generateReport) { return(true); } return(false); }
public async void About() { var message = "Copyright (c) 2019 Georgy Perevozghikov <*****@*****.**>\nGithub page: https://github.com/lizaalert/lacmus/. Press `Github` button for more details.\nProvided by Yandex Cloud: https://cloud.yandex.com/." + "\nThis program comes with ABSOLUTELY NO WARRANTY." + "\nThis is free software, and you are welcome to redistribute it under GNU GPLv3 conditions.\nPress `License` button to learn more about the license"; var msgBoxCustomParams = new MessageBoxCustomParams { ButtonDefinitions = new [] { new ButtonDefinition { Name = "Ok", Type = ButtonType.Colored }, new ButtonDefinition { Name = "License" }, new ButtonDefinition { Name = "Github" } }, ContentTitle = "About", ContentHeader = "Lacmus desktop application. Version 0.3.2 alpha.", ContentMessage = message, Icon = Icon.Avalonia, Style = Style.None, ShowInCenter = true, Window = new MsBoxCustomWindow { Height = 400, Width = 1000, CanResize = true } }; var msgbox = MessageBoxManager.GetMessageBoxCustomWindow(msgBoxCustomParams); var result = await msgbox.Show(); switch (result.ToLower()) { case "ok": return; case "license": OpenUrl("https://github.com/lizaalert/lacmus/blob/master/LICENSE"); break; case "github": OpenUrl("https://github.com/lizaalert/lacmus"); break; } }
/// <summary> /// Gets the fatal error window. /// </summary> /// <param name="title">The title.</param> /// <param name="header">The header.</param> /// <param name="message">The message.</param> /// <returns>MsgBox.BaseWindows.IMsBoxWindow<System.String>.</returns> public static FatalErrorMessageBox GetFatalErrorWindow(string title, string header, string message) { var parameters = new MessageBoxCustomParams { CanResize = false, ShowInCenter = true, ContentTitle = title, ContentHeader = header, ContentMessage = message, Icon = MsgBox.Enums.Icon.Error, WindowStartupLocation = WindowStartupLocation.CenterOwner }; if (Dispatcher.UIThread.CheckAccess()) { var font = ResolveFont(); var window = new MsgBox.Views.MsBoxCustomWindow(parameters.Style) { Icon = StaticResources.GetAppIcon(), FontFamily = font.GetFontFamily() }; parameters.Window = window; window.DataContext = new MsgBox.ViewModels.MsBoxCustomViewModel(parameters); return(new FatalErrorMessageBox(window)); } else { var task = Dispatcher.UIThread.InvokeAsync(() => { var window = new MsgBox.Views.MsBoxCustomWindow(parameters.Style) { Icon = StaticResources.GetAppIcon() }; parameters.Window = window; window.DataContext = new MsgBox.ViewModels.MsBoxCustomViewModel(parameters); return(new FatalErrorMessageBox(window)); }); Task.WaitAll(task); return(task.Result); } }
/// <summary> /// Gets the fatal error window. /// </summary> /// <param name="title">The title.</param> /// <param name="header">The header.</param> /// <param name="message">The message.</param> /// <returns>MsgBox.BaseWindows.IMsBoxWindow<System.String>.</returns> public static Controls.Themes.CustomMessageBox GetFatalErrorWindow(string title, string header, string message) { var font = ResolveFont(); var parameters = new MessageBoxCustomParams { CanResize = false, ShowInCenter = true, ContentTitle = title, ContentHeader = header, ContentMessage = message, Icon = Icon.Error, WindowStartupLocation = WindowStartupLocation.CenterOwner, FontFamily = font.GetFontFamily(), WindowIcon = StaticResources.GetAppIcon() }; var window = new Controls.Themes.CustomMessageBox(); window.DataContext = new MsBoxCustomViewModel(new MsCustomParams(parameters), window); return(window); }
public MsBoxCustomViewModel(MessageBoxCustomParams @params, MsBoxCustomWindow msBoxCustomWindow) : base(@params) { ContentMessage = @params.ContentMessage; _window = msBoxCustomWindow; ButtonDefinitions = @params.ButtonDefinitions; }
// public ReactiveCommand<string, Unit> ButtonClickCommand { get; private set; } public MsBoxCustomViewModel(MessageBoxCustomParams @params) : base(@params) { _window = @params.Window; ButtonDefinitions = @params.ButtonDefinitions; }