コード例 #1
0
        public override void CalcPoint()
        {
            float num3;

            this.fd = base.Area.FormulaDataArray[0];
            double[] dd    = base.Manager.Canvas.BackChart.DataProvider["DATE"];
            int      index = 0;
            int      num2  = 1;

            if (base.ControlPoints[0].X > base.ControlPoints[1].X)
            {
                index = 1;
                num2  = 0;
            }
            this.Bar1 = FormulaChart.FindIndex(dd, base.ControlPoints[index].X);
            this.Bar2 = FormulaChart.FindIndex(dd, base.ControlPoints[num2].X);
            if (this.regressionType != RegressionType.UpDownTrend)
            {
                FormulaBase.CalcLinearRegression(this.fd, this.Bar2, this.Bar2 - this.Bar1, out this.A, out this.B);
            }
            else
            {
                this.A = base.ControlPoints[index].Y;
                this.B = (base.ControlPoints[num2].Y - base.ControlPoints[index].Y) / ((double)(this.Bar2 - this.Bar1));
            }
            ObjectPoint point  = base.ControlPoints[index];
            ObjectPoint point2 = base.ControlPoints[num2];

            point.Y  = this.A;
            point2.Y = this.A + (this.B * (this.Bar2 - this.Bar1));
            this.scLines.Clear();
            if (this.centerLine)
            {
                this.scLines.Add(point, point2);
            }
            if (((this.regressionType == RegressionType.Channel) || (this.regressionType == RegressionType.AsynChannel)) || (this.regressionType == RegressionType.UpDownTrend))
            {
                float num4 = base.CalcDelta(this.fd, this.A, this.B, this.Bar1, this.Bar2, "H", true);
                float num5 = base.CalcDelta(this.fd, this.A, this.B, this.Bar1, this.Bar2, "L", false);
                if (this.regressionType == RegressionType.Channel)
                {
                    num3 = Math.Max(Math.Abs(num4), Math.Abs(num5));
                }
                else
                {
                    num3 = -num4;
                }
                if (this.upLine)
                {
                    this.AddLine(point, point2, num3);
                }
                if (this.regressionType != RegressionType.Channel)
                {
                    num3 = num5;
                }
                if (this.downLine)
                {
                    this.AddLine(point, point2, -num3);
                }
            }
            else if ((this.regressionType == RegressionType.StdChannel) || (this.regressionType == RegressionType.StdErrorChannel))
            {
                num3 = this.Std(this.regressionType == RegressionType.StdErrorChannel);
                this.AddLine(point, point2, num3);
                this.AddLine(point, point2, -num3);
            }
            base.pfStart = new PointF[this.scLines.Count];
            base.pfEnd   = new PointF[this.scLines.Count];
            for (int i = 0; i < this.scLines.Count; i++)
            {
                ObjectSegment segment = this.scLines[i];
                if (!double.IsNaN(segment.op1.Y) && !double.IsNaN(segment.op2.Y))
                {
                    base.pfStart[i] = base.ToPointF(segment.op1);
                    base.pfEnd[i]   = base.ToPointF(segment.op2);
                    if (this.openStart)
                    {
                        base.ExpandLine(ref base.pfEnd[i], ref base.pfStart[i]);
                    }
                    if (this.openEnd)
                    {
                        base.ExpandLine(ref base.pfStart[i], ref base.pfEnd[i]);
                    }
                }
                else
                {
                    base.pfStart[i] = PointF.Empty;
                    base.pfEnd[i]   = PointF.Empty;
                }
            }
        }
コード例 #2
0
 public virtual void Add(ObjectSegment os)
 {
     base.List.Add(os);
 }
コード例 #3
0
 public bool InLineSegment(int X, int Y, ObjectSegment os, int PenWidth)
 {
     return(this.InLineSegment(X, Y, os.op1, os.op2, PenWidth));
 }