📄 customemotionaddfromentityform.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.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
public class CustomEmotionAddFromEntityForm : XIMDialog
{
private string _filePath;
private IFrameworkWindow _frameworkWin;
private ICustomEmotionManager _iceManager;
private Image _image;
private XButton btnCancel;
private XButton btnOk;
private IContainer components;
private Label lItem2;
private Label lItem3;
private Label lTitle;
private Panel panel1;
private PictureBox pbEmotion;
private Panel pSingleAdd;
private XTextBox tbName;
private XTextBox tbShotCut;
private UPanel upPicture;
public CustomEmotionAddFromEntityForm(IFrameworkWindow frameworkWin, string shortCut, string name, string filePath)
{
this._frameworkWin = frameworkWin;
this._iceManager = this._frameworkWin.AccountManager.CurrentUser.CustomEmotionManager;
this.InitializeComponent();
this.InitializeForm(shortCut, name, filePath);
}
private void btnCancel_Click(object sender, EventArgs e)
{
base.Close();
}
private void btnOk_Click(object sender, EventArgs e)
{
string key = this.tbShotCut.Text.Trim();
string name = this.tbName.Text.Trim();
CustomEmotionStatus unKonwError = CustomEmotionStatus.UnKonwError;
try
{
if (ImpsEmoticons.Instance.ContainsKey(key))
{
this._frameworkWin.UnifiedMessageBox.ShowInfo(this, "自定义表情添加失败:与系统表情快捷键重复");
this.tbShotCut.Focus();
return;
}
Imps.Client.Core.CustomEmotion.CustomEmotion emotionByShortCut = this._iceManager.OwnerEmotions.GetEmotionByShortCut(key);
if (emotionByShortCut != null)
{
if (this._frameworkWin.UnifiedMessageBox.ShowConfirmation(this, "与其他表情的输入快捷键重复\r\n点击“是”将删除原表情\r\n“否”将重新设置快捷键。") != DialogResult.Yes)
{
this.tbShotCut.Focus();
return;
}
this._iceManager.DeleteOwnerEmotion(emotionByShortCut);
emotionByShortCut = this._iceManager.AddOwnerEmotion(key, name, this._filePath, out unKonwError);
}
else
{
emotionByShortCut = this._iceManager.AddOwnerEmotion(key, name, this._filePath, out unKonwError);
}
}
catch (Exception exception)
{
ClientLogger.WriteException("自定义表情 -> 从会话窗口添加", exception);
}
if (unKonwError == CustomEmotionStatus.OK)
{
base.Close();
}
else
{
this._frameworkWin.UnifiedMessageBox.ShowError(this, "自定义表情添加失败:" + CustomEmotionUtils.GetCustomEmotionStatusDesc(unKonwError, this._frameworkWin.AccountManager.CurrentUser) + "。");
this.tbShotCut.Focus();
}
}
private void CustomEmotionAddFromEntityForm_FormClosed(object sender, FormClosedEventArgs e)
{
if (this._image != null)
{
this._image.Dispose();
this._image = null;
}
}
private void CustomEmotionAddFromEntityForm_Load(object sender, EventArgs e)
{
this.tbShotCut.Focus();
}
protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.panel1 = new Panel();
this.upPicture = new UPanel();
this.pbEmotion = new PictureBox();
this.lTitle = new Label();
this.pSingleAdd = new Panel();
this.tbName = new XTextBox();
this.tbShotCut = new XTextBox();
this.lItem2 = new Label();
this.lItem3 = new Label();
this.btnOk = new XButton();
this.btnCancel = new XButton();
this.panel1.SuspendLayout();
this.upPicture.SuspendLayout();
this.pbEmotion.BeginInit();
this.pSingleAdd.SuspendLayout();
base.SuspendLayout();
this.panel1.BackColor = Color.White;
this.panel1.Controls.Add(this.upPicture);
this.panel1.Controls.Add(this.lTitle);
this.panel1.Controls.Add(this.pSingleAdd);
this.panel1.Location = new System.Drawing.Point(1, 3);
this.panel1.Name = "panel1";
this.panel1.Size = new Size(0x146, 0xf3);
this.panel1.TabIndex = 1;
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.Location = new System.Drawing.Point(0x18, 15);
this.upPicture.Name = "upPicture";
this.upPicture.set_Padding(new Padding(2));
this.upPicture.Size = new Size(0x59, 0x59);
this.upPicture.TabIndex = 14;
this.pbEmotion.Dock = DockStyle.Fill;
this.pbEmotion.Location = new System.Drawing.Point(2, 2);
this.pbEmotion.Name = "pbEmotion";
this.pbEmotion.Size = new Size(0x55, 0x55);
this.pbEmotion.SizeMode = (PictureBoxSizeMode) 4;
this.pbEmotion.TabIndex = 12;
this.pbEmotion.TabStop = false;
this.lTitle.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Regular, GraphicsUnit.Point, 0);
this.lTitle.Location = new System.Drawing.Point(0x77, 15);
this.lTitle.Name = "lTitle";
this.lTitle.Size = new Size(0xc1, 0x57);
this.lTitle.TabIndex = 0;
this.lTitle.Text = "若要添加此图片为自定义表情,请先设置快捷键,然后点击确定。";
this.pSingleAdd.Controls.Add(this.tbName);
this.pSingleAdd.Controls.Add(this.tbShotCut);
this.pSingleAdd.Controls.Add(this.lItem2);
this.pSingleAdd.Controls.Add(this.lItem3);
this.pSingleAdd.Location = new System.Drawing.Point(0x11, 0x73);
this.pSingleAdd.Name = "pSingleAdd";
this.pSingleAdd.Size = new Size(0x11f, 0x70);
this.pSingleAdd.TabIndex = 1;
this.tbName.Location = new System.Drawing.Point(3, 0x51);
this.tbName.MaxLength = 8;
this.tbName.Name = "tbName";
this.tbName.Size = new Size(0xef, 20);
this.tbName.TabIndex = 1;
this.tbName.KeyDown += new KeyEventHandler(this.tbName_KeyDown);
this.tbShotCut.Location = new System.Drawing.Point(3, 0x20);
this.tbShotCut.MaxLength = 8;
this.tbShotCut.Name = "tbShotCut";
this.tbShotCut.Size = new Size(0xef, 20);
this.tbShotCut.TabIndex = 0;
this.tbShotCut.TextChanged += new EventHandler(this.tbShotCut_TextChanged);
this.tbShotCut.KeyDown += new KeyEventHandler(this.tbShotCut_KeyDown);
this.lItem2.set_AutoSize(true);
this.lItem2.Location = new System.Drawing.Point(3, 11);
this.lItem2.Name = "lItem2";
this.lItem2.Size = new Size(0x114, 13);
this.lItem2.TabIndex = 6;
this.lItem2.Text = "1、设置表情键盘输入快捷键,8个字符以内,如:prz";
this.lItem3.set_AutoSize(true);
this.lItem3.Location = new System.Drawing.Point(3, 60);
this.lItem3.Name = "lItem3";
this.lItem3.Size = new Size(0x91, 13);
this.lItem3.TabIndex = 8;
this.lItem3.Text = "2、设置表情名称(可选)";
this.btnOk.AutoArrangementX = true;
this.btnOk.AutoSizeToImage = false;
this.btnOk.BackColor = Color.Transparent;
this.btnOk.BackgroundImageDisable = null;
this.btnOk.BackgroundImageDown = null;
this.btnOk.BackgroundImageHover = null;
this.btnOk.ChangeSkin = true;
this.btnOk.Location = new System.Drawing.Point(0x61, 0xff);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new Size(0x4b, 0x17);
this.btnOk.TabIndex = 3;
this.btnOk.Text = "确定";
this.btnOk.set_UseVisualStyleBackColor(false);
this.btnOk.Click += new EventHandler(this.btnOk_Click);
this.btnCancel.AutoArrangementX = true;
this.btnCancel.AutoSizeToImage = false;
this.btnCancel.BackColor = Color.Transparent;
this.btnCancel.BackgroundImageDisable = null;
this.btnCancel.BackgroundImageDown = null;
this.btnCancel.BackgroundImageHover = null;
this.btnCancel.ChangeSkin = true;
this.btnCancel.DialogResult = DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(0xb0, 0xff);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new Size(0x4b, 0x17);
this.btnCancel.TabIndex = 4;
this.btnCancel.Text = "取消";
this.btnCancel.set_UseVisualStyleBackColor(false);
this.btnCancel.Click += new EventHandler(this.btnCancel_Click);
base.set_AutoScaleDimensions(new SizeF(6f, 13f));
base.set_AutoScaleMode(1);
base.BaseHeight = 400;
base.BaseWidth = 0x160;
base.CancelButton = this.btnCancel;
base.ClientSize = new Size(0x160, 400);
base.Controls.Add(this.panel1);
base.Controls.Add(this.btnOk);
base.Controls.Add(this.btnCancel);
base.DisplayLocation = new System.Drawing.Point(15, 15);
base.DisplaySize = new Size(0x160, 400);
base.MinimizeBox = false;
base.Name = "CustomEmotionAddFromEntityForm";
base.set_Padding(new Padding(4, 0, 4, 0x2b));
base.Text = "Fetion 2008";
base.add_FormClosed(new FormClosedEventHandler(this, (IntPtr) this.CustomEmotionAddFromEntityForm_FormClosed));
base.Load += new EventHandler(this.CustomEmotionAddFromEntityForm_Load);
this.panel1.ResumeLayout(false);
this.upPicture.ResumeLayout(false);
this.pbEmotion.EndInit();
this.pSingleAdd.ResumeLayout(false);
this.pSingleAdd.PerformLayout();
base.ResumeLayout(false);
}
private void InitializeForm(string shortCut, string name, string filePath)
{
try
{
this.tbName.Text = name;
this.tbShotCut.Text = shortCut;
this._filePath = filePath;
this._image = Image.FromFile(this._filePath);
if ((this._image.Width > this.pbEmotion.Width) || (this._image.Height > this.pbEmotion.Height))
{
this.pbEmotion.SizeMode = (PictureBoxSizeMode) 4;
}
else
{
this.pbEmotion.SizeMode = PictureBoxSizeMode.CenterImage;
}
this.pbEmotion.Image = CustomEmotionUtils.ClearImage(this._image);
}
catch
{
}
}
private void tbName_KeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyCode == Keys.Return) || (e.KeyCode == Keys.Tab))
{
this.btnOk.Focus();
}
}
private void tbShotCut_KeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyCode == Keys.Return) || (e.KeyCode == Keys.Tab))
{
this.tbName.Focus();
}
}
private void tbShotCut_TextChanged(object sender, EventArgs e)
{
string text = this.tbShotCut.Text.Replace(" ", "");
this.tbShotCut.Text = text;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -