www.pudn.com > Fetion.rar > BasicInfoControl.cs
namespace Imps.Client.Pc
{
using Imps.Client;
using Imps.Client.Core;
using Imps.Client.Pc.Controls;
using Imps.Client.Pc.Utils;
using Imps.Client.Resource;
using Imps.Client.Utils;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
public class BasicInfoControl : GroupOptionsControlBase
{
private IFrameworkWindow _framework;
public Image _newImage;
private IContainer components;
private GroupBox gbBasicInfo;
private GroupBox gbNickname;
private XButton xbtnGroupPortrait;
private XLabel xlblCreateDate;
private XLabel xlblGroupBulletin;
private XLabel xlblGroupID;
private XLabel xlblGroupName;
private XLabel xlblSuperManager;
private PictureBox xpbProtrait;
private XTextBox xtbGroupBulletin;
private XTextBox xtbGroupID;
private XTextBox xtbGroupName;
private XTextBox xtbGroupNickName;
private XTextBox xtbSuperManager;
public BasicInfoControl(IFrameworkWindow wnd)
{
this._framework = wnd;
this.InitializeComponent();
base.Disposed += new EventHandler(this.BasicInfoControl_Disposed);
}
private void _personalGroup_MemberLoadStatusChanged(object sender, GroupLoadStatusChangedEventArgs e)
{
if ((e.NewStatus == PersonalGroupLoadStatus.Loaded) && (base._personalGroup.SuperManger != null))
{
this.xtbSuperManager.Text = base._personalGroup.SuperManger.DisplayName;
}
}
private void BasicInfoControl_Disposed(object sender, EventArgs e)
{
try
{
base._personalGroup.MemberLoadStatusChanged -= new EventHandler(this._personalGroup_MemberLoadStatusChanged);
}
catch (Exception)
{
}
}
public override bool CheckUserInput()
{
string str = this.xtbGroupName.Text.Trim();
if (str.Length <= 0)
{
BalloonHelper.ShowInputErrorBallon(this.xtbGroupName, StringTable.CreatePersonalGroup.MsgGroupNameNotEmpty, StringTable.Options.TitleInvalidInput);
return false;
}
int num = 0x40;
if (str.Length > num)
{
BalloonHelper.ShowInputErrorBallon(this.xtbGroupName, string.Format(StringTable.CreatePersonalGroup.MsgGroupNameTooLong, num), StringTable.Options.TitleInvalidInput);
return false;
}
return true;
}
protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void handleUiEvent()
{
this.xtbGroupID.TextChanged += new EventHandler(this.uiData_GroupInfo_Changed);
this.xtbGroupBulletin.TextChanged += new EventHandler(this.uiData_GroupInfo_Changed);
this.xtbGroupName.TextChanged += new EventHandler(this.uiData_GroupInfo_Changed);
this.xtbGroupNickName.TextChanged += new EventHandler(this.uiData_UserInfo_Changed);
}
private void InitializeComponent()
{
ComponentResourceManager manager = new ComponentResourceManager(typeof(BasicInfoControl));
this.gbBasicInfo = new GroupBox();
this.xbtnGroupPortrait = new XButton();
this.xtbGroupBulletin = new XTextBox();
this.xlblGroupBulletin = new XLabel();
this.xlblCreateDate = new XLabel();
this.xtbGroupName = new XTextBox();
this.xtbSuperManager = new XTextBox();
this.xtbGroupID = new XTextBox();
this.xlblGroupName = new XLabel();
this.xlblSuperManager = new XLabel();
this.xlblGroupID = new XLabel();
this.xpbProtrait = new PictureBox();
this.gbNickname = new GroupBox();
this.xtbGroupNickName = new XTextBox();
this.gbBasicInfo.SuspendLayout();
((ISupportInitialize) this.xpbProtrait).BeginInit();
this.gbNickname.SuspendLayout();
base.SuspendLayout();
this.gbBasicInfo.Controls.Add(this.xbtnGroupPortrait);
this.gbBasicInfo.Controls.Add(this.xtbGroupBulletin);
this.gbBasicInfo.Controls.Add(this.xlblGroupBulletin);
this.gbBasicInfo.Controls.Add(this.xlblCreateDate);
this.gbBasicInfo.Controls.Add(this.xtbGroupName);
this.gbBasicInfo.Controls.Add(this.xtbSuperManager);
this.gbBasicInfo.Controls.Add(this.xtbGroupID);
this.gbBasicInfo.Controls.Add(this.xlblGroupName);
this.gbBasicInfo.Controls.Add(this.xlblSuperManager);
this.gbBasicInfo.Controls.Add(this.xlblGroupID);
this.gbBasicInfo.Controls.Add(this.xpbProtrait);
this.gbBasicInfo.Location = new System.Drawing.Point(3, 3);
this.gbBasicInfo.Name = "gbBasicInfo";
this.gbBasicInfo.Size = new Size(0x133, 230);
this.gbBasicInfo.TabIndex = 0;
this.gbBasicInfo.TabStop = false;
this.gbBasicInfo.Text = "基本资料";
this.xbtnGroupPortrait.AutoArrangementX = true;
this.xbtnGroupPortrait.AutoSizeToImage = false;
this.xbtnGroupPortrait.BackColor = Color.Transparent;
this.xbtnGroupPortrait.BackgroundImage = (Image) manager.GetObject("xbtnGroupPortrait.BackgroundImage");
this.xbtnGroupPortrait.BackgroundImageDisable = (Image) manager.GetObject("xbtnGroupPortrait.BackgroundImageDisable");
this.xbtnGroupPortrait.BackgroundImageDown = (Image) manager.GetObject("xbtnGroupPortrait.BackgroundImageDown");
this.xbtnGroupPortrait.BackgroundImageHover = (Image) manager.GetObject("xbtnGroupPortrait.BackgroundImageHover");
this.xbtnGroupPortrait.ChangeSkin = false;
this.xbtnGroupPortrait.Location = new System.Drawing.Point(0xcc, 0x59);
this.xbtnGroupPortrait.Name = "xbtnGroupPortrait";
this.xbtnGroupPortrait.Size = new Size(0x61, 0x15);
this.xbtnGroupPortrait.TabIndex = 15;
this.xbtnGroupPortrait.Text = "设置群形象...";
this.xbtnGroupPortrait.UseVisualStyleBackColor = false;
this.xbtnGroupPortrait.Click += new EventHandler(this.xbtnGroupPortrait_Click);
this.xtbGroupBulletin.BackColor = Color.White;
this.xtbGroupBulletin.BorderStyle = BorderStyle.FixedSingle;
this.xtbGroupBulletin.EmptyTextTip = "";
this.xtbGroupBulletin.EmptyTextTipColor = Color.DarkGray;
this.xtbGroupBulletin.Location = new System.Drawing.Point(0x15, 0x97);
this.xtbGroupBulletin.MaxLength = 0x40;
this.xtbGroupBulletin.Multiline = true;
this.xtbGroupBulletin.Name = "xtbGroupBulletin";
this.xtbGroupBulletin.ScrollBars = ScrollBars.Vertical;
this.xtbGroupBulletin.Size = new Size(0x109, 70);
this.xtbGroupBulletin.TabIndex = 0x13;
this.xlblGroupBulletin.AutoSize = true;
this.xlblGroupBulletin.BorderColor = Color.Empty;
this.xlblGroupBulletin.ButtonBorderStyle = ButtonBorderStyle.None;
this.xlblGroupBulletin.Location = new System.Drawing.Point(0x1a, 0x84);
this.xlblGroupBulletin.Name = "xlblGroupBulletin";
this.xlblGroupBulletin.Size = new Size(0xf7, 13);
this.xlblGroupBulletin.TabIndex = 0x12;
this.xlblGroupBulletin.Text = "群公告:(仅群内成员可见,限制64字以内)";
this.xlblCreateDate.AutoSize = true;
this.xlblCreateDate.BorderColor = Color.Empty;
this.xlblCreateDate.ButtonBorderStyle = ButtonBorderStyle.None;
this.xlblCreateDate.ForeColor = Color.ForestGreen;
this.xlblCreateDate.Location = new System.Drawing.Point(9, 0x6f);
this.xlblCreateDate.Name = "xlblCreateDate";
this.xlblCreateDate.Size = new Size(0x73, 13);
this.xlblCreateDate.TabIndex = 0x11;
this.xlblCreateDate.Text = "创建于,生命期为天";
this.xtbGroupName.BackColor = Color.White;
this.xtbGroupName.BorderStyle = BorderStyle.FixedSingle;
this.xtbGroupName.EmptyTextTip = "";
this.xtbGroupName.EmptyTextTipColor = Color.DarkGray;
this.xtbGroupName.Location = new System.Drawing.Point(0x57, 0x51);
this.xtbGroupName.MaxLength = 0x40;
this.xtbGroupName.Name = "xtbGroupName";
this.xtbGroupName.Size = new Size(100, 20);
this.xtbGroupName.TabIndex = 5;
this.xtbSuperManager.BackColor = Color.White;
this.xtbSuperManager.BorderStyle = BorderStyle.FixedSingle;
this.xtbSuperManager.EmptyTextTip = "";
this.xtbSuperManager.EmptyTextTipColor = Color.DarkGray;
this.xtbSuperManager.Location = new System.Drawing.Point(0x57, 0x31);
this.xtbSuperManager.Name = "xtbSuperManager";
this.xtbSuperManager.Size = new Size(100, 20);
this.xtbSuperManager.TabIndex = 4;
this.xtbGroupID.BackColor = Color.White;
this.xtbGroupID.BorderStyle = BorderStyle.FixedSingle;
this.xtbGroupID.EmptyTextTip = "";
this.xtbGroupID.EmptyTextTipColor = Color.DarkGray;
this.xtbGroupID.Location = new System.Drawing.Point(0x57, 0x13);
this.xtbGroupID.Name = "xtbGroupID";
this.xtbGroupID.Size = new Size(100, 20);
this.xtbGroupID.TabIndex = 3;
this.xlblGroupName.AutoSize = true;
this.xlblGroupName.BorderColor = Color.Empty;
this.xlblGroupName.ButtonBorderStyle = ButtonBorderStyle.None;
this.xlblGroupName.Location = new System.Drawing.Point(0x1a, 0x53);
this.xlblGroupName.Name = "xlblGroupName";
this.xlblGroupName.Size = new Size(0x37, 13);
this.xlblGroupName.TabIndex = 2;
this.xlblGroupName.Text = "群名称:";
this.xlblSuperManager.AutoSize = true;
this.xlblSuperManager.BorderColor = Color.Empty;
this.xlblSuperManager.ButtonBorderStyle = ButtonBorderStyle.None;
this.xlblSuperManager.Location = new System.Drawing.Point(2, 0x31);
this.xlblSuperManager.Name = "xlblSuperManager";
this.xlblSuperManager.Size = new Size(0x4f, 13);
this.xlblSuperManager.TabIndex = 1;
this.xlblSuperManager.Text = "超级管理员:";
this.xlblGroupID.AutoSize = true;
this.xlblGroupID.BorderColor = Color.Empty;
this.xlblGroupID.ButtonBorderStyle = ButtonBorderStyle.None;
this.xlblGroupID.Location = new System.Drawing.Point(0x1a, 0x15);
this.xlblGroupID.Name = "xlblGroupID";
this.xlblGroupID.Size = new Size(0x37, 13);
this.xlblGroupID.TabIndex = 0;
this.xlblGroupID.Text = "群号码:";
this.xpbProtrait.Anchor = AnchorStyles.None;
this.xpbProtrait.BackColor = Color.Silver;
this.xpbProtrait.Image = (Image) manager.GetObject("xpbProtrait.Image");
this.xpbProtrait.Location = new System.Drawing.Point(0xde, 0x15);
this.xpbProtrait.Name = "xpbProtrait";
this.xpbProtrait.Padding = new Padding(1);
this.xpbProtrait.Size = new Size(0x40, 0x40);
this.xpbProtrait.SizeMode = PictureBoxSizeMode.StretchImage;
this.xpbProtrait.TabIndex = 0x10;
this.xpbProtrait.TabStop = false;
this.xpbProtrait.Click += new EventHandler(this.xpbProtrait_Click);
this.gbNickname.Controls.Add(this.xtbGroupNickName);
this.gbNickname.Location = new System.Drawing.Point(3, 0xec);
this.gbNickname.Name = "gbNickname";
this.gbNickname.Size = new Size(0x133, 50);
this.gbNickname.TabIndex = 1;
this.gbNickname.TabStop = false;
this.gbNickname.Text = "群内昵称设置";
this.xtbGroupNickName.BackColor = Color.White;
this.xtbGroupNickName.BorderStyle = BorderStyle.FixedSingle;
this.xtbGroupNickName.EmptyTextTip = "";
this.xtbGroupNickName.EmptyTextTipColor = Color.DarkGray;
this.xtbGroupNickName.Location = new System.Drawing.Point(0x15, 0x16);
this.xtbGroupNickName.MaxLength = 0x40;
this.xtbGroupNickName.Name = "xtbGroupNickName";
this.xtbGroupNickName.Size = new Size(0xfc, 20);
this.xtbGroupNickName.TabIndex = 0;
base.AutoScaleDimensions = new SizeF(6f, 13f);
base.AutoScaleMode = AutoScaleMode.Font;
this.BackColor = Color.Transparent;
base.Controls.Add(this.gbNickname);
base.Controls.Add(this.gbBasicInfo);
base.Name = "BasicInfoControl";
base.Size = new Size(0x13a, 290);
this.gbBasicInfo.ResumeLayout(false);
this.gbBasicInfo.PerformLayout();
((ISupportInitialize) this.xpbProtrait).EndInit();
this.gbNickname.ResumeLayout(false);
this.gbNickname.PerformLayout();
base.ResumeLayout(false);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
}
private void setContolsEditable()
{
this.xtbGroupID.ReadOnly = true;
this.xtbGroupBulletin.ReadOnly = !base._personalGroup.UserInfo.EnableModifyGroupInfo;
this.xtbGroupName.ReadOnly = !base._personalGroup.UserInfo.EnableModifyGroupInfo;
this.xtbSuperManager.ReadOnly = true;
this.xtbGroupNickName.ReadOnly = !base._personalGroup.UserInfo.EnableModifyMyInfo;
this.xpbProtrait.Enabled = base._personalGroup.UserInfo.EnableModifyGroupInfo;
this.xbtnGroupPortrait.Enabled = base._personalGroup.UserInfo.EnableModifyGroupInfo;
}
private bool show_portraitform()
{
using (GroupPortraitForm form = new GroupPortraitForm(this._framework, ImpsPathInfo.StartupPath + @"\GroupPortraits\", this.CurrentUser.PersistentManager.BaseDirForGroupPortrait, base._personalGroup))
{
if (form.ShowDialog(this) == DialogResult.OK)
{
this.xpbProtrait.Image = form.ResultImg;
return true;
}
return false;
}
}
private void uiData_GroupInfo_Changed(object sender, EventArgs e)
{
UiErrorHelper.HandEventSafely(this._framework, delegate {
base.GroupInfoModified = true;
});
}
private void uiData_Portrait_Changed()
{
UiErrorHelper.HandEventSafely(this._framework, delegate {
base.PortraitModified = true;
});
}
private void uiData_Updated()
{
UiErrorHelper.HandEventSafely(this._framework, delegate {
base.GroupInfoModified = false;
base.UserInfoModified = false;
});
}
private void uiData_UserInfo_Changed(object sender, EventArgs e)
{
UiErrorHelper.HandEventSafely(this._framework, delegate {
base.UserInfoModified = true;
});
}
public override bool UpdateData(bool update)
{
if (update)
{
if (!this.CheckUserInput())
{
return false;
}
try
{
base._personalGroup.GroupInfo.Bulletin.ProposedValue = this.xtbGroupBulletin.Text;
base._personalGroup.GroupInfo.Name.ProposedValue = this.xtbGroupName.Text.Trim();
base._personalGroup.UserInfo.GroupNickName.ProposedValue = this.xtbGroupNickName.Text.Trim();
this.uiData_Updated();
}
catch (Exception exception)
{
this._framework.UnifiedMessageBox.ShowError(this, exception.ToString());
}
}
else
{
try
{
this.handleUiEvent();
this.setContolsEditable();
this.xtbGroupID.Text = base._personalGroup.GroupInfo.Id;
if (((this.CurrentUser.Status == UserAccountStatus.Logon) && (base._personalGroup.MemberLoadStatus == PersonalGroupLoadStatus.None)) && ((((UserIdentity) base._personalGroup.UserInfo.GroupUserIdentity.Value) != UserIdentity.WaitingApprove) && (((UserIdentity) base._personalGroup.UserInfo.GroupUserIdentity.Value) != UserIdentity.Rejct)))
{
AsyncBizOperation op = new AsyncBizOperation();
this.CurrentUser.PersonalGroupManager.GetGroupMemberList(base._personalGroup, op);
base._personalGroup.MemberLoadStatusChanged += new EventHandler(this._personalGroup_MemberLoadStatusChanged);
}
if (base._personalGroup.SuperManger != null)
{
this.xtbSuperManager.Text = base._personalGroup.SuperManger.DisplayName;
}
this.xtbGroupBulletin.Text = base._personalGroup.GroupInfo.Bulletin.Value;
this.xtbGroupName.Text = base._personalGroup.GroupInfo.Name.Value;
this.xtbGroupNickName.Text = base._personalGroup.UserInfo.GroupNickName.Value;
this.xlblCreateDate.Text = "";
if (base._personalGroup.GroupInfo.CreateDate.HasValue)
{
DateTime time = base._personalGroup.GroupInfo.CreateDate.Value;
TimeSpan span = (TimeSpan) (DateTime.Now.Date - time.Date);
int totalDays = (int) span.TotalDays;
this.xlblCreateDate.Text = string.Format("创建于{0}年{1}月{2}日,已存在{3}天", new object[] { time.Date.Year.ToString(), time.Date.Month.ToString(), time.Date.Day.ToString(), totalDays.ToString() });
}
this.xpbProtrait.Image = (Image) base._personalGroup.GroupInfo.Portrait;
}
catch (Exception exception2)
{
ClientLogger.WriteException(exception2);
return false;
}
finally
{
base.GroupInfoModified = false;
base.UserInfoModified = false;
}
}
return true;
}
private void xbtnGroupPortrait_Click(object sender, EventArgs e)
{
if (this.show_portraitform())
{
this.uiData_Portrait_Changed();
this._newImage = this.xpbProtrait.Image;
}
}
private void xpbProtrait_Click(object sender, EventArgs e)
{
if (this.show_portraitform())
{
this.uiData_Portrait_Changed();
this._newImage = this.xpbProtrait.Image;
}
}
private Imps.Client.Core.User CurrentUser
{
get
{
return this._framework.AccountManager.CurrentUser;
}
}
}
}