public GuiHalSurface CreateSurface(int Width, int Height, GuiHalSurface.CreateFlags flags, GuiHalSurface.PixelFormat pixelFormat)
        {
            GuiHalSurface newSurface;

            switch (pixelFormat)
            {
                case GuiHalSurface.PixelFormat.PixelFormatBgra32:
                    newSurface = new GuiHalSurfaceWindowsFormsDXBackend(GuiHalSurface.ImageFormats.pix_format_bgra32);
                    break;
                default:
                    throw new NotImplementedException();
            }

            newSurface.Init(Width, Height, flags, pixelFormat);
            return newSurface;
        }
 public WindowsFormBridgeDXBackend(GuiHalSurface app, GuiHalSurface.ImageFormats format)
     : base(app, format)
 {
     SetUpFormsWindow(app, format);
 }
        public override void Init(int width, int height, GuiHalSurface.CreateFlags flags, GuiHalSurface.PixelFormat pixelFormat)
        {
            //if (windowsFormsWindow.m_sys_format == PlatformSupportAbstract.ImageFormats.pix_format_undefined)
            {
                //  return false;
            }

            m_window_flags = flags;

            initialWidth = width;
            initialHeight = height;

            int bitDepth = GetBitDepthForPixelFormat(m_format);
            switch (bitDepth)
            {
                case 24:
                    backBuffer = new ImageBuffer(initialWidth, initialHeight, 24, new BlenderBGR());
                    break;

                case 32:
                    backBuffer = new ImageBuffer(initialWidth, initialHeight, 32, new BlenderBGRA());
                    break;

                case 128:
                    throw new NotImplementedException();
                    //backBuffer = null;
                    //m_BackBufferFloat = new ImageBufferFloat(initialWidth, initialHeight, 128, new BlenderBGRAFloat());
                    //break;

                default:
                    throw new NotImplementedException("Don't support this bit depth yet.");
            }

            System.Drawing.Size clientSize = new System.Drawing.Size();
            clientSize.Width = (int)width;
            clientSize.Height = (int)height;
            windowsFormsWindow.ClientSize = clientSize;

            if ((m_window_flags & CreateFlags.Resizable) == 0)
            {
                windowsFormsWindow.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
                windowsFormsWindow.MaximizeBox = false;
            }

            clientSize.Width = width;
            clientSize.Height = height;
            windowsFormsWindow.ClientSize = clientSize;

            Bounds = new rect_d(0, 0, width, height);

            OnInitialize();
            windowsFormsWindow.m_WindowContentNeedsRedraw = true;
        }