📄 customemotionmanagerform.cs
字号:
namespace Imps.Client.Pc
{
using Imps.Client.Core;
using Imps.Client.Core.CustomEmotion;
using Imps.Client.Pc.BizControls;
using Imps.Client.Pc.Controls;
using Imps.Client.Pc.CustomEmotionUI;
using Imps.Client.Resource;
using Imps.Client.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using System.Xml;
public class CustomEmotionManagerForm : XIMDialog
{
private int _ceCount;
private int _curBegin;
private int _curEnd;
private IList<Imps.Client.Core.CustomEmotion.CustomEmotion> _curPageCustomEmotionList;
private CustomEmotionAddForm _customEmotionAddForm;
private Dictionary<string, Image> _dicImageByID;
private IFrameworkWindow _frameworkWin;
private ICustomEmotionManager _iceManager;
private XButton btnAdd;
private XButton btnDelete;
private XButton btnEdit;
private XButton btnExport;
private XButton btnImport;
private XButton btnOK;
private menu_widget cmsExport;
private DataGridViewTextBoxColumn columnImage;
private DataGridViewTextBoxColumn columnName;
private DataGridViewTextBoxColumn columnShotCut;
private IContainer components;
private const int COUNTPERPAGE = 30;
private DataGridView dgvCustomEmotionList;
private Label label1;
private Label label2;
private bool listBinded;
private LinkLabel llLastPage;
private LinkLabel llNextPage;
private Label lPages;
private Label lTitleMessage;
private Panel panel1;
private Panel panel2;
private PictureBox pbEmotion;
private SaveFileDialog sfdExport;
private ToolStripMenuItem tsmiExportAll;
private ToolStripMenuItem tsmiExportSelected;
private UPanel upGridView;
private UPanel upPicture;
public CustomEmotionManagerForm(IFrameworkWindow frameworkWin)
{
this.InitializeComponent();
this._frameworkWin = frameworkWin;
this._iceManager = frameworkWin.AccountManager.CurrentUser.CustomEmotionManager;
this.dgvCustomEmotionList.set_AutoGenerateColumns(false);
}
private void _customEmotionAddForm_AddCustomEmotion(object sender, CustomEmotionEventArgs e)
{
this.listBinded = false;
try
{
Imps.Client.Core.CustomEmotion.CustomEmotion customEmotion = e.CustomEmotion;
this._curPageCustomEmotionList.Insert(0, customEmotion);
this._ceCount++;
if (this._curEnd < 0x1d)
{
this._curEnd++;
}
if (this._curPageCustomEmotionList.get_Count() > 30)
{
for (int i = 0x1d; i < (this._curPageCustomEmotionList.get_Count() - 1); i++)
{
this._curPageCustomEmotionList.RemoveAt(i);
}
}
string id = customEmotion.Id;
if (!this._dicImageByID.ContainsKey(id))
{
this._dicImageByID.set_Item(id, this._iceManager.GetThumbnailEmotionImage(customEmotion));
}
this.dgvCustomEmotionList.get_Rows().RemoveAt(0x1d);
this.dgvCustomEmotionList.get_Rows().Insert(0, 1);
DataGridViewRow row = this.dgvCustomEmotionList.get_Rows().get_Item(0);
row.set_Tag(customEmotion);
DataGridViewImageCell cell = new DataGridViewImageCell();
cell.get_Style().set_NullValue(new Bitmap(1, 1));
cell.set_Value(this._dicImageByID.get_Item(id));
cell.get_Style().set_Alignment(0x20);
DataGridViewTextBoxCell cell2 = new DataGridViewTextBoxCell();
cell2.set_Value(customEmotion.ShortCut);
DataGridViewTextBoxCell cell3 = new DataGridViewTextBoxCell();
cell3.set_Value(customEmotion.Name);
row.get_Cells().set_Item(0, cell);
row.get_Cells().set_Item(1, cell2);
row.get_Cells().set_Item(2, cell3);
this.llNextPage.Enabled = (this._curEnd + 1) < this._ceCount;
this.llLastPage.Enabled = this._curBegin > 0;
int num2 = (this._curBegin / 30) + 1;
int num3 = ((this._ceCount % 30) > 0) ? ((this._ceCount / 30) + 1) : (this._ceCount / 30);
if (num3 == 0)
{
num3 = 1;
}
this.lPages.Text = num2.ToString() + "/" + num3.ToString();
foreach (DataGridViewRow row2 in this.dgvCustomEmotionList.get_SelectedRows())
{
row2.set_Selected(false);
}
this.btnDelete.Enabled = false;
this.btnEdit.Enabled = false;
this.btnExport.Enabled = this._ceCount > 0;
this.tsmiExportSelected.set_Enabled(false);
this.pbEmotion.Image = null;
this.dgvCustomEmotionList.set_FirstDisplayedScrollingRowIndex(0);
Form form = sender as CustomEmotionAddForm;
if (form != null)
{
form.Activate();
}
}
catch (Exception)
{
}
this.listBinded = true;
try
{
this.dgvCustomEmotionList.get_Rows().get_Item(0).set_Selected(true);
}
catch
{
}
}
private void _customEmotionAddForm_RefreshList(object sender, CustomEmotionEventArgs e)
{
Imps.Client.Core.CustomEmotion.CustomEmotion customEmotion = e.CustomEmotion;
if (this._curPageCustomEmotionList.Contains(customEmotion))
{
this.LoadCustomEmotion(this._curBegin);
this.BindList();
}
int index = this._curPageCustomEmotionList.IndexOf(customEmotion);
if (index >= 0)
{
this.dgvCustomEmotionList.get_Rows().get_Item(index).set_Selected(true);
this.dgvCustomEmotionList.set_CurrentCell(this.dgvCustomEmotionList.get_Rows().get_Item(index).get_Cells().get_Item(0));
this.dgvCustomEmotionList.set_FirstDisplayedScrollingRowIndex(index);
}
}
private void BindList()
{
this.listBinded = false;
try
{
this.btnExport.Enabled = this._ceCount > 0;
this.dgvCustomEmotionList.get_Rows().Clear();
this.dgvCustomEmotionList.set_RowCount(30);
for (int i = 0; i < this._curPageCustomEmotionList.get_Count(); i++)
{
Imps.Client.Core.CustomEmotion.CustomEmotion emotion = this._curPageCustomEmotionList.get_Item(i);
string id = emotion.Id;
if (!this._dicImageByID.ContainsKey(id))
{
this._dicImageByID.set_Item(id, this._iceManager.GetThumbnailEmotionImage(emotion));
}
DataGridViewRow row = this.dgvCustomEmotionList.get_Rows().get_Item(i);
row.set_Tag(emotion);
DataGridViewImageCell cell = new DataGridViewImageCell();
cell.get_Style().set_NullValue(new Bitmap(1, 1));
cell.set_Value(this._dicImageByID.get_Item(id));
cell.get_Style().set_Alignment(0x20);
DataGridViewTextBoxCell cell2 = new DataGridViewTextBoxCell();
cell2.set_Value(emotion.ShortCut);
DataGridViewTextBoxCell cell3 = new DataGridViewTextBoxCell();
cell3.set_Value(emotion.Name);
row.get_Cells().set_Item(0, cell);
row.get_Cells().set_Item(1, cell2);
row.get_Cells().set_Item(2, cell3);
}
this.llNextPage.Enabled = (this._curEnd + 1) < this._ceCount;
this.llLastPage.Enabled = this._curBegin > 0;
int num2 = (this._curBegin / 30) + 1;
int num3 = ((this._ceCount % 30) > 0) ? ((this._ceCount / 30) + 1) : (this._ceCount / 30);
if (num3 == 0)
{
num3 = 1;
}
this.lPages.Text = num2.ToString() + "/" + num3.ToString();
foreach (DataGridViewRow row2 in this.dgvCustomEmotionList.get_SelectedRows())
{
row2.set_Selected(false);
}
this.btnDelete.Enabled = false;
this.btnEdit.Enabled = false;
this.tsmiExportSelected.set_Enabled(false);
this.pbEmotion.Image = null;
}
catch (Exception exception)
{
ClientLogger.WriteException("自定义表情 -> 绑定列表", exception);
}
this.listBinded = true;
}
private void btnAdd_Click(object sender, EventArgs e)
{
if ((this._customEmotionAddForm != null) && !this._customEmotionAddForm.IsDisposed)
{
if (this._customEmotionAddForm.OperateType != CustomEmotionAddForm.OperateTypeEnum.Add)
{
this._customEmotionAddForm.Close();
this._customEmotionAddForm.Dispose();
this._customEmotionAddForm = new CustomEmotionAddForm(CustomEmotionAddForm.OperateTypeEnum.Add, this._frameworkWin);
this._customEmotionAddForm.AddCE += new EventHandler<CustomEmotionEventArgs>(this, (IntPtr) this._customEmotionAddForm_AddCustomEmotion);
this._customEmotionAddForm.RefreshList += new EventHandler<CustomEmotionEventArgs>(this, (IntPtr) this._customEmotionAddForm_RefreshList);
}
}
else
{
this._customEmotionAddForm = new CustomEmotionAddForm(CustomEmotionAddForm.OperateTypeEnum.Add, this._frameworkWin);
this._customEmotionAddForm.AddCE += new EventHandler<CustomEmotionEventArgs>(this, (IntPtr) this._customEmotionAddForm_AddCustomEmotion);
this._customEmotionAddForm.RefreshList += new EventHandler<CustomEmotionEventArgs>(this, (IntPtr) this._customEmotionAddForm_RefreshList);
}
ControlHelper.ShowFormCenterOnParent(this._customEmotionAddForm, this);
this._customEmotionAddForm.Focus();
}
private void btnDelete_Click(object sender, EventArgs e)
{
if ((this.dgvCustomEmotionList.get_SelectedRows().Count >= 1) && (this._frameworkWin.UnifiedMessageBox.ShowConfirmation(this, "您确定要删除该表情吗?") == DialogResult.Yes))
{
foreach (DataGridViewRow row in this.dgvCustomEmotionList.get_SelectedRows())
{
Imps.Client.Core.CustomEmotion.CustomEmotion emotion = row.get_Tag() as Imps.Client.Core.CustomEmotion.CustomEmotion;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -