/// <summary> /// 初始化数据库 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnInitailDb_Click(object sender, EventArgs e) { InitalizeDb initalizeDb = new InitalizeDb(m_dicTemplateDb, m_sysConfig); bool flag = initalizeDb.Do_Initalize(); if (flag) { DialogMessageBox.Show("初始化成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { DialogMessageBox.Show("数据库初始化失败,请查看详细日志信息。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
static string GetImgSource(MessageType mt) { string name = mt switch { MessageType.Generic => "Generic", MessageType.Information => "Generic", MessageType.Error => "Error", MessageType.Warning => "Info", MessageType.Question => "Question", MessageType.Success => "Happy", _ => "Generic" }; return($"{AppViewModel.WPFApplicationBasePath}Img/MessageIcons/{name}.png"); } // Create the message actions var actions = new List <DialogMessageActionViewModel>(); // Create a cancel action if available if (allowCancel) { actions.Add(new DialogMessageActionViewModel() { DisplayText = Resources.Cancel, DisplayDescription = Resources.Cancel, IsCancel = true, ActionResult = new UserInputResult(), }); } // Add additional actions actions.AddRange(additionalActions); // Create the default action actions.Add(new DialogMessageActionViewModel() { DisplayText = Resources.Ok, DisplayDescription = Resources.Ok, IsDefault = true, ActionResult = new UserInputResult() { CanceledByUser = false }, }); // Run on the UI thread return(await Application.Current.Dispatcher.Invoke(async() => { // Create the view model var vm = new DialogMessageViewModel() { MessageText = message, Title = headerMessage, MessageType = messageType, DialogImageSource = (ImageSource) new ImageSourceConverter().ConvertFromString(GetImgSource(messageType)), DialogActions = actions, DefaultActionResult = new UserInputResult(), }; // Create the message box var dialog = new DialogMessageBox(vm); // Show the dialog and get the result UserInputResult result = await Dialog.ShowDialogWindowAsync(dialog); // Return the result return !result.CanceledByUser; })); }