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

📄 groupsmsform.cs

📁 飞信的收发使用csharp进行开发
💻 CS
📖 第 1 页 / 共 2 页
字号:
            this.btnSend.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.btnSend.BackColor = Color.FromArgb(0xf8, 0xef, 0xe4);
            this.btnSend.BackgroundImage = (Image) manager.GetObject("btnSend.BackgroundImage");
            this.btnSend.BorderColor = Color.FromArgb(0xf7, 0xb2, 0x53);
            this.btnSend.Disabled = false;
            this.btnSend.DisabledBackgroudColor = Color.White;
            this.btnSend.DisabledBackgroundImage = (Image) manager.GetObject("btnSend.DisabledBackgroundImage");
            this.btnSend.DisabledBorderColor = Color.Gray;
            this.btnSend.DisabledDropDownButtonImage = (Image) manager.GetObject("btnSend.DisabledDropDownButtonImage");
            this.btnSend.DisabledForeColor = Color.Gray;
            this.btnSend.DropDownButtonImage = (Image) manager.GetObject("btnSend.DropDownButtonImage");
            this.btnSend.DropDownMenu = this.menuSendType;
            this.btnSend.Location = new Point(0x1b7, 0x1d3);
            this.btnSend.Name = "btnSend";
            this.btnSend.Padding = new Padding(1);
            this.btnSend.Size = new Size(0x54, 0x19);
            this.btnSend.TabIndex = 0;
            this.btnSend.TabStop = false;
            this.btnSend.Text = "发送";
            this.btnSend.ToolTipText = "点击发送聊天信息";
            this.btnSend.ButtonClick += new EventHandler(this.btnSend_Click);
            this.menuSendType.Items.AddRange(new ToolStripItem[] { this.tsSendEnter, this.tsSendCtrlEnter });
            this.menuSendType.Name = "contextMenuSendMessage";
            this.menuSendType.Size = new Size(0xcc, 0x30);
            this.tsSendEnter.Checked = true;
            this.tsSendEnter.CheckState = CheckState.Checked;
            this.tsSendEnter.Name = "tsSendEnter";
            this.tsSendEnter.Size = new Size(0xcb, 0x16);
            this.tsSendEnter.Text = "按 Enter 键发送消息";
            this.tsSendEnter.Click += new EventHandler(this.tsSendEnter_Click);
            this.tsSendCtrlEnter.Name = "tsSendCtrlEnter";
            this.tsSendCtrlEnter.Size = new Size(0xcb, 0x16);
            this.tsSendCtrlEnter.Text = "按 Ctrl+Enter 键发送消息";
            this.tsSendCtrlEnter.Click += new EventHandler(this.tsSendCtrlEnter_Click);
            this.btnCancel.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.btnCancel.DialogResult = DialogResult.Cancel;
            this.btnCancel.Location = new Point(0x211, 0x1d3);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new Size(0x54, 0x19);
            this.btnCancel.TabIndex = 2;
            this.btnCancel.Text = "取消";
            this.btnCancel.UseVisualStyleBackColor = true;
            this.btnCancel.Click += new EventHandler(this.btnCancel_Click);
            this.btnAddMyMobileNo.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.btnAddMyMobileNo.Location = new Point(0xfb, 0x1d3);
            this.btnAddMyMobileNo.Name = "btnAddMyMobileNo";
            this.btnAddMyMobileNo.Size = new Size(0x74, 0x19);
            this.btnAddMyMobileNo.TabIndex = 3;
            this.btnAddMyMobileNo.Text = "插入我的手机号";
            this.btnAddMyMobileNo.UseVisualStyleBackColor = true;
            this.btnAddMyMobileNo.Click += new EventHandler(this.btnAddMyMobileNo_Click);
            this.pnlMain.BackColor = Color.Transparent;
            this.pnlMain.Controls.Add(this.btnCancel);
            this.pnlMain.Controls.Add(this.btnSend);
            this.pnlMain.Controls.Add(this.panel2);
            this.pnlMain.Controls.Add(this.plInviteContacts);
            this.pnlMain.Controls.Add(this.btnAddMyMobileNo);
            this.pnlMain.Dock = DockStyle.Fill;
            this.pnlMain.Location = new Point(8, 8);
            this.pnlMain.Name = "pnlMain";
            this.pnlMain.Size = new Size(0x265, 0x1f0);
            this.pnlMain.TabIndex = 6;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.CancelButton = this.btnCancel;
            base.ClientSize = new Size(0x275, 0x200);
            base.Controls.Add(this.pnlMain);
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            this.MinimumSize = new Size(520, 460);
            base.Name = "GroupSMSForm";
            base.Padding = new Padding(8);
            base.Text = "群发短信";
            base.Controls.SetChildIndex(this.pnlMain, 0);
            base.Controls.SetChildIndex(base.menubar, 0);
            this.panel2.ResumeLayout(false);
            this.splitContainer1.Panel1.ResumeLayout(false);
            this.splitContainer1.Panel1.PerformLayout();
            this.splitContainer1.Panel2.ResumeLayout(false);
            this.splitContainer1.ResumeLayout(false);
            this.panel1.ResumeLayout(false);
            this.panel3.ResumeLayout(false);
            this.panel4.ResumeLayout(false);
            this.panel4.PerformLayout();
            this.menuSendType.ResumeLayout(false);
            this.pnlMain.ResumeLayout(false);
            base.ResumeLayout(false);
        }

        private void Localize()
        {
            this.btnSend.Text = StringTable.Conversation.BtnSend;
            this.btnCancel.Text = StringTable.Conversation.BtnCancel;
        }

        protected override void OnFormClosed(FormClosedEventArgs e)
        {
            this._historyChatManager = null;
            this.CurrentUser.StatusChanged -= new EventHandler<UserSatusChangedEventArgs>(this.CurrentUser_StatusChanged);
            if (this._groupSMSFailedForm != null)
            {
                this._groupSMSFailedForm.Close();
            }
            base.OnFormClosed(e);
            this.CurrentUser.Configuration.UserSetting.ConversationSetting.SendMessageByEnterKey.Value = this.tsSendEnter.Checked;
        }

        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            if (((this._stackSMSItems.Count > 0) && !this._sendFrequent) && (this._frameworkWin.UnifiedMessageBox.ShowConfirmation(this, "如果您现在关闭窗口,将无法看到短信发送的结果,\r\n\r\n是否现在就关闭窗口?") != DialogResult.Yes))
            {
                e.Cancel = true;
            }
            else
            {
                base.OnFormClosing(e);
            }
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.txtSendContent.MaxLength = this.MaxInputLength;
            this.Localize();
            this.FormatSendInfo();
            if (this.CurrentUser.Configuration.UserSetting.ConversationSetting.SendMessageByEnterKey == null)
            {
                this.tsSendCtrlEnter.Checked = true;
                this.tsSendEnter.Checked = false;
            }
        }

        private void op_ImpsError(object sender, ImpsErrorEventArgs e)
        {
            if (!base.IsDisposed && (e.Description == "486"))
            {
                this._sendFrequent = true;
                this._historyChatManager.LinkButtonFont = new Font("Microsoft Sans Serif", 9.5f, FontStyle.Regular, GraphicsUnit.Point, 0);
                this._historyChatManager.AppentString("<font size=9.5 color=#a31515>【系统提示】: " + e.Summary + "</font>");
                OleKey newKey = OleKeyManager.Instance.NewKey;
                this._historyChatManager.AppendLink(newKey, "详细内容", "frequent");
                this._historyChatManager.AppendCRLF();
                this.txtSendContent.Enabled = false;
                this.btnAddMyMobileNo.Enabled = false;
                this.txtSendContent.Enabled = false;
            }
            else
            {
                this.SendNext();
            }
        }

        private void op_Successed(object sender, EventArgs e)
        {
            this.SendNext();
        }

        private void SendNext()
        {
            if (this._stackSMSItems.Count > 0)
            {
                this._currentSendingItem = this._stackSMSItems.Dequeue();
                SMSManager.AsyncSendSMS(this.CurrentUser, this._currentSendingItem.Contact.Uri.Raw, this._currentSendingItem.Content, this.op);
            }
            else
            {
                this.sending = false;
                if (!base.IsDisposed)
                {
                    this._historyChatManager.AppentString("<font size=9.5 color=#a31515>【系统提示】:短信发送完毕!</font>");
                    this._historyChatManager.AppendCRLF();
                }
            }
        }

        private void SendSMS()
        {
            SimpleEventHandler method = null;
            SimpleEventHandler handler2 = null;
            try
            {
                if (this.txtSendContent.Text.Trim() == "")
                {
                    if (method == null)
                    {
                        method = delegate {
                            this._frameworkWin.UnifiedMessageBox.ShowInfo(StringTable.Conversation.MsgPleaseInputContent);
                        };
                    }
                    base.BeginInvoke(method);
                }
                else
                {
                    List<Imps.Client.Core.Contact> selectedContacts = this.inviteControl.SelectedContacts;
                    if (selectedContacts.Count == 0)
                    {
                        if (handler2 == null)
                        {
                            handler2 = delegate {
                                this._frameworkWin.UnifiedMessageBox.ShowInfo("您至少要选择一个联系人!");
                            };
                        }
                        base.BeginInvoke(handler2);
                    }
                    else
                    {
                        string text = this.txtSendContent.Text;
                        if (this.op == null)
                        {
                            this.op = new AsyncBizOperation();
                            this.op.Successed += new EventHandler(this.op_Successed);
                            this.op.ImpsError += new EventHandler<ImpsErrorEventArgs>(this.op_ImpsError);
                        }
                        foreach (Imps.Client.Core.Contact contact in selectedContacts)
                        {
                            if (!(contact.Uri.Raw == this.CurrentUser.Uri.Raw) && !contact.EnableSMS)
                            {
                                continue;
                            }
                            SendSMSItem item = new SendSMSItem(contact, text);
                            this._stackSMSItems.Enqueue(item);
                        }
                        if ((this._stackSMSItems.Count > 0) && !this.sending)
                        {
                            this.StartSend();
                        }
                        this._alreadySendCount++;
                        this.FormatSendInfo();
                        this._historyChatManager.AppendRichTextPlainString(this.txtSendContent.Text + "\r\n--------------------\r\n");
                        this._historyChatManager.ScrollToEnd();
                        this.txtSendContent.Text = "";
                    }
                }
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
            }
        }

        private void splitContainer1_SplitterMoved(object sender, SplitterEventArgs e)
        {
            this.txtSendContent.Focus();
        }

        private void StartSend()
        {
            this.sending = true;
            this.SendNext();
        }

        private void tsSendCtrlEnter_Click(object sender, EventArgs e)
        {
            this.tsSendEnter.Checked = false;
            this.tsSendCtrlEnter.Checked = true;
        }

        private void tsSendEnter_Click(object sender, EventArgs e)
        {
            this.tsSendEnter.Checked = true;
            this.tsSendCtrlEnter.Checked = false;
        }

        private void txtHistory_KeyDown(object sender, KeyEventArgs e)
        {
        }

        private void txtSendContent_KeyDown(object sender, KeyEventArgs e)
        {
            if (Keys.ProcessKey == e.KeyCode)
            {
                this.m_fIsProcessKey = true;
            }
            else if ((e.KeyCode == Keys.A) && (e.Modifiers == Keys.Control))
            {
                this.txtSendContent.SelectAll();
            }
            else if ((e.KeyCode == Keys.S) && (e.Modifiers == Keys.Alt))
            {
                e.SuppressKeyPress = true;
                this.SendSMS();
            }
            else if (((this.tsSendEnter.Checked && (e.KeyCode == Keys.Return)) && !e.Control) || ((this.tsSendCtrlEnter.Checked && e.Control) && (e.KeyCode == Keys.Return)))
            {
                e.SuppressKeyPress = true;
                this.SendSMS();
            }
        }

        private void txtSendContent_TextChanged(object sender, EventArgs e)
        {
            base.BeginInvoke(delegate {
                this.btnSend.Disabled = this.txtSendContent.Text.Trim() == "";
                this.lblInputInfo.Text = string.Format(StringTable.Conversation.MsgSMSInputInfo, this.MaxInputLength - this.txtSendContent.Text.Length);
            });
        }

        public int AlreadySendCount
        {
            get
            {
                return this._alreadySendCount;
            }
        }

        public Imps.Client.Core.User CurrentUser
        {
            get
            {
                return this._frameworkWin.AccountManager.CurrentUser;
            }
        }

        public int MaxInputLength
        {
            get
            {
                return this.CurrentUser.Configuration.SystemSetting.SysSmsSetting.MaxMsgLenSmsOnline;
            }
        }
    }
}

⌨️ 快捷键说明

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