Exemplo n.º 1
0
        ///<summary>Returns true if the given directXFormat works for a DirectX tooth chart on the local computer.</summary>
        public static bool TestDirectXFormat(Form callingForm, string directXFormat)
        {
            ToothChartWrapper toothChartTest = new ToothChartWrapper();

            toothChartTest.Visible = false;
            //We add the invisible tooth chart to our form so that the device context will initialize properly
            //and our device creation test will then be accurate.
            callingForm.Controls.Add(toothChartTest);
            toothChartTest.DeviceFormat = new ToothChartDirectX.DirectXDeviceFormat(directXFormat);
            toothChartTest.DrawMode     = DrawingMode.DirectX;      //Creates the device.
            if (toothChartTest.DrawMode == DrawingMode.Simple2D)
            {
                //The chart is set back to 2D mode when there is an error initializing.
                callingForm.Controls.Remove(toothChartTest);
                toothChartTest.Dispose();
                return(false);
            }
            //Now we check to be sure that one can draw and retrieve a screen shot from a DirectX control
            //using the specified device format.
            try {
                Bitmap screenShot = toothChartTest.GetBitmap();
                screenShot.Dispose();
            }
            catch {
                callingForm.Controls.Remove(toothChartTest);
                toothChartTest.Dispose();
                return(false);
            }
            callingForm.Controls.Remove(toothChartTest);
            toothChartTest.Dispose();
            return(true);
        }