using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using SigmaDrawerStyle; #if WEB_SERVICE #else using System.Drawing.Design; #endif using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Serialization; namespace GeoSigma.SigmaDrawerStyle { [TypeConverter(typeof(PropertySorter))] [XmlRoot("InNameAny")] public class CurveInNameAny : CurveView { /// /// 属性类别排序 /// private List categorys = new List() { "基础属性", "文字", "线属性", "桩号" , "其他"}; /// /// Initializes a new instance of the class. /// public CurveInNameAny() { TypeName = "任意处写名字"; } [XmlIgnore] [Category("其他"), DisplayName("小数位数"), Description("小数位数"), PropertyOrder(1)] public int DecimalName { get { return Text.DecimalName; } set { Text.DecimalName = value; } } [XmlIgnore] [Category("\t桩号"), DisplayName("桩号列表"), Description("桩号列表"), PropertyOrder(1)] public string LocateList { get { return Location.Value; } set { Location.Value = value; } } //private Font _TextFont; //[XmlIgnore] //[Category("\t文字"), DisplayName("\t\t\t\t\t\t\t字体")] //[TypeConverterAttribute(typeof(FontPropertyConvert))] //public Font TextFont //{ // get // { // _TextFont=Font.FromLogFont(NameFont); // return _TextFont; // } // set // { // _TextFont=value; // NameFont=LogFontConverter.convert(_TextFont); // } //} [XmlIgnore] [Category("\t\t\t文字"), DisplayName("高度"), PropertyOrder(1)] [TypeConverter(typeof(PropertyDoubleConverter))] public double TextHeight { get { return Text.Height; } set { Text.Height = value; } } [XmlIgnore] [Category("\t\t\t文字"), DisplayName("类型"), PropertyOrder(2)] [TypeConverter(typeof(Converter.CurveNameLineTypeConverter))] public int InNameType {//数目或步长 get { return Style.Value & ((int)LineType.PLINE_MARK_NAME_NUM | (int)LineType.PLINE_MARK_NAME_STEP); } set { Style.Value &= ~((int)LineType.PLINE_MARK_NAME_NUM | (int)LineType.PLINE_MARK_NAME_STEP); Style.Value |= value; } } [XmlIgnore] [Category("\t\t\t文字"), DisplayName("数量"), PropertyOrder(3)] [TypeConverter(typeof(PropertyIntConverter))] public int NameNum { get { return (int)(Text.NumOrStep + 0.0001); } set { Text.NumOrStep = value; } } [Browsable(true)] [XmlIgnore] [Category("\t\t\t文字"), DisplayName("步长"), PropertyOrder(4)] [TypeConverter(typeof(Converter.CurveNameLineTypeConverter))] public double Step { get { return Text.NumOrStep; } set { Text.NumOrStep = value; } } [XmlIgnore] [Category("\t\t\t文字"), DisplayName("偏移"), PropertyOrder(5)] [TypeConverter(typeof(Converter.CurveNameLineTypeConverter))] public double Offset { get { return Text.Offset; } set { Text.Offset = value; } } [XmlIgnore] [Category("\t\t\t文字"), DisplayName("颜色"), PropertyOrder(6)] #if WEB_SERVICE #else [Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))] #endif [TypeConverter(typeof(PropertyColorIndicatorConvert))] public Color TextColor { get { return ColorTranslator.FromWin32(Text.ColorRef); } set { Text.ColorRef = ColorTranslator.ToWin32(value); } } [XmlIgnore] [Category("\t\t\t文字"), DisplayName("自动缩小字体"), PropertyOrder(7)] [TypeConverter(typeof(Converter.YesNoConverter))] public bool AutoDecrease { get { if ((Style.Value & (int)Constants.PLINE_IN_NAME_AUTO_DECREASE) != 0) return true; return false; } set { if (value == true) { Style.Value |= (int)Constants.PLINE_IN_NAME_AUTO_DECREASE; } else { Style.Value &= ~(int)Constants.PLINE_IN_NAME_AUTO_DECREASE; } } } [XmlIgnore] [Category("\t\t线属性"), DisplayName("宽度"), PropertyOrder(8)] [TypeConverter(typeof(Converter.CurveNameLineTypeConverter))] public double Width { get { return Curve.Width; } set { Curve.Width = value; } } [XmlIgnore] [Category("\t\t线属性"), DisplayName("颜色"), PropertyOrder(9)] #if WEB_SERVICE #else [Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))] #endif //[TypeConverter(typeof(PropertyColorIndicatorConvert))] public Color CurveColor { get { return ColorTranslator.FromWin32(Curve.ColorRef); } set { Curve.ColorRef = ColorTranslator.ToWin32(value); } } [Category("\t\t线属性"), DisplayName("样式"), PropertyOrder(10)] [TypeConverter(typeof(Converter.CurveLineStyleConverter))] public CurveLineStyle CurveStyle { get { if (hasLineType(LineType.PLINE_ZERO)) { return CurveLineStyle.Default; } if (hasLineType(LineType.PLINE_NODRAW)) { return CurveLineStyle.NoDraw; } if (hasLineType(LineType.PLINE_CLOSE)) { return CurveLineStyle.Close; } return CurveLineStyle.Default; } set { clearLineType(LineType.PLINE_ZERO); clearLineType(LineType.PLINE_NODRAW); clearLineType(LineType.PLINE_CLOSE); if (value == CurveLineStyle.NoDraw) { setLineType(LineType.PLINE_NODRAW); } if (value == CurveLineStyle.Close) { setLineType(LineType.PLINE_CLOSE); } } } [XmlIgnore] [Category("\t\t线属性"), DisplayName("线端"), PropertyOrder(11)] [TypeConverter(typeof(Converter.CurveCapConverter))] public CurveCap CurveLineCap { get { return hasLineType(LineType.PLINE_SMOOTH_HEAD) ? CurveCap.Round : CurveCap.Square; } set { if (value == CurveCap.Round) { setLineType(LineType.PLINE_SMOOTH_HEAD); } else { clearLineType(LineType.PLINE_SMOOTH_HEAD); } } } [XmlIgnore] [Category("\t\t线属性"), DisplayName("平滑"), PropertyOrder(12)] [TypeConverter(typeof(Converter.CurveSmoothnessConverter))] public CurveSmoothness CurveSmoothness { get { if (hasLineType(LineType.PLINE_BEZIER)) { return CurveSmoothness.Bezier; } if (hasLineType(LineType.PLINE_SPLINE)) { return CurveSmoothness.Spline; } return CurveSmoothness.None; } set { // 清理,因为我们这里使用枚举表示,选中其中一个之后,其它的都要清理掉 clearLineType(LineType.PLINE_BEZIER); clearLineType(LineType.PLINE_SPLINE); if (value == CurveSmoothness.Bezier) { setLineType(LineType.PLINE_BEZIER); } else if (value == CurveSmoothness.Spline) { setLineType(LineType.PLINE_SPLINE); } } } [XmlIgnore] [Category("\t\t线属性"), DisplayName("透明"), PropertyOrder(13)] [TypeConverter(typeof(Converter.CurveAlphaModeConverter))] public CurveAlphaMode CurveAlphaMode { get { if (hasLineType(LineType.PLINE_TRANSPARENT)) { return CurveAlphaMode.Transparent; } if (hasLineType(LineType.PLINE_TRANSPARENT_VALUE)) { return CurveAlphaMode.Alphand; } return CurveAlphaMode.None; } set { clearLineType(LineType.PLINE_TRANSPARENT); clearLineType(LineType.PLINE_TRANSPARENT_VALUE); if (value == CurveAlphaMode.Transparent) { setLineType(LineType.PLINE_TRANSPARENT); } else if (value == CurveAlphaMode.Alphand) { setLineType(LineType.PLINE_TRANSPARENT_VALUE); } } } //[XmlIgnore] //[Category("\t基础属性"), DisplayName("\t\t\t\t虚线(有线长度 无线长度 ...)")] //public string VirtureValues //{ // get // { // return _VirtureType.VirtureValues; // } // set // { // _VirtureType.VirtureValues=value; // } //} //[XmlIgnore] //[Category("\t线属性"), DisplayName("\t\t\t仅拐点处虚线")] //public bool OnlyNodeVirture //{ // get // { // return _VirtureType.OnlyNodeVirture; // } // set // { // _VirtureType.OnlyNodeVirture=value; // } //} //[XmlIgnore] //[Category("\t线属性"), DisplayName("\t\t平行间距")] //public double Offset //{ // get // { // return _Base.Offset; // } // set // { // _Base.Offset=value; // } //} [XmlIgnore] [Category("\t\t线属性"), DisplayName("光滑步长"), PropertyOrder(12)] [TypeConverter(typeof(PropertyDoubleConverter))] public double SmoothStep { get { return Curve.SmoothStep; } set { Curve.SmoothStep = value; } } [Browsable(false)] public InNameStyle Style { get; set; } = new InNameStyle(); [Browsable(false)] public InNameAnyText Text { get; set; } = new InNameAnyText(); [Browsable(false)] public InNameCurve Curve { get; set; } = new InNameCurve(); [Browsable(false)] public InNameAnyLocation Location { get; set; } = new InNameAnyLocation(); private bool hasLineType(LineType lineType) { return (Style.Value & (int)lineType) != 0; } private void setLineType(LineType lineType) { Style.Value |= (int)lineType; } private void clearLineType(LineType lineType) { Style.Value &= ~(int)lineType; } //[Browsable(false)] //[XmlElement("Font")] //public LogFont NameFont { get; set; } //private Font _TextFont; //[XmlIgnore] //[Category("\t名字"), DisplayName("\t\t\t\t\t\t\t字体")] //public Font TextFont //{ // get // { // _TextFont=Font.FromLogFont(NameFont); // return _TextFont; // } // set // { // _TextFont=value; // NameFont=new LogFont(); // _TextFont.ToLogFont(NameFont); // } //} } public class InNameAnyText { [XmlAttribute] public double Height { get; set; } = 200; [XmlAttribute("Color")] public int ColorRef { get; set; } [XmlAttribute] public double NumOrStep { get; set; } [XmlAttribute] public double Offset { get; set; } // 存储小数位数,默认为0 [XmlAttribute] public int DecimalName { get; set; } = -1; } public class InNameAnyLocation { [XmlAttribute] public string Value { get; set; } = "1000"; } }