public void NavOnLoad(params object[] parsObjects)
        {
            //初始化隐藏召测表格
            LvRecVisi = Visibility.Collapsed;
            RecLineItems.Clear();
            LineItems.Clear();
            var tmlId = (int)parsObjects[0];

            if (tmlId > 0)
            {
                SelectedTmlChange(tmlId);
            }
        }
        /// <summary>
        /// 初始化 需要显示的回路、输出、输入信息
        /// </summary>
        private void InitViewModel()
        {
            if (_terminalInformation == null)
            {
                return;
            }


            AttachRtuId = _terminalInformation.AttachRtuId;
            RtuId       = _terminalInformation.RtuId;
            PhyId       = _terminalInformation.PhyId;
            RtuName     = _terminalInformation.RtuName;
            Remark      = _terminalInformation.Remark;

            LduCommType = _terminalInformation.RtuModel == 30910 ? "无线" : "有线";

            LineItems.Clear();
            foreach (var t in _terminalInformation.LduLines)
            {
                LineItems.Add(new LduLineViewModel(t, LoopCollectionInfo));
            }
        }
 public void OnUserHideOrClosing()
 {
     RecLineItems.Clear();
     LineItems.Clear();
 }
        /// <summary>
        /// Draws the graph
        /// </summary>
        private void DrawGraph()
        {
            if (CanvasHeight == 0 || CanvasWidth == 0)
            {
                return;
            }

            //clear the containers
            RectangleItems.Clear();
            LineItems.Clear();
            TextItems.Clear();
            PointCollection points = new PointCollection();

            //set some stuff
            int numPoints = 100;
            int ticks     = 8;

            //get the max an min of the efficieny points
            double maxOrd = EfficiencyMeasurements.Max(e => e.Efficiency);
            double minOrd = EfficiencyMeasurements.Min(e => e.Efficiency);

            //get ordinate graph bounds that look nice
            double ordTickRange = GetTickRange(maxOrd - minOrd, ticks);
            double ordTickMag   = Math.Log10(ordTickRange) > 0 ? Math.Ceiling(Math.Log10(ordTickRange)) : Math.Floor(Math.Log10(ordTickRange));

            maxOrd = ordTickRange * Math.Round(1 + maxOrd / ordTickRange);
            minOrd = ordTickRange * (Math.Round(minOrd / ordTickRange - 1));

            double minAbsc = 0;// Properties.Settings.Default.LOWERELIMT * 0.75;
            double maxAbsc = Properties.Settings.Default.UPPERENERGY;

            //get abscissa graph bounds that look nice
            double abscTickRange = GetTickRange(maxAbsc - minAbsc, ticks);
            double abscTickMag   = Math.Log10(abscTickRange) > 0 ? Math.Ceiling(Math.Log10(abscTickRange)) : Math.Floor(Math.Log10(abscTickRange));

            maxAbsc = abscTickRange * Math.Round(maxAbsc / abscTickRange);
            minAbsc = abscTickRange * (Math.Round(minAbsc / abscTickRange));


            int       seperation = 20;
            Rectangle chart      = new Rectangle(0.2 * CanvasWidth - seperation, seperation, (int)(0.8F * CanvasWidth), (int)(0.8F * CanvasHeight));

            //Rectangle chart = new Rectangle();
            RectangleItems.Add(chart);

            //get the energy limit
            double lowE  = minAbsc;// Properties.Settings.Default.LOWERELIMT * 0.75;
            double highE = maxAbsc;

            //get the position converstion factors.
            double xconv = chart.Width / (highE - lowE);
            double xoff  = chart.Right - (xconv * highE);

            double yconv = chart.Height / (minOrd - maxOrd);
            double yoff  = chart.Bottom - (yconv * minOrd);


            //build a formatting string
            StringBuilder format = new StringBuilder("0");

            format.Append(ordTickMag >= 0 ? "" : ".");
            for (int j = 0; j < Math.Abs(ordTickMag); j++)
            {
                format.Append(0);
            }
            //loop through and add lables
            int    tickLength = 10;
            double ord = minOrd, absc = minAbsc;

            while (Math.Round(ord, (int)Math.Abs(ordTickMag)) <= maxOrd)
            {
                //draw the y-axis
                double y;// = (yconv * (ord) + yoff);
                if (Math.Abs(ord - minOrd) < 1e-6)
                {
                    y = chart.Bottom - chart.StrokeWeight / 2;
                }
                else if (Math.Abs(ord - maxOrd) < 1e-6)
                {
                    y = chart.Top + chart.StrokeWeight / 2;
                }
                else
                {
                    y = (yconv * (ord) + yoff);
                    LineItems.Add(new Line(chart.Left, y, chart.Right, y)
                    {
                        LineDashArray = { 2, 1 },
                    });
                }

                LineItems.Add(new Line(chart.Left - tickLength, y, chart.Left + tickLength, y));
                //create the label
                string    label     = (ord).ToString(format.ToString());
                ChartText labelText = new ChartText(label)
                {
                    //position the label
                    //X = chart.Left - 2 - 0.2*CanvasWidth,
                    X      = 0,
                    Y      = y + (ordTickRange * yconv) / 2,
                    Width  = chart.Left - tickLength - 2,
                    Height = Math.Abs(ordTickRange * yconv),
                    TextHorizontalAlignment = HorizontalAlignment.Right,
                    TextVerticalAlignment   = VerticalAlignment.Center
                };

                TextItems.Add(labelText);
                ord += ordTickRange;
            }
            while (Math.Round(absc, (int)Math.Abs(abscTickMag)) <= maxAbsc)
            {
                //draw the x-axis
                double x;// = (xconv * (absc) + xoff);
                if (Math.Abs(absc - minAbsc) < 1e-6)
                {
                    x = chart.Left + chart.StrokeWeight / 2;
                }
                else if (Math.Abs(absc - maxAbsc) < 1e-6)
                {
                    x = chart.Right - chart.StrokeWeight / 2;
                }
                else
                {
                    x = (xconv * (absc) + xoff);
                    LineItems.Add(new Line(x, chart.Bottom, x, chart.Top)
                    {
                        LineDashArray = { 2, 1 },
                    });
                }

                LineItems.Add(new Line(x, chart.Bottom + tickLength, x, chart.Bottom - tickLength));

                string    label     = (absc).ToString();
                ChartText labelText = new ChartText(label)
                {
                    Width  = abscTickRange * xconv,
                    Height = 0.2 * CanvasHeight - tickLength - 2 - seperation,
                    //position the label
                    X = x - (abscTickRange * xconv) / 2,
                    Y = chart.Bottom + tickLength + 2,
                    TextHorizontalAlignment = HorizontalAlignment.Center,
                    TextVerticalAlignment   = VerticalAlignment.Top
                };

                TextItems.Add(labelText);
                absc += abscTickRange;
            }

            //fill the an array of points that represents the curve
            double eJump = (highE - lowE) / numPoints;
            //CurvePoints = new Point[numPoints];
            double ene = lowE;

            for (int i = 0; i < numPoints; i++)
            {
                ene += eJump;
                double eff = data.GetEfficiency(ene);
                int    x   = Convert.ToInt32(ene * xconv + xoff);
                double y   = yoff + eff * yconv;
                if (y > chart.Bottom || double.IsNaN(y))
                {
                    y = chart.Bottom;
                }
                else if (y < chart.Top || double.IsInfinity(y))
                {
                    y = chart.Top;
                }

                points.Add(new Point(x, y));
            }
            this.CurvePoints = points;
            //make the graph thick
            //put the efficiency points on the chart
            for (int i = 0; i < EfficiencyMeasurements.Count; i++)
            {
                int x      = Convert.ToInt32(EfficiencyMeasurements[i].Energy * xconv + xoff);
                int y      = Convert.ToInt32(yoff + EfficiencyMeasurements[i].Efficiency * yconv);
                int ptSize = 2;
                RectangleItems.Add(new Rectangle(x - ptSize, y - ptSize, 2 * ptSize, 2 * ptSize));
                //add the error bars
                LineItems.Add(new Line(x, y - EfficiencyMeasurements[i].EfficiencyUncertainty * yconv,
                                       x, y + EfficiencyMeasurements[i].EfficiencyUncertainty * yconv));
            }
            WriteEfficiencyEquation();
        }