コード例 #1
0
ファイル: ComboBoxEx.cs プロジェクト: git-thinh/limada
        protected virtual void DrawShape(Graphics g, Rectangle bounds, int index, DrawItemState state)
        {
            if (index != -1)
            {
                var shape = this.Items[index] as Xwt.Drawing.Image;
                if (shape != null)
                {
                    var color = state.HasFlag(DrawItemState.Selected) ? SystemColors.Highlight : BackColor;
                    using (var b = new SolidBrush(color)) {
                        g.FillRectangle(b, bounds);
                    }
                    if (state.HasFlag(DrawItemState.ComboBoxEdit))
                    {
                        bounds.Inflate(-5, -3);
                    }
                    else
                    {
                        bounds.Inflate(-5, -3);
                    }
                    g.SmoothingMode = SmoothingMode.AntiAlias;

                    var location = bounds.Location.ToXwt();
                    var size     = bounds.Size.ToXwt();
                    var surface  = new GdiSurface()
                    {
                        Graphics = g
                    };
                    surface.Context.SetColor(color.ToXwt());
                    surface.Context.DrawImage(shape, location, 1);
                }
            }
        }