示例#1
0
        protected virtual void OnViewExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            Gdk.Window win = args.Event.Window;

            // Draw the window border
            win.DrawRectangle(darkgc, false, 0, 0, dimensions + 1, dimensions + 1);

            if (arena != null)
            {
                const int d = Constants.ARENA_SIZE;

                // Clear the pixmap
                view_pixmap.DrawRectangle(whitegc, true, 0, 0, d, d);
                arena.draw(view_graphics);

                if (scaling_ == ScalingMode.None)
                {
                    win.DrawDrawable(whitegc, view_pixmap, 0, 0, 1, 1, d, d);
                }
                else
                {
                    Gdk.Pixbuf pb = Gdk.Pixbuf.FromDrawable(view_pixmap, win.Screen.DefaultColormap,
                                                            0, 0, 0, 0, d, d);

                    Gdk.Pixbuf spb = null;
                    switch (scaling_)
                    {
                    case ScalingMode.Nearest2x:
                    case ScalingMode.Nearest3x:
                        spb = pb.ScaleSimple(dimensions, dimensions, Gdk.InterpType.Nearest);
                        break;

                    case ScalingMode.Bilinear2x:
                    case ScalingMode.Bilinear3x:
                        spb = pb.ScaleSimple(dimensions, dimensions, Gdk.InterpType.Bilinear);
                        break;
                    }

                    win.DrawPixbuf(whitegc, spb, 0, 0, 1, 1, dimensions, dimensions,
                                   Gdk.RgbDither.None, 0, 0);
                }
            }

            args.RetVal = true;
        }