📄 customemotion.cs
字号:
namespace Imps.Client.Core.CustomEmotion
{
using Imps.Client.Core;
using System;
using System.Collections.Generic;
public class CustomEmotion : IComparable<Imps.Client.Core.CustomEmotion.CustomEmotion>
{
private int? _clicks;
private DateTime? _expireDate;
private MessageObject _msgObject;
public CustomEmotion() : this(null)
{
}
public CustomEmotion(MessageObject msgObject)
{
this._clicks = null;
this._expireDate = null;
if (msgObject != null)
{
this._msgObject = msgObject;
}
else
{
this._msgObject = new MessageObject();
}
this._msgObject.Type = MessageObjectType.CE;
this._msgObject.Text = this.ShortCut;
}
public int CompareTo(Imps.Client.Core.CustomEmotion.CustomEmotion other)
{
int num = 0;
if (other.Clicks == this.Clicks)
{
num = string.Compare(this.ShortCut, other.ShortCut);
}
else
{
num = this.Clicks - other.Clicks;
}
return -num;
}
public static Imps.Client.Core.CustomEmotion.CustomEmotion FromXml(string xml)
{
MessageObject msgObject = MessageObject.FromXML(xml);
string text = msgObject.Text;
Imps.Client.Core.CustomEmotion.CustomEmotion emotion = new Imps.Client.Core.CustomEmotion.CustomEmotion(msgObject);
if (!string.IsNullOrEmpty(text))
{
emotion.ShortCut = text;
}
return emotion;
}
public string ToMessageXML()
{
List<string> fields = new List<string>();
fields.Add("NAME");
fields.Add("ID");
return this.ToXML(fields, false);
}
public override string ToString()
{
return this.ShortCut;
}
public string ToXML()
{
return this._msgObject.ToXML();
}
public string ToXML(List<string> fields, bool ignore)
{
return this._msgObject.ToXML(fields, false);
}
public bool Animated
{
get
{
string attributeString = this._msgObject.GetAttributeString("ANIMATED");
if (string.IsNullOrEmpty(attributeString))
{
return false;
}
return (attributeString == "1");
}
set
{
this._msgObject.SetAttributeString("ANIMATED", value ? "1" : "0");
}
}
public int Clicks
{
get
{
if (!this._clicks.get_HasValue())
{
this._clicks = 0;
string attributeString = this._msgObject.GetAttributeString("CLICKS");
if (!string.IsNullOrEmpty(attributeString))
{
int num = 0;
if (int.TryParse(attributeString, ref num))
{
this._clicks = new int?(num);
}
}
}
return this._clicks.get_Value();
}
set
{
this._clicks = new int?(value);
this._msgObject.SetAttributeString("CLICKS", value.ToString());
}
}
public DateTime? ExpireDate
{
get
{
if (this._expireDate.get_HasValue())
{
return new DateTime?(this._expireDate.get_Value());
}
string attributeString = this._msgObject.GetAttributeString("EXPIREDATE");
if (string.IsNullOrEmpty(attributeString))
{
return null;
}
try
{
DateTime time;
if (DateTime.TryParse(attributeString, ref time))
{
this._expireDate = new DateTime?(time);
}
}
catch
{
}
return this._expireDate;
}
set
{
this._expireDate = value;
if (!value.get_HasValue())
{
this._msgObject.SetAttributeString("EXPIREDATE", string.Empty);
}
else
{
this._msgObject.SetAttributeString("EXPIREDATE", value.get_Value().ToString("yyyy-MM-dd HH:mm:ss"));
}
}
}
public string Id
{
get
{
return this._msgObject.GetAttributeString("ID").ToUpper();
}
set
{
this._msgObject.SetAttributeString("ID", value.ToUpper());
}
}
public string Name
{
get
{
return this._msgObject.GetAttributeString("NAME");
}
set
{
this._msgObject.SetAttributeString("NAME", value);
}
}
public string ShortCut
{
get
{
return this._msgObject.GetAttributeString("SHORTCUT");
}
set
{
this._msgObject.SetAttributeString("SHORTCUT", value);
this._msgObject.Text = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -