📄 groupportraitform.cs
字号:
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void GetCustomPortraits()
{
if (Directory.Exists(this._customImagesDir))
{
FileInfo[] files = new DirectoryInfo(this._customImagesDir).GetFiles("*.dat");
if (files.Length > 0)
{
foreach (FileInfo info2 in files)
{
if (info2.Length > 0)
{
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[] defaultGroupPortraits = ImpsPortrait.GetDefaultGroupPortraits();
if (defaultGroupPortraits != null)
{
for (int i = 0; i < defaultGroupPortraits.Length; i++)
{
headicon headicon = new headicon(defaultGroupPortraits[i].Image, defaultGroupPortraits[i].Description);
headicon.iconpath = defaultGroupPortraits[i].Description;
this.lbPortrait.add(headicon);
}
}
}
public FileInfo[] GetInitPortraits()
{
FileInfo[] files = null;
if (Directory.Exists(this._defaultImagesDir))
{
files = new DirectoryInfo(this._defaultImagesDir).GetFiles("*.jpg");
}
return files;
}
private void InitializeComponent()
{
ComponentResourceManager manager = new ComponentResourceManager(typeof(GroupPortraitForm));
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.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
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.DialogResult = DialogResult.OK;
this.buttonOK.Enabled = false;
this.buttonOK.Location = new System.Drawing.Point(0xa2, 0x17b);
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.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
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(0xf5, 0x17b);
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(6, 0x18);
this.m_pane.Name = "m_pane";
this.m_pane.Size = new Size(0x144, 0x15d);
this.m_pane.TabIndex = 7;
this.pbMyPortrait.BackColor = Color.White;
this.pbMyPortrait.BorderColor = Color.FromArgb(0xa4, 170, 220);
this.pbMyPortrait.Image = Resources.PGDefault;
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.ToolTipText = "";
this.pbMyPortrait.UseHandCursor = false;
base.set_AutoScaleDimensions(new SizeF(6f, 13f));
base.set_AutoScaleMode(1);
base.BaseHeight = 0x1b7;
base.BaseWidth = 0x15f;
base.ClientSize = new Size(0x159, 0x19d);
base.Controls.Add(this.m_pane);
base.Controls.Add(this.buttonOK);
base.Controls.Add(this.buttonCancel);
base.DisplayLocation = new System.Drawing.Point(0x12, 0x26);
base.Icon = (Icon) manager.GetObject("$this.Icon");
base.MinimizeBox = false;
base.Name = "GroupPortraitForm";
base.set_Padding(new Padding(6, 0x18, 0x13, 8));
base.ShowInTaskbar = false;
base.StartPosition = FormStartPosition.CenterParent;
base.Text = "群形象";
base.CancelButton = this.buttonCancel;
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.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()
{
this.lbPortrait.Location = new System.Drawing.Point(8, this.buttonAdd.Location.Y);
base.OnCreateControl();
}
private void PortraitForm_Shown(object sender, EventArgs e)
{
try
{
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.lbPortrait.Sorted = true;
if (this._personalGroup != null)
{
this.pbMyPortrait.Image = (Image) this._personalGroup.GroupInfo.Portrait;
}
else
{
this.pbMyPortrait.Image = ImpsPortrait.GetDefaultGroupPortrait(0x60, 0x60);
}
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
private 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);
}
}
public Image ResultImg
{
get
{
return this._resultImg;
}
set
{
this._resultImg = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -