// *********************************************************************** // Assembly : HZH_Controls // Created : 08-08-2019 // // *********************************************************************** // // Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com // // // Blog: https://www.cnblogs.com/bfyx // GitHub:https://github.com/kwwwvagaa/NetWinformControl // gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git // // If you use this code, please keep this note. // *********************************************************************** using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace HZH_Controls.Forms { /// /// Class FrmDialog. /// Implements the /// /// public partial class FrmDialog : FrmBase { /// /// The BLN enter close /// bool blnEnterClose = true; /// /// Initializes a new instance of the class. /// /// The string message. /// The string title. /// if set to true [BLN show cancel]. /// if set to true [BLN show close]. /// if set to true [blnis enter close]. private FrmDialog( string strMessage, string strTitle, bool blnShowCancel = false, bool blnShowClose = false, bool blnisEnterClose = true) { InitializeComponent(); InitFormMove(this.lblTitle); if (!string.IsNullOrWhiteSpace(strTitle)) lblTitle.Text = strTitle; lblMsg.Text = strMessage; if (blnShowCancel) { this.tableLayoutPanel1.ColumnStyles[1].Width = 1; this.tableLayoutPanel1.ColumnStyles[2].Width = 50; } else { this.tableLayoutPanel1.ColumnStyles[1].Width = 0; this.tableLayoutPanel1.ColumnStyles[2].Width = 0; } //btnCancel.Visible = blnShowCancel; //ucSplitLine_V1.Visible = blnShowCancel; btnClose.Visible = blnShowClose; blnEnterClose = blnisEnterClose; //if (blnShowCancel) //{ // btnOK.BtnForeColor = Color.FromArgb(255, 85, 51); //} } #region 显示一个模式信息框 /// /// 功能描述:显示一个模式信息框 /// 作  者:HZH /// 创建日期:2019-03-04 15:49:48 /// 任务编号:POS /// /// owner /// strMessage /// strTitle /// blnShowCancel /// isShowMaskDialog /// blnShowClose /// if set to true [BLN is enter close]. /// 大小偏移,当默认大小过大或过小时,可以进行调整(增量) /// 返回值 public static DialogResult ShowDialog( IWin32Window owner, string strMessage, string strTitle = "提示", bool blnShowCancel = false, bool isShowMaskDialog = true, bool blnShowClose = false, bool blnIsEnterClose = true, Size? deviationSize = null) { DialogResult result = DialogResult.Cancel; if (owner == null || (owner is Control && (owner as Control).IsDisposed)) { var frm = new FrmDialog(strMessage, strTitle, blnShowCancel, blnShowClose, blnIsEnterClose) { StartPosition = FormStartPosition.CenterScreen, IsShowMaskDialog = isShowMaskDialog, TopMost = true }; if (deviationSize != null) { frm.Width += deviationSize.Value.Width; frm.Height += deviationSize.Value.Height; } result = frm.ShowDialog(); } else { if (owner is Control) { owner = (owner as Control).FindForm(); } var frm = new FrmDialog(strMessage, strTitle, blnShowCancel, blnShowClose, blnIsEnterClose) { StartPosition = (owner != null) ? FormStartPosition.CenterParent : FormStartPosition.CenterScreen, IsShowMaskDialog = isShowMaskDialog, TopMost = true }; if (deviationSize != null) { frm.Width += deviationSize.Value.Width; frm.Height += deviationSize.Value.Height; } result = frm.ShowDialog(owner); } return result; } #endregion /// /// Handles the BtnClick event of the btnOK control. /// /// The source of the event. /// The instance containing the event data. private void btnOK_BtnClick(object sender, EventArgs e) { this.DialogResult = System.Windows.Forms.DialogResult.OK; } /// /// Handles the BtnClick event of the btnCancel control. /// /// The source of the event. /// The instance containing the event data. private void btnCancel_BtnClick(object sender, EventArgs e) { this.DialogResult = System.Windows.Forms.DialogResult.Cancel; } /// /// Handles the MouseDown event of the btnClose control. /// /// The source of the event. /// The instance containing the event data. private void btnClose_MouseDown(object sender, MouseEventArgs e) { this.DialogResult = System.Windows.Forms.DialogResult.Cancel; } /// /// Does the enter. /// protected override void DoEnter() { if (blnEnterClose) this.DialogResult = System.Windows.Forms.DialogResult.OK; } /// /// Handles the VisibleChanged event of the FrmDialog control. /// /// The source of the event. /// The instance containing the event data. private void FrmDialog_VisibleChanged(object sender, EventArgs e) { } } }