public static void SaveClaheMode(ClaheMode[] cModeList) { DataSet ds = GetClaheModel(); DataTable table = ds.Tables[0]; if (table != null) { table.Clear(); for (int j = 0; j < cModeList.Length; ++j) { ClaheMode c = cModeList[j]; if (c.Name != "Self Define") { DataRow row = table.NewRow(); row[0] = c.Name; row["Para"] = c.Paras; table.Rows.Add(row); } } } DataSet changeSet = ds.GetChanges(); if (changeSet != null) { changeSet.WriteXml(fileClaheModel, XmlWriteMode.WriteSchema); } ds.Dispose(); }
private void SaveModel() { ClaheMode[] temp = new ClaheMode[ClaheModels.Count]; ClaheModels.Values.CopyTo(temp, 0); SaveClaheMode(temp); LoadClaheModels(); }
public void LoadClaheModels() { ClaheModels = new Dictionary <string, ClaheMode>(); DataSet ds = GetClaheModel(); DataTable table = ds.Tables[0]; if (table != null) { for (int j = 0; j < table.Rows.Count; ++j) { ClaheMode c = new ClaheMode(); DataRow row = table.Rows[j]; c.Name = row[0].ToString(); c.Paras = row["Para"].ToString(); ClaheModels.Add(c.Name, c); } } ClaheMode self = new ClaheMode(); self.Name = "Self Define"; self.Paras = "8,8,128,4"; ClaheModels.Add(self.Name, self); comboBoxClaheModel.Items.Clear(); ClaheMode[] temp = new ClaheMode[ClaheModels.Count]; ClaheModels.Values.CopyTo(temp, 0); for (int i = 0; i < temp.Length; i++) { comboBoxClaheModel.Items.Add(temp[i].Name); } }
//0 - NO //1 - 16,16,128,16 //2 - 8 ,8 ,128,4 //3 - 8 ,8 ,128,0.5 //4 - SELF private void comboBoxClaheModel_SelectedIndexChanged(object sender, EventArgs e) { this.textBox1.TextChanged -= new EventHandler(textBox_TextChanged); this.textBox2.TextChanged -= new EventHandler(textBox_TextChanged); this.textBox3.TextChanged -= new EventHandler(textBox_TextChanged); this.textBox4.TextChanged -= new EventHandler(textBox_TextChanged); bool onlyread = comboBoxClaheModel.SelectedItem.ToString() != "Self Define"; textBox1.ReadOnly = onlyread; textBox2.ReadOnly = onlyread; textBox3.ReadOnly = onlyread; textBox4.ReadOnly = onlyread; textBox5.ReadOnly = onlyread; btnAddModel.Enabled = !onlyread; Color backcolor = onlyread ? Color.LightSteelBlue : Color.White; textBox1.BackColor = backcolor; textBox2.BackColor = backcolor; textBox3.BackColor = backcolor; textBox4.BackColor = backcolor; textBox5.BackColor = backcolor; if (comboBoxClaheModel.SelectedItem.ToString() == "No Process") { groupBox1.Visible = false; } else { groupBox1.Visible = true; ClaheMode cm = ClaheModels[comboBoxClaheModel.SelectedItem.ToString()]; string[] paras = cm.Paras.Split(','); textBox1.Text = paras[0]; textBox2.Text = paras[1]; textBox3.Text = paras[2]; textBox4.Text = paras[3]; textBox5.Text = cm.Name; btnDeleteModel.Enabled = CheckISSelfDefine(); btnModify.Enabled = CheckISSelfDefine(); } if (ClaheModelChanged != null) { try { ClaheModelChanged(int.Parse(textBox1.Text), int.Parse(textBox2.Text), int.Parse(textBox3.Text), float.Parse(textBox4.Text)); } catch (System.Exception ex) { } } this.textBox1.TextChanged += new EventHandler(textBox_TextChanged); this.textBox2.TextChanged += new EventHandler(textBox_TextChanged); this.textBox3.TextChanged += new EventHandler(textBox_TextChanged); this.textBox4.TextChanged += new EventHandler(textBox_TextChanged); }
private void btnAddModel_Click(object sender, EventArgs e) { string name = this.textBox5.Text.Trim(); if (ClaheModels.ContainsKey(name) || name == "Self Define") { cls_MessageBox.Show("Name existed,please change!"); return; } ClaheMode cm = new ClaheMode(); cm.Name = name; cm.Paras = textBox1.Text.Trim() + "," + textBox2.Text.Trim() + "," + textBox3.Text.Trim() + "," + textBox4.Text.Trim(); ClaheModels.Add(name, cm); SaveModel(); comboBoxClaheModel.SelectedItem = name; }
private void textBox_TextChanged(object sender, EventArgs e) { TextBox tb = sender as TextBox; if (tb == null) { return; } float tmp = 0f; try { tmp = float.Parse(tb.Text); } catch (System.Exception ex) { return; } if (ClaheModelChanged != null) { try { ClaheModelChanged(int.Parse(textBox1.Text), int.Parse(textBox2.Text), int.Parse(textBox3.Text), float.Parse(textBox4.Text)); } catch (System.Exception ex) { } } if (CheckISSelfDefine()) { string name = this.textBox5.Text.Trim(); ClaheMode cm = new ClaheMode(); cm.Name = name; cm.Paras = textBox1.Text.Trim() + "," + textBox2.Text.Trim() + "," + textBox3.Text.Trim() + "," + textBox4.Text.Trim(); ClaheModels[name] = cm; SaveModel(); comboBoxClaheModel.SelectedItem = name; } }