Esempio n. 1
0
        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);
                }
            }
        }