Example #1
0
        public void TestGetDiff()
        {
            // 基础测试
            Time t1 = new Time(2000, 1, 1, 0, 0, 0);
            Time t2 = new Time(2000, 1, 1, 0, 3, 1);
            Assert.AreEqual(181, t2.Getdiff(t1));

            // 当日期变更时的测试
            t1 = new Time(2000, 1, 1, 23, 59, 50);
            t2 = new Time(2000, 1, 2, 0, 1, 20);
            Assert.AreEqual(90, t2.Getdiff(t1));

            // 当月变更时的测试
            t1 = new Time(2000, 1, 31, 23, 58, 40);
            t2 = new Time(2000, 2, 1, 0, 4, 30);
            Assert.AreEqual(350, t2.Getdiff(t1));

            // 当年变更时的测试
            t1 = new Time(2000, 12, 31, 23, 59, 50);
            t2 = new Time(2001, 1, 1, 0, 3, 5);
            Assert.AreEqual(195, t2.Getdiff(t1));
        }
Example #2
0
        public void drawGraphics(ScaleData sData)
        {
            // 获取本列中的所有数据
            List<ColumnHeaderData> list = _header.Data;

            for (int ii = 0; ii < list.Count; ++ii)
            {
                // 获取单项数据
                ColumnHeaderData c = list.ElementAt(ii);
                List<double> data = c.Data.DData;

                double min = c.Data.Min;
                double max = c.Data.Max;

                if(max==min)
                {
                    max = max + 1;
                }

                double span = max - min;

                double scale = _body.Height * 1.0 / 3.0;

                //Time ROOT = new Time(_model.TDATE._StringData.ElementAt(sData.pos[0]).ToString(),
                //                     _model.TTIME._StringData.ElementAt(sData.pos[0]).ToString());

                Time ROOT = sData.FirstTime;

                int rowInterval = sData.Datetime[0].Getdiff(sData.Datetime[2]) / 3;

                for (int i = 0; i < 3; ++ i)
                {
                    for (int j = i==0 ? 0 : sData.Pos[i-1]; j < sData.Pos[i]; ++j)
                    {
                        Time first = new Time(_model.TDATE.StringData.ElementAt(j).ToString(),
                                              _model.TTIME.StringData.ElementAt(j).ToString());

                        Time second = new Time(_model.TDATE.StringData.ElementAt(j + 1).ToString(),
                                              _model.TTIME.StringData.ElementAt(j + 1).ToString());
                        int interval = first.Getdiff(second);

                        Line line = new Line()
                        {
                            X1 = (data.ElementAt(j) - min) * this._body.Width / span,
                            Y1 = (ROOT.Getdiff(first)) * 1.0 / rowInterval * scale,
                            X2 = (data.ElementAt(j+1) - min) * this._body.Width / span,
                            Y2 = (ROOT.Getdiff(second)) * 1.0 / rowInterval * scale,
                            Stroke = colors[ii],
                            StrokeThickness = 0.8
                        };

                        _body.Children.Add(line);
                    }
                }
            }
        }