📄 portraitform.cs
字号:
this.components.Dispose();
}
base.Dispose(disposing);
}
private void GetCustomPortraits()
{
string path = this._user.PersistentManager.BaseDirForMyUsedPortrait;
if (Directory.Exists(path))
{
FileInfo[] files = new DirectoryInfo(path).GetFiles("*.dat");
if (files.Length > 0)
{
foreach (FileInfo info2 in files)
{
Image image = ImpsResources.LoadImage(info2.FullName);
if (image != null)
{
Image icon = ImageHelper.TryGetSquareThumbnailImage(image, 0x60);
int num = info2.Name.LastIndexOf('.');
headicon headicon = new headicon(icon, info2.Name.Substring(0, (-1 == num) ? info2.Name.Length : num));
headicon.iconpath = info2.FullName.ToLower();
this.lbPortrait.add(headicon);
}
}
}
}
}
private void GetDefaultPortraits()
{
Imps.Client.Resource.Portrait[] defaultPortraits = ImpsPortrait.GetDefaultPortraits();
if (defaultPortraits != null)
{
for (int i = 0; i < defaultPortraits.Length; i++)
{
headicon headicon = new headicon(defaultPortraits[i].Image, defaultPortraits[i].Description);
headicon.iconpath = defaultPortraits[i].Description;
this.lbPortrait.add(headicon);
}
}
}
private void InitializeComponent()
{
ComponentResourceManager manager = new ComponentResourceManager(typeof(PortraitForm));
this.buttonAdd = new XButton();
this.buttonDel = new XButton();
this.buttonOK = new XButton();
this.buttonCancel = new XButton();
this.label1 = new XLabel();
this.m_pane = new Panel();
this.pbMyPortrait = new DisplayPortrait();
this.m_pane.SuspendLayout();
base.SuspendLayout();
this.buttonAdd.AutoArrangementX = true;
this.buttonAdd.AutoSizeToImage = false;
this.buttonAdd.BackColor = Color.Transparent;
this.buttonAdd.BackgroundImage = (Image) manager.GetObject("buttonAdd.BackgroundImage");
this.buttonAdd.BackgroundImageDisable = (Image) manager.GetObject("buttonAdd.BackgroundImageDisable");
this.buttonAdd.BackgroundImageDown = (Image) manager.GetObject("buttonAdd.BackgroundImageDown");
this.buttonAdd.BackgroundImageHover = (Image) manager.GetObject("buttonAdd.BackgroundImageHover");
this.buttonAdd.ChangeSkin = false;
this.buttonAdd.Location = new System.Drawing.Point(0xe8, 9);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new Size(0x4b, 0x15);
this.buttonAdd.TabIndex = 2;
this.buttonAdd.Text = "添加...";
this.buttonAdd.set_UseVisualStyleBackColor(false);
this.buttonAdd.Click += new EventHandler(this.buttonAdd_Click);
this.buttonDel.AutoArrangementX = true;
this.buttonDel.AutoSizeToImage = false;
this.buttonDel.BackColor = Color.Transparent;
this.buttonDel.BackgroundImage = (Image) manager.GetObject("buttonDel.BackgroundImage");
this.buttonDel.BackgroundImageDisable = (Image) manager.GetObject("buttonDel.BackgroundImageDisable");
this.buttonDel.BackgroundImageDown = (Image) manager.GetObject("buttonDel.BackgroundImageDown");
this.buttonDel.BackgroundImageHover = (Image) manager.GetObject("buttonDel.BackgroundImageHover");
this.buttonDel.ChangeSkin = false;
this.buttonDel.Enabled = false;
this.buttonDel.Location = new System.Drawing.Point(0xe8, 0x26);
this.buttonDel.Name = "buttonDel";
this.buttonDel.Size = new Size(0x4b, 0x15);
this.buttonDel.TabIndex = 3;
this.buttonDel.Text = "删除";
this.buttonDel.set_UseVisualStyleBackColor(false);
this.buttonDel.Click += new EventHandler(this.buttonDel_Click);
this.buttonOK.AutoArrangementX = true;
this.buttonOK.AutoSizeToImage = false;
this.buttonOK.BackColor = Color.Transparent;
this.buttonOK.BackgroundImageDisable = null;
this.buttonOK.BackgroundImageDown = null;
this.buttonOK.BackgroundImageHover = null;
this.buttonOK.CausesValidation = false;
this.buttonOK.ChangeSkin = true;
this.buttonOK.Enabled = false;
this.buttonOK.Location = new System.Drawing.Point(0x9e, 0x142);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new Size(0x4b, 0x17);
this.buttonOK.TabIndex = 4;
this.buttonOK.Text = "确定";
this.buttonOK.set_UseVisualStyleBackColor(false);
this.buttonOK.Click += new EventHandler(this.buttonOK_Click);
this.buttonCancel.AutoArrangementX = true;
this.buttonCancel.AutoSizeToImage = false;
this.buttonCancel.BackColor = Color.Transparent;
this.buttonCancel.BackgroundImageDisable = null;
this.buttonCancel.BackgroundImageDown = null;
this.buttonCancel.BackgroundImageHover = null;
this.buttonCancel.ChangeSkin = true;
this.buttonCancel.DialogResult = DialogResult.Cancel;
this.buttonCancel.Location = new System.Drawing.Point(0xef, 0x142);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new Size(0x4b, 0x17);
this.buttonCancel.TabIndex = 5;
this.buttonCancel.Text = "取消";
this.buttonCancel.set_UseVisualStyleBackColor(false);
this.buttonCancel.Click += new EventHandler(this.buttonCancel_Click);
this.label1.set_AutoSize(true);
this.label1.BorderColor = Color.Empty;
this.label1.ButtonBorderStyle = ButtonBorderStyle.None;
this.label1.Location = new System.Drawing.Point(0xd1, 0x55);
this.label1.Name = "label1";
this.label1.Size = new Size(0x1f, 13);
this.label1.TabIndex = 6;
this.label1.Text = "预览";
this.m_pane.BackColor = Color.Transparent;
this.m_pane.Controls.Add(this.pbMyPortrait);
this.m_pane.Controls.Add(this.buttonAdd);
this.m_pane.Controls.Add(this.label1);
this.m_pane.Controls.Add(this.buttonDel);
this.m_pane.Location = new System.Drawing.Point(0, 0);
this.m_pane.Name = "m_pane";
this.m_pane.Size = new Size(0x144, 320);
this.m_pane.TabIndex = 7;
this.pbMyPortrait.BackColor = Color.White;
this.pbMyPortrait.BorderColor = Color.FromArgb(0xa4, 170, 220);
this.pbMyPortrait.Image = (Image) manager.GetObject("pbMyPortrait.Image");
this.pbMyPortrait.Location = new System.Drawing.Point(0xd4, 0x68);
this.pbMyPortrait.Name = "pbMyPortrait";
this.pbMyPortrait.ShowSecondBorder = false;
this.pbMyPortrait.Size = new Size(0x66, 0x66);
this.pbMyPortrait.TabIndex = 7;
this.pbMyPortrait.TabStop = false;
this.pbMyPortrait.ToolTipText = "";
this.pbMyPortrait.UseHandCursor = false;
base.set_AutoScaleDimensions(new SizeF(6f, 13f));
base.set_AutoScaleMode(1);
base.BaseHeight = 410;
base.BaseWidth = 0x149;
base.CancelButton = this.buttonCancel;
base.ClientSize = new Size(0x143, 0x180);
base.Controls.Add(this.m_pane);
base.Controls.Add(this.buttonCancel);
base.Controls.Add(this.buttonOK);
base.DisplayLocation = new System.Drawing.Point(0x12, 0x26);
base.Icon = (Icon) manager.GetObject("$this.Icon");
base.MinimizeBox = false;
base.Name = "PortraitForm";
base.set_Padding(new Padding(1, 0x16, 13, 4));
base.ShowInTaskbar = false;
base.StartPosition = FormStartPosition.CenterParent;
base.Text = "我的头像";
base.add_Shown(new EventHandler(this.PortraitForm_Shown));
this.m_pane.ResumeLayout(false);
this.m_pane.PerformLayout();
base.ResumeLayout(false);
}
private void lbPortrait_SelectedIndexChanged(object sender, EventArgs e)
{
headicon headicon = this.lbPortrait.get_selected_item();
if (headicon == null)
{
this.pbMyPortrait.Image = null;
this.buttonDel.Enabled = false;
this.buttonOK.Enabled = false;
}
else
{
if (this.lbPortrait.get_selected_index() <= this.m_index_of_customicon)
{
this.buttonDel.Enabled = false;
}
else
{
this.buttonDel.Enabled = true;
}
this.pbMyPortrait.Image = headicon.icon;
this.label1.Visible = true;
this.buttonOK.Enabled = true;
}
}
protected override void OnClosing(CancelEventArgs e)
{
this.lbPortrait.drawer = null;
base.OnClosing(e);
}
protected override void OnCreateControl()
{
base.OnCreateControl();
}
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
try
{
base.Close();
return;
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
base.OnKeyDown(e);
}
private void PortraitForm_Shown(object sender, EventArgs e)
{
this.m_index_of_sysicon = this.lbPortrait.add_separator("系统默认头像");
this.GetDefaultPortraits();
this.lbPortrait.SelectedIndex = 0;
this.m_index_of_customicon = this.lbPortrait.Items.Count;
this.m_index_of_customicon = this.lbPortrait.add_separator("自定义头像");
this.GetCustomPortraits();
this.label1.Visible = true;
this.pbMyPortrait.Image = this._user.PersonalInfo.Portrait;
this.SetSelectedPortrait();
}
private void SetSelectedPortrait()
{
if (this._user.Configuration.UserSetting.SaveMyInfo)
{
string text = this._user.Configuration.UserSetting.ConversationSetting.CurrentPortraitFileInfo.Split(new char[] { ',' })[1];
int num = 0;
foreach (object obj2 in this.lbPortrait.Items)
{
if (obj2 is headicon)
{
headicon headicon = (headicon) obj2;
if (headicon.iconpath.CompareTo(text.ToLower()) == 0)
{
this.lbPortrait.SelectedIndex = num;
this.lbPortrait.Invalidate();
break;
}
}
num++;
}
}
this.buttonOK.Enabled = false;
}
private static void uploadPortrait_ImpsError(object sender, ImpsErrorEventArgs e)
{
try
{
AsyncBizOperation operation = (AsyncBizOperation) sender;
object[] contextForUi = (object[]) operation.ContextForUi;
IFrameworkWindow framework = (IFrameworkWindow) contextForUi[0];
Form owner = (Form) contextForUi[1];
UiErrorHelper.ShowImpsError(framework, owner, e);
}
catch (Exception exception)
{
ClientLogger.WriteException("上传头像", exception);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -