private void _btnAddReceiver_Click(Object sender, EventArgs e)
        {
            var item = new EmailReceiverItem();

            item.ReceiverName         = "请填写";
            item.ReceiverEmailAddress = "请填写";
            this._listReceiverItems.AddEmailReceiverItem(item);
            this._listReceiverItems.SelectedIndex = this._listReceiverItems.Items.Count - 1;
        }
Ejemplo n.º 2
0
        private void CustomDrawItem(Object sender, DrawItemEventArgs e)
        {
            if (e.Index == -1 || this.DesignMode)
            {
                return;
            }
            var obj = this.Items[e.Index];
            EmailReceiverItem receiverInfo = obj as EmailReceiverItem;

            if (receiverInfo == null)
            {
                return;
            }
            var g = e.Graphics;

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            var   forceColor      = e.ForeColor;
            var   backgroundColor = e.BackColor;
            Int32 textBeginX      = 5;
            Int32 textBeginY      = 3;

            var backgroudRect      = new Rectangle(e.Bounds.X - 1, e.Bounds.Y - 1, e.Bounds.Width + 1, e.Bounds.Height + 2);
            var attachmentFlagRect = new Rectangle(5, 5, 20, 20);

            if (this.MouseHoverItemIndex == e.Index)
            {
                backgroundColor = Color.FromArgb(190, 190, 190);
            }
            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                backgroundColor = Color.FromArgb(175, 175, 175);
            }
            Brush backBrush = new SolidBrush(backgroundColor);

            g.FillRectangle(backBrush, backgroudRect);

            var nameRect = new Rectangle(textBeginX, textBeginY, e.Bounds.Width - textBeginX, e.Bounds.Height);

            //绘制接收人名称
            TextRenderer.DrawText(g, receiverInfo.ReceiverName, e.Font, nameRect, e.ForeColor, TextFormatFlags.EndEllipsis);
            //计算名称占用大小
            var nameDrawSize = TextRenderer.MeasureText(receiverInfo.ReceiverName, e.Font);

            textBeginX += nameDrawSize.Width;
            //间隔
            textBeginX += 20;
            var addressRect = new Rectangle(textBeginX, textBeginY, e.Bounds.Width - textBeginX, e.Bounds.Height);

            //绘制接收人邮件地址
            TextRenderer.DrawText(g, receiverInfo.ReceiverEmailAddress, e.Font, addressRect, e.ForeColor, TextFormatFlags.EndEllipsis);
        }
Ejemplo n.º 3
0
 public void AddEmailReceiverItem(EmailReceiverItem info)
 {
     this.EmailReceiverItems.Add(info);
     this.Items.Add(info);
     this.Refresh();
 }