Dispose() protected method

Clean up any resources being used.
protected Dispose ( bool disposing ) : void
disposing bool true if managed resources should be disposed; otherwise, false.
return void
Esempio n. 1
0
        public void Release()
        {
            if (defaultBlack != null)
            {
                defaultBlack.Release();
                defaultBlack = null;
            }

            if (defaultWhite != null)
            {
                defaultWhite.Release();
                defaultWhite = null;
            }

            if (defaultGray != null)
            {
                defaultGray.Release();
                defaultGray = null;
            }

            if (defaultDarkGray != null)
            {
                defaultDarkGray.Release();
                defaultDarkGray = null;
            }

            if (irradiance != null)
            {
                irradiance.Release();
                irradiance = null;
            }

            if (prefiltered != null)
            {
                prefiltered.Release();
                prefiltered = null;
            }

            if (mat != null)
            {
                mat.Release();
                mat = null;
            }

            if (sphere != null)
            {
                sphere.Release();
                sphere = null;
            }

            if (cube != null)
            {
                cube.Release();
                cube = null;
            }

            if (glview != null)
            {
                FHost.Child = null;
                glview.Dispose();
                glview = null;
            }
        }
        //static int numPoints = 0;

        public drawing.Bitmap ParseSqlGeometry(List <SqlGeometry> geometries, double width, double height, Func <Point, Point> transform, drawing.Pen pen, drawing.Brush brush)//, ImageSource pointSymbol = null, Geometry symbol = null)
        {
            //if (width + height > 5000)
            //{
            //    throw new NotImplementedException();
            //}

            gl = new GLControl(new OpenTK.Graphics.GraphicsMode(32, 24, 8, 4));
            gl.MakeCurrent();

            //Debug.Print("ParseSqlGeometry started");
            //numPoints = 0;

            gl.Width = (int)width; gl.Height = (int)height;

            GL.Enable(EnableCap.PointSmooth);
            GL.Hint(HintTarget.PointSmoothHint, HintMode.Nicest);
            //GL.Enable(EnableCap.LineSmooth);
            //GL.Hint(HintTarget.LineSmoothHint, HintMode.Nicest);

            //GL.Disable(EnableCap.Texture2D);

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(0, width, 0, height, -1, 1);       // Bottom-left corner pixel has coordinate (0, 0)
            GL.Viewport(0, 0, (int)width, (int)height); // Use all of the glControl painting area

            GL.ClearColor(drawing.Color.Transparent);

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.Color3(pen.Color);
            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
            GL.PointSize(5f);
            GL.LineWidth(2f);
            //GL.Color4(System.Drawing.Color.LightBlue);
            //GL.Enable(EnableCap.VertexArray);

            //OpenTKHelper.pen = pen;

            //OpenTKHelper.brush = brush;

            int p = 0;

            if (geometries != null)
            {
                foreach (SqlGeometry item in geometries)
                {
                    p += AddGeometry(item, transform);
                }
            }
            //***************
            //var image2 = GrabScreenshot((int)width, (int)height);

            //image2.Save(DateTime.Now.ToString("yyyy,MM,dd,hh,mm,ss") + ".png", drawing.Imaging.ImageFormat.Png);

            //image2.Dispose();
            //**********
            GL.Finish();

            var result = GrabScreenshot();

            gl.Dispose();

            return(result);
        }