Beispiel #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;
        }
Beispiel #2
0
        static void OnExposed(object o, ExposeEventArgs args)
        {
            if (Graphics.DrawingThread.IsAlive)
            {
                Graphics.DrawingThread.Join();
            }

            Gdk.Threads.Enter();

            Gtk.DrawingArea area = (DrawingArea)o;
            Gdk.Window      win  = area.GdkWindow;
            Gdk.GC          gc   = new Gdk.GC(win);
            //Cairo.Context g = CairoHelper.Create(win);

            win.DrawDrawable(gc, Graphics.Pixmap, 0, 0, 0, 0, Globals.WIDTH, Globals.HEIGHT);

            //((IDisposable)g.Target).Dispose();
            //((IDisposable)g).Dispose();

            Gdk.Threads.Leave();
        }