Пример #1
0
        public BDeviceChart(DateTime start, DateTime stop, BeamCutDevice device)
        {
            InitializeComponent();
            Device = device;
            MachineTimeLineForm = new MachineTimeLine();

            ZedGraphControl.GraphPane.Title.Text = $"Device: {Device.Name}";
            ZedGraphControl.MouseDoubleClick    += ZedGraphControl_MouseDoubleClick;
            ZedGraphControl.IsShowPointValues    = true;

            ZedGraphControl.GraphPane.XAxis.Title.Text = "Date";
            ZedGraphControl.GraphPane.YAxis.Title.Text = "Cut quantity (ps), Cut times (t)";

            var RecordList = BeamCutQuery.GetBDeviceStatistic(start, stop, device);

            if (RecordList == null)
            {
                return;
            }

            var pane = ZedGraphControl.GraphPane;

            pane.XAxis.MajorGrid.DashOn = 2.0F;
            pane.XAxis.MajorGrid.Color  = System.Drawing.Color.LightGray;
            pane.YAxis.MajorGrid.DashOn = 2.0F;
            pane.YAxis.MajorGrid.Color  = System.Drawing.Color.LightGray;

            pane.XAxis.Scale.IsVisible = true;
            pane.YAxis.Scale.IsVisible = true;

            pane.XAxis.MajorGrid.IsVisible = true;
            pane.YAxis.MajorGrid.IsVisible = true;


            //var pointsCurve;
            pane.XAxis.Scale.TextLabels = RecordList.Select(i => i.Date).ToArray();
            pane.XAxis.Type             = ZedGraph.AxisType.Text;

            LineItem CutQuantity = pane.AddCurve("Quantity", null, RecordList.Select(i => (double)i.TotalCutQty).ToArray(), System.Drawing.Color.DarkRed);
            LineItem CutTimes    = pane.AddCurve("Cut Times", null, RecordList.Select(i => (double)i.TotalCuttime).ToArray(), System.Drawing.Color.Blue);

            CutQuantity.Line.IsVisible = true;
            CutQuantity.Line.Width     = 1.0F;
            //Create your own scale of colors.

            CutQuantity.Symbol.Fill             = new Fill(new System.Drawing.Color[] { System.Drawing.Color.Blue, System.Drawing.Color.Green, System.Drawing.Color.Red });
            CutQuantity.Symbol.Fill.Type        = FillType.Solid;
            CutQuantity.Symbol.Type             = SymbolType.Circle;
            CutQuantity.Symbol.Border.IsVisible = true;

            CutTimes.Line.IsVisible          = true;
            CutTimes.Line.Width              = 1.0F;
            CutTimes.Symbol.Fill             = new Fill(new System.Drawing.Color[] { System.Drawing.Color.Black, System.Drawing.Color.Black, System.Drawing.Color.Black });
            CutTimes.Symbol.Fill.Type        = FillType.Solid;
            CutTimes.Symbol.Type             = SymbolType.Diamond;
            CutTimes.Symbol.Border.IsVisible = true;

            for (int i = 0; i < CutQuantity.Points.Count; i++)
            {
                var    pt   = CutQuantity.Points[i];
                string date = ZedGraphControl.GraphPane.XAxis.Scale.TextLabels[i];

                TextObj text1 = new TextObj(
                    $"{pt.Y}", pt.X, pt.Y + 0.1,
                    CoordType.AxisXYScale, AlignH.Left, AlignV.Top);
                text1.ZOrder         = ZOrder.A_InFront;
                text1.FontSpec.Angle = 0;

                pane.GraphObjList.Add(text1);

                pt = CutTimes.Points[i];
                TextObj text2 = new TextObj(
                    $"{pt.Y}", pt.X, pt.Y + 0.1,
                    CoordType.AxisXYScale, AlignH.Left, AlignV.Center);
                text2.ZOrder         = ZOrder.A_InFront;
                text2.FontSpec.Angle = 0;
                pane.GraphObjList.Add(text2);
            }

            pane.AxisChange();
            ZedGraphControl.Refresh();
            this.Controls.Add(ZedGraphControl);
            ZedGraphControl.Dock = DockStyle.Fill;
            ZedGraphControl.BringToFront();
        }