www.pudn.com > Fetion.rar > ApplyForJoinForm.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.Resource;
using Imps.Client.Utils;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
public class ApplyForJoinForm : XIMDialog
{
private string _applyNote;
private AsyncBizOperation _bz;
private IFrameworkWindow _framework;
public PersonalGroup _personalgroup;
private bool _seeDetail;
private IContainer components;
private Label lblGroupId;
private Label lblGroupName;
private Panel pnlApplyNote;
private Panel pnlContent;
private UPanel pnlGroupInfo;
private Panel pnlPortrait;
private XButton xbtnCancel;
private XButton xbtnOK;
private XLabel xlblApplyNote;
private XLabel xlblAttention;
private XLabel xlblCatagory;
private XLabel xlblCatagoryTag;
private XLabel xlblGroupID;
private XLabel xlblGroupIntroduce;
private XLabel xlblGroupName;
private XLabel xlblMemberCountTag;
private XLabel xlblMembersCount;
private XPictureBox xpbPortrait;
private XTextBox xtbApplyNote;
private XTextBox xtbIntroduce;
public ApplyForJoinForm(IFrameworkWindow framework, PersonalGroup pg, bool seeDetail)
{
this._framework = framework;
this._personalgroup = pg;
this.InitializeComponent();
base.Controls.SetChildIndex(this.pnlContent, 0);
base.ShowInTaskbar = false;
this._bz = new AsyncBizOperation();
this._seeDetail = seeDetail;
this.xpbPortrait.Image = ImpsPortrait.GetDefaultGroupPortrait(0x60, 0x60);
this._personalgroup.GroupInfo.PropertiesChanged += new EventHandler(this.GroupInfo_PropertiesChanged);
this.UpdateGroupInfo(seeDetail);
this.CurrentUser.StatusChanged += new EventHandler(this.CurrentUser_StatusChanged);
}
private void ApplyForJoinForm_Activated(object sender, EventArgs e)
{
if (this._seeDetail)
{
this.xbtnCancel.Focus();
}
else
{
this.xtbApplyNote.Focus();
}
}
private void ApplyForJoinForm_FormClosing(object sender, FormClosingEventArgs e)
{
this._personalgroup.GroupInfo.PropertiesChanged -= new EventHandler(this.GroupInfo_PropertiesChanged);
}
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 string getCategoryString(string categoryID)
{
foreach (PersonalGroupCategory.Category category in this.CurrentUser.PersonalGroupManager.GroupCategory.Categorys.Keys)
{
if (category.Id == categoryID)
{
return category.Name;
}
foreach (PersonalGroupCategory.Category category2 in this.CurrentUser.PersonalGroupManager.GroupCategory.Categorys[category])
{
if (category2.Id == categoryID)
{
return string.Format("{0}/{1}", category.Name, category2.Name);
}
}
}
return string.Empty;
}
private void GroupInfo_PropertiesChanged(object sender, PropertiesChangedEventArgs e)
{
try
{
this.xpbPortrait.Image = (Image) this._personalgroup.GroupInfo.Portrait;
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
private void InitializeComponent()
{
ComponentResourceManager manager = new ComponentResourceManager(typeof(ApplyForJoinForm));
this.pnlContent = new Panel();
this.pnlApplyNote = new Panel();
this.xlblApplyNote = new XLabel();
this.xtbApplyNote = new XTextBox();
this.xlblAttention = new XLabel();
this.pnlGroupInfo = new UPanel();
this.xlblCatagory = new XLabel();
this.xlblMembersCount = new XLabel();
this.xlblMemberCountTag = new XLabel();
this.xlblCatagoryTag = new XLabel();
this.xlblGroupIntroduce = new XLabel();
this.xlblGroupName = new XLabel();
this.lblGroupName = new Label();
this.xtbIntroduce = new XTextBox();
this.lblGroupId = new Label();
this.pnlPortrait = new Panel();
this.xpbPortrait = new XPictureBox();
this.xlblGroupID = new XLabel();
this.xbtnOK = new XButton();
this.xbtnCancel = new XButton();
this.pnlContent.SuspendLayout();
this.pnlApplyNote.SuspendLayout();
this.pnlGroupInfo.SuspendLayout();
this.pnlPortrait.SuspendLayout();
base.SuspendLayout();
this.pnlContent.BackColor = Color.Transparent;
this.pnlContent.Controls.Add(this.pnlApplyNote);
this.pnlContent.Controls.Add(this.xlblAttention);
this.pnlContent.Controls.Add(this.pnlGroupInfo);
this.pnlContent.Location = new System.Drawing.Point(9, 0x11);
this.pnlContent.Name = "pnlContent";
this.pnlContent.Padding = new Padding(3);
this.pnlContent.Size = new Size(0x16d, 0x134);
this.pnlContent.TabIndex = 4;
this.pnlApplyNote.BackColor = Color.Transparent;
this.pnlApplyNote.Controls.Add(this.xlblApplyNote);
this.pnlApplyNote.Controls.Add(this.xtbApplyNote);
this.pnlApplyNote.Location = new System.Drawing.Point(1, 0xd4);
this.pnlApplyNote.Name = "pnlApplyNote";
this.pnlApplyNote.Size = new Size(0x16c, 90);
this.pnlApplyNote.TabIndex = 4;
this.xlblApplyNote.AutoSize = true;
this.xlblApplyNote.BorderColor = Color.Empty;
this.xlblApplyNote.ButtonBorderStyle = ButtonBorderStyle.None;
this.xlblApplyNote.Location = new System.Drawing.Point(7, 9);
this.xlblApplyNote.Name = "xlblApplyNote";
this.xlblApplyNote.Size = new Size(0x43, 13);
this.xlblApplyNote.TabIndex = 0;
this.xlblApplyNote.Text = "申请说明:";
this.xtbApplyNote.BackColor = Color.White;
this.xtbApplyNote.BorderStyle = BorderStyle.FixedSingle;
this.xtbApplyNote.EmptyTextTip = "";
this.xtbApplyNote.EmptyTextTipColor = Color.DarkGray;
this.xtbApplyNote.Location = new System.Drawing.Point(6, 0x1d);
this.xtbApplyNote.MaxLength = 0x80;
this.xtbApplyNote.Multiline = true;
this.xtbApplyNote.Name = "xtbApplyNote";
this.xtbApplyNote.ScrollBars = ScrollBars.Vertical;
this.xtbApplyNote.Size = new Size(350, 0x37);
this.xtbApplyNote.TabIndex = 0;
this.xlblAttention.AutoSize = true;
this.xlblAttention.BorderColor = Color.Empty;
this.xlblAttention.ButtonBorderStyle = ButtonBorderStyle.None;
this.xlblAttention.ForeColor = Color.MidnightBlue;
this.xlblAttention.Location = new System.Drawing.Point(3, 10);
this.xlblAttention.Name = "xlblAttention";
this.xlblAttention.Size = new Size(0x1f, 13);
this.xlblAttention.TabIndex = 0;
this.xlblAttention.Text = "注:";
this.pnlGroupInfo.BorderColor = Color.Silver;
this.pnlGroupInfo.BorderInsideColor = Color.Transparent;
this.pnlGroupInfo.BorderInsideWidth = 0;
this.pnlGroupInfo.BorderWidth = 1;
this.pnlGroupInfo.Controls.Add(this.xlblCatagory);
this.pnlGroupInfo.Controls.Add(this.xlblMembersCount);
this.pnlGroupInfo.Controls.Add(this.xlblMemberCountTag);
this.pnlGroupInfo.Controls.Add(this.xlblCatagoryTag);
this.pnlGroupInfo.Controls.Add(this.xlblGroupIntroduce);
this.pnlGroupInfo.Controls.Add(this.xlblGroupName);
this.pnlGroupInfo.Controls.Add(this.lblGroupName);
this.pnlGroupInfo.Controls.Add(this.xtbIntroduce);
this.pnlGroupInfo.Controls.Add(this.lblGroupId);
this.pnlGroupInfo.Controls.Add(this.pnlPortrait);
this.pnlGroupInfo.Controls.Add(this.xlblGroupID);
this.pnlGroupInfo.Location = new System.Drawing.Point(6, 0x1f);
this.pnlGroupInfo.Name = "pnlGroupInfo";
this.pnlGroupInfo.Size = new Size(350, 0xaf);
this.pnlGroupInfo.TabIndex = 7;
this.xlblCatagory.AutoEllipsis = true;
this.xlblCatagory.BorderColor = Color.Empty;
this.xlblCatagory.ButtonBorderStyle = ButtonBorderStyle.None;
this.xlblCatagory.Location = new System.Drawing.Point(0x8a, 0x38);
this.xlblCatagory.Name = "xlblCatagory";
this.xlblCatagory.Size = new Size(0xc7, 13);
this.xlblCatagory.TabIndex = 11;
this.xlblCatagory.Text = "默认分类";
this.xlblMembersCount.AutoEllipsis = true;
this.xlblMembersCount.BorderColor = Color.Empty;
this.xlblMembersCount.ButtonBorderStyle = ButtonBorderStyle.None;
this.xlblMembersCount.Location = new System.Drawing.Point(0x8a, 0x4f);
this.xlblMembersCount.Name = "xlblMembersCount";
this.xlblMembersCount.Size = new Size(0xc7, 13);
this.xlblMembersCount.TabIndex = 10;
this.xlblMembersCount.Text = "0";
this.xlblMemberCountTag.AutoSize = true;
this.xlblMemberCountTag.BorderColor = Color.Empty;
this.xlblMemberCountTag.ButtonBorderStyle = ButtonBorderStyle.None;
this.xlblMemberCountTag.Location = new System.Drawing.Point(0x55, 0x4f);
this.xlblMemberCountTag.Name = "xlblMemberCountTag";
this.xlblMemberCountTag.Size = new Size(0x37, 13);
this.xlblMemberCountTag.TabIndex = 5;
this.xlblMemberCountTag.Text = "成员数:";
this.xlblCatagoryTag.AutoSize = true;
this.xlblCatagoryTag.BorderColor = Color.Empty;
this.xlblCatagoryTag.ButtonBorderStyle = ButtonBorderStyle.None;
this.xlblCatagoryTag.Location = new System.Drawing.Point(0x55, 0x38);
this.xlblCatagoryTag.Name = "xlblCatagoryTag";
this.xlblCatagoryTag.Size = new Size(0x37, 13);
this.xlblCatagoryTag.TabIndex = 9;
this.xlblCatagoryTag.Text = "群分类:";
this.xlblGroupIntroduce.AutoSize = true;
this.xlblGroupIntroduce.BorderColor = Color.Empty;
this.xlblGroupIntroduce.ButtonBorderStyle = ButtonBorderStyle.None;
this.xlblGroupIntroduce.Location = new System.Drawing.Point(0x55, 0x66);
this.xlblGroupIntroduce.Name = "xlblGroupIntroduce";
this.xlblGroupIntroduce.Size = new Size(0x37, 13);
this.xlblGroupIntroduce.TabIndex = 3;
this.xlblGroupIntroduce.Text = "群简介:";
this.xlblGroupName.AutoSize = true;
this.xlblGroupName.BorderColor = Color.Empty;
this.xlblGroupName.ButtonBorderStyle = ButtonBorderStyle.None;
this.xlblGroupName.Location = new System.Drawing.Point(0x55, 10);
this.xlblGroupName.Name = "xlblGroupName";
this.xlblGroupName.Size = new Size(0x37, 13);
this.xlblGroupName.TabIndex = 1;
this.xlblGroupName.Text = "群名称:";
this.lblGroupName.AutoEllipsis = true;
this.lblGroupName.Location = new System.Drawing.Point(0x8a, 10);
this.lblGroupName.Name = "lblGroupName";
this.lblGroupName.Size = new Size(0xc7, 0x10);
this.lblGroupName.TabIndex = 7;
this.lblGroupName.Text = "groupName";
this.lblGroupName.UseMnemonic = false;
this.xtbIntroduce.BackColor = Color.FromArgb(240, 240, 240);
this.xtbIntroduce.BorderStyle = BorderStyle.FixedSingle;
this.xtbIntroduce.EmptyTextTip = "";
this.xtbIntroduce.EmptyTextTipColor = Color.DarkGray;
this.xtbIntroduce.Location = new System.Drawing.Point(140, 0x66);
this.xtbIntroduce.MaxLength = 0x100;
this.xtbIntroduce.Multiline = true;
this.xtbIntroduce.Name = "xtbIntroduce";
this.xtbIntroduce.ReadOnly = true;
this.xtbIntroduce.ScrollBars = ScrollBars.Vertical;
this.xtbIntroduce.Size = new Size(0xc5, 0x43);
this.xtbIntroduce.TabIndex = 4;
this.lblGroupId.AutoEllipsis = true;
this.lblGroupId.Location = new System.Drawing.Point(0x8a, 0x21);
this.lblGroupId.Name = "lblGroupId";
this.lblGroupId.Size = new Size(0xc7, 0x10);
this.lblGroupId.TabIndex = 6;
this.lblGroupId.Text = "groupid";
this.lblGroupId.UseMnemonic = false;
this.pnlPortrait.BackColor = Color.Silver;
this.pnlPortrait.Controls.Add(this.xpbPortrait);
this.pnlPortrait.Location = new System.Drawing.Point(10, 10);
this.pnlPortrait.Name = "pnlPortrait";
this.pnlPortrait.Padding = new Padding(1);
this.pnlPortrait.Size = new Size(0x41, 0x41);
this.pnlPortrait.TabIndex = 5;
this.xpbPortrait.BackColor = Color.White;
this.xpbPortrait.BorderColor = Color.Black;
this.xpbPortrait.BorderStyle = BorderStyle.None;
this.xpbPortrait.ButtonBorderStyle = ButtonBorderStyle.Solid;
this.xpbPortrait.Dock = DockStyle.Fill;
this.xpbPortrait.Image = null;
this.xpbPortrait.Location = new System.Drawing.Point(1, 1);
this.xpbPortrait.Name = "xpbPortrait";
this.xpbPortrait.Size = new Size(0x3f, 0x3f);
this.xpbPortrait.SizeMode = PictureBoxSizeMode.StretchImage;
this.xpbPortrait.TabIndex = 0;
this.xpbPortrait.Text = "xPictureBox1";
this.xlblGroupID.AutoSize = true;
this.xlblGroupID.BorderColor = Color.Empty;
this.xlblGroupID.ButtonBorderStyle = ButtonBorderStyle.None;
this.xlblGroupID.Location = new System.Drawing.Point(0x55, 0x21);
this.xlblGroupID.Name = "xlblGroupID";
this.xlblGroupID.Size = new Size(0x36, 13);
this.xlblGroupID.TabIndex = 2;
this.xlblGroupID.Text = "群 ID:";
this.xbtnOK.AutoArrangementX = true;
this.xbtnOK.AutoSizeToImage = false;
this.xbtnOK.BackColor = Color.Transparent;
this.xbtnOK.BackgroundImageDisable = null;
this.xbtnOK.BackgroundImageDown = null;
this.xbtnOK.BackgroundImageHover = null;
this.xbtnOK.ChangeSkin = true;
this.xbtnOK.DialogResult = DialogResult.OK;
this.xbtnOK.Location = new System.Drawing.Point(0xdd, 0x156);
this.xbtnOK.Name = "xbtnOK";
this.xbtnOK.Size = new Size(0x4b, 0x19);
this.xbtnOK.TabIndex = 0;
this.xbtnOK.Text = "确定";
this.xbtnOK.UseVisualStyleBackColor = false;
this.xbtnOK.Click += new EventHandler(this.xbtnOK_Click);
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(0x12e, 0x156);
this.xbtnCancel.Name = "xbtnCancel";
this.xbtnCancel.Size = new Size(0x4b, 0x19);
this.xbtnCancel.TabIndex = 1;
this.xbtnCancel.Text = "取消";
this.xbtnCancel.UseVisualStyleBackColor = false;
this.xbtnCancel.Click += new EventHandler(this.xbtnCancel_Click);
base.AutoScaleDimensions = new SizeF(6f, 13f);
base.AutoScaleMode = AutoScaleMode.Font;
base.BaseHeight = 0x191;
base.BaseWidth = 0x192;
base.CancelButton = this.xbtnCancel;
base.ClientSize = new Size(0x18c, 0x177);
base.Controls.Add(this.xbtnOK);
base.Controls.Add(this.xbtnCancel);
base.Controls.Add(this.pnlContent);
base.DisplayLocation = new System.Drawing.Point(0x12, 0x16);
base.Icon = (Icon) manager.GetObject("$this.Icon");
base.Name = "ApplyForJoinForm";
base.Padding = new Padding(6, 0x22, 0x13, 9);
base.Text = "申请加入";
base.Activated += new EventHandler(this.ApplyForJoinForm_Activated);
base.FormClosing += new FormClosingEventHandler(this.ApplyForJoinForm_FormClosing);
this.pnlContent.ResumeLayout(false);
this.pnlContent.PerformLayout();
this.pnlApplyNote.ResumeLayout(false);
this.pnlApplyNote.PerformLayout();
this.pnlGroupInfo.ResumeLayout(false);
this.pnlGroupInfo.PerformLayout();
this.pnlPortrait.ResumeLayout(false);
base.ResumeLayout(false);
}
protected override void OnClosed(EventArgs e)
{
try
{
this.CurrentUser.StatusChanged -= new EventHandler(this.CurrentUser_StatusChanged);
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
base.OnClosed(e);
}
private void UpdateGroupInfo(bool seeDetail)
{
this.xlblGroupName.Text = StringTable.CreatePersonalGroup.GroupNamePrompt;
this.lblGroupId.Text = this._personalgroup.GroupInfo.Id;
string str = this._personalgroup.GroupInfo.Name.Value;
this.lblGroupName.Text = str;
this.xlblCatagory.Text = this.getCategoryString(this._personalgroup.GroupInfo.Category.Value);
this.xlblMembersCount.Text = string.Format("{0}/{1}", this._personalgroup.GroupInfo.MembersCount.ToString(), this._personalgroup.GroupInfo.LimitMemberCount.ToString());
this.xtbIntroduce.Text = this._personalgroup.GroupInfo.Introduce.Value;
switch (this._personalgroup.GroupInfo.ValidateType.Value)
{
case PersonalGroupValidateType.AllAgree:
this.xlblAttention.Text = StringTable.SearchPersonalGroup.Attention_AllAgree;
break;
case PersonalGroupValidateType.AllRejct:
this.xlblAttention.Text = StringTable.SearchPersonalGroup.Attention_AllReject;
break;
case PersonalGroupValidateType.NeedValidate:
this.xlblAttention.Text = StringTable.SearchPersonalGroup.Attention_NeedApprove;
break;
default:
this.xlblAttention.Text = "";
break;
}
if (this.CurrentUser.PersonalGroups[this._personalgroup.Uri] != null)
{
this.xpbPortrait.Image = (Image) this.CurrentUser.PersonalGroups[this._personalgroup.Uri].GroupInfo.Portrait;
}
else
{
try
{
this.CurrentUser.PersonalGroupManager.AsyncDownLoadGroupPortrait(this._personalgroup);
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
if (seeDetail)
{
this.pnlApplyNote.Visible = false;
this.pnlContent.Height = 220;
this.xbtnOK.Visible = false;
this.xbtnCancel.Text = "关闭";
base.Text = string.Format("{0}", this._personalgroup.GroupInfo.Name.Value);
}
else
{
if ((((PersonalGroupValidateType) this._personalgroup.GroupInfo.ValidateType.Value) == PersonalGroupValidateType.AllAgree) || (((PersonalGroupValidateType) this._personalgroup.GroupInfo.ValidateType.Value) == PersonalGroupValidateType.AllRejct))
{
this.pnlApplyNote.Visible = false;
this.pnlContent.Height = 220;
}
base.Text = string.Format("申请加入群 - {0}", this._personalgroup.GroupInfo.Name.Value);
}
}
private void xbtnCancel_Click(object sender, EventArgs e)
{
base.Close();
}
private void xbtnOK_Click(object sender, EventArgs e)
{
try
{
if (!this._seeDetail && (((PersonalGroupValidateType) this._personalgroup.GroupInfo.ValidateType.Value) != PersonalGroupValidateType.AllRejct))
{
if (this.CurrentUser.PersonalGroups[this._personalgroup.Uri] != null)
{
return;
}
this.ApplyNote = this.xtbApplyNote.Text;
}
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
base.Close();
}
public string ApplyNote
{
get
{
return this._applyNote;
}
internal set
{
this._applyNote = value;
}
}
private Imps.Client.Core.User CurrentUser
{
get
{
return this._framework.AccountManager.CurrentUser;
}
}
}
}