📄 impsmessagebox.cs
字号:
case MessageBoxButtons.OKCancel:
this.SetBtnText(StringTable.DialogButton.btnOk, StringTable.DialogButton.btnCancel, string.Empty);
base.AcceptButton = this.btnA;
base.CancelButton = this.btnB;
break;
case MessageBoxButtons.AbortRetryIgnore:
this.SetBtnText(StringTable.DialogButton.btnCancel, StringTable.DialogButton.btnRetry, StringTable.DialogButton.btnCancel);
base.AcceptButton = this.btnA;
base.CancelButton = this.btnC;
break;
case MessageBoxButtons.YesNoCancel:
this.SetBtnText(StringTable.DialogButton.btnYes, StringTable.DialogButton.btnNo, StringTable.DialogButton.btnCancel);
base.AcceptButton = this.btnA;
base.CancelButton = this.btnC;
break;
case MessageBoxButtons.YesNo:
this.SetBtnText(StringTable.DialogButton.btnYes, StringTable.DialogButton.btnNo, string.Empty);
base.AcceptButton = this.btnA;
base.CancelButton = this.btnB;
break;
case MessageBoxButtons.RetryCancel:
this.SetBtnText(StringTable.DialogButton.btnRetry, StringTable.DialogButton.btnCancel, string.Empty);
base.AcceptButton = this.btnA;
base.CancelButton = this.btnB;
break;
}
MessageBoxDefaultButton button = this._defaultBtn;
if (button != MessageBoxDefaultButton.Button1)
{
if (button != MessageBoxDefaultButton.Button2)
{
if (button == MessageBoxDefaultButton.Button3)
{
base.AcceptButton = this.btnC;
}
return;
}
}
else
{
base.AcceptButton = this.btnA;
return;
}
base.AcceptButton = this.btnB;
}
private void InitializeComponent()
{
this.pnlContainer = new Panel();
this.pbIcon = new PictureBox();
this.lbMessage = new XLabel();
this.btnC = new XButton();
this.btnB = new XButton();
this.btnA = new XButton();
this.pnlContainer.SuspendLayout();
this.pbIcon.BeginInit();
base.SuspendLayout();
this.pnlContainer.BackColor = Color.Transparent;
this.pnlContainer.Controls.Add(this.pbIcon);
this.pnlContainer.Controls.Add(this.lbMessage);
this.pnlContainer.Location = new System.Drawing.Point(3, 0);
this.pnlContainer.Name = "pnlContainer";
this.pnlContainer.Size = new Size(240, 0x40);
this.pnlContainer.TabIndex = 2;
this.pbIcon.set_ErrorImage(null);
this.pbIcon.set_InitialImage(null);
this.pbIcon.Location = new System.Drawing.Point(3, 3);
this.pbIcon.Name = "pbIcon";
this.pbIcon.Size = new Size(100, 50);
this.pbIcon.SizeMode = PictureBoxSizeMode.AutoSize;
this.pbIcon.TabIndex = 4;
this.pbIcon.TabStop = false;
this.pbIcon.Visible = false;
this.lbMessage.set_AutoSize(true);
this.lbMessage.BorderColor = Color.Empty;
this.lbMessage.ButtonBorderStyle = ButtonBorderStyle.None;
this.lbMessage.Location = new System.Drawing.Point(0x3a, 11);
this.lbMessage.Name = "lbMessage";
this.lbMessage.Size = new Size(0, 13);
this.lbMessage.TabIndex = 3;
this.lbMessage.UseMnemonic = false;
this.btnC.Anchor = AnchorStyles.Top;
this.btnC.AutoArrangementX = true;
this.btnC.AutoSizeToImage = false;
this.btnC.BackColor = Color.Transparent;
this.btnC.BackgroundImageDisable = null;
this.btnC.BackgroundImageDown = null;
this.btnC.BackgroundImageHover = null;
this.btnC.ChangeSkin = true;
this.btnC.Location = new System.Drawing.Point(0xae, 0x5c);
this.btnC.Name = "btnC";
this.btnC.Size = new Size(0x4b, 0x19);
this.btnC.TabIndex = 2;
this.btnC.set_UseVisualStyleBackColor(false);
this.btnC.Click += new EventHandler(this.btnC_Click);
this.btnB.Anchor = AnchorStyles.Top;
this.btnB.AutoArrangementX = true;
this.btnB.AutoSizeToImage = false;
this.btnB.BackColor = Color.Transparent;
this.btnB.BackgroundImageDisable = null;
this.btnB.BackgroundImageDown = null;
this.btnB.BackgroundImageHover = null;
this.btnB.ChangeSkin = true;
this.btnB.Location = new System.Drawing.Point(0x5d, 0x5c);
this.btnB.Name = "btnB";
this.btnB.Size = new Size(0x4b, 0x19);
this.btnB.TabIndex = 1;
this.btnB.set_UseVisualStyleBackColor(false);
this.btnB.Click += new EventHandler(this.btnB_Click);
this.btnA.Anchor = AnchorStyles.Top;
this.btnA.AutoArrangementX = true;
this.btnA.AutoSizeToImage = false;
this.btnA.BackColor = Color.Transparent;
this.btnA.BackgroundImageDisable = null;
this.btnA.BackgroundImageDown = null;
this.btnA.BackgroundImageHover = null;
this.btnA.ChangeSkin = true;
this.btnA.Location = new System.Drawing.Point(12, 0x5c);
this.btnA.Name = "btnA";
this.btnA.Size = new Size(0x4b, 0x19);
this.btnA.TabIndex = 0;
this.btnA.set_UseVisualStyleBackColor(false);
this.btnA.Click += new EventHandler(this.btnA_Click);
base.set_AutoScaleDimensions(new SizeF(6f, 13f));
base.set_AutoScaleMode(1);
base.BaseHeight = 0xab;
base.BaseWidth = 0x115;
base.ClientSize = new Size(0x115, 0xab);
base.Controls.Add(this.pnlContainer);
base.Controls.Add(this.btnC);
base.Controls.Add(this.btnB);
base.Controls.Add(this.btnA);
base.DisplayLocation = new System.Drawing.Point(15, 15);
base.DisplaySize = new Size(0x115, 0xab);
base.KeyPreview = true;
base.Name = "ImpsMessageBox";
base.set_Padding(new Padding(6, 0x22, 0x13, 9));
base.ShowInTaskbar = false;
base.StartPosition = FormStartPosition.CenterScreen;
base.Text = "ImpsMessageBox";
base.add_Shown(new EventHandler(this.ImpsMessageBox_Shown));
this.pnlContainer.ResumeLayout(false);
this.pnlContainer.PerformLayout();
this.pbIcon.EndInit();
base.ResumeLayout(false);
}
private void InitIcon(MessageBoxIcon icon)
{
this.pbIcon.Visible = true;
switch (icon)
{
case MessageBoxIcon.Hand:
this.pbIcon.Image = ImpsIcons.InfoImage;
return;
case MessageBoxIcon.Question:
this.pbIcon.Image = ImpsIcons.InfoImage;
return;
case MessageBoxIcon.Exclamation:
this.pbIcon.Image = ImpsIcons.InfoImage;
return;
case MessageBoxIcon.Asterisk:
this.pbIcon.Image = ImpsIcons.InfoImage;
return;
}
this.pbIcon.Image = null;
this.pbIcon.Visible = false;
}
private void LoadResource(string details)
{
base.Text = AppDictionary.CurrentClientName;
base.MinimizeBox = false;
int num2 = Screen.PrimaryScreen.WorkingArea.Width / 2;
int num3 = 160;
TextFormatFlags flags = 0x800;
Size size = TextRenderer.MeasureText(details, this.lbMessage.Font, this.lbMessage.Size, flags);
int num4 = (int) Math.Ceiling(((double) size.Width) / ((double) num2));
int width = size.Width + 10;
if (width < num3)
{
width = num3;
}
else if (width > num2)
{
width = num2;
}
this.lbMessage.set_AutoSize(false);
this.lbMessage.Size = new Size(width, num4 * (size.Height + 5));
this.lbMessage.Text = details;
}
private void SetBtnText(string strA, string strB, string strC)
{
this.btnA.Text = strA;
this.btnA.Visible = strA.Length > 0;
this.btnB.Text = strB;
this.btnB.Visible = strB.Length > 0;
this.btnC.Text = strC;
this.btnC.Visible = strC.Length > 0;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -