您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
97 行
2.7 KiB
97 行
2.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using Unity.UIWidgets.foundation;
|
|
|
|
namespace Unity.UIWidgets.widgets {
|
|
public class IconData : IEquatable<IconData> {
|
|
public IconData(
|
|
int codePoint,
|
|
string fontFamily = null
|
|
) {
|
|
this.codePoint = codePoint;
|
|
this.fontFamily = fontFamily;
|
|
}
|
|
|
|
public readonly int codePoint;
|
|
|
|
public readonly string fontFamily;
|
|
|
|
public bool Equals(IconData other) {
|
|
if (ReferenceEquals(null, other)) {
|
|
return false;
|
|
}
|
|
|
|
if (ReferenceEquals(this, other)) {
|
|
return true;
|
|
}
|
|
|
|
return codePoint == other.codePoint &&
|
|
string.Equals(fontFamily, other.fontFamily);
|
|
}
|
|
|
|
public override bool Equals(object obj) {
|
|
if (ReferenceEquals(null, obj)) {
|
|
return false;
|
|
}
|
|
|
|
if (ReferenceEquals(this, obj)) {
|
|
return true;
|
|
}
|
|
|
|
if (obj.GetType() != GetType()) {
|
|
return false;
|
|
}
|
|
|
|
return Equals((IconData) obj);
|
|
}
|
|
|
|
public override int GetHashCode() {
|
|
unchecked {
|
|
return (codePoint * 397) ^ (fontFamily != null ? fontFamily.GetHashCode() : 0);
|
|
}
|
|
}
|
|
|
|
public static bool operator ==(IconData left, IconData right) {
|
|
return Equals(left, right);
|
|
}
|
|
|
|
public static bool operator !=(IconData left, IconData right) {
|
|
return !Equals(left, right);
|
|
}
|
|
|
|
public override string ToString() {
|
|
return "IconData(U+" + codePoint.ToString("X5") + ")";
|
|
}
|
|
}
|
|
|
|
public class IconDataProperty : DiagnosticsProperty<IconData> {
|
|
public IconDataProperty(
|
|
String name,
|
|
IconData value,
|
|
String ifNull = null,
|
|
bool showName = true,
|
|
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.singleLine,
|
|
DiagnosticLevel level = DiagnosticLevel.info
|
|
) : base(name, value,
|
|
showName: showName,
|
|
ifNull: ifNull,
|
|
style: style,
|
|
level: level
|
|
) {
|
|
D.assert(showName != null);
|
|
D.assert(style != null);
|
|
D.assert(level != null);
|
|
}
|
|
|
|
|
|
public override Dictionary<String, Object> toJsonMap(DiagnosticsSerializationDelegate _delegate) {
|
|
Dictionary<String, Object> json = base.toJsonMap(_delegate);
|
|
if (value != null) {
|
|
json["valueProperties"] = new Dictionary<String, Object>(){
|
|
{"codePoint", value.codePoint},
|
|
};
|
|
}
|
|
return json;
|
|
}
|
|
}
|
|
}
|