コード例 #1
0
        void Draw()
        {
            if (pixmap == null)
            {
                return;
            }

            Style     style = Style;
            StateType state = Sensitive ? StateType.Normal : StateType.Insensitive;

            if (width <= 0 || height <= 0)
            {
                return;
            }

            //clear the pixmap
            GtkBeans.Style.PaintFlatBox(style, pixmap, StateType.Normal, ShadowType.None, null, this, "curve_bg", 0, 0, Allocation.Width, Allocation.Height);

            //draw the grid lines
            for (int i = 0; i < 5; i++)
            {
                pixmap.DrawLine(style.DarkGC(state),
                                x_offset,
                                i * (int)(height / 4.0) + y_offset,
                                width + x_offset,
                                i * (int)(height / 4.0) + y_offset);
                pixmap.DrawLine(style.DarkGC(state),
                                i * (int)(width / 4.0) + x_offset,
                                y_offset,
                                i * (int)(width / 4.0) + x_offset,
                                height + y_offset);
            }

            //draw the curve
            pixmap.DrawPoints(style.ForegroundGC(state), Interpolate(width, height));

            //draw the bullets
            if (CurveType != CurveType.Free)
            {
                foreach (var keyval in points)
                {
                    if (keyval.Key < MinX)
                    {
                        continue;
                    }
                    int x = Project(keyval.Key, MinX, MaxX, width);
                    int y = height - Project(keyval.Value, MinY, MaxY, height);
                    pixmap.DrawArc(style.ForegroundGC(state), true, x, y, radius * 2, radius * 2, 0, 360 * 64);
                }
            }
            GdkWindow.DrawDrawable(style.ForegroundGC(state), pixmap, 0, 0, 0, 0, Allocation.Width, Allocation.Height);
        }