using DrawGraph; using Newtonsoft.Json; using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; namespace DrawGraph { [JsonObject(MemberSerialization.OptOut)] [Serializable] public class DottedLinesPackObj : PackObjBase { private double xPageSpan = 3.0; private double xMajorGridStep = 1.0; private int lineCount = 1; private ELineType lineType = ELineType.Vertical; private string noDrawLineStr = ""; private Color lineColor = Color.Black; public ELineType LineType { get { return this.lineType; } set { this.lineType = value; } } public double XMajorGridStep { get { return this.xMajorGridStep; } set { this.xMajorGridStep = value; } } public double XPageSpan { get { return this.xPageSpan; } set { this.xPageSpan = value; } } public Color LineColor { get { return this.lineColor; } set { this.lineColor = value; } } [ClassAttributs(CName = "不画的线集合", Description = "不画的线集合,以逗号分隔")] public string NoDrawLineStr { get { return this.noDrawLineStr; } set { this.noDrawLineStr = value; } } public DottedLinesPackObj(ZedGraphControl zgc, PackObjManager poManager) : base(zgc, poManager) { this.baseZed = zgc; base.PackText = "虚线集合" + this.index.ToString(); } public override void Draw() { bool flag = this.baseZed == null; if (!flag) { this.Clear(); Color red = this.LineColor; bool isSelect = base.IsSelect; if (isSelect) { red = Color.Red; } this.lineCount = (int)Math.Floor(this.xPageSpan / this.xMajorGridStep); string[] source = this.NoDrawLineStr.Replace(",", ",").Split(new char[] { ',' }); int i = 0; while (i < this.lineCount) { bool flag2 = this.NoDrawLineStr != ""; if (!flag2) { goto IL_C2; } string text = source.FirstOrDefault((string s) => s == (i + 1).ToString()); bool flag3 = text != null; if (!flag3) { goto IL_C2; } IL_1EC: int j = i; i = j + 1; continue; IL_C2: bool flag4 = this.LineType == ELineType.Vertical; if (flag4) { float num = base.RealX + (float)(i + 1) * ((base.RealEndX - base.RealX) / (float)this.lineCount); bool flag5 = i < this.lineCount - 1; if (flag5) { ZUtil.DrawLine((double)num, (double)base.RealY, (double)num, (double)base.RealEndY, this.baseZed, base.PackTag + "-" + i.ToString(), red, DashStyle.Dot); } } else { bool flag6 = this.LineType == ELineType.Horizontal; if (flag6) { float num2 = base.RealY + (float)(i + 1) * ((base.RealEndY - base.RealY) / (float)this.lineCount); bool flag7 = i < this.lineCount - 1; if (flag7) { ZUtil.DrawLine((double)base.RealX, (double)num2, (double)base.RealEndX, (double)num2, this.baseZed, base.PackTag + "-" + i.ToString(), red, DashStyle.Dot); } } } goto IL_1EC; } base.Refresh(); } } public override void Clear() { for (int i = 0; i < this.lineCount; i++) { GraphObj graphObj = this.baseZed.MasterPane.GraphObjList[base.PackTag + "-" + i.ToString()]; bool flag = graphObj != null; if (flag) { this.baseZed.MasterPane.GraphObjList.Remove(graphObj); } } } } }