⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 impsmessagebox.cs

📁 飞信的收发使用csharp进行开发
💻 CS
📖 第 1 页 / 共 2 页
字号:
                    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.components = new Container();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(ImpsMessageBox));
            this.pnlContainer = new Panel();
            this.btnC = new XButton();
            this.btnB = new XButton();
            this.btnA = new XButton();
            this.pbIcon = new PictureBox();
            this.lbMessage = new XLabel();
            this.pnlContainer.SuspendLayout();
            ((ISupportInitialize) this.pbIcon).BeginInit();
            base.SuspendLayout();
            this.pnlContainer.BackColor = Color.Transparent;
            this.pnlContainer.Controls.Add(this.btnC);
            this.pnlContainer.Controls.Add(this.btnB);
            this.pnlContainer.Controls.Add(this.btnA);
            this.pnlContainer.Controls.Add(this.pbIcon);
            this.pnlContainer.Controls.Add(this.lbMessage);
            this.pnlContainer.Dock = DockStyle.Fill;
            this.pnlContainer.Location = new Point(6, 0x1f);
            this.pnlContainer.Name = "pnlContainer";
            this.pnlContainer.Size = new Size(240, 60);
            this.pnlContainer.TabIndex = 2;
            this.btnC.Anchor = AnchorStyles.None;
            this.btnC.Location = new Point(0xb9, 0x2d);
            this.btnC.Name = "btnC";
            this.btnC.Size = new Size(0x4b, 0x17);
            this.btnC.TabIndex = 2;
            this.btnC.UseVisualStyleBackColor = true;
            this.btnC.Click += new EventHandler(this.btnC_Click);
            this.btnB.Anchor = AnchorStyles.None;
            this.btnB.Location = new Point(0x68, 0x2d);
            this.btnB.Name = "btnB";
            this.btnB.Size = new Size(0x4b, 0x17);
            this.btnB.TabIndex = 1;
            this.btnB.UseVisualStyleBackColor = true;
            this.btnB.Click += new EventHandler(this.btnB_Click);
            this.btnA.Anchor = AnchorStyles.None;
            this.btnA.Location = new Point(0x17, 0x2d);
            this.btnA.Name = "btnA";
            this.btnA.Size = new Size(0x4b, 0x17);
            this.btnA.TabIndex = 0;
            this.btnA.UseVisualStyleBackColor = true;
            this.btnA.Click += new EventHandler(this.btnA_Click);
            this.pbIcon.ErrorImage = null;
            this.pbIcon.InitialImage = null;
            this.pbIcon.Location = new Point(3, 3);
            this.pbIcon.Name = "pbIcon";
            this.pbIcon.Size = new Size(0x30, 0x30);
            this.pbIcon.TabIndex = 4;
            this.pbIcon.TabStop = false;
            this.pbIcon.Visible = false;
            this.lbMessage.AutoSize = true;
            this.lbMessage.Location = new Point(0x3a, 10);
            this.lbMessage.Name = "lbMessage";
            this.lbMessage.Size = new Size(0, 12);
            this.lbMessage.TabIndex = 3;
            this.lbMessage.UseMnemonic = false;
            this.lbMessage.SizeChanged += new EventHandler(this.lbMessage_SizeChanged);
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x109, 0x63);
            base.Controls.Add(this.pnlContainer);
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.Name = "ImpsMessageBox";
            base.Padding = new Padding(6, 0x1f, 0x13, 8);
            base.ShowInTaskbar = false;
            base.StartPosition = FormStartPosition.CenterParent;
            base.Text = "ImpsMessageBox";
            base.Shown += new EventHandler(this.ImpsMessageBox_Shown);
            base.Controls.SetChildIndex(this.pnlContainer, 0);
            base.Controls.SetChildIndex(base.menubar, 0);
            this.pnlContainer.ResumeLayout(false);
            this.pnlContainer.PerformLayout();
            ((ISupportInitialize) this.pbIcon).EndInit();
            base.ResumeLayout(false);
        }

        private void InitIcon(MessageBoxIcon icon)
        {
            switch (icon)
            {
                case MessageBoxIcon.Hand:
                case MessageBoxIcon.Question:
                case MessageBoxIcon.Exclamation:
                case MessageBoxIcon.Asterisk:
                    break;

                default:
                    this.pbIcon.Visible = false;
                    break;
            }
        }

        private void lbMessage_SizeChanged(object sender, EventArgs e)
        {
            Point location = this.lbMessage.Location;
            Size size = this.lbMessage.Size;
            if (!this.pbIcon.Visible)
            {
                this.lbMessage.Left -= 0x30;
            }
            int num = 0x23;
            if ((location.X + size.Width) > this.pnlContainer.Width)
            {
                int num2 = (location.X + size.Width) + num;
                if (!this.pbIcon.Visible)
                {
                    num2 -= 0x30;
                }
                base.Width = num2;
            }
            if ((((location.Y + size.Height) + 0x21) + 15) > (this.pnlContainer.Height + 15))
            {
                base.Height += (((location.Y + size.Height) - this.pnlContainer.Height) + 10) + 15;
            }
            this.AdjustBtnPosition();
            this.AdjustTextPosition();
        }

        private void LoadResource(string details)
        {
            base.Text = AppDictionary.CurrentClientName;
            base.MinimizeBox = false;
            this.lbMessage.Text = this.MessageParser(details);
        }

        private string MessageParser(string input)
        {
            string[] strArray = input.Split(new char[] { '\n' });
            int width = Screen.PrimaryScreen.WorkingArea.Width;
            int num2 = 0;
            int index = 0;
            using (Graphics graphics = base.CreateGraphics())
            {
                for (int j = 0; j < strArray.Length; j++)
                {
                    string[] strArray2;
                    IntPtr ptr;
                    (strArray2 = strArray)[(int) (ptr = (IntPtr) j)] = strArray2[(int) ptr] + "\n";
                    SizeF ef = graphics.MeasureString(strArray[j], this.lbMessage.Font);
                    if (ef.Width > num2)
                    {
                        index = j;
                        num2 = (int) ef.Width;
                    }
                }
            }
            int num5 = 0;
            int num6 = num2 / strArray[index].Length;
            if (num2 > ((width * 3) / 5))
            {
                num5 = ((width * 3) / 5) / num6;
            }
            else
            {
                return input;
            }
            if (this.pbIcon.Visible)
            {
                num5 -= (this.pbIcon.Width / num6) + 2;
            }
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < strArray.Length; i++)
            {
                if (strArray[i].Length > num5)
                {
                    int num8 = strArray[i].Length / num5;
                    if ((strArray[i].Length % num5) > 0)
                    {
                        num8++;
                    }
                    int num9 = num5 - 1;
                    for (int k = 0; k < (num8 - 1); k++)
                    {
                        strArray[i] = strArray[i].Insert(num9 * (k + 1), "\r\n");
                    }
                    builder.Append(strArray[i]);
                }
                else
                {
                    builder.Append(strArray[i]);
                }
            }
            return builder.ToString();
        }

        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 + -