duheng
8 天以前 4de480ec624d3b79ca690dc906e10cd2fbdc9be7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraBars.ViewInfo;
using DevExpress.XtraCharts;
using DevExpress.XtraGrid.Views.Grid; 
 
namespace IStation.WinFrmUI.CalcErQu
{
 
    public partial class AnaResultInfoCtrl定水量 : UserControl
    {
        DevExpress.XtraCharts.XYDiagram mainDiagram;
        //计算时间跨度
        protected int _calcSpaceMinute = 2;
        public int CalcSpaceMinute { get { return _calcSpaceMinute; } set { _calcSpaceMinute = value; } }
 
        DevExpress.XtraCharts.ConstantLine _moveConstantLineIn实时数据 = null;
 
        public AnaResultInfoCtrl定水量()
        {
            InitializeComponent();
 
 
            this.gridView1.OptionsDetail.ShowDetailTabs = false;//不显示TAB名
            this.gridView1.OptionsView.ShowGroupPanel = false;//隐藏最上面的GroupPanel
            this.gridView1.OptionsSelection.MultiSelect = false;//单选
            //this.gridViewMain.OptionsBehavior.Editable = false;//只读 
            this.gridView1.IndicatorWidth = 4;
            this.gridView1.RowClick += new DevExpress.XtraGrid.Views.Grid.RowClickEventHandler(this.GridViewMain_RowClick);
            //this.gridViewMain.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(this.GridViewMain_CustomDrawRowIndicator);
            //this.gridViewMain.CustomUnboundColumnData += new DevExpress.XtraGrid.Views.Base.CustomColumnDataEventHandler(this.GridViewMain_CustomUnboundColumnData);
            //this.gridViewMain.DoubleClick += new System.EventHandler(this.GridViewMain_DoubleClick);
            //this.gridView1.RowCellClick += new DevExpress.XtraGrid.Views.Grid.RowCellClickEventHandler(this.GridViewMain_RowCellClick);
            //this.gridView1.CellValueChanged += new DevExpress.XtraGrid.Views.Base.CellValueChangedEventHandler(this.gridViewMain_CellValueChanged);
 
            this.chartControl实时数据.CustomPaint += new DevExpress.XtraCharts.CustomPaintEventHandler(this.ChartControl实时数据_CustomPaint);
 
            mainDiagram = this.chartControl实时数据.Diagram as DevExpress.XtraCharts.XYDiagram;
 
 
            _moveConstantLineIn实时数据 = mainDiagram.AxisX.ConstantLines[0];
            _moveConstantLineIn实时数据.Visible = false;
        }
 
        List<Model.TimeWaterLevel> _waterLevels长江;
        public void SetRiverWaterLevels(List<Model.TimeWaterLevel> waterLevels长江)
        {
            this._waterLevels长江 = waterLevels长江;
        }
        IStation.CalcModel.AnaPrj _anaPrj = null;
        DateTime _startTime, _endTime;
 
 
        #region 泵信息
        private List<IStation.CalcModel.PumpInfo> _allPumpInfo = null;
        public void SetPumpInfo(List<IStation.CalcModel.PumpInfo> allPumpInfo)
        {
            this._allPumpInfo = allPumpInfo;
        }
 
 
  
        #endregion
 
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="targeFlow"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="anaPrj"></param>
        public void SetBindingData( 
             DateTime startTime, DateTime endTime,
             IStation.CalcModel.AnaPrj anaPrj)
        {
            if (anaPrj == null)
                return;
           
            this.CalcSpaceMinute = IStation.WinFrmUI.CalcErQu.Properties.Settings.Default.CalcSpaceMinute;
 
            this._startTime = startTime;
            this._endTime = endTime;
            this._anaPrj = anaPrj;
 
            InitialRealTimeData(anaPrj);
            InitialGrid运行时间();
            InitialChart实时数据(anaPrj);
            InitialChart累计数据(anaPrj);
        }
 
