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

📄 contactgroupform.cs

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

    public class ContactGroupForm : XIMDialog
    {
        private bool _canClose;
        private int? _groupId;
        private IFrameworkWindow _iFrameworkWindow;
        private bool _isFrist = true;
        private AsyncBizOperation _op;
        private Imps.Client.Core.User _user;
        private XButton buttonCancel;
        private XButton buttonOK;
        private IContainer components;
        private XLabel labelName;
        private Panel panel1;
        private XTextBox textBoxName;

        public ContactGroupForm(IFrameworkWindow iFrameworkWindow, int? groupId, AsyncBizOperation op)
        {
            this.InitializeComponent();
            this.initComponentRegion();
            this._iFrameworkWindow = iFrameworkWindow;
            this._user = this._iFrameworkWindow.AccountManager.CurrentUser;
            this._groupId = groupId;
            if (op == null)
            {
                op = new AsyncBizOperation();
            }
            this._op = op;
            ControlHelper.ForceControlImeHangul(this.textBoxName);
            this.textBoxName.MaxLength = 0x40;
        }

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

        private void buttonOK_Click(object sender, EventArgs e)
        {
            string newName = this.textBoxName.Text.Trim();
            if (newName.Length == 0)
            {
                this._iFrameworkWindow.UnifiedMessageBox.ShowError(this, StringTable.ContactGroup.MsgAddGroupNameEmpty);
                this._canClose = false;
            }
            else if (newName.Length > 0x40)
            {
                this._iFrameworkWindow.UnifiedMessageBox.ShowError(this, StringTable.ContactGroup.MsgAddGroupNameTooLong);
                this._canClose = false;
            }
            else if (this._groupId.HasValue)
            {
                Imps.Client.Core.ContactGroup group = this._user.ContactList.Groups.FindContactGroup(this._groupId) as Imps.Client.Core.ContactGroup;
                if (group == null)
                {
                    this._iFrameworkWindow.UnifiedMessageBox.ShowError(this, StringTable.ContactGroup.MsgNotExist);
                }
                else
                {
                    this._canClose = group.AsyncUpdate(newName, this._op);
                }
            }
            else if (newName == StringTable.ContactGroup.ChatFriendGroup)
            {
                this._iFrameworkWindow.UnifiedMessageBox.ShowError(this, StringTable.ContactGroup.NotAllowFixedGroupName);
            }
            else
            {
                this._canClose = this._user.ContactList.AsyncAddGroup(newName, this._op);
            }
        }

        private void ContactGroupForm_Load(object sender, EventArgs e)
        {
            this.labelName.Text = StringTable.ContactGroup.InputGroupName;
            this._isFrist = true;
            if (!this._groupId.HasValue)
            {
                base.Text = StringTable.ContactGroup.TitleText_New;
                this.textBoxName.Text = "";
            }
            else
            {
                base.Text = StringTable.ContactGroup.TitleText_Rename;
                Imps.Client.Core.ContactGroup group = this._user.ContactList.Groups.FindContactGroup(this._groupId) as Imps.Client.Core.ContactGroup;
                if (group == null)
                {
                    this._iFrameworkWindow.UnifiedMessageBox.ShowError(StringTable.ContactGroup.MsgNotExist);
                }
                else
                {
                    this.textBoxName.Text = group.Name;
                }
            }
        }

        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(ContactGroupForm));
            this.textBoxName = new XTextBox();
            this.buttonCancel = new XButton();
            this.buttonOK = new XButton();
            this.labelName = new XLabel();
            this.panel1 = new Panel();
            this.panel1.SuspendLayout();
            base.SuspendLayout();
            base.menubar.Location = new Point(2, 0x15);
            this.textBoxName.BackColor = Color.White;
            this.textBoxName.BorderStyle = BorderStyle.FixedSingle;
            this.textBoxName.Location = new Point(12, 0x21);
            this.textBoxName.MaxLength = 0x40;
            this.textBoxName.Name = "textBoxName";
            this.textBoxName.Size = new Size(0x112, 20);
            this.textBoxName.TabIndex = 1;
            this.buttonCancel.AutoEllipsis = true;
            this.buttonCancel.DialogResult = DialogResult.Cancel;
            this.buttonCancel.Location = new Point(0xd4, 0x40);
            this.buttonCancel.Name = "buttonCancel";
            this.buttonCancel.Size = new Size(0x4b, 0x17);
            this.buttonCancel.TabIndex = 3;
            this.buttonCancel.Text = "取消";
            this.buttonCancel.UseVisualStyleBackColor = true;
            this.buttonCancel.Click += new EventHandler(this.buttonCancel_Click);
            this.buttonOK.AutoEllipsis = true;
            this.buttonOK.DialogResult = DialogResult.OK;
            this.buttonOK.Location = new Point(0x83, 0x40);
            this.buttonOK.Name = "buttonOK";
            this.buttonOK.Size = new Size(0x4b, 0x17);
            this.buttonOK.TabIndex = 2;
            this.buttonOK.Text = "确定";
            this.buttonOK.UseVisualStyleBackColor = true;
            this.buttonOK.Click += new EventHandler(this.buttonOK_Click);
            this.labelName.AutoSize = true;
            this.labelName.BackColor = Color.Transparent;
            this.labelName.Location = new Point(12, 11);
            this.labelName.Name = "labelName";
            this.labelName.Size = new Size(0x51, 13);
            this.labelName.TabIndex = 0x27;
            this.labelName.Text = "labelInputName";
            this.panel1.BackColor = Color.Transparent;
            this.panel1.Controls.Add(this.buttonCancel);
            this.panel1.Controls.Add(this.labelName);
            this.panel1.Controls.Add(this.textBoxName);
            this.panel1.Controls.Add(this.buttonOK);
            this.panel1.Dock = DockStyle.Fill;
            this.panel1.Location = new Point(8, 8);
            this.panel1.Name = "panel1";
            this.panel1.Size = new Size(0x13a, 0x8a);
            this.panel1.TabIndex = 40;
            base.AcceptButton = this.buttonOK;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.CancelButton = this.buttonCancel;
            base.ClientSize = new Size(330, 0x9a);
            base.Controls.Add(this.panel1);
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.MinimizeBox = false;
            base.Name = "ContactGroupForm";
            base.Padding = new Padding(8);
            base.ShowInTaskbar = false;
            base.StartPosition = FormStartPosition.Manual;
            base.Text = "管理组";
            base.Load += new EventHandler(this.ContactGroupForm_Load);
            base.Controls.SetChildIndex(this.panel1, 0);
            base.Controls.SetChildIndex(base.menubar, 0);
            this.panel1.ResumeLayout(false);
            this.panel1.PerformLayout();
            base.ResumeLayout(false);
        }

        protected override void OnActivated(EventArgs e)
        {
            base.OnActivated(e);
            if (this._isFrist)
            {
                this.textBoxName.Focus();
                this._isFrist = false;
            }
        }

        protected override void OnClosing(CancelEventArgs e)
        {
            if ((base.DialogResult == DialogResult.OK) && !this._canClose)
            {
                e.Cancel = true;
            }
        }

        public int? GroupId
        {
            get
            {
                return this._groupId;
            }
        }
    }
}

⌨️ 快捷键说明

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