/// <summary> /// RenderForm constructor. /// </summary> public RenderForm(GraphicsWindow graphicsWindow, Size clientSize) { if (graphicsWindow == null) { throw new ArgumentNullException("graphicsWindow"); } // Store GraphicsWindow reference _Window = graphicsWindow; // Initialize Form extents ClientSize = clientSize; // No need to erase window background SetStyle(ControlStyles.AllPaintingInWmPaint, true); // No need to draw window background SetStyle(ControlStyles.Opaque, true); // Buffer control SetStyle(ControlStyles.DoubleBuffer, false); // Redraw window on resize SetStyle(ControlStyles.ResizeRedraw, true); // Painting handled by user SetStyle(ControlStyles.UserPaint, true); // React on window resize event Resize += _Window.FormResize; // React on window closed event FormClosed += _Window.FormClosed; }
/// <summary> /// Creates a handle for the control. /// </summary> protected override void CreateHandle() { // Create the render window _RenderWindow = new GraphicsWindow(this); _RenderWindow.Width = (uint)base.ClientSize.Width; _RenderWindow.Height = (uint)base.ClientSize.Height; // OVerride default swap interval _RenderWindow.SwapInterval = SwapInterval; // "Select" device pixel format before creating control handle switch (Environment.OSVersion.Platform) { case PlatformID.Unix: _RenderWindow.PreCreateObjectX11(SurfaceFormat); break; } // Base implementation base.CreateHandle(); }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.HandleDestroyed"/> event. /// </summary> /// <param name="e"> /// An <see cref="T:System.EventArgs"/> that contains the event data. /// </param> protected override void OnHandleDestroyed(EventArgs e) { if (DesignMode == false) { if (_RenderContext != null) { // Raise DestroyContext event _RenderContext.MakeCurrent(true); RaiseGraphicsContextDestroyed(new GraphicsControlEventArgs(_RenderContext, _RenderWindow)); _RenderContext.MakeCurrent(false); // Dispose the renderer context _RenderContext.Dispose(); _RenderContext = null; } // Dispose the renderer window if (_RenderWindow != null) { _RenderWindow.Dispose(); _RenderWindow = null; } } // Base implementation base.OnHandleDestroyed(e); }
/// <summary> /// RenderForm constructor. /// </summary> public RenderForm(GraphicsWindow graphicsWindow, Size clientSize) { if (graphicsWindow == null) throw new ArgumentNullException("graphicsWindow"); // Store GraphicsWindow reference _Window = graphicsWindow; // Initialize Form extents ClientSize = clientSize; // No need to erase window background SetStyle(ControlStyles.AllPaintingInWmPaint, true); // No need to draw window background SetStyle(ControlStyles.Opaque, true); // Buffer control SetStyle(ControlStyles.DoubleBuffer, false); // Redraw window on resize SetStyle(ControlStyles.ResizeRedraw, true); // Painting handled by user SetStyle(ControlStyles.UserPaint, true); // React on window resize event Resize += _Window.FormResize; // React on window closed event FormClosed += _Window.FormClosed; }