        #region 累计数据
        private void InitialChart累计数据(IStation.CalcModel.AnaPrj anaPrj)
        {
            var series累计流量 = chartControl累计数据.Series[0];
            var series累计电量 = chartControl累计数据.Series[1];
            var series累计电费 = chartControl累计数据.Series[2];
            series累计流量.Points.Clear();
            series累计电量.Points.Clear();
            series累计电费.Points.Clear();
            for (int i = 0; i < realTimeDataList.Count - 1; i++)
            {
                var time = realTimeDataList[i].Time;
 
                series累计流量.Points.Add(new SeriesPoint(time, new double[] { realTimeDataList[i].TotalFlow }));
                series累计电量.Points.Add(new SeriesPoint(time, new double[] { realTimeDataList[i].TotalEle }));
                series累计电费.Points.Add(new SeriesPoint(time, new double[] { realTimeDataList[i].TotalMoney }));
            }
 
 
            var diagram =
                chartControl累计数据.Diagram as DevExpress.XtraCharts.XYDiagram;
            var axis = diagram.AxisX;
            axis.VisualRange.Auto = false;
            axis.WholeRange.Auto = false;
            axis.WholeRange.SideMarginsValue = 0;
            axis.VisualRange.SideMarginsValue = 0;
            axis.WholeRange.SetMinMaxValues(_startTime, _endTime);
            axis.VisualRange.SetMinMaxValues(_startTime, _endTime);
            axis.WholeRange.AlwaysShowZeroLevel = false;
        }
 
 
        #endregion
 
 
        //实时数据
        List<IStation.ViewModel.RealTimeData> realTimeDataList;
        private void InitialRealTimeData(IStation.CalcModel.AnaPrj anaPrj)
        {
            //List<DateTime> splitTimeList = new List<DateTime>();
            //splitTimeList.Add(this._startTime);
            //splitTimeList.Add(this._endTime);
 
            //foreach (var item in anaPrj.BlockTimes)
            //{ 
            //    if (!splitTimeList.Contains(item.StartTime))
            //        splitTimeList.Add(item.StartTime);
            //    if (!splitTimeList.Contains(item.EndTime))
            //        splitTimeList.Add(item.EndTime);
            //}
            //splitTimeList = splitTimeList.Distinct().ToList();
            //splitTimeList.Sort();
            //realTimeDataList = new List<IStation.ViewModel.RealTimeData>();
 
            //double total_flow = 0;
            //double total_power = 0;
            //double total_money = 0;
            //for (int i = 0; i < splitTimeList.Count - 1; i++)
            //{
            //    bool isClosePump = true;
            //    DateTime startTime = splitTimeList[i];
            //    DateTime endTime = splitTimeList[i + 1];
 
            //    foreach (var item in anaPrj.BlockTimes)
            //    {
 
            //        if (startTime >= item.StartTime && startTime < item.EndTime)
            //        {
            //            isClosePump = false;
 
            //            foreach (var sd in item.SumData)
            //            {
            //                if (sd.Time <= endTime)
            //                {
            //                    IStation.ViewModel.RealTimeData rtd = new IStation.ViewModel.RealTimeData();
            //                    rtd.Time = sd.Time; 
            //                    rtd.OpenPumpCount = item.OpenPumpCount;
            //                    rtd.Head = sd.Head;
            //                    rtd.Flow = sd.Flow;
            //                    rtd.Power = sd.Power;
            //                    rtd.WaterLevelQ = sd.WaterLevelQ;
            //                    rtd.WaterLevelC = IStation.Calc.ErQuCalcBaseHelper.GetRiverWaterLevelByTime(_waterLevels长江, rtd.Time);
 
            //                    total_flow += sd.SFlow;
            //                    total_power += sd.Power;
            //                    total_money += sd.Money;
 
            //                    rtd.TotalFlow = total_flow;
            //                    rtd.TotalEle = total_power;
            //                    rtd.TotalMoney = total_money;
 
            //                    //rtd.PumpDatas = sd.PumpDatas;
 
            //                    realTimeDataList.Add(rtd);
            //                }
            //            }
            //            break;
            //        }
            //    }
            //    if (isClosePump)
            //    {
            //        for (var time = startTime; time < endTime; time = time.AddMinutes(this._calcSpaceMinute))
            //        {
            //            IStation.ViewModel.RealTimeData rtd = new IStation.ViewModel.RealTimeData();
            //            rtd.Time = time;
            //            rtd.OpenPumpCount = 0;
            //            rtd.Flow = 0;
            //            rtd.Power = 0;
            //            rtd.WaterLevelC = IStation.Calc.ErQuCalcBaseHelper.GetRiverWaterLevelByTime(_waterLevels长江, rtd.Time);
            //            rtd.WaterLevelQ = rtd.WaterLevelC;
 
            //            rtd.TotalFlow = total_flow;
            //            rtd.TotalEle = total_power;
            //            rtd.TotalMoney = total_money;
 
            //            realTimeDataList.Add(rtd);
            //        }
            //    }
            //}
 
 
        }
 
