www.pudn.com > Fetion.rar > 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 _curPageCustomEmotionList;
private CustomEmotionAddForm _customEmotionAddForm;
private Dictionary _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.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.Count > 30)
{
for (int i = 0x1d; i < (this._curPageCustomEmotionList.Count - 1); i++)
{
this._curPageCustomEmotionList.RemoveAt(i);
}
}
string id = customEmotion.Id;
if (!this._dicImageByID.ContainsKey(id))
{
this._dicImageByID[id] = this._iceManager.GetThumbnailEmotionImage(customEmotion);
}
this.dgvCustomEmotionList.Rows.RemoveAt(0x1d);
this.dgvCustomEmotionList.Rows.Insert(0, 1);
DataGridViewRow row = this.dgvCustomEmotionList.Rows[0];
row.Tag = customEmotion;
DataGridViewImageCell cell = new DataGridViewImageCell();
cell.Style.NullValue = new Bitmap(1, 1);
cell.Value = this._dicImageByID[id];
cell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
DataGridViewTextBoxCell cell2 = new DataGridViewTextBoxCell();
cell2.Value = customEmotion.ShortCut;
DataGridViewTextBoxCell cell3 = new DataGridViewTextBoxCell();
cell3.Value = customEmotion.Name;
row.Cells[0] = cell;
row.Cells[1] = cell2;
row.Cells[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.SelectedRows)
{
row2.Selected = false;
}
this.btnDelete.Enabled = false;
this.btnEdit.Enabled = false;
this.btnExport.Enabled = this._ceCount > 0;
this.tsmiExportSelected.Enabled = false;
this.pbEmotion.Image = null;
this.dgvCustomEmotionList.FirstDisplayedScrollingRowIndex = 0;
Form form = sender as CustomEmotionAddForm;
if (form != null)
{
form.Activate();
}
}
catch (Exception)
{
}
this.listBinded = true;
try
{
this.dgvCustomEmotionList.Rows[0].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.Rows[index].Selected = true;
this.dgvCustomEmotionList.CurrentCell = this.dgvCustomEmotionList.Rows[index].Cells[0];
this.dgvCustomEmotionList.FirstDisplayedScrollingRowIndex = index;
}
}
private void BindList()
{
this.listBinded = false;
try
{
this.btnExport.Enabled = this._ceCount > 0;
this.dgvCustomEmotionList.Rows.Clear();
this.dgvCustomEmotionList.RowCount = 30;
for (int i = 0; i < this._curPageCustomEmotionList.Count; i++)
{
Imps.Client.Core.CustomEmotion.CustomEmotion emotion = this._curPageCustomEmotionList[i];
string id = emotion.Id;
if (!this._dicImageByID.ContainsKey(id))
{
this._dicImageByID[id] = this._iceManager.GetThumbnailEmotionImage(emotion);
}
DataGridViewRow row = this.dgvCustomEmotionList.Rows[i];
row.Tag = emotion;
DataGridViewImageCell cell = new DataGridViewImageCell();
cell.Style.NullValue = new Bitmap(1, 1);
cell.Value = this._dicImageByID[id];
cell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
DataGridViewTextBoxCell cell2 = new DataGridViewTextBoxCell();
cell2.Value = emotion.ShortCut;
DataGridViewTextBoxCell cell3 = new DataGridViewTextBoxCell();
cell3.Value = emotion.Name;
row.Cells[0] = cell;
row.Cells[1] = cell2;
row.Cells[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.SelectedRows)
{
row2.Selected = false;
}
this.btnDelete.Enabled = false;
this.btnEdit.Enabled = false;
this.tsmiExportSelected.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(this._customEmotionAddForm_AddCustomEmotion);
this._customEmotionAddForm.RefreshList += new EventHandler(this._customEmotionAddForm_RefreshList);
}
}
else
{
this._customEmotionAddForm = new CustomEmotionAddForm(CustomEmotionAddForm.OperateTypeEnum.Add, this._frameworkWin);
this._customEmotionAddForm.AddCE += new EventHandler(this._customEmotionAddForm_AddCustomEmotion);
this._customEmotionAddForm.RefreshList += new EventHandler(this._customEmotionAddForm_RefreshList);
}
ControlHelper.ShowFormCenterOnParent(this._customEmotionAddForm, this);
this._customEmotionAddForm.Focus();
}
private void btnDelete_Click(object sender, EventArgs e)
{
if ((this.dgvCustomEmotionList.SelectedRows.Count >= 1) && (this._frameworkWin.UnifiedMessageBox.ShowConfirmation(this, "您确定要删除该表情吗?") == DialogResult.Yes))
{
foreach (DataGridViewRow row in this.dgvCustomEmotionList.SelectedRows)
{
Imps.Client.Core.CustomEmotion.CustomEmotion tag = row.Tag as Imps.Client.Core.CustomEmotion.CustomEmotion;
if (tag != null)
{
try
{
this._iceManager.DeleteOwnerEmotion(tag);
continue;
}
catch (Exception exception)
{
ClientLogger.WriteException("自定义表情 -> 删除", exception);
continue;
}
}
}
this.LoadCustomEmotion(this._curBegin);
this.BindList();
}
}
private void btnEdit_Click(object sender, EventArgs e)
{
if (this.dgvCustomEmotionList.SelectedRows.Count >= 1)
{
if ((this._customEmotionAddForm != null) && !this._customEmotionAddForm.IsDisposed)
{
if (this._customEmotionAddForm.OperateType != CustomEmotionAddForm.OperateTypeEnum.Edit)
{
this._customEmotionAddForm.Close();
this._customEmotionAddForm.Dispose();
this._customEmotionAddForm = new CustomEmotionAddForm(CustomEmotionAddForm.OperateTypeEnum.Edit, this._frameworkWin);
this._customEmotionAddForm.AddCE += new EventHandler(this._customEmotionAddForm_AddCustomEmotion);
this._customEmotionAddForm.RefreshList += new EventHandler(this._customEmotionAddForm_RefreshList);
}
}
else
{
this._customEmotionAddForm = new CustomEmotionAddForm(CustomEmotionAddForm.OperateTypeEnum.Edit, this._frameworkWin);
this._customEmotionAddForm.AddCE += new EventHandler(this._customEmotionAddForm_AddCustomEmotion);
this._customEmotionAddForm.RefreshList += new EventHandler(this._customEmotionAddForm_RefreshList);
}
int num = this.dgvCustomEmotionList.SelectedRows.Count - 1;
this._customEmotionAddForm.EditCustomEmotion = this.dgvCustomEmotionList.SelectedRows[num].Tag as Imps.Client.Core.CustomEmotion.CustomEmotion;
ControlHelper.ShowFormCenterOnParent(this._customEmotionAddForm, this);
this._customEmotionAddForm.Focus();
}
}
private void btnExport_Click(object sender, EventArgs e)
{
this.cmsExport.Show(this.btnExport, 0, this.btnExport.Height);
}
private void btnImport_Click(object sender, EventArgs e)
{
if ((this._customEmotionAddForm != null) && !this._customEmotionAddForm.IsDisposed)
{
if (this._customEmotionAddForm.OperateType != CustomEmotionAddForm.OperateTypeEnum.Import)
{
this._customEmotionAddForm.Close();
this._customEmotionAddForm.Dispose();
this._customEmotionAddForm = new CustomEmotionAddForm(CustomEmotionAddForm.OperateTypeEnum.Import, this._frameworkWin);
this._customEmotionAddForm.AddCE += new EventHandler(this._customEmotionAddForm_AddCustomEmotion);
this._customEmotionAddForm.RefreshList += new EventHandler(this._customEmotionAddForm_RefreshList);
}
}
else
{
this._customEmotionAddForm = new CustomEmotionAddForm(CustomEmotionAddForm.OperateTypeEnum.Import, this._frameworkWin);
this._customEmotionAddForm.AddCE += new EventHandler(this._customEmotionAddForm_AddCustomEmotion);
this._customEmotionAddForm.RefreshList += new EventHandler(this._customEmotionAddForm_RefreshList);
}
ControlHelper.ShowFormCenterOnParent(this._customEmotionAddForm, this);
this._customEmotionAddForm.Focus();
}
private void btnOK_Click(object sender, EventArgs e)
{
base.Close();
}
private void CustomEmotionManagerForm_FormClosed(object sender, FormClosedEventArgs e)
{
if ((this._customEmotionAddForm != null) && !this._customEmotionAddForm.IsDisposed)
{
this._customEmotionAddForm.Close();
this._customEmotionAddForm.Dispose();
}
}
private void CustomEmotionManagerForm_Load(object sender, EventArgs e)
{
this._dicImageByID = new Dictionary();
this.LoadCustomEmotion(this._curBegin);
this.BindList();
scroll_widget _widget = scroll_maker.instance.vscroll();
_widget.host = this.dgvCustomEmotionList;
this.dgvCustomEmotionList.Parent.Controls.Add(_widget);
this.btnAdd.Focus();
}
private void dgvCustomEmotionList_CellEnter(object sender, DataGridViewCellEventArgs e)
{
if (this.dgvCustomEmotionList.Rows[e.RowIndex].Tag == null)
{
if (this.llLastPage.Enabled)
{
this.llLastPage.Focus();
}
else
{
this.btnAdd.Focus();
}
}
}
private void dgvCustomEmotionList_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
ClientLogger.WriteException("自定义表情 -> 列表绑定", e.Exception);
e.Cancel = true;
}
private void dgvCustomEmotionList_Enter(object sender, EventArgs e)
{
this.dgvCustomEmotionList.CurrentCell = this.dgvCustomEmotionList[0, 0];
}
private void dgvCustomEmotionList_Scroll(object sender, ScrollEventArgs e)
{
if ((e.NewValue > (this._curPageCustomEmotionList.Count - 1)) && (this._curPageCustomEmotionList.Count > 0))
{
this.dgvCustomEmotionList.FirstDisplayedScrollingRowIndex = this._curPageCustomEmotionList.Count - 1;
}
}
private void dgvCustomEmotionList_SelectionChanged(object sender, EventArgs e)
{
try
{
if (this.listBinded)
{
foreach (DataGridViewRow row in this.dgvCustomEmotionList.SelectedRows)
{
if (row.Tag == null)
{
row.Selected = false;
}
}
bool flag = this.dgvCustomEmotionList.SelectedRows.Count > 0;
this.btnDelete.Enabled = flag;
this.btnEdit.Enabled = this.dgvCustomEmotionList.SelectedRows.Count == 1;
this.tsmiExportSelected.Enabled = flag;
if (flag)
{
Imps.Client.Core.CustomEmotion.CustomEmotion tag;
if (this.dgvCustomEmotionList.CurrentRow.Selected)
{
tag = this.dgvCustomEmotionList.CurrentRow.Tag as Imps.Client.Core.CustomEmotion.CustomEmotion;
}
else
{
tag = this.dgvCustomEmotionList.SelectedRows[0].Tag as Imps.Client.Core.CustomEmotion.CustomEmotion;
}
Image emotionImageById = this._iceManager.GetEmotionImageById(tag.Id);
if (emotionImageById != null)
{
if ((emotionImageById.Width > this.pbEmotion.Width) || (emotionImageById.Height > this.pbEmotion.Height))
{
this.pbEmotion.SizeMode = PictureBoxSizeMode.Zoom;
}
else
{
this.pbEmotion.SizeMode = PictureBoxSizeMode.CenterImage;
}
}
this.pbEmotion.Image = CustomEmotionUtils.ClearImage(emotionImageById);
}
else
{
this.pbEmotion.Image = null;
}
}
}
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 GetCustomEmotionStorePath(string id)
{
return this._frameworkWin.AccountManager.CurrentUser.CustomEmotionManager.GetOwnerEmotionImagePath(id);
}
private string GetSaveFilePath()
{
string fileName = string.Empty;
if (this.sfdExport.ShowDialog(this) == DialogResult.OK)
{
fileName = this.sfdExport.FileName;
}
return fileName;
}
private void InitializeComponent()
{
this.components = new Container();
DataGridViewCellStyle style = new DataGridViewCellStyle();
DataGridViewCellStyle style2 = new DataGridViewCellStyle();
DataGridViewCellStyle style3 = new DataGridViewCellStyle();
DataGridViewCellStyle style4 = new DataGridViewCellStyle();
DataGridViewCellStyle style5 = new DataGridViewCellStyle();
ComponentResourceManager manager = new ComponentResourceManager(typeof(CustomEmotionManagerForm));
this.dgvCustomEmotionList = new DataGridView();
this.columnImage = new DataGridViewTextBoxColumn();
this.columnShotCut = new DataGridViewTextBoxColumn();
this.columnName = new DataGridViewTextBoxColumn();
this.lTitleMessage = new Label();
this.lPages = new Label();
this.btnAdd = new XButton();
this.btnDelete = new XButton();
this.btnEdit = new XButton();
this.btnImport = new XButton();
this.btnExport = new XButton();
this.cmsExport = new menu_widget(this.components);
this.tsmiExportSelected = new ToolStripMenuItem();
this.tsmiExportAll = new ToolStripMenuItem();
this.pbEmotion = new PictureBox();
this.btnOK = new XButton();
this.sfdExport = new SaveFileDialog();
this.llLastPage = new LinkLabel();
this.llNextPage = new LinkLabel();
this.panel1 = new Panel();
this.panel2 = new Panel();
this.label1 = new Label();
this.upGridView = new UPanel();
this.upPicture = new UPanel();
this.label2 = new Label();
((ISupportInitialize) this.dgvCustomEmotionList).BeginInit();
this.cmsExport.SuspendLayout();
((ISupportInitialize) this.pbEmotion).BeginInit();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.upGridView.SuspendLayout();
this.upPicture.SuspendLayout();
base.SuspendLayout();
this.dgvCustomEmotionList.AllowUserToAddRows = false;
this.dgvCustomEmotionList.AllowUserToDeleteRows = false;
this.dgvCustomEmotionList.AllowUserToResizeColumns = false;
this.dgvCustomEmotionList.AllowUserToResizeRows = false;
style.BackColor = Color.White;
style.ForeColor = Color.Black;
style.SelectionBackColor = Color.FromArgb(0xa8, 0xe9, 0xfe);
style.SelectionForeColor = Color.Black;
this.dgvCustomEmotionList.AlternatingRowsDefaultCellStyle = style;
this.dgvCustomEmotionList.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
this.dgvCustomEmotionList.BackgroundColor = Color.White;
this.dgvCustomEmotionList.BorderStyle = BorderStyle.None;
this.dgvCustomEmotionList.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
style2.Alignment = DataGridViewContentAlignment.MiddleCenter;
style2.BackColor = Color.White;
style2.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Regular, GraphicsUnit.Point, 0);
style2.ForeColor = SystemColors.WindowText;
style2.SelectionBackColor = SystemColors.Highlight;
style2.SelectionForeColor = SystemColors.HighlightText;
style2.WrapMode = DataGridViewTriState.True;
this.dgvCustomEmotionList.ColumnHeadersDefaultCellStyle = style2;
this.dgvCustomEmotionList.ColumnHeadersHeight = 0x16;
this.dgvCustomEmotionList.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
this.dgvCustomEmotionList.Columns.AddRange(new DataGridViewColumn[] { this.columnImage, this.columnShotCut, this.columnName });
style3.Alignment = DataGridViewContentAlignment.MiddleLeft;
style3.BackColor = Color.FromArgb(0xf4, 0xf7, 0xf9);
style3.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Regular, GraphicsUnit.Point, 0);
style3.ForeColor = Color.Black;
style3.SelectionBackColor = Color.FromArgb(0xa8, 0xe9, 0xfe);
style3.SelectionForeColor = Color.Black;
style3.WrapMode = DataGridViewTriState.False;
this.dgvCustomEmotionList.DefaultCellStyle = style3;
this.dgvCustomEmotionList.Dock = DockStyle.Fill;
this.dgvCustomEmotionList.EnableHeadersVisualStyles = false;
this.dgvCustomEmotionList.GridColor = Color.FromArgb(0xdb, 0xe8, 240);
this.dgvCustomEmotionList.Location = new System.Drawing.Point(1, 1);
this.dgvCustomEmotionList.Name = "dgvCustomEmotionList";
this.dgvCustomEmotionList.ReadOnly = true;
this.dgvCustomEmotionList.RowHeadersVisible = false;
this.dgvCustomEmotionList.RowTemplate.Height = 0x17;
this.dgvCustomEmotionList.RowTemplate.ReadOnly = true;
this.dgvCustomEmotionList.ScrollBars = ScrollBars.Vertical;
this.dgvCustomEmotionList.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
this.dgvCustomEmotionList.Size = new Size(0xe3, 0x141);
this.dgvCustomEmotionList.TabIndex = 0;
this.dgvCustomEmotionList.Enter += new EventHandler(this.dgvCustomEmotionList_Enter);
this.dgvCustomEmotionList.Scroll += new ScrollEventHandler(this.dgvCustomEmotionList_Scroll);
this.dgvCustomEmotionList.DataError += new DataGridViewDataErrorEventHandler(this.dgvCustomEmotionList_DataError);
this.dgvCustomEmotionList.CellEnter += new DataGridViewCellEventHandler(this.dgvCustomEmotionList_CellEnter);
this.dgvCustomEmotionList.SelectionChanged += new EventHandler(this.dgvCustomEmotionList_SelectionChanged);
this.columnImage.HeaderText = "表情图片";
this.columnImage.Name = "columnImage";
this.columnImage.ReadOnly = true;
this.columnImage.Resizable = DataGridViewTriState.False;
this.columnImage.SortMode = DataGridViewColumnSortMode.NotSortable;
this.columnShotCut.DataPropertyName = "ShortCut";
style4.Alignment = DataGridViewContentAlignment.MiddleCenter;
this.columnShotCut.DefaultCellStyle = style4;
this.columnShotCut.HeaderText = "快捷方式";
this.columnShotCut.Name = "columnShotCut";
this.columnShotCut.ReadOnly = true;
this.columnShotCut.SortMode = DataGridViewColumnSortMode.NotSortable;
this.columnName.DataPropertyName = "Name";
style5.Alignment = DataGridViewContentAlignment.MiddleCenter;
this.columnName.DefaultCellStyle = style5;
this.columnName.HeaderText = "表情名称";
this.columnName.Name = "columnName";
this.columnName.ReadOnly = true;
this.columnName.SortMode = DataGridViewColumnSortMode.NotSortable;
this.lTitleMessage.AutoSize = true;
this.lTitleMessage.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Regular, GraphicsUnit.Point, 0);
this.lTitleMessage.Location = new System.Drawing.Point(9, 8);
this.lTitleMessage.Name = "lTitleMessage";
this.lTitleMessage.Size = new Size(270, 0x11);
this.lTitleMessage.TabIndex = 1;
this.lTitleMessage.Text = "点击“添加表情”按钮,添加你喜欢的图片。";
this.lPages.AutoSize = true;
this.lPages.ForeColor = Color.Blue;
this.lPages.Location = new System.Drawing.Point(11, 0x164);
this.lPages.Name = "lPages";
this.lPages.Size = new Size(0x1d, 13);
this.lPages.TabIndex = 4;
this.lPages.Text = "N/M";
this.btnAdd.AutoArrangementX = true;
this.btnAdd.AutoSizeToImage = false;
this.btnAdd.BackColor = Color.Transparent;
this.btnAdd.BackgroundImage = (Image) manager.GetObject("btnAdd.BackgroundImage");
this.btnAdd.BackgroundImageDisable = (Image) manager.GetObject("btnAdd.BackgroundImageDisable");
this.btnAdd.BackgroundImageDown = (Image) manager.GetObject("btnAdd.BackgroundImageDown");
this.btnAdd.BackgroundImageHover = (Image) manager.GetObject("btnAdd.BackgroundImageHover");
this.btnAdd.ChangeSkin = false;
this.btnAdd.Location = new System.Drawing.Point(0xf2, 30);
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new Size(0x59, 0x15);
this.btnAdd.TabIndex = 3;
this.btnAdd.Text = "添加表情...";
this.btnAdd.UseVisualStyleBackColor = false;
this.btnAdd.Click += new EventHandler(this.btnAdd_Click);
this.btnDelete.AutoArrangementX = true;
this.btnDelete.AutoSizeToImage = false;
this.btnDelete.BackColor = Color.Transparent;
this.btnDelete.BackgroundImage = (Image) manager.GetObject("btnDelete.BackgroundImage");
this.btnDelete.BackgroundImageDisable = (Image) manager.GetObject("btnDelete.BackgroundImageDisable");
this.btnDelete.BackgroundImageDown = (Image) manager.GetObject("btnDelete.BackgroundImageDown");
this.btnDelete.BackgroundImageHover = (Image) manager.GetObject("btnDelete.BackgroundImageHover");
this.btnDelete.ChangeSkin = false;
this.btnDelete.Enabled = false;
this.btnDelete.Location = new System.Drawing.Point(0xf2, 60);
this.btnDelete.Name = "btnDelete";
this.btnDelete.Size = new Size(0x59, 0x15);
this.btnDelete.TabIndex = 4;
this.btnDelete.Text = "删除表情...";
this.btnDelete.UseVisualStyleBackColor = false;
this.btnDelete.Click += new EventHandler(this.btnDelete_Click);
this.btnEdit.AutoArrangementX = true;
this.btnEdit.AutoSizeToImage = false;
this.btnEdit.BackColor = Color.Transparent;
this.btnEdit.BackgroundImage = (Image) manager.GetObject("btnEdit.BackgroundImage");
this.btnEdit.BackgroundImageDisable = (Image) manager.GetObject("btnEdit.BackgroundImageDisable");
this.btnEdit.BackgroundImageDown = (Image) manager.GetObject("btnEdit.BackgroundImageDown");
this.btnEdit.BackgroundImageHover = (Image) manager.GetObject("btnEdit.BackgroundImageHover");
this.btnEdit.ChangeSkin = false;
this.btnEdit.Enabled = false;
this.btnEdit.Location = new System.Drawing.Point(0xf2, 90);
this.btnEdit.Name = "btnEdit";
this.btnEdit.Size = new Size(0x59, 0x15);
this.btnEdit.TabIndex = 5;
this.btnEdit.Text = "编辑...";
this.btnEdit.UseVisualStyleBackColor = false;
this.btnEdit.Click += new EventHandler(this.btnEdit_Click);
this.btnImport.AutoArrangementX = true;
this.btnImport.AutoSizeToImage = false;
this.btnImport.BackColor = Color.Transparent;
this.btnImport.BackgroundImage = (Image) manager.GetObject("btnImport.BackgroundImage");
this.btnImport.BackgroundImageDisable = (Image) manager.GetObject("btnImport.BackgroundImageDisable");
this.btnImport.BackgroundImageDown = (Image) manager.GetObject("btnImport.BackgroundImageDown");
this.btnImport.BackgroundImageHover = (Image) manager.GetObject("btnImport.BackgroundImageHover");
this.btnImport.ChangeSkin = false;
this.btnImport.Location = new System.Drawing.Point(0xf2, 120);
this.btnImport.Name = "btnImport";
this.btnImport.Size = new Size(0x59, 0x15);
this.btnImport.TabIndex = 6;
this.btnImport.Text = "导入表情...";
this.btnImport.UseVisualStyleBackColor = false;
this.btnImport.Click += new EventHandler(this.btnImport_Click);
this.btnExport.AutoArrangementX = true;
this.btnExport.AutoSizeToImage = false;
this.btnExport.BackColor = Color.Transparent;
this.btnExport.BackgroundImage = (Image) manager.GetObject("btnExport.BackgroundImage");
this.btnExport.BackgroundImageDisable = (Image) manager.GetObject("btnExport.BackgroundImageDisable");
this.btnExport.BackgroundImageDown = (Image) manager.GetObject("btnExport.BackgroundImageDown");
this.btnExport.BackgroundImageHover = (Image) manager.GetObject("btnExport.BackgroundImageHover");
this.btnExport.BackgroundImageLayout = ImageLayout.None;
this.btnExport.ChangeSkin = false;
this.btnExport.ContextMenuStrip = this.cmsExport;
this.btnExport.Image = (Image) manager.GetObject("btnExport.Image");
this.btnExport.ImageAlign = ContentAlignment.MiddleRight;
this.btnExport.Location = new System.Drawing.Point(0xf2, 150);
this.btnExport.Name = "btnExport";
this.btnExport.Size = new Size(0x59, 0x15);
this.btnExport.TabIndex = 7;
this.btnExport.Text = "导出表情...";
this.btnExport.UseVisualStyleBackColor = false;
this.btnExport.Click += new EventHandler(this.btnExport_Click);
this.cmsExport.Items.AddRange(new ToolStripItem[] { this.tsmiExportSelected, this.tsmiExportAll });
this.cmsExport.Name = "cmsExport";
this.cmsExport.Size = new Size(0x93, 0x30);
this.cmsExport.UseMnemonic = true;
this.tsmiExportSelected.Enabled = false;
this.tsmiExportSelected.Name = "tsmiExportSelected";
this.tsmiExportSelected.Size = new Size(0x92, 0x16);
this.tsmiExportSelected.Text = "导出选择表情";
this.tsmiExportSelected.Click += new EventHandler(this.tsmiExportSelected_Click);
this.tsmiExportAll.Name = "tsmiExportAll";
this.tsmiExportAll.Size = new Size(0x92, 0x16);
this.tsmiExportAll.Text = "导出全部表情";
this.tsmiExportAll.Click += new EventHandler(this.tsmiExportAll_Click);
this.pbEmotion.Dock = DockStyle.Fill;
this.pbEmotion.Location = new System.Drawing.Point(3, 8);
this.pbEmotion.Name = "pbEmotion";
this.pbEmotion.Size = new Size(0x53, 0x53);
this.pbEmotion.SizeMode = PictureBoxSizeMode.Zoom;
this.pbEmotion.TabIndex = 12;
this.pbEmotion.TabStop = false;
this.btnOK.AutoArrangementX = true;
this.btnOK.AutoSizeToImage = true;
this.btnOK.BackColor = Color.Transparent;
this.btnOK.BackgroundImageDisable = null;
this.btnOK.BackgroundImageDown = null;
this.btnOK.BackgroundImageHover = null;
this.btnOK.ChangeSkin = true;
this.btnOK.DialogResult = DialogResult.Cancel;
this.btnOK.Location = new System.Drawing.Point(0x101, 0x180);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new Size(0x4d, 0x1b);
this.btnOK.TabIndex = 1;
this.btnOK.Text = "确定";
this.btnOK.UseVisualStyleBackColor = false;
this.btnOK.Click += new EventHandler(this.btnOK_Click);
this.sfdExport.DefaultExt = "ffl";
this.sfdExport.Filter = "飞信表情文件*.ffl|*.ffl";
this.llLastPage.AutoSize = true;
this.llLastPage.LinkColor = Color.Green;
this.llLastPage.Location = new System.Drawing.Point(0x79, 0x164);
this.llLastPage.Name = "llLastPage";
this.llLastPage.Size = new Size(0x37, 13);
this.llLastPage.TabIndex = 1;
this.llLastPage.TabStop = true;
this.llLastPage.Text = "<上一页";
this.llLastPage.LinkClicked += new LinkLabelLinkClickedEventHandler(this.llLastPage_LinkClicked);
this.llNextPage.AutoSize = true;
this.llNextPage.LinkColor = Color.Green;
this.llNextPage.Location = new System.Drawing.Point(0xb7, 0x164);
this.llNextPage.Name = "llNextPage";
this.llNextPage.Size = new Size(0x3a, 13);
this.llNextPage.TabIndex = 2;
this.llNextPage.TabStop = true;
this.llNextPage.Text = "下一页 >";
this.llNextPage.LinkClicked += new LinkLabelLinkClickedEventHandler(this.llNextPage_LinkClicked);
this.panel1.Controls.Add(this.panel2);
this.panel1.Controls.Add(this.upGridView);
this.panel1.Controls.Add(this.upPicture);
this.panel1.Controls.Add(this.lTitleMessage);
this.panel1.Controls.Add(this.btnAdd);
this.panel1.Controls.Add(this.llNextPage);
this.panel1.Controls.Add(this.llLastPage);
this.panel1.Controls.Add(this.btnDelete);
this.panel1.Controls.Add(this.lPages);
this.panel1.Controls.Add(this.btnEdit);
this.panel1.Controls.Add(this.btnImport);
this.panel1.Controls.Add(this.btnExport);
this.panel1.Location = new System.Drawing.Point(1, 2);
this.panel1.Name = "panel1";
this.panel1.Size = new Size(0x152, 0x178);
this.panel1.TabIndex = 0;
this.panel2.Controls.Add(this.label1);
this.panel2.Location = new System.Drawing.Point(0x103, 0xfb);
this.panel2.Name = "panel2";
this.panel2.Size = new Size(0x37, 0x10);
this.panel2.TabIndex = 15;
this.label1.AutoSize = true;
this.label1.Dock = DockStyle.Fill;
this.label1.Location = new System.Drawing.Point(0, 0);
this.label1.Name = "label1";
this.label1.Size = new Size(0x37, 13);
this.label1.TabIndex = 0x10;
this.label1.Text = "表情预览";
this.upGridView.BorderColor = Color.FromArgb(0xcb, 0xd4, 0xde);
this.upGridView.BorderInsideColor = Color.White;
this.upGridView.BorderInsideWidth = 1;
this.upGridView.BorderWidth = 1;
this.upGridView.Controls.Add(this.dgvCustomEmotionList);
this.upGridView.Location = new System.Drawing.Point(8, 30);
this.upGridView.Name = "upGridView";
this.upGridView.Padding = new Padding(1);
this.upGridView.Size = new Size(0xe5, 0x143);
this.upGridView.TabIndex = 0;
this.upPicture.BorderColor = Color.FromArgb(0xcb, 0xd4, 0xde);
this.upPicture.BorderInsideColor = Color.White;
this.upPicture.BorderInsideWidth = 1;
this.upPicture.BorderWidth = 1;
this.upPicture.Controls.Add(this.pbEmotion);
this.upPicture.Controls.Add(this.label2);
this.upPicture.Location = new System.Drawing.Point(0xf2, 0x103);
this.upPicture.Name = "upPicture";
this.upPicture.Padding = new Padding(3);
this.upPicture.Size = new Size(0x59, 0x5e);
this.upPicture.TabIndex = 13;
this.label2.Dock = DockStyle.Top;
this.label2.Location = new System.Drawing.Point(3, 3);
this.label2.Name = "label2";
this.label2.Size = new Size(0x53, 5);
this.label2.TabIndex = 13;
base.AutoScaleDimensions = new SizeF(6f, 13f);
base.AutoScaleMode = AutoScaleMode.Font;
this.BackColor = Color.White;
base.BaseHeight = 0x272;
base.BaseWidth = 0x170;
base.CancelButton = this.btnOK;
base.ClientSize = new Size(0x170, 0x272);
base.Controls.Add(this.panel1);
base.Controls.Add(this.btnOK);
base.DisplayLocation = new System.Drawing.Point(15, 15);
base.DisplaySize = new Size(0x170, 0x272);
base.FormBorderStyle = FormBorderStyle.FixedSingle;
base.MinimizeBox = false;
base.Name = "CustomEmotionManagerForm";
base.Padding = new Padding(8);
base.StartPosition = FormStartPosition.CenterParent;
base.Text = "Fetion 2008";
base.FormClosed += new FormClosedEventHandler(this.CustomEmotionManagerForm_FormClosed);
base.Load += new EventHandler(this.CustomEmotionManagerForm_Load);
((ISupportInitialize) this.dgvCustomEmotionList).EndInit();
this.cmsExport.ResumeLayout(false);
((ISupportInitialize) this.pbEmotion).EndInit();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
this.upGridView.ResumeLayout(false);
this.upPicture.ResumeLayout(false);
base.ResumeLayout(false);
}
private void llLastPage_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
this.LoadCustomEmotion(this._curBegin - 30);
this.BindList();
}
private void llNextPage_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
this.LoadCustomEmotion(this._curBegin + 30);
this.BindList();
}
private void LoadCustomEmotion(int begin)
{
try
{
this._ceCount = this._iceManager.OwnerEmotions.Count;
if (this._ceCount > 0)
{
goto Label_0035;
}
this._curPageCustomEmotionList = new List();
return;
Label_002F:
begin -= 30;
Label_0035:
if (begin >= this._ceCount)
{
goto Label_002F;
}
if (begin < 0)
{
begin = 0;
}
this._curBegin = begin;
if ((this._curBegin + 30) >= this._ceCount)
{
this._curEnd = this._ceCount - 1;
}
else
{
this._curEnd = (this._curBegin + 30) - 1;
}
this._curPageCustomEmotionList = this._iceManager.OwnerEmotions.GetEmotions(this._curBegin, this._curEnd);
}
catch (Exception exception)
{
ClientLogger.WriteException("自定义表情 -> 加载列表", exception);
this._ceCount = 0;
this._curBegin = 0;
this._curEnd = 0;
this._curPageCustomEmotionList = new List();
}
}
private void SetControlText()
{
this.lTitleMessage.Text = StringTable.CustomEmotions.CustomEmotionManager.TitleMessage;
this.btnAdd.Text = StringTable.CustomEmotions.CustomEmotionManager.Add;
this.btnDelete.Text = StringTable.CustomEmotions.CustomEmotionManager.Delete;
this.btnEdit.Text = StringTable.CustomEmotions.CustomEmotionManager.Edit;
this.btnImport.Text = StringTable.CustomEmotions.CustomEmotionManager.Import;
this.btnExport.Text = StringTable.CustomEmotions.CustomEmotionManager.Export;
this.tsmiExportSelected.Text = StringTable.CustomEmotions.CustomEmotionManager.ExportSelected;
this.tsmiExportAll.Text = StringTable.CustomEmotions.CustomEmotionManager.ExportAll;
this.llLastPage.Text = StringTable.CustomEmotions.CustomEmotionManager.LastPage;
this.llNextPage.Text = StringTable.CustomEmotions.CustomEmotionManager.NextPage;
this.btnOK.Text = StringTable.CustomEmotions.CustomEmotionManager.OK;
this.columnImage.HeaderText = StringTable.CustomEmotions.CustomEmotionManager.ImageHeaderText;
this.columnName.HeaderText = StringTable.CustomEmotions.CustomEmotionManager.NameHeaderText;
this.columnShotCut.HeaderText = StringTable.CustomEmotions.CustomEmotionManager.ShotCutHeaderText;
}
private void tsmiExportAll_Click(object sender, EventArgs e)
{
if (this._ceCount >= 1)
{
string saveFilePath = this.GetSaveFilePath();
if (saveFilePath != string.Empty)
{
XmlDocument listDoc = new XmlDocument();
XmlNode newChild = listDoc.CreateElement("CustomEmotions");
IList fileNames = new List();
foreach (Imps.Client.Core.CustomEmotion.CustomEmotion emotion in this._iceManager.OwnerEmotions.LstEmoitons)
{
string customEmotionStorePath = this.GetCustomEmotionStorePath(emotion.Id);
XmlNode node2 = listDoc.CreateElement("ce");
XmlAttribute node = listDoc.CreateAttribute("Name");
node.Value = emotion.Name;
XmlAttribute attribute2 = listDoc.CreateAttribute("ShortCut");
attribute2.Value = emotion.ShortCut;
XmlAttribute attribute3 = listDoc.CreateAttribute("FileName");
attribute3.Value = Path.GetFileName(customEmotionStorePath);
node2.Attributes.Append(node);
node2.Attributes.Append(attribute2);
node2.Attributes.Append(attribute3);
fileNames.Add(customEmotionStorePath);
newChild.AppendChild(node2);
}
listDoc.AppendChild(newChild);
try
{
GZipCompressXml.Compress(fileNames, saveFilePath, listDoc);
this._frameworkWin.UnifiedMessageBox.ShowInfo(this, "表情导出成功!");
}
catch (Exception exception)
{
ClientLogger.WriteException("自定义表情 -> 导出所有", exception);
this._frameworkWin.UnifiedMessageBox.ShowInfo(this, "表情导出失败。");
}
}
}
}
private void tsmiExportSelected_Click(object sender, EventArgs e)
{
if (this.dgvCustomEmotionList.SelectedRows.Count >= 1)
{
string saveFilePath = this.GetSaveFilePath();
if (saveFilePath != string.Empty)
{
XmlDocument listDoc = new XmlDocument();
XmlNode newChild = listDoc.CreateElement("CustomEmotions");
IList fileNames = new List();
foreach (DataGridViewRow row in this.dgvCustomEmotionList.SelectedRows)
{
Imps.Client.Core.CustomEmotion.CustomEmotion tag = row.Tag as Imps.Client.Core.CustomEmotion.CustomEmotion;
string customEmotionStorePath = this.GetCustomEmotionStorePath(tag.Id);
XmlNode node2 = listDoc.CreateElement("ce");
XmlAttribute node = listDoc.CreateAttribute("Name");
node.Value = tag.Name;
XmlAttribute attribute2 = listDoc.CreateAttribute("ShortCut");
attribute2.Value = tag.ShortCut;
XmlAttribute attribute3 = listDoc.CreateAttribute("FileName");
attribute3.Value = Path.GetFileName(customEmotionStorePath);
node2.Attributes.Append(node);
node2.Attributes.Append(attribute2);
node2.Attributes.Append(attribute3);
fileNames.Add(customEmotionStorePath);
newChild.AppendChild(node2);
}
listDoc.AppendChild(newChild);
try
{
GZipCompressXml.Compress(fileNames, saveFilePath, listDoc);
this._frameworkWin.UnifiedMessageBox.ShowInfo(this, "表情导出成功!");
}
catch (Exception exception)
{
ClientLogger.WriteException("自定义表情 -> 导出选择", exception);
this._frameworkWin.UnifiedMessageBox.ShowInfo(this, "表情导出失败。");
}
}
}
}
}
}