AIMS/DrawGraph/BoardPack/LinesPackObj.cs
2022-12-29 21:57:18 +08:00

188 lines
3.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using DrawGraph;
using Newtonsoft.Json;
using System;
using System.Drawing;
using System.Linq;
namespace DrawGraph
{
[JsonObject(MemberSerialization.OptOut)]
[Serializable]
public class LinesPackObj : PackObjBase
{
private double xPageSpan = 3.0;
private double xMajorGridStep = 1.0;
private int lineCount = 1;
private ELineType lineType = ELineType.Vertical;
private int lineWidth = 1;
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(Description = "线粗细")]
public int LineWidth
{
get
{
return this.lineWidth;
}
set
{
this.lineWidth = value;
}
}
[ClassAttributs(CName = "不画的线集合", Description = "不画的线集合,以逗号分隔")]
public string NoDrawLineStr
{
get
{
return this.noDrawLineStr;
}
set
{
this.noDrawLineStr = value;
}
}
public LinesPackObj(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_1F6:
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.DrawLineWidth((double)num, (double)base.RealY, (double)num, (double)base.RealEndY, this.baseZed, base.PackTag + "-" + i.ToString(), red, this.LineWidth);
}
}
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.DrawLineWidth((double)base.RealX, (double)num2, (double)base.RealEndX, (double)num2, this.baseZed, base.PackTag + "-" + i.ToString(), red, this.LineWidth);
}
}
}
goto IL_1F6;
}
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);
}
}
}
}
}