-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathConversationListBox.cs
69 lines (64 loc) · 2.36 KB
/
ConversationListBox.cs
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
using System;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace DigiRite
{
class ConversationListBox : ListBox
{ /* Custom draw the ConverstationHistory list box. */
protected override void OnDrawItem(DrawItemEventArgs e)
{
if ((e.Index >= 0) && (e.Index < Items.Count))
{
ListBoxConversationItem lbci = Items[e.Index] as ListBoxConversationItem;
if (null != lbci)
{
string t = lbci.ToString();
Color backColor = BackColor;
switch (lbci.origin)
{
case Conversation.Origin.INITIATE:
backColor = Color.PaleGreen;
break;
case Conversation.Origin.TO_ME:
backColor = Color.Pink;
break;
case Conversation.Origin.TO_OTHER:
backColor = Color.White;
break;
case Conversation.Origin.TRANSMIT:
backColor = Color.Yellow;
break;
case Conversation.Origin.TRANSMIT_REDUCED:
backColor = Color.LightGoldenrodYellow;
break;
default:
break;
}
using (SolidBrush sb = new SolidBrush(backColor))
e.Graphics.FillRectangle(sb, e.Bounds);
using (SolidBrush sb = new SolidBrush(e.ForeColor))
e.Graphics.DrawString(t, Font, sb, e.Bounds.Left, e.Bounds.Top);
e.DrawFocusRectangle();
return;
}
}
base.OnDrawItem(e);
}
}
public static class Conversation
{ public enum Origin { TRANSMIT, TRANSMIT_REDUCED, TO_ME, TO_OTHER, INITIATE }; }
class ListBoxConversationItem
{
string s;
public Conversation.Origin origin;
public ListBoxConversationItem(string s, Conversation.Origin o)
{
this.s = s;
origin = o;
}
public override string ToString()
{ return s;}
}
}