        #region 实时数据
 
 
        private void InitialChart实时数据(IStation.CalcModel.AnaPrj anaPrj)
        {
            DevExpress.XtraCharts.Series seriesCJSW = this.chartControl实时数据.Series[0];
            DevExpress.XtraCharts.Series series前池液位 = this.chartControl实时数据.Series[1];
 
            DevExpress.XtraCharts.Series series流量 = this.chartControl实时数据.Series[2];
            DevExpress.XtraCharts.Series series功率 = this.chartControl实时数据.Series[3];
            seriesCJSW.Points.Clear();
            series流量.Points.Clear();
            series功率.Points.Clear();
            series前池液位.Points.Clear();
            double min_flow = double.MaxValue, max_flow = 0;
            double min_power = double.MaxValue, max_power = 0;
            for (int i = 0; i < realTimeDataList.Count; i++)
            {
                var time = realTimeDataList[i].Time;
                seriesCJSW.Points.Add(new SeriesPoint(time, new double[] {
                    Math.Round( realTimeDataList[i].WaterLevelC, 2) }));
                series流量.Points.Add(new SeriesPoint(time, new double[] {
                       100 * ((int)( realTimeDataList[i].Flow/100 )) }));
                series功率.Points.Add(new SeriesPoint(time, new double[] {
                       10 * ((int)( realTimeDataList[i].Power / 10)) }));
                series前池液位.Points.Add(new SeriesPoint(time, new double[] {
                    Math.Round(realTimeDataList[i].WaterLevelQ, 2) }));
 
                if (realTimeDataList[i].Flow > 1000)
                {
                    min_power = Math.Min(min_power, realTimeDataList[i].Power);
                    max_power = Math.Max(max_power, realTimeDataList[i].Power);
 
                    min_flow = Math.Min(min_flow, realTimeDataList[i].Flow);
                    max_flow = Math.Max(max_flow, realTimeDataList[i].Flow);
                }
            }
 
            SetChartCoord实时数据(min_flow, max_flow, min_power, max_power);
        }
     
        double rang_up_flow  = 0;
        double rang_down_flow  = 0;
        private void SetChartCoord实时数据(double min_flow,double max_flow,double min_power,double max_power)
        {
            if (this.mainDiagram == null)
                return;
 
            var axis_time = this.mainDiagram.AxisX;
            axis_time.VisualRange.Auto = false;
            axis_time.WholeRange.Auto = false;
            axis_time.WholeRange.SideMarginsValue = 0;
            axis_time.VisualRange.SideMarginsValue = 0;
            axis_time.WholeRange.SetMinMaxValues(_startTime, _endTime);
            axis_time.VisualRange.SetMinMaxValues(_startTime, _endTime);
            axis_time.WholeRange.AlwaysShowZeroLevel = false;
 
 
 
            double coord_min_flow = 5000 * ((int)(min_flow / 5000 - 2));
            double coord_max_flow = 5000 * ((int)(max_flow / 5000 + 2));
            int coord_space_flow = (int)((coord_max_flow - coord_min_flow) / 1000) * 100;
            var coord_flows = new List<CustomAxisLabel>();
            double disp_flow = coord_min_flow;
            for (int i = 0; i < 20; i++)
            {
                coord_flows.Add(new CustomAxisLabel(disp_flow.ToString(), disp_flow));
                disp_flow = disp_flow + coord_space_flow;
                if (disp_flow > coord_max_flow)
                    break;
            }
            rang_up_flow = Convert.ToDouble(
                coord_flows[coord_flows.Count - 1].AxisValue);
            rang_down_flow = Convert.ToDouble(
                coord_flows[coord_flows.Count - 2].AxisValue);
            rang_down_flow = rang_up_flow + (rang_up_flow - rang_down_flow) / 3;
 
            double coord_min_power = 500 * ((int)(min_power / 500  ));
            double coord_max_power = 500 * ((int)(max_power / 500 + 2));
            int coord_space_power = (int)((coord_max_power - coord_min_power) / 10);
            List<CustomAxisLabel> coord_powers = new List<CustomAxisLabel>();
            double disp_power = coord_min_power;
            for (int i = 0; i < 20; i++)
            {
                coord_powers.Add(new CustomAxisLabel(disp_power.ToString(), disp_power));
                disp_power = disp_power + coord_space_power;
                if (disp_power > coord_max_power)
                    break;
            }
 
            int grid_num = Math.Max(coord_powers.Count, coord_flows.Count);
 
            List<CustomAxisLabel> coord_sw = new List<CustomAxisLabel>();
            for (int i = 0; i < grid_num; i++)
            {
                var h = i * 0.5;
                coord_sw.Add(new CustomAxisLabel(h.ToString(), h));
            }
 
 
 
            var axis_flow = this.mainDiagram.AxisY;
            axis_flow.CustomLabels.Clear(); 
            axis_flow.CustomLabels.AddRange(coord_flows.ToArray());
 
            axis_flow.NumericScaleOptions.AutoGrid = false;
            axis_flow.VisualRange.Auto = false;
            axis_flow.WholeRange.Auto = false;
            axis_flow.WholeRange.SideMarginsValue = 0;
            axis_flow.VisualRange.SideMarginsValue = 0;
            axis_flow.WholeRange.AutoSideMargins = false;
            axis_flow.VisualRange.AutoSideMargins = false;
            axis_flow.WholeRange.SetMinMaxValues(coord_min_flow, coord_min_flow + (grid_num - 1)* coord_space_flow);
            axis_flow.VisualRange.SetMinMaxValues(coord_min_flow, coord_min_flow + (grid_num - 1) * coord_space_flow);
            axis_flow.WholeRange.AlwaysShowZeroLevel = false;
 
     
 
 
 
            var axis_sw = mainDiagram.SecondaryAxesY.GetAxisByName("SecondarySW");
            axis_sw.CustomLabels.Clear();
            axis_sw.CustomLabels.AddRange(coord_sw.ToArray());
            axis_sw.VisualRange.Auto = false;
            axis_sw.WholeRange.Auto = false;
            axis_sw.WholeRange.SideMarginsValue = 0;
            axis_sw.VisualRange.SideMarginsValue = 0;
            axis_sw.WholeRange.AutoSideMargins = false;
            axis_sw.VisualRange.AutoSideMargins = false;
            axis_sw.WholeRange.SetMinMaxValues(0, 11);
            axis_sw.VisualRange.SetMinMaxValues(0, 11);
            axis_sw.WholeRange.AlwaysShowZeroLevel = false;
 
 
 
            var axis_power = mainDiagram.SecondaryAxesY.GetAxisByName("SecondaryGL");
            axis_power.CustomLabels.Clear();
            axis_power.CustomLabels.AddRange(coord_powers.ToArray());
 
            axis_power.NumericScaleOptions.AutoGrid = false; 
            axis_power.VisualRange.Auto = false;
            axis_power.WholeRange.Auto = false;
            axis_power.WholeRange.SideMarginsValue = 0;
            axis_power.VisualRange.SideMarginsValue = 0;
            axis_power.WholeRange.AutoSideMargins = false;
            axis_power.VisualRange.AutoSideMargins = false;
            axis_power.WholeRange.SetMinMaxValues(coord_min_power, coord_min_power + (grid_num - 1) * coord_space_power);
            axis_power.VisualRange.SetMinMaxValues(coord_min_power, coord_min_power + (grid_num - 1) * coord_space_power);
            axis_power.WholeRange.AlwaysShowZeroLevel = false;
        }
 
 
        #endregion
 
        #region 运行区间 Chart
 
        private object _rightClickObj = null;
        private bool _isMoveQueryLine = false;
        private Point _clickLocation;
        class SpanTimeBlock
        {
            public SpanTimeBlock(int pumpIndx, DateTime start, DateTime end)
            {
                this.PumpIndx = pumpIndx;
                this.Start = start;
                this.End = end;
            }
            public SpanTimeBlock(int pumpIndx, DateTime start, DateTime end, double flow, double power, double money)
            {
                this.PumpIndx = pumpIndx;
                this.Start = start;
                this.End = end;
                this.TotalFlow = flow;
                this.TotalPower = power;
                this.TotalMoney = money;
            }
            public int PumpIndx { get; set; }
            public DateTime Start { get; set; }
            public DateTime End { get; set; }
            public double TotalFlow { get; set; }
            public double TotalPower { get; set; }
            public double TotalMoney { get; set; }
        }
        public Action<IStation.CalcModel.AnaPrj> OnRefreshTimeSpan = null;
 
 
 
        AnimationTipInfoDlg _tipDlg = null;
        private void tabbedControlGroup1_CustomHeaderButtonClick(object sender,
            DevExpress.XtraTab.ViewInfo.CustomHeaderButtonEventArgs e)
        {
            if (e.Button.Tag == null)
                return;
            if (e.Button.Tag.ToString() == "Setting")
            {
                if (OnRefreshTimeSpan != null)
                {
                    OnRefreshTimeSpan.Invoke(this._anaPrj);
                }
            }
            if (e.Button.Tag.ToString() == "Export")
            {
                SaveFileDialog dlg = new SaveFileDialog();
                dlg.Title = "导出信息列表";
                dlg.FileName = "信息列表.xls";
                dlg.Filter = "excel文件 (*.xls)|*.xls";
                if (dlg.ShowDialog() == DialogResult.OK)
                    this.gridControl运行列表.ExportToXls(dlg.FileName);
            }
            if (e.Button.Tag.ToString() == "ViewTip")
            {
 
            }
            if (e.Button.Tag.ToString() == "Animation")
            {
                ShowChartTipWindow(true);
            }
        }
 
 
        bool _isDispAnimationTip = false;
        private void ShowChartTipWindow(bool isShow)
        {
            if (_tipDlg != null)
            {
                if (isShow)
                {
                    if (_isDispAnimationTip)
                        return;
                    _isDispAnimationTip = true;
 
                    _tipDlg.SetBindingData(this._anaPrj);
                    _tipDlg.SetRealTimeDataList(realTimeDataList);
                    _tipDlg.Show();
                }
                else
                {
                    _isDispAnimationTip = false;
                    _tipDlg.StopAnimation();
                    _tipDlg.Hide();
                }
                return;
            }
 
 
 
            _tipDlg = new AnimationTipInfoDlg();
              _tipDlg.TopMost = true;
            _tipDlg.Name = "AnimationTipInfoDlg";
            _tipDlg.WindowState = FormWindowState.Normal;
            _tipDlg.SetPumpInfo(this._allPumpInfo);
            _tipDlg.OnStopAnimation += () =>
            {
   
                _moveConstantLineIn实时数据.Visible = false;
            };
            _tipDlg.OnStartAnimation += () =>
            {
   
                _moveConstantLineIn实时数据.Visible = true;
            };
 
            _tipDlg.OnRefreshAnimation += (t, d) =>
            {
 
 
                _moveConstantLineIn实时数据.Title.Text = t.ToString("HH:mm");
                _moveConstantLineIn实时数据.AxisValueSerializable = t.ToString();
 
                //if (d == null || d.OpenPumpCount == 0)
                //    return;
                //chartPumpCurveParalCtrl1.SetPumpRun(d);
            };
 
            _isDispAnimationTip = true;
 
            _moveConstantLineIn实时数据.Title.Text = this._startTime.ToString("HH:mm");
            _moveConstantLineIn实时数据.AxisValueSerializable = this._startTime.ToString();
 
            _tipDlg.OnHide = () =>
            {
                _isDispAnimationTip = false;
                _tipDlg.Hide();
            };
            _tipDlg.SetRealTimeDataList(realTimeDataList);
            _tipDlg.SetBindingData(this._anaPrj);
            _tipDlg.Show();
        }
 
 
 
 
        #endregion
 
 
        #region Grid
        class CurrentGridViewModel
        {
            public string PumpName { get; set; }
 
            public double SumFlow { get; set; }//已经考虑时间段  (累计值)
            public double SumPower { get; set; }//已经考虑时间段 (累计值 度)
            public double SumMoney { get; set; }//已经考虑时间段 (累计值) 
            public double SpanTime { get; set; }
            public string StartTime { get; set; }
            public string EndTime { get; set; }
 
            public List<SubItem> SubItems { get; set; }
 
            public class SubItem
            {
                public string StartTime { get; set; }
                public string EndTime { get; set; }
                public double SpanTime { get; set; }
                public double SumFlow { get; set; }//已经考虑时间段  (累计值)
                public double SumPower { get; set; }//已经考虑时间段 (累计值 度)
                public double SumMoney { get; set; }//已经考虑时间段 (累计值) 
            }
 
            internal void Round()
            {
                this.SumFlow = Math.Round(this.SumFlow, 0);
                this.SumPower = Math.Round(this.SumPower, 0);
                this.SumMoney = Math.Round(this.SumMoney, 0);
            }
        }
   
        private void InitialGrid运行时间()
        {
            List<CurrentGridViewModel> gridBidings = new List<CurrentGridViewModel>();
 
 
 
            foreach (var item in this._anaPrj.BlockTimes)
            {
                List<SpanTimeBlock> openTimeSpan = new List<SpanTimeBlock>();
                List<SpanTimeBlock> closeTimeSpan = new List<SpanTimeBlock>();
 
                var pd = new CurrentGridViewModel();
                pd.PumpName = string.Format("{0}台泵", item.OpenPumpCount);
 
 
                pd.StartTime = item.StartTime.ToString("HH:mm");
                pd.EndTime = item.EndTime.ToString("HH:mm");
                pd.SpanTime = Math.Round((item.EndTime - item.StartTime).TotalMinutes, 0);
 
 
          
                    pd.SumFlow  = item.SumFlow;
                    pd.SumPower  = item.SumPower;
                    pd.SumMoney  = item.SumMoney;
                
 
                pd.Round();
 
                gridBidings.Add(pd);
            }
 
            this.bindingSourceGrid.DataSource = gridBidings;
 
        }
 
        private void GridViewMain_RowClick(object sender, RowClickEventArgs e)
        {
            if (e.RowHandle < 0) return;
 
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                //gridViewPrj = gridViewMain.GetRow(e.RowHandle) as AnaPrj;
                contextMenuGrid.Show(gridControl运行列表, e.Location);
            }
            else
            {
                //SetRibbonButtonDisp(SPump.WinFrmUI.SeriesTreeView.eNodeLevel.Pump);
            }
        }
 
        private void MenuItemGrid切换模式_Click(object sender, EventArgs e)
        {
            //if (MenuItemGrid切换模式.Text == "切换成时间段显示")
            //{
            //    _gridDispStyle = 1;
            //    MenuItemGrid切换模式.Text = "切换成泵分组显示";
            //    InitialGrid运行时间();
            //}
            //else
            //{
            //    _gridDispStyle = 0;
            //    MenuItemGrid切换模式.Text = "切换成时间段显示";
            //    InitialGrid运行时间();
            //}
        }
        #endregion
 
 
 
        private void ChartControl实时数据_CustomPaint(object sender, CustomPaintEventArgs e)
        {
            if(_anaPrj == null || mainDiagram == null) return;
            Graphics g = e.Graphics;
            //g.SetClip(CalculateDiagramBounds());
            g.SmoothingMode = SmoothingMode.AntiAlias;
           
            {
                foreach (var item in this._anaPrj.BlockTimes)
                {
                    if (  item.OpenPumpCount <= 0) continue;
 
                    var pump_count = item.OpenPumpCount;
 
                    using (Font font = new Font("黑体",   9,   FontStyle.Italic))
                    using (SolidBrush brushText = new SolidBrush(Color.Black))
                    using (SolidBrush brush = new SolidBrush(PumpCountColorHelper.GetColor(pump_count)  ))
                    {
                        //  
                        var pt1 = mainDiagram.DiagramToPoint(item.StartTime,  rang_down_flow);
                        var pt2 = mainDiagram.DiagramToPoint(item.EndTime, rang_up_flow);
                        g.FillRectangle(brush, pt1.Point.X, pt1.Point.Y,
                            Math.Abs(pt1.Point.X - pt2.Point.X), Math.Abs(pt1.Point.Y - pt2.Point.Y));
                        g.DrawString(string.Format("{0}台", pump_count), font, brushText,
                            new Point(pt1.Point.X, pt1.Point.Y+3));
                    }
                }
            }
 
        }
 
        private void tabbedControlGroup2_CustomHeaderButtonClick(object sender, DevExpress.XtraTab.ViewInfo.CustomHeaderButtonEventArgs e)
        {
            if (chartControl实时数据.Legend.Visibility == DevExpress.Utils.DefaultBoolean.True)
            {
                chartControl实时数据.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
                chartControl累计数据.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
            }
            else
            {
                chartControl实时数据.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
                chartControl累计数据.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
            }
 
        }
    }
}