using System; using System.Windows.Forms; namespace AIProofread.Controls { public partial class FormMessage : BaseWinForm { public FormMessage() { InitializeComponent(); } private void SetMessage(string message) { LblMeesage.Text = message; } private string currentConfirmText; private string currentConfirmAction; private void SetConfirmText(string confirmText) { currentConfirmText = confirmText; if (confirmText == "proofread") { confirmText = "重新校对"; } BtnConfirm.Text = confirmText; BtnConfirm.Visible = true; BtnConfirm.Enabled = true; } private void HideConfirm() { BtnConfirm.Visible = false; BtnConfirm.Enabled = false; BtnClose.Location = new System.Drawing.Point(( (this.Width - BtnClose.Width) / 2 ), BtnClose.Location.Y); } private void ResetButtons() { BtnClose.Location = new System.Drawing.Point(200, BtnClose.Location.Y); BtnConfirm.Location = new System.Drawing.Point(60, BtnConfirm.Location.Y); BtnConfirm.Visible = true; BtnConfirm.Enabled = true; } public static DialogResult ShowMessage(string message,string confirmText = "确认",string confirmAction = null) { FormMessage formMessage = new FormMessage(); formMessage.SetMessage(message); formMessage.currentConfirmAction = confirmAction; if(string.IsNullOrEmpty(confirmText)) { formMessage.HideConfirm(); } else { formMessage.ResetButtons(); } return formMessage.ShowDialog(); } private void BtnClose_Click(object sender, EventArgs e) { this.Close(); } private void BtnConfirm_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(currentConfirmAction)) { string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); Globals.ThisAddIn.SendMessageToWeb(currentConfirmAction, time); } this.Close(); } private void IconClose_Click(object sender, EventArgs e) { this.Close(); } } }