You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
195 lines
5.9 KiB
C#
195 lines
5.9 KiB
C#
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Xml.Serialization;
|
|
using GeoSigma.SigmaDrawerUtil;
|
|
|
|
namespace GeoSigma.SigmaDrawerStyle
|
|
{
|
|
/// <summary>
|
|
/// 渐变充填效果
|
|
/// </summary>
|
|
[XmlRoot("Effect")]
|
|
public class CurveEffect : CurveView
|
|
{
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="CurveEffect"/> class.
|
|
/// </summary>
|
|
public CurveEffect()
|
|
{
|
|
TypeName = "渐变色";
|
|
Mode = 1;
|
|
}
|
|
private GradientColors effectColor;
|
|
[Category("基础属性"), DisplayName("\t\t颜色"), Description("颜色")]
|
|
[XmlIgnoreAttribute]
|
|
[TypeConverter(typeof(SigmaDrawerStyle.Converter.BaseCollectionConverter))]
|
|
#if WEB_SERVICE
|
|
#else
|
|
[Editor("GeoSigma.SigmaDrawerStyle.PropertyEditorGradientColor, SigmaDrawerStyle", typeof(System.Drawing.Design.UITypeEditor))]
|
|
#endif
|
|
// [Editor("UCDraw.Editor.CurveGradientEditor, UCDraw", typeof(System.Drawing.Design.UITypeEditor))]
|
|
public GradientColors EffectColor
|
|
{
|
|
get
|
|
{
|
|
if (effectColor == null)
|
|
{
|
|
effectColor = new GradientColors();
|
|
effectColor.AddRange(GradientColorManager.DefaultColorTemplate.CloneColors());
|
|
}
|
|
if (effectColor != null && effectColor.Count > 0)
|
|
{
|
|
double dStep = 100D / (effectColor.Count - 1);
|
|
for (int i = 0; i < effectColor.Count; i++)
|
|
{
|
|
// effectColor[i].Z = $"{dStep * i}";
|
|
effectColor[i].Z = dStep * i;
|
|
}
|
|
}
|
|
return effectColor;
|
|
}
|
|
set
|
|
{
|
|
if (value == null)
|
|
{
|
|
effectColor = null;
|
|
}
|
|
else
|
|
{
|
|
effectColor.Clear();
|
|
effectColor.AddRange(value.Select(item => item.Clone()));
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 颜色字符串
|
|
/// </summary>
|
|
[Browsable(false)]
|
|
[XmlElement("Color")]
|
|
public ValueColor ColorString
|
|
{
|
|
get
|
|
{
|
|
if (effectColor == null || effectColor.Count == 0)
|
|
{
|
|
return null;
|
|
}
|
|
StringBuilder strbData = new StringBuilder();
|
|
foreach (GradientColorItem colorItem in effectColor)
|
|
{
|
|
Color color = Color.FromArgb(colorItem.R, colorItem.G, colorItem.B);
|
|
strbData.Append(ColorTranslator.ToHtml(color) + " ");
|
|
}
|
|
return new ValueColor(strbData.ToString().Trim());
|
|
}
|
|
set
|
|
{
|
|
string[] straColor = value.Value.Split(' ');
|
|
effectColor = new GradientColors();
|
|
int nCount = straColor.Length;
|
|
double dStep = 100.0 / (nCount - 1);
|
|
for (int i = 0; i < straColor.Length; i++)
|
|
{
|
|
Color color = ColorTranslator.FromHtml(straColor[i]);
|
|
effectColor.Add(new GradientColorItem()
|
|
{
|
|
R = color.R,
|
|
G = color.G,
|
|
B = color.B,
|
|
Z = dStep * i,
|
|
Smooth = GradientColorItem.SmoothMode.G,
|
|
//Value = ColorRGBtoInt.Color2LongString(color),
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
[Category("基础属性"), DisplayName("\t充填方式"), Description("充填方式")]
|
|
[XmlAttribute("Mode")]
|
|
[TypeConverter(typeof(Converter.GradientTypeConverter))]
|
|
public int Mode { get; set; }
|
|
|
|
[Category("基础属性"), DisplayName("显示方式"), Description("显示方式")]
|
|
[XmlAttribute("Style")]
|
|
[TypeConverter(typeof(Converter.LineTypeLiteConverter))]
|
|
public int Style { get; set; }
|
|
|
|
/// <summary>
|
|
/// 颜色数量
|
|
/// </summary>
|
|
[Browsable(false)]
|
|
[XmlAttribute("Number")]
|
|
public int Number
|
|
{
|
|
get
|
|
{
|
|
if (EffectColor == null || EffectColor.Count == 0)
|
|
{
|
|
return 0;
|
|
}
|
|
return EffectColor.Count;
|
|
}
|
|
set
|
|
{
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 渐变颜色类
|
|
/// </summary>
|
|
public class ValueColor
|
|
{
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="ValueColor"/> class.
|
|
/// </summary>
|
|
public ValueColor()
|
|
{
|
|
return;
|
|
}
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="ValueColor"/> class.
|
|
/// </summary>
|
|
/// <param name="data">颜色数据</param>
|
|
public ValueColor(string data)
|
|
{
|
|
Value = data;
|
|
}
|
|
/// <summary>
|
|
/// 颜色属性字符串
|
|
/// </summary>
|
|
[XmlAttribute]
|
|
public string Value
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
}
|
|
}
|
|
|
|
public class CurveEffectColor
|
|
{
|
|
//[Category("\t其他"), DisplayName("\t\t渐变色")]
|
|
[Browsable(false)]
|
|
[XmlAttribute("Value")]
|
|
public string Value { get; set; }
|
|
|
|
[Browsable(false)]
|
|
[XmlIgnore]
|
|
public string ZValue
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
[Browsable(false)]
|
|
[XmlIgnore]
|
|
public string Smooth
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
}
|
|
}
|