コード例 #1
0
ファイル: SearchResultsList.cs プロジェクト: vijeetgv/GCAL
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
        {
            CELSearch.Results res = listBox1.Items[e.Index] as CELSearch.Results;

            e.DrawBackground();
            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                e.Graphics.FillRectangle(Brushes.LightYellow, e.Bounds);
            }


            PointF pt = new PointF(e.Bounds.Left + 4, e.Bounds.Top + 4);

            e.Graphics.DrawString(res.Title, boldFont, Brushes.Black, pt, StringFormat.GenericDefault);
            SizeF siz;

            pt.Y += boldFont.Height;
            e.Graphics.DrawString(res.Type, typeFont, Brushes.Blue, pt);
            pt.Y += typeFont.Height + 2;
            PointF curr = new PointF(pt.X, pt.Y);

            foreach (CELSearch.ResultsLine line in res.Lines)
            {
                siz = e.Graphics.MeasureString(line.Prefix, normalFont);
                e.Graphics.DrawString(line.Prefix, normalFont, Brushes.Black, curr);
                curr.X += siz.Width;
                siz     = e.Graphics.MeasureString(line.Term, normalFont);
                e.Graphics.FillRectangle(Brushes.LightGreen, curr.X, curr.Y, siz.Width, siz.Height);
                e.Graphics.DrawString(line.Term, normalFont, Brushes.Black, curr);
                curr.X += siz.Width - 2;
                siz     = e.Graphics.MeasureString(line.Postfix, normalFont);
                e.Graphics.DrawString(line.Postfix, normalFont, Brushes.Black, curr);
                curr.X  = pt.X;
                curr.Y += normalFont.Height + 1;
            }
        }
コード例 #2
0
ファイル: SearchResultsList.cs プロジェクト: vijeetgv/GCAL
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void listBox1_MeasureItem(object sender, MeasureItemEventArgs e)
 {
     CELSearch.Results res = listBox1.Items[e.Index] as CELSearch.Results;
     e.ItemHeight = 6 + boldFont.Height + (normalFont.Height + 1) * res.Lines.Count + typeFont.Height;
 }