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

📄 testconnect.cs

📁 飞信的收发使用csharp进行开发
💻 CS
字号:
namespace Imps.Client.Pc.Options
{
    using Imps.Client.Base;
    using Imps.Client.Pc.BizControls;
    using Imps.Client.Pc.Controls;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    public class TestConnect : XIMDialog
    {
        private XButton btnClose;
        private TestConnectionCallBack callback;
        private IContainer components;
        private RichTextBox ctlMessage;
        private Panel pnlContainer;

        public TestConnect()
        {
            this.InitializeComponent();
            base.ShowIcon = false;
        }

        private void AppendText(string text, Color color)
        {
            MyDelegate method = null;
            if (base.Created)
            {
                if (method == null)
                {
                    method = delegate {
                        this.ctlMessage.Select(this.ctlMessage.Text.Length, 0);
                        this.ctlMessage.SelectionColor = color;
                        this.ctlMessage.AppendText(text + "\r\n");
                    };
                }
                base.Invoke(method);
            }
        }

        private void AttachEventHandler()
        {
            this.callback = (TestConnectionCallBack) Delegate.Combine(this.callback, new TestConnectionCallBack(this.ShowMsg));
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            base.Close();
        }

        private void DetachEventHandler()
        {
            this.callback = (TestConnectionCallBack) Delegate.Remove(this.callback, new TestConnectionCallBack(this.ShowMsg));
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(TestConnect));
            this.pnlContainer = new Panel();
            this.ctlMessage = new RichTextBox();
            this.btnClose = new XButton();
            this.pnlContainer.SuspendLayout();
            base.SuspendLayout();
            this.pnlContainer.BackColor = Color.Transparent;
            this.pnlContainer.Controls.Add(this.ctlMessage);
            this.pnlContainer.Controls.Add(this.btnClose);
            this.pnlContainer.Dock = DockStyle.Fill;
            this.pnlContainer.Location = new Point(6, 0x22);
            this.pnlContainer.Name = "pnlContainer";
            this.pnlContainer.Size = new Size(0x10b, 0xf2);
            this.pnlContainer.TabIndex = 0;
            this.ctlMessage.BorderStyle = BorderStyle.FixedSingle;
            this.ctlMessage.Font = new Font("SimSun", 9f);
            this.ctlMessage.Location = new Point(2, 4);
            this.ctlMessage.Name = "ctlMessage";
            this.ctlMessage.ReadOnly = true;
            this.ctlMessage.Size = new Size(0x103, 0xb7);
            this.ctlMessage.TabIndex = 0;
            this.ctlMessage.Text = "";
            this.btnClose.DialogResult = DialogResult.Cancel;
            this.btnClose.Location = new Point(0xb1, 0xc1);
            this.btnClose.Name = "btnClose";
            this.btnClose.Size = new Size(0x4b, 0x19);
            this.btnClose.TabIndex = 1;
            this.btnClose.Text = "关闭";
            this.btnClose.UseVisualStyleBackColor = true;
            this.btnClose.Click += new EventHandler(this.btnClose_Click);
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.CancelButton = this.btnClose;
            base.ClientSize = new Size(0x124, 0x11d);
            base.Controls.Add(this.pnlContainer);
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.MinimizeBox = false;
            base.Name = "TestConnect";
            base.Padding = new Padding(6, 0x22, 0x13, 9);
            base.ShowInTaskbar = false;
            base.StartPosition = FormStartPosition.CenterParent;
            base.Text = "连接测试";
            base.FormClosing += new FormClosingEventHandler(this.TestConnect_FormClosing);
            base.Controls.SetChildIndex(this.pnlContainer, 0);
            base.Controls.SetChildIndex(base.menubar, 0);
            this.pnlContainer.ResumeLayout(false);
            base.ResumeLayout(false);
        }

        public void ShowMsg(TestConnectionStatus status, string msg)
        {
            switch (status)
            {
                case TestConnectionStatus.Info:
                case TestConnectionStatus.Successed:
                    this.AppendText(msg, Color.Blue);
                    return;

                case TestConnectionStatus.Failed:
                    this.AppendText(msg, Color.Red);
                    return;
            }
        }

        private void TestConnect_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.DetachEventHandler();
        }

        private delegate void MyDelegate();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -