Ejemplo n.º 1
0
		private void butOK_Click(object sender,System.EventArgs e) {
			//ComputerPref computerPref=ComputerPrefs.GetForLocalComputer();
			if(radioDirectXChart.Checked) {
				if(!TestDirectXFormat(this,selectedDirectXFormat)){
					MessageBox.Show(Lan.g(this,"Please choose a different device format, "+
						"the selected device format will not support the DirectX 3D tooth chart on this computer"));
					return;
				}
				ComputerPrefs.LocalComputer.GraphicsSimple=DrawingMode.DirectX;
				ComputerPrefs.LocalComputer.DirectXFormat=selectedDirectXFormat;
			}
			else if(radioSimpleChart.Checked) {
				ComputerPrefs.LocalComputer.GraphicsSimple=DrawingMode.Simple2D;
			}
			else { //OpenGL
				OpenGLWinFormsControl contextTester=new OpenGLWinFormsControl();
				try {
					if(contextTester.TaoInitializeContexts(selectedFormatNum)!=selectedFormatNum) {
						throw new Exception(Lan.g(this,"Could not initialize pixel format ")+selectedFormatNum.ToString()+".");
					}
				} 
				catch(Exception ex) {
					MessageBox.Show(Lan.g(this,"Please choose a different pixel format, the selected pixel format will not support the 3D tooth chart on this computer: "+ex.Message));
					contextTester.Dispose();
					return;
				}
				contextTester.Dispose();
				ComputerPrefs.LocalComputer.GraphicsUseHardware=checkHardwareAccel.Checked;
				ComputerPrefs.LocalComputer.GraphicsDoubleBuffering=checkDoubleBuffering.Checked;
				ComputerPrefs.LocalComputer.PreferredPixelFormatNum=selectedFormatNum;
				ComputerPrefs.LocalComputer.GraphicsSimple=DrawingMode.OpenGL;
			}
			ComputerPrefs.Update(ComputerPrefs.LocalComputer);
			DialogResult=DialogResult.OK;
		}
Ejemplo n.º 2
0
		///<Summary>Get all formats for the grid based on the current filters.</Summary>
		private void RefreshFormats() {
			this.Cursor=Cursors.WaitCursor;
			gridFormats.Rows.Clear();
			gridFormats.Invalidate();
			textSelected.Text="";
			Application.DoEvents();
			if(this.radioDirectXChart.Checked){
				xformats=ToothChartDirectX.GetStandardDeviceFormats();
			}
			else if(this.radioOpenGLChart.Checked){
				OpenGLWinFormsControl contextFinder=new OpenGLWinFormsControl();
				//Get raw formats.
				Gdi.PIXELFORMATDESCRIPTOR[] rawformats=OpenGLWinFormsControl.GetPixelFormats(contextFinder.GetHDC());
				if(checkAllFormats.Checked){
					formats=new OpenGLWinFormsControl.PixelFormatValue[rawformats.Length];
					for(int i=0;i<rawformats.Length;i++) {
						formats[i]=new OpenGLWinFormsControl.PixelFormatValue();
						formats[i].formatNumber=i+1;
						formats[i].pfd=rawformats[i];
					}
				}
				else{
					//Prioritize formats as requested by the user.
					formats=OpenGLWinFormsControl.PrioritizePixelFormats(rawformats,checkDoubleBuffering.Checked,checkHardwareAccel.Checked);
				}
				contextFinder.Dispose();
			}
			//Update the format grid to reflect possible changes in formats.
			FillGrid();
			this.Cursor=Cursors.Default;
		}