Esempio n. 1
0
        protected override bool OnExposeEvent(Gdk.EventExpose args)
        {
            using (var g = Gdk.CairoHelper.Create(args.Window)) {
                g.SetSourceRGBA(1, 1, 1, 0);
                g.Operator = Cairo.Operator.Source;
                g.Paint();
            }
            Cairo.Color bgColor         = new Cairo.Color(1, 1, 1);
            Cairo.Color titleBgColor    = new Cairo.Color(0.88, 0.88, 0.98);
            Cairo.Color categoryBgColor = new Cairo.Color(0.58, 0.58, 0.98);
            Cairo.Color borderColor     = new Cairo.Color(0.4, 0.4, 0.6);
            Cairo.Color textColor       = new Cairo.Color(0.3, 0.3, 1);
            Cairo.Color gridColor       = new Cairo.Color(0.8, 0.8, 0.8);

            using (var g = Gdk.CairoHelper.Create(args.Window)) {
                g.LineWidth = 1;

                Gdk.GC gc = new Gdk.GC(args.Window);
                layout.SetMarkup(TitleText);
                int width, height;
                layout.GetPixelSize(out width, out height);
                width += xBorder * 2;
                FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, true, false, 0.5, 0.5, height + yBorder * 2 + 1.5, width, height + yBorder * 2);
                g.Color = titleBgColor;
                g.FillPreserve();
                g.Color = borderColor;
                g.Stroke();
                gc.RgbFgColor = (HslColor)textColor;
                args.Window.DrawLayout(gc, xBorder, yBorder, layout);

                FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, false, true, 0.5, height * 2 + yBorder * 2 + 0.5, height, Allocation.Width - 1, Allocation.Height - height * 2 - yBorder * 2 - 1);
                g.Color = bgColor;
                g.FillPreserve();
                g.Color = borderColor;
                g.Stroke();



                g.MoveTo(xSpacer + 0.5, height * 2 + yBorder * 2);
                g.LineTo(xSpacer + 0.5, Allocation.Height - 1);
                g.Color = gridColor;
                g.Stroke();

                int y = height + yBorder * 2;

                for (int i = 0; i < Items.Count; i++)
                {
                    KeyValuePair <string, string> pair = Items[i];

                    layout.SetMarkup(pair.Key);
                    layout.GetPixelSize(out width, out height);

                    if (i == 0)
                    {
                        FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, false, true, false, false, 0, y + 0.5, height + 1.5, Allocation.Width, height);
                        g.Color = categoryBgColor;
                        g.FillPreserve();
                        g.Color = borderColor;
                        g.Stroke();

                        g.MoveTo(xSpacer + 0.5, height + yBorder * 2 + 1);
                        g.LineTo(xSpacer + 0.5, height * 2 + yBorder * 2 + 1);
                        g.Color = gridColor;
                        g.Stroke();
                    }

                    gc.RgbFgColor = (HslColor)(i == 0 ? bgColor : textColor);

                    args.Window.DrawLayout(gc, xBorder, y, layout);
                    layout.SetMarkup(pair.Value);
                    args.Window.DrawLayout(gc, xSpacer + xBorder, y, layout);

                    // draw top line
                    if (i > 0)
                    {
                        g.MoveTo(1, y + 0.5);
                        g.LineTo(Allocation.Width - 1, y + 0.5);
                        g.Color = gridColor;
                        g.Stroke();
                    }
                    y += height;
                }
                gc.Dispose();
            }

            GtkWorkarounds.UpdateNativeShadow(this);
            return(false);
        }