public void RegisterConfigParameter( Config.Parameter parameter ) { string strType = ""; if( parameter.Field != null ) strType = parameter.Field.FieldType.Name; else if( parameter.Property != null ) strType = parameter.Property.PropertyType.Name; string description = string.Format( "\"{0}\", Default: \"{1}\"", strType, parameter.DefaultValue ); AddCommand( parameter.Name, OnConsoleConfigCommand, parameter, description ); }
public StartForm() { this.BackgroundImage = null; bool FileFail = false; InitializeComponent(); FileStream fs = null; try { fs = new FileStream("Config.bin", FileMode.Open, FileAccess.Read); config = Serializer.Deserialize<Config>(fs); fs.Close(); } catch(Exception ex) { FileFail = true; if (fs != null) fs.Close(); System.Windows.Forms.MessageBox.Show("Error! Небыл найден файл настроек\n" + ex.Message); } ModeDescription[] DML = null; using (SharpDX.DXGI.Factory myFactory = new SharpDX.DXGI.Factory()) { int MyAdapterCount = myFactory.GetAdapterCount(); try { using (SharpDX.DXGI.Adapter MyAdapter = myFactory.GetAdapter(MyAdapterCount - 1)) { using (Output OP = MyAdapter.Outputs[0]) DML = OP.GetDisplayModeList(Format.R8G8B8A8_UNorm, DisplayModeEnumerationFlags.Interlaced); } } catch (System.Exception ex) { using (SharpDX.DXGI.Adapter MyAdapter = myFactory.GetAdapter(MyAdapterCount - 0)) { using (Output OP = MyAdapter.Outputs[0]) DML = OP.GetDisplayModeList(Format.R8G8B8A8_UNorm, DisplayModeEnumerationFlags.Interlaced); } } } int mw = 0, mh = 0; foreach (ModeDescription dm in DML) { bool cor = true; foreach (DisplayMode dmd in LDM) { if (dmd.Width == dm.Width && dmd.Height == dm.Height) { cor = false; } } if (cor && dm.Width >= 1024 && dm.Height >= 768) LDM.Add(new DisplayMode(dm.Width, dm.Height)); if (dm.Width > mw) mw = dm.Width; if (dm.Height > mh) mh = dm.Height; } if (LDM.Count < 1) { System.Windows.Forms.MessageBox.Show("Error! Минимальное поддерживаемое разрешение экрана 1024х768"); this.Close(); } if (config.Width > mw || config.Height > mh) { FileFail = true; } if (GetResIndex(config.Width, config.Height, LDM) < 0) FileFail = true; if (FileFail) { config = new Config(); SaveC(config, "Config.bin"); } SetData(); for (int num = 0; num < LDM.Count; num++) { comboBox1.Items.Add(LDM[num].Width.ToString() + "x" + LDM[num].Height.ToString()); } int Res = GetResIndex(config.Width, config.Height, LDM); if (Res > -1) { comboBox1.SelectedIndex = Res; } if (config.VSync>0) { checkBox1.Checked = true; } else { checkBox1.Checked = false; } if (config.InvAlt > 0) { checkBox3.Checked = true; } else { checkBox3.Checked = false; } comboBox2.Items.Add("High"); comboBox2.Items.Add("Medium"); comboBox2.Items.Add("Low"); comboBox2.Items.Add("Disable"); if (config.Shadow < 1) { comboBox2.SelectedIndex = 3; } else { comboBox2.SelectedIndex = config.ShadowQuality; } comboBox3.Items.Add("Disable"); comboBox3.Items.Add("Low"); comboBox3.Items.Add("Medium"); comboBox3.Items.Add("High"); if (config.MultiSample > -1 && config.MultiSample < 2) { comboBox3.SelectedIndex = 0; } if (config.MultiSample > 1 && config.MultiSample < 4) { comboBox3.SelectedIndex = 1; } if (config.MultiSample > 3 && config.MultiSample < 8) { comboBox3.SelectedIndex = 2; } if (config.MultiSample > 7) { comboBox3.SelectedIndex = 3; } comboBox4.Items.Add("Disable"); comboBox4.Items.Add("4"); comboBox4.Items.Add("8"); comboBox4.Items.Add("12"); if (config.Light > -1 && config.Light < 4) { comboBox4.SelectedIndex = 0; } if (config.Light > 3 && config.Light < 7) { comboBox4.SelectedIndex = 1; } if (config.Light > 7 && config.Light < 11) { comboBox4.SelectedIndex = 2; } if (config.Light > 11) { comboBox4.SelectedIndex = 3; } if (config.FullScr > 0) { checkBox2.Checked = true; } else { checkBox2.Checked = false; } if (config.Refract > 0) { checkBox4.Checked = true; } else { checkBox4.Checked = false; } }