public void UpdateFields() { foreach (SwProperty s in this._innerArray) { if (s.Ctl != null) { if (s.Ctl is System.Windows.Forms.ComboBox) { int si = 0; string ss = s.Value.Split(' ', '-')[0]; if (s.Ctl.Name.Contains("cbM")) { ss = s.Value; } if (s.Ctl.Name.ToUpper().Contains("AUTHOR")) { si = (s.Ctl as System.Windows.Forms.ComboBox).FindString(CutlistData.GetAuthorFullName(ss)); } else { si = (s.Ctl as System.Windows.Forms.ComboBox).FindString(ss); } if (si < 0 && !s.Ctl.Name.ToUpper().Contains("CUSTOMER")) { (s.Ctl as System.Windows.Forms.ComboBox).SelectedValue = ss; } else { (s.Ctl as System.Windows.Forms.ComboBox).SelectedIndex = si; } if ((s.Ctl as System.Windows.Forms.ComboBox).SelectedItem == null) { (s.Ctl as System.Windows.Forms.ComboBox).Text = ss; } } else if (s.Ctl is System.Windows.Forms.NumericUpDown) { decimal x = 0; if (decimal.TryParse(s.Value, out x)) { (s.Ctl as System.Windows.Forms.NumericUpDown).Value = x; } else { (s.Ctl as System.Windows.Forms.NumericUpDown).Value = 100; } } else { s.Ctl.Text = s.Value; } } } }
/// <summary> /// Pull data from config resources and populate the form. /// </summary> private void init() { cbDefaultMaterial.DisplayMember = "DESCR"; cbDefaultMaterial.ValueMember = "MATID"; cbDefaultMaterial.DataSource = cd.Materials.Tables[0]; cbDefaultMaterial.SelectedValue = Properties.Settings.Default.DefaultMaterial; cbDept.DisplayMember = "DEPT_NAME"; cbDept.ValueMember = "DEPT_ID"; cbDept.DataSource = cd.GetDepartments().Tables[0]; for (int i = 0; i < 26; i++) { cbRevLimit.Items.Add("A" + (char)(i + 65)); } chbDBEnabled.Checked = Properties.Settings.Default.EnableDBWrite; chbFlameWar.Checked = Properties.Settings.Default.FlameWar; chbTestingMode.Checked = Properties.Settings.Default.Testing; cbDept.SelectedValue = Properties.Settings.Default.UserDept; cbRevLimit.SelectedIndex = Properties.Settings.Default.RevLimit - 1; chbSounds.Checked = Properties.Settings.Default.MakeSounds; chbWarnings.Checked = Properties.Settings.Default.Warn; chbOpWarnings.Checked = Properties.Settings.Default.ProgWarn; chbIdiotLight.Checked = Properties.Settings.Default.IdiotLight; chbOnlyActive.Checked = Properties.Settings.Default.OnlyActiveAuthors; chbOnlyActiveCustomers.Checked = Properties.Settings.Default.OnlyCurrentCustomers; chbRememberCustomer.Checked = Properties.Settings.Default.RememberLastCustomer; checkBox1.Checked = Properties.Settings.Default.WarnExcludeAssy; checkBox2.Checked = Properties.Settings.Default.CHIHideLWH; textBox1.Text = Properties.Settings.Default.BOMFilter[0].ToString(); textBox2.Text = Properties.Settings.Default.GaugePath; textBox3.Text = Properties.Settings.Default.BOMTemplatePath; checkBox3.Checked = Properties.Settings.Default.SaveFirst; checkBox4.Checked = Properties.Settings.Default.SilenceGaugeErrors; checkBox5.Checked = Properties.Settings.Default.ExportEDrw; checkBox6.Checked = Properties.Settings.Default.ExportImg; checkBox7.Checked = Properties.Settings.Default.CutlistNotSelectedWarning; checkBox8.Checked = Properties.Settings.Default.AutoOpenPriority; chbFilterBOM.Checked = Properties.Settings.Default.FilterBOM; textBox4.Text = Properties.Settings.Default.DrawingTemplate; textBox5.Text = Properties.Settings.Default.DraftingStandard; ToolTip tt = new ToolTip(); tt.ShowAlways = true; tt.SetToolTip(label4, "You probably don't want to mess with this."); var t = new System.Globalization.CultureInfo("en-US", false).TextInfo; string currentUserName = t.ToTitleCase(cd.GetAuthorFullName(cd.GetCurrentAuthorInitial()).ToLower()); dataGridView1.AutoResizeRows(); dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; dataGridView1.AutoResizeColumns(); dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dataGridView1.DataSource = get_stats(); dataGridView1.Columns["Avg Daily Usage"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataGridView1.Columns["Total Since Reset"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataGridView1.Columns["Your Avg Daily Usage"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataGridView1.Columns["Your Total Since Reset"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataGridView1.Columns["σ"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataGridView1.Columns["Avg Daily Usage"].ToolTipText = string.Format(@"{0} work days since {1}", workDays, odometerStart.ToShortDateString()); dataGridView1.Columns["Total Since Reset"].ToolTipText = @"Reset @ " + odometerStart.ToShortDateString(); dataGridView1.Columns["Your Avg Daily Usage"].ToolTipText = string.Format(@"{0}'s average", currentUserName); dataGridView1.Columns["Your Total Since Reset"].ToolTipText = string.Format(@"{0}'s total, reset @ {1}", currentUserName, odometerStart.ToShortDateString()); dataGridView1.Columns["σ"].ToolTipText = @"Standard deviation"; dataGridView1.Columns["Avg Daily Usage"].DefaultCellStyle.Format = @"#.###"; dataGridView1.Columns["Your Avg Daily Usage"].DefaultCellStyle.Format = @"#.###"; dataGridView1.Columns["σ"].DefaultCellStyle.Format = @"#.###"; initialated = true; }