📄 groupinviteform.cs
字号:
namespace Imps.Client.Pc
{
using Imps.Client;
using Imps.Client.Core;
using Imps.Client.Pc.BizControls;
using Imps.Client.Pc.Controls;
using Imps.Client.Utils;
using Imps.Common;
using Imps.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
public class GroupInviteForm : XIMDialog
{
private IFrameworkWindow _framework;
private InviteControl _inviteControl;
private PersonalGroup _inviteGroup;
private IContainer components;
private HtmlLabel lblInfo;
private AsyncBizOperation op;
private Panel pnlInvite;
private Panel pnlMain;
private XButton xbtnCancel;
private XButton xbtnSend;
public GroupInviteForm(IFrameworkWindow wnd, List<Contact> selectedContacts, PersonalGroup group)
{
this.InitializeComponent();
base.Controls.SetChildIndex(this.pnlMain, 0);
this._framework = wnd;
this._inviteGroup = group;
this.CurrentUser.StatusChanged += new EventHandler<UserSatusChangedEventArgs>(this, (IntPtr) this.CurrentUser_StatusChanged);
string text = StringHelper.EncodString(StringHelper.GetPaddingStringEndEllipsis(group.GroupInfo.Name.Value, 11));
this.lblInfo.Text = string.Format("欢迎邀请您的好友加入群<a href='{0}'>{1}({2})</a>。用户未开通飞信服务,或使用旧版本客户端收不到邀请!", group.Uri.Raw, text, group.Uri.Id);
this.lblInfo.LabelLinkClick += new EventHandler<LabelLinkClickEventArgs>(this, (IntPtr) this.lblInfo_LabelLinkClick);
this._inviteControl = new InviteControl(wnd, selectedContacts, null, SelectContactsType.InviteJoinGroup);
int maxJoinGroupInviteCount = this.CurrentUser.Configuration.SystemSetting.GroupMsgSetting.MaxJoinGroupInviteCount;
this._inviteControl.Message = "";
this._inviteControl.MaxSelectedCount = maxJoinGroupInviteCount;
this._inviteControl.Dock = DockStyle.Fill;
this._inviteControl.MessageLabelHeight = 1;
this._inviteControl.SearchTextboxAtTop = true;
this.pnlInvite.Controls.Add(this._inviteControl);
if ((this._inviteControl.SelectedContacts != null) && (this._inviteControl.SelectedContacts.get_Count() > 0))
{
this.xbtnSend.Enabled = true;
}
else
{
this.xbtnSend.Enabled = false;
}
this._inviteControl.SelectedContactsChanged += new EventHandler(this._inviteControl_SelectedContactsChanged);
}
private void _inviteControl_SelectedContactsChanged(object sender, EventArgs e)
{
try
{
if (((sender as InviteControl).SelectedContacts != null) && ((sender as InviteControl).SelectedContacts.get_Count() > 0))
{
this.xbtnSend.Enabled = true;
}
else
{
this.xbtnSend.Enabled = false;
}
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
private void CurrentUser_StatusChanged(object sender, UserSatusChangedEventArgs e)
{
try
{
if (e.NewStatus != UserAccountStatus.Logon)
{
base.Close();
}
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.pnlMain = new Panel();
this.pnlInvite = new Panel();
this.lblInfo = new HtmlLabel();
this.xbtnCancel = new XButton();
this.xbtnSend = new XButton();
this.pnlMain.SuspendLayout();
base.SuspendLayout();
this.pnlMain.BackColor = Color.Transparent;
this.pnlMain.Controls.Add(this.pnlInvite);
this.pnlMain.Controls.Add(this.lblInfo);
this.pnlMain.Location = new System.Drawing.Point(7, 3);
this.pnlMain.Name = "pnlMain";
this.pnlMain.Size = new Size(0x13b, 0x1f5);
this.pnlMain.TabIndex = 0;
this.pnlInvite.Location = new System.Drawing.Point(11, 0x34);
this.pnlInvite.Name = "pnlInvite";
this.pnlInvite.Size = new Size(0x125, 440);
this.pnlInvite.TabIndex = 2;
this.lblInfo.LinkColor = Color.Blue;
this.lblInfo.Location = new System.Drawing.Point(11, 8);
this.lblInfo.Name = "lblInfo";
this.lblInfo.ShowBackgroundImage = false;
this.lblInfo.Size = new Size(0x125, 0x27);
this.lblInfo.TabIndex = 1;
this.lblInfo.Text = "欢迎邀请您的好友加入群。";
this.xbtnCancel.AutoArrangementX = true;
this.xbtnCancel.AutoSizeToImage = false;
this.xbtnCancel.BackColor = Color.Transparent;
this.xbtnCancel.BackgroundImageDisable = null;
this.xbtnCancel.BackgroundImageDown = null;
this.xbtnCancel.BackgroundImageHover = null;
this.xbtnCancel.ChangeSkin = true;
this.xbtnCancel.DialogResult = DialogResult.Cancel;
this.xbtnCancel.Location = new System.Drawing.Point(0xf7, 510);
this.xbtnCancel.Name = "xbtnCancel";
this.xbtnCancel.Size = new Size(0x4b, 0x17);
this.xbtnCancel.TabIndex = 4;
this.xbtnCancel.Text = "取消";
this.xbtnCancel.set_UseVisualStyleBackColor(false);
this.xbtnCancel.Click += new EventHandler(this.xbtnCancel_Click);
this.xbtnSend.AutoArrangementX = true;
this.xbtnSend.AutoSizeToImage = false;
this.xbtnSend.BackColor = Color.Transparent;
this.xbtnSend.BackgroundImageDisable = null;
this.xbtnSend.BackgroundImageDown = null;
this.xbtnSend.BackgroundImageHover = null;
this.xbtnSend.ChangeSkin = true;
this.xbtnSend.Location = new System.Drawing.Point(0xa4, 510);
this.xbtnSend.Name = "xbtnSend";
this.xbtnSend.Size = new Size(0x4b, 0x17);
this.xbtnSend.TabIndex = 3;
this.xbtnSend.Text = "确定";
this.xbtnSend.set_UseVisualStyleBackColor(false);
this.xbtnSend.Click += new EventHandler(this.xbtnSend_Click);
base.set_AutoScaleDimensions(new SizeF(6f, 13f));
base.set_AutoScaleMode(1);
base.BaseHeight = 0x21d;
base.BaseWidth = 0x153;
base.ClientSize = new Size(0x153, 0x21d);
base.Controls.Add(this.xbtnCancel);
base.Controls.Add(this.pnlMain);
base.Controls.Add(this.xbtnSend);
base.DisplayLocation = new System.Drawing.Point(15, 15);
base.DisplaySize = new Size(0x153, 0x21d);
base.Name = "GroupInviteForm";
base.set_Padding(new Padding(4, 0, 4, 0x2b));
base.Text = "邀请飞信好友加入群";
base.CancelButton = this.xbtnCancel;
this.pnlMain.ResumeLayout(false);
base.ResumeLayout(false);
}
private void lblInfo_LabelLinkClick(object sender, LabelLinkClickEventArgs e)
{
try
{
if (!string.IsNullOrEmpty(e.Url))
{
IicUri uri = new IicUri(e.Url);
PersonalGroup group = this.CurrentUser.PersonalGroups[uri];
if (group != null)
{
this._framework.PersonalGroupManager.ShowGroupSetting(this, group, GroupOption.Normal);
}
}
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
private void op_ImpsError(object sender, ImpsErrorEventArgs e)
{
try
{
this._framework.UnifiedMessageBox.ShowError(e.Summary);
base.Close();
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
private void op_Successed(object sender, EventArgs e)
{
try
{
this._framework.UnifiedMessageBox.ShowInfo(string.Format("邀请飞信好友加入群{0}({1})已经发送成功!", this._inviteGroup.GroupInfo.Name.Value, this._inviteGroup.Uri.Id));
base.Close();
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
private void xbtnCancel_Click(object sender, EventArgs e)
{
base.Close();
}
private void xbtnSend_Click(object sender, EventArgs e)
{
try
{
if (this._inviteControl.SelectedContacts.get_Count() <= 0)
{
this._framework.UnifiedMessageBox.ShowError("请至少选择一个联系人!");
}
else
{
this.op = new AsyncBizOperation();
this.op.ImpsError += new EventHandler<ImpsErrorEventArgs>(this, (IntPtr) this.op_ImpsError);
this.op.Successed += new EventHandler(this.op_Successed);
this.CurrentUser.PersonalGroupManager.AsyncInviteFriends(this._inviteControl.SelectedContacts, this._inviteGroup, this.op);
this.xbtnSend.Enabled = false;
}
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
private User CurrentUser
{
get
{
return this._framework.AccountManager.CurrentUser;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -