コード例 #1
0
ファイル: xxxForm1Backup.cs プロジェクト: AndyZap/EspMod
        public void PlotDataRec(GraphPainter gp, DataStruct ds)
        {
            if (gp == GraphBot)
            {
                labelBotL.Text = "";
                labelBotR.Text = "";
            }
            else if (gp == GraphTop)
            {
                labelTopL.Text = "";
                labelTopR.Text = "";
            }

            gp.SetAxisTitles("", "");

            gp.data.Clear();

            gp.SetData(0, ds.elapsed, ds.flow_goal, Color.Blue, 2, DashStyle.Dash);
            gp.SetData(1, ds.elapsed, ds.pressure_goal, Color.LimeGreen, 2, DashStyle.Dash);

            gp.SetData(2, ds.elapsed, ds.flow, Color.Blue, 3, DashStyle.Solid);
            gp.SetData(3, ds.elapsed, ds.pressure, Color.LimeGreen, 3, DashStyle.Solid);

            gp.SetData(4, ds.elapsed, ds.flow_weight, Color.Brown, 3, DashStyle.Solid);

            List <double> temperature_scaled        = new List <double>();
            List <double> temperature_target_scaled = new List <double>();

            foreach (var t in ds.temperature_basket)
            {
                temperature_scaled.Add(t / 10.0);
            }
            foreach (var t in ds.temperature_goal)
            {
                temperature_target_scaled.Add(t / 10.0);
            }

            gp.SetData(5, ds.elapsed, temperature_target_scaled, Color.Red, 2, DashStyle.Dash);
            gp.SetData(6, ds.elapsed, temperature_scaled, Color.Red, 3, DashStyle.Solid);

            var           pi   = ds.getPreinfTime();
            List <double> x_pi = new List <double>(); x_pi.Add(pi); x_pi.Add(pi);
            List <double> y_pi = new List <double>(); y_pi.Add(0); y_pi.Add(1);

            gp.SetData(7, x_pi, y_pi, Color.Brown, 2, DashStyle.Solid);

            gp.SetAutoLimits();

            gp.panel.Refresh();
        }
コード例 #2
0
ファイル: xxxForm1Backup.cs プロジェクト: AndyZap/EspMod
        private void listData_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0 || e.Index >= listData.Items.Count)
            {
                return;
            }

            string key = (string)listData.Items[e.Index];

            if (!Data.ContainsKey(key))
            {
                return;
            }

            DataStruct d = Data[key];

            Brush myBrush = Brushes.Black;

            if (e.Index % 2 == 0)
            {
                var brush = new SolidBrush(Color.FromArgb(255, 240, 240, 240));
                e.Graphics.FillRectangle(brush, e.Bounds);
            }
            else
            {
                e.Graphics.FillRectangle(Brushes.White, e.Bounds);
            }

            Rectangle myrec = e.Bounds;

            // plot color bar.  blue is the current one, RefPlotKey is red
            myrec.X = labHasPlot.Left + 2; myrec.Width = labHasPlot.Width - 5;
            if (listData.GetSelected(e.Index))
            {
                e.Graphics.FillRectangle(Brushes.Blue, myrec);
            }
            else
            {
                e.Graphics.FillRectangle(key == RefPlotKey ? Brushes.Red : Brushes.White, myrec);
            }

            // Text. Move the text a bit down
            myrec.Y += 2;

            myrec.X = labName.Left; myrec.Width = labName.Width;
            e.Graphics.DrawString(d.name, e.Font, myBrush, myrec, StringFormat.GenericTypographic);

            myrec.X = labProfile.Left; myrec.Width = labProfile.Width;
            e.Graphics.DrawString(d.profile, e.Font, myBrush, myrec, StringFormat.GenericTypographic);

            myrec.X = labGrind.Left; myrec.Width = labGrind.Width;
            e.Graphics.DrawString(d.grind, e.Font, myBrush, myrec, StringFormat.GenericTypographic);

            myrec.X = labBeanWeight.Left; myrec.Width = labBeanWeight.Width;
            e.Graphics.DrawString(d.bean_weight.ToString("0.0"), e.Font, myBrush, myrec, StringFormat.GenericTypographic);


            myrec.X = labRatio.Left; myrec.Width = labRatio.Width;
            e.Graphics.DrawString(d.getRatio().ToString("0.0"), e.Font, myBrush, myrec, StringFormat.GenericTypographic);

            myrec.X = labAvFlow.Left; myrec.Width = labAvFlow.Width;
            e.Graphics.DrawString(d.getAverageWeightFlow().ToString("0.0"), e.Font, myBrush, myrec, StringFormat.GenericTypographic);

            myrec.X = labPI.Left; myrec.Width = labPI.Width;
            e.Graphics.DrawString(d.getPreinfTime().ToString("0"), e.Font, myBrush, myrec, StringFormat.GenericTypographic);

            myrec.X = labDate.Left; myrec.Width = labDate.Width;
            e.Graphics.DrawString(d.getNiceDateStr(DateTime.Now), e.Font, myBrush, myrec, StringFormat.GenericTypographic);

            myrec.X = labVideo.Left; myrec.Width = labVideo.Width;
            e.Graphics.DrawString(d.has_video ? "v": "", e.Font, myBrush, myrec, StringFormat.GenericTypographic);

            if (checkShowNotes.Checked)
            {
                if (d.notes != "") // notes, on a separate line
                {
                    myrec.X  = labGrind.Left + 5; myrec.Width = e.Bounds.Width - labName.Left - 10;
                    myrec.Y += e.Bounds.Height / 2;

                    var notes_str = TrimStringToDraw(d.notes, e.Graphics, e.Font, myrec.Width);
                    if (notes_str.StartsWith("*"))
                    {
                        myrec.X -= 20;
                    }

                    Font font1 = new Font(e.Font.FontFamily, (float)(e.Font.Size * 0.7), FontStyle.Regular);
                    e.Graphics.DrawString(notes_str, font1, myBrush, myrec, StringFormat.GenericTypographic);
                }
            }
        }