Пример #1
0
        public void Paint(Window dest, bool fillBg)
        {
            // TestProgram.TestSomething3(this, dest, fillBg);
            // TestProgram.TestSomething4(this, dest, fillBg);
            //#if WIN32
            //        wxBufferedPaintDC   dc(dest);
            //#else
            //      ClientDC dc = new ClientDC(dest);
            //#endif

            //      dest.PrepareDC(dc);
            //      BufferedDC wdc = new BufferedDC(dc, m_pixmap);

            // Erik's (temporary) patch

            PaintDC  dc2 = new PaintDC(dest);
            MemoryDC mDC = new MemoryDC();

            wx.Bitmap bitmap = GlobalVariables.current_grid.m_pixmap;
            mDC.SelectObject(bitmap);
            dc2.DrawBitmap(bitmap, 0, 0, true);
            // mDC.DrawRectangle(10, 10, 100, 100);
            mDC.SelectObject(wx.Bitmap.NullBitmap);

            dc2.DrawBitmap(bitmap, 30, 30);

            mDC.Dispose();
            dc2.Dispose(); //needed
        }
Пример #2
0
        public grid(Window parent, int width, int height)
        {
            m_pixmap = new wx.Bitmap(width, height);
            m_parent = parent;
            m_dc     = new MemoryDC();

            m_hmult = 1;
            m_vmult = 1;

            m_xBase = 0;
            m_yBase = 0;
        }
Пример #3
0
        public void OnPaint(object sender, Event evt)
        {
            using (MemoryDC dc = new MemoryDC()) {
                wx.Bitmap m_pixmap = new wx.Bitmap(100, 100);

                dc.SelectObject(m_pixmap);
                // Erik: Test code
                dc.Pen = new wx.Pen(wx.Colour.wxGREEN, 100);
                dc.DrawLine(0, 0, 1000, 1000);
                dc.SelectObject(wx.Bitmap.NullBitmap);
            }
        }
Пример #4
0
        public static void TestSomething2()
        {
#if true
            ClientDC dc  = new ClientDC(GlobalVariables.field_grid.m_parent);
            Pen      pen = new Pen(new Colour(0xF0, 0x00, 0x00), 1); // red pen of width 1
            dc.Background     = new Brush(new Colour(0x00, 0x00, 0xFF));
            dc.BackgroundMode = DCBackgroundMode.SOLID;
            dc.Clear();
            dc.SetPen(pen);
            dc.DrawPoint(10, 10);
            dc.DrawRectangle(2, 2, 100, 100);
            // dc.SetPen(wx.Pen.null);
            dc.Dispose();
            return;
#endif

            grid g;
            g = GlobalVariables.field_grid;
#if true
            g.m_parent.BackgroundStyle  = BackgroundStyle.wxBG_STYLE_COLOUR;
            g.m_parent.BackgroundColour = new Colour(0x00, 0x80, 0x00);
#endif

#if true
            g.m_pixmap = new Bitmap(500, 500);
            MemoryDC mDC    = new MemoryDC();
            Bitmap   bitmap = g.m_pixmap;
            mDC.SelectObject(bitmap);
            // dc.DrawBitmap(bitmap, 0, 0, true);
            mDC.SetBrush(new Brush(new Colour(0xFF, 0x00, 0x00)));
            mDC.DrawRectangle(10, 10, 100, 100);
            mDC.SelectObject(Bitmap.NullBitmap);
            // dc.DrawBitmap(bitmap, 30, 30);
            mDC.Dispose();
#endif
            ClientDC       clientDC = new ClientDC(g.m_parent);
            ScrolledWindow w        = (ScrolledWindow)g.m_parent;
            w.PrepareDC(clientDC);
            BufferedDC wdc = new BufferedDC(clientDC, g.m_pixmap);


#if true
            wdc.DrawBitmap(bitmap, 10, 10);

            wdc.Dispose();
            wdc = null;
#endif
        }
Пример #5
0
        public void OnPaint(object sender, Event e)
        {
            PaintDC dc = new PaintDC(this);

            dc.Font           = font;
            dc.TextForeground = textColour;
            dc.BackgroundMode = DCBackgroundMode.TRANSPARENT;

            dc.BackgroundMode = DCBackgroundMode.SOLID;
            dc.Background     = new Brush(new Colour(0x80, 0, 0));
            dc.Clear();

            dc.DrawText("wxWidgets common dialogs test application", 10, 10);

            Image img;

            // img = new Image(50, 50);
            img = GlobalFunctions.get_pixmap(GlobalVariables.itin_xpm);

            List <byte>   list    = new List <byte>();
            ASCIIEncoding encoder = new ASCIIEncoding();

            byte[] terminator = new byte[] { 0x10, 0x13 };
            list.Clear();
            list.AddRange(encoder.GetBytes("/* XPM */")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("static char * plaid[] = {")); list.AddRange(terminator);
//      list.AddRange(encoder.GetBytes("/* plaid pixmap ")); list.AddRange(terminator);
//      list.AddRange(encoder.GetBytes(" * width height ncolors chars_per_pixel */")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"22 22 5 2\",")); list.AddRange(terminator);
//      list.AddRange(encoder.GetBytes("/* colors */")); list.AddRange(terminator);
#if false
            list.AddRange(encoder.GetBytes("\".  c red       m white  s light_color \",")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"Y  c green     m black  s lines_in_mix \",")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"+  c yellow    m white  s lines_in_dark \",")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"x              m black  s dark_color \",")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"   c none               s mask \",")); list.AddRange(terminator);
#else
            list.AddRange(encoder.GetBytes("\".      c lightgray\",")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"Y      c #000000000000\",")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"+      c #000000000000\",")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"x      c #000000000000\",")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"       c #000000000000\",")); list.AddRange(terminator);
#endif
//      list.AddRange(encoder.GetBytes("/* pixels */")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"                      x x x x x + x x x x x \", ")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"                    . x x x x x x x x x x x \", ")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"                  . x x x x x x + x x x x x \", ")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"                . x . x x x x x x x x x x x \", ")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"              . x . x x x x x x + x x x x x \", ")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"            Y Y Y Y Y + x + x + x + x + x + \", ")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"          x x . x . x x x x x x + x x x x x \", ")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"        . x . x . x . x x x x x x x x x x x \", ")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"      . x x x . x . x x x x x x + x x x x x \", ")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"    . x . x . x . x . x x x x x x x x x x x \", ")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"  . x . x x x . x . x x x x x x + x x x x x \", ")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\". . . . . x . . . . . x . x . x Y x . x . x \", ")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\". . . . . x . . . . . . x . x . Y . x . x . \",")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\". . . . . x . . . . . x . x . x Y x . x . x \", ")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\". . . . . x . . . . . . x . x . Y . x . x . \", ")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\". . . . . x . . . . . x . x . x Y x . x . x \", ")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\"x x x x x x x x x x x x x x x x x x x x x x \", ")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\". . . . . x . . . . . x . x . x Y x . x . x \", ")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\". . . . . x . . . . . . x . x . Y . x . x . \", ")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\". . . . . x . . . . . x . x . x Y x . x . x \", ")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\". . . . . x . . . . . . x . x . Y . x . x . \", ")); list.AddRange(terminator);
            list.AddRange(encoder.GetBytes("\". . . . . x . . . . . x . x . x Y x . x . x \"")); list.AddRange(terminator);

            byte[] data      = list.ToArray();
            string debugData = encoder.GetString(data);
            img = new Image(data, BitmapType.wxBITMAP_TYPE_XPM);

            img = ConvertFormat(GlobalVariables.itin_xpm);


            MemoryDC mDC    = new MemoryDC();
            Bitmap   bitmap = new Bitmap(img, -1);
            bitmap = GlobalVariables.current_grid.m_pixmap;
            mDC.SelectObject(bitmap);
            dc.DrawBitmap(bitmap, 0, 0, true);
            // mDC.DrawRectangle(10, 10, 100, 100);
            mDC.SelectObject(Bitmap.NullBitmap);

            dc.DrawBitmap(bitmap, 30, 30);



            mDC.Dispose();
            dc.Dispose(); //needed
        }
Пример #6
0
        public static void TestSomething4(grid grid, Window dest, bool fillBg)
        {
            PaintDC dc2 = new PaintDC(dest);

            dc2.BackgroundMode = DCBackgroundMode.SOLID;
            dc2.Background     = new Brush(new Colour(0x80, 0, 0));
            dc2.Clear();

#if false
            MemoryDC mDC    = new MemoryDC();
            Bitmap   bitmap = null; // new Bitmap(img, -1);
            bitmap = GlobalVariables.current_grid.m_pixmap;
            mDC.SelectObject(bitmap);
            dc2.DrawBitmap(bitmap, 0, 0, true);
            // mDC.DrawRectangle(10, 10, 100, 100);
            mDC.SelectObject(Bitmap.NullBitmap);

            dc2.DrawBitmap(bitmap, 30, 30);



            mDC.Dispose();
            dc2.Dispose(); //needed
#else
            if ((DateTime.Now - mLastTime).TotalMilliseconds < 500)
            {
                return;
            }

            try {
#if WIN32
                wxBufferedPaintDC   dc(dest);
#else
                ClientDC dc = new ClientDC(dest);
#endif

                dest.PrepareDC(dc);
                BufferedDC wdc = new BufferedDC(dc, grid.m_pixmap);
            } catch (Exception) {
            }
#endif
            return;


            if ((DateTime.Now - mLastTime).TotalMilliseconds < 500)
            {
                return;
            }

            try {
#if WIN32
                wxBufferedPaintDC   dc(dest);
#else
                ClientDC dc = new ClientDC(dest);
#endif

                dest.PrepareDC(dc);
                BufferedDC wdc = new BufferedDC(dc, grid.m_pixmap);
            } catch (Exception) {
            }
            mLastTime = DateTime.Now;
        }