public List <TextValuePair> GetPortList(int elt_account_number) { SqlConnection conn = new SqlConnection(GetConnectionString(AppConstants.DB_CONN_PROD)); SqlCommand cmd = new SqlCommand() { Connection = conn, CommandType = CommandType.Text, CommandText = string.Format(SQLConstants.SELECT_LIST_PORT, elt_account_number.ToString()) }; List <TextValuePair> list = new List <TextValuePair>(); try { conn.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { TextValuePair item = new TextValuePair() { Text = Convert.ToString(reader["port_name"]), Value = Convert.ToString(reader["port_code"]) }; list.Add(item); } } } catch (Exception ex) { throw ex; } finally { conn.Close(); conn.Dispose(); } return(list); }
public void TestTextEvent() { TextValuePair <GenericParameterHelper> target = new TextValuePair <GenericParameterHelper>("AA", null); bool changing = false; bool changed = false; bool error = false; target.PropertyChanging += (sender, e) => { if (e.PropertyName == "Text") { changing = true; if (target.Text != "AA") { error = true; } } }; target.PropertyChanged += (sender, e) => { if (changing && e.PropertyName == "Text") { changed = true; if (target.Text != "BB") { error = true; } } }; target.Text = "BB"; Assert.IsFalse(error); Assert.IsTrue(changing); Assert.IsTrue(changed); }
public static object[] RefineSuggestionsText(string[] sugs) { object[] os = new object[sugs.Length]; for (int i = 0; i < os.Length; ++i) { if (String.IsNullOrEmpty(sugs[i])) { os[i] = new TextValuePair("(حذف)", sugs[i]); } else if (StringUtil.StringContainsAny(sugs[i], WordSpecialCharacters.SpecialCharsArray)) { os[i] = new TextValuePair( sugs[i].Replace( WordSpecialCharacters.FootnoteDelimiter.ToString(), WordSpecialCharacters.FootnoteDelimiterReplacementString) .Replace( WordSpecialCharacters.FormulaDelimiter.ToString(), WordSpecialCharacters.FormulaDelimiterReplacementString) , sugs[i] ); } else { os[i] = sugs[i]; } } return(os); }
public void TestEqual() { GenericParameterHelper value = new GenericParameterHelper(); TextValuePair <GenericParameterHelper> pair1 = new TextValuePair <GenericParameterHelper>(); TextValuePair <GenericParameterHelper> pair2 = new TextValuePair <GenericParameterHelper>(); Assert.IsTrue(pair1.Equals(pair2)); Assert.IsTrue(pair1 == pair2); Assert.IsFalse(pair1 != pair2); pair1.Text = "1"; Assert.IsFalse(pair1.Equals(pair2)); Assert.IsFalse(pair1 == pair2); Assert.IsTrue(pair1 != pair2); pair2.Text = "12".Substring(0, 1); Assert.IsTrue(pair1.Equals(pair2)); Assert.IsTrue(pair1 == pair2); Assert.IsFalse(pair1 != pair2); pair1.Value = value; Assert.IsFalse(pair1.Equals(pair2)); Assert.IsFalse(pair1 == pair2); Assert.IsTrue(pair1 != pair2); pair2.Value = value; Assert.IsTrue(pair1.Equals(pair2)); Assert.IsTrue(pair1 == pair2); Assert.IsFalse(pair1 != pair2); }
private void ChangeLanguage(string lang) { Properties.Settings.Default.Language = lang; Properties.Settings.Default.Save(); Localizer.InitLocalizedResource(lang); TextValuePair[] configs = new TextValuePair[] { new TextValuePair("s2t".Localize(), "s2t.json"), new TextValuePair("t2s".Localize(), "t2s.json"), new TextValuePair("s2hk".Localize(), "s2hk.json"), new TextValuePair("s2tw".Localize(), "s2tw.json"), new TextValuePair("s2twp".Localize(), "s2twp.json"), new TextValuePair("hk2s".Localize(), "hk2s.json"), new TextValuePair("tw2s".Localize(), "tw2s.json"), new TextValuePair("tw2sp".Localize(), "tw2sp.json"), new TextValuePair("t2tw".Localize(), "t2tw.json"), new TextValuePair("t2hk".Localize(), "t2hk.json"), }; var origIndex = comboBox_Config.SelectedIndex; comboBox_Config.Items.Clear(); comboBox_Config.Items.AddRange(configs); comboBox_Config.SelectedIndex = origIndex == -1 ? 0 : origIndex; fileToolStripMenuItem.Text = "File".Localize(); loadToolStripMenuItem.Text = "Load".Localize(); saveToolStripMenuItem.Text = "Save".Localize(); convertTextToolStripMenuItem.Text = "ConvertText".Localize(); convertFilesToolStripMenuItem.Text = "ConvertFiles".Localize(); exitToolStripMenuItem.Text = "Exit".Localize(); editToolStripMenuItem.Text = "Edit".Localize(); undoToolStripMenuItem.Text = "Undo".Localize(); clearToolStripMenuItem.Text = "Clear".Localize(); cutToolStripMenuItem.Text = "Cut".Localize(); copyToolStripMenuItem.Text = "Copy".Localize(); pasteToolStripMenuItem.Text = "Paste".Localize(); deleteToolStripMenuItem.Text = "Delete".Localize(); selectAllToolStripMenuItem.Text = "SelectAll".Localize(); languageToolStripMenuItem.Text = "Language".Localize(); button_Convert.Text = "Convert".Localize(); button_Select.Text = "SelectFiles".Localize(); button_Clear.Text = "Clear".Localize(); dataGridView_FileList.Columns["FileName"].HeaderText = "FileName".Localize(); dataGridView_FileList.Columns["ErrorMessage"].HeaderText = "ErrorMessage".Localize(); }
private void SignUpForm_Load(object sender, EventArgs e) { var keySizes = new List <TextValuePair>(); for (int i = MinKeySize; i <= MaxKeySize; i += 64) { var keyValuePair = new TextValuePair(i.ToString(), i); keySizes.Add(keyValuePair); } this.keySizeCb.DisplayMember = nameof(TextValuePair.Text); this.keySizeCb.ValueMember = nameof(TextValuePair.Value); this.keySizeCb.DataSource = keySizes; this.keySizeCb.SelectedIndex = 0; }
public void TestProperty() { TextValuePair <GenericParameterHelper> target = new TextValuePair <GenericParameterHelper>(); Assert.AreEqual(target.Text, default(string), "测试 Text 默认值失败。"); Assert.AreEqual(target.Value, default(GenericParameterHelper), "测试 Value 默认值失败。"); target.Text = "TT"; target.Value = new GenericParameterHelper(1); Assert.AreEqual(target.Text, "TT", "测试 Text 赋值失败。"); Assert.AreEqual(target.Value, new GenericParameterHelper(1), "测试 Value 赋值失败。"); target = new TextValuePair <GenericParameterHelper>("TT", new GenericParameterHelper(2)); Assert.AreEqual(target.Text, "TT", "测试 Text 构造函数赋值失败。"); Assert.AreEqual(target.Value, new GenericParameterHelper(2), "测试 Value 构造函数赋值失败。"); }
public List <TextValuePair> GetOceanExportFileNumbers(string ELT_account_number) { SqlConnection conn = new SqlConnection(GetConnectionString(AppConstants.DB_CONN_PROD)); SqlCommand cmd = new SqlCommand() { Connection = conn, CommandType = CommandType.StoredProcedure, CommandText = "DataList.GetOceanExportFileNumbers" }; List <TextValuePair> list = new List <TextValuePair>(); try { cmd.Parameters.Add(new SqlParameter("@ELT_account_number", ELT_account_number)); conn.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { TextValuePair item = new TextValuePair() { Text = Convert.ToString(reader["file_no"]), Value = Convert.ToString(reader["file_no"]) }; list.Add(item); } } } catch (Exception ex) { throw ex; } finally { conn.Close(); conn.Dispose(); } return(list); }
private void SetDropdownList() { TextValuePair[] configs = new TextValuePair[] { new TextValuePair("簡體 => 繁體", "s2t.json"), new TextValuePair("繁體 => 簡體", "t2s.json"), new TextValuePair("簡體 => 香港繁體", "s2hk.json"), new TextValuePair("簡體 => 臺灣正體", "s2tw.json"), new TextValuePair("簡體 => 繁體(臺灣正體標準)並轉換爲臺灣常用詞彙", "s2twp.json"), new TextValuePair("香港繁體 => 簡體", "hk2s.json"), new TextValuePair("臺灣 => 體到簡體", "tw2s.json"), new TextValuePair("繁體(臺灣正體標準)=> 簡體 並轉換爲中國大陸常用詞彙", "tw2sp.json"), new TextValuePair("繁體(OpenCC 標準)=> 臺灣正體", "t2tw.json"), new TextValuePair("繁體(OpenCC 標準)=> 香港繁體", "t2hk.json"), }; var origIndex = cboConfiguration.SelectedIndex; cboConfiguration.Items.Clear(); cboConfiguration.Items.AddRange(configs); cboConfiguration.SelectedIndex = origIndex == -1 ? 0 : origIndex; }
public void TestValueEvent() { GenericParameterHelper para = new GenericParameterHelper(); TextValuePair <GenericParameterHelper> target = new TextValuePair <GenericParameterHelper>("AA", null); bool changing = false; bool changed = false; bool error = false; target.PropertyChanging += (sender, e) => { if (e.PropertyName == "Value") { changing = true; if (target.Value != null) { error = true; } } }; target.PropertyChanged += (sender, e) => { if (changing && e.PropertyName == "Value") { changed = true; if (target.Value != para) { error = true; } } }; target.Value = para; Assert.IsFalse(error); Assert.IsTrue(changing); Assert.IsTrue(changed); }
public void TestValueEvent() { GenericParameterHelper para = new GenericParameterHelper(); TextValuePair<GenericParameterHelper> target = new TextValuePair<GenericParameterHelper>("AA", null); bool changing = false; bool changed = false; bool error = false; target.PropertyChanging += (sender, e) => { if (e.PropertyName == "Value") { changing = true; if (target.Value != null) { error = true; } } }; target.PropertyChanged += (sender, e) => { if (changing && e.PropertyName == "Value") { changed = true; if (target.Value != para) { error = true; } } }; target.Value = para; Assert.IsFalse(error); Assert.IsTrue(changing); Assert.IsTrue(changed); }
public void TestEditableObjectText() { TextValuePair<GenericParameterHelper> target = new TextValuePair<GenericParameterHelper>("AA", null); IEditableObject obj = (IEditableObject)target; bool changing = false; bool changed = false; bool error = false; target.PropertyChanging += (sender, e) => { if (e.PropertyName == "Text") { changing = true; if (target.Text != "AA") { error = true; } } }; target.PropertyChanged += (sender, e) => { if (changing && e.PropertyName == "Text") { changed = true; if (target.Text != "BB") { error = true; } } }; // Test Text obj.BeginEdit(); target.Text = "BB"; Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); obj.CancelEdit(); Assert.AreEqual(target.Text, "AA"); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); obj.EndEdit(); Assert.AreEqual(target.Text, "AA"); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); obj.CancelEdit(); Assert.AreEqual(target.Text, "AA"); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); obj.BeginEdit(); target.Text = "BB"; obj.EndEdit(); Assert.AreEqual(target.Text, "BB"); Assert.IsFalse(error); Assert.IsTrue(changing); Assert.IsTrue(changed); changing = false; changed = false; obj.CancelEdit(); Assert.AreEqual(target.Text, "BB"); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); // Test Text without change changing = changed = error = false; obj.BeginEdit(); target.Text = "BB"; obj.EndEdit(); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); }
public void TestEditableObjectValue() { GenericParameterHelper para1 = new GenericParameterHelper(1); GenericParameterHelper para2 = new GenericParameterHelper(2); TextValuePair<GenericParameterHelper> target = new TextValuePair<GenericParameterHelper>("", para1); IEditableObject obj = (IEditableObject)target; bool changing = false; bool changed = false; bool error = false; target.PropertyChanging += (sender, e) => { if (e.PropertyName == "Value") { changing = true; if (target.Value != para1) { error = true; } } }; target.PropertyChanged += (sender, e) => { if (changing && e.PropertyName == "Value") { changed = true; if (target.Value != para2) { error = true; } } }; // Test Value obj.BeginEdit(); target.Value = para2; Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); obj.CancelEdit(); Assert.AreEqual(target.Value, para1); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); obj.EndEdit(); Assert.AreEqual(target.Value, para1); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); obj.CancelEdit(); Assert.AreEqual(target.Value, para1); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); obj.BeginEdit(); target.Value = para2; obj.EndEdit(); Assert.AreEqual(target.Value, para2); Assert.IsFalse(error); Assert.IsTrue(changing); Assert.IsTrue(changed); changing = false; changed = false; obj.CancelEdit(); Assert.AreEqual(target.Value, para2); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); // Test Value without change changing = changed = error = false; obj.BeginEdit(); target.Value = para2; obj.EndEdit(); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); }
public void TestEditableObjectValue() { var para1 = new GenericParameterHelper(1); var para2 = new GenericParameterHelper(2); var target = new TextValuePair <GenericParameterHelper>("", para1); var obj = (IEditableObject)target; var changing = false; var changed = false; var error = false; target.PropertyChanging += (sender, e) => { if (e.PropertyName == "Value") { changing = true; if (target.Value != para1) { error = true; } } }; target.PropertyChanged += (sender, e) => { if (changing && e.PropertyName == "Value") { changed = true; if (target.Value != para2) { error = true; } } }; // Test Value obj.BeginEdit(); target.Value = para2; Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); obj.CancelEdit(); Assert.AreEqual(target.Value, para1); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); obj.EndEdit(); Assert.AreEqual(target.Value, para1); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); obj.CancelEdit(); Assert.AreEqual(target.Value, para1); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); obj.BeginEdit(); target.Value = para2; obj.EndEdit(); Assert.AreEqual(target.Value, para2); Assert.IsFalse(error); Assert.IsTrue(changing); Assert.IsTrue(changed); changing = false; changed = false; obj.CancelEdit(); Assert.AreEqual(target.Value, para2); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); // Test Value without change changing = changed = error = false; obj.BeginEdit(); target.Value = para2; obj.EndEdit(); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); }
public async void LoadItems()//Text and Value Olmalı. { this.Items.Clear(); DataAccess db = new DataAccess(SLUtility.GetHostUrl()); var list = await db.Query(this.Controller, this.Action, this.Type, null); foreach (IDictionary<string, object> dyn in list) { TextValuePair pair = new TextValuePair(dyn["Text"].ToString(), dyn["Value"]); this.Items.Add(pair); } }
public void TestEditableObjectText() { TextValuePair <GenericParameterHelper> target = new TextValuePair <GenericParameterHelper>("AA", null); IEditableObject obj = (IEditableObject)target; bool changing = false; bool changed = false; bool error = false; target.PropertyChanging += (sender, e) => { if (e.PropertyName == "Text") { changing = true; if (target.Text != "AA") { error = true; } } }; target.PropertyChanged += (sender, e) => { if (changing && e.PropertyName == "Text") { changed = true; if (target.Text != "BB") { error = true; } } }; // Test Text obj.BeginEdit(); target.Text = "BB"; Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); obj.CancelEdit(); Assert.AreEqual(target.Text, "AA"); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); obj.EndEdit(); Assert.AreEqual(target.Text, "AA"); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); obj.CancelEdit(); Assert.AreEqual(target.Text, "AA"); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); obj.BeginEdit(); target.Text = "BB"; obj.EndEdit(); Assert.AreEqual(target.Text, "BB"); Assert.IsFalse(error); Assert.IsTrue(changing); Assert.IsTrue(changed); changing = false; changed = false; obj.CancelEdit(); Assert.AreEqual(target.Text, "BB"); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); // Test Text without change changing = changed = error = false; obj.BeginEdit(); target.Text = "BB"; obj.EndEdit(); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); }
public void TestEqual() { GenericParameterHelper value = new GenericParameterHelper(); TextValuePair<GenericParameterHelper> pair1 = new TextValuePair<GenericParameterHelper>(); TextValuePair<GenericParameterHelper> pair2 = new TextValuePair<GenericParameterHelper>(); Assert.IsTrue(pair1.Equals(pair2)); Assert.IsTrue(pair1 == pair2); Assert.IsFalse(pair1 != pair2); pair1.Text = "1"; Assert.IsFalse(pair1.Equals(pair2)); Assert.IsFalse(pair1 == pair2); Assert.IsTrue(pair1 != pair2); pair2.Text = "12".Substring(0, 1); Assert.IsTrue(pair1.Equals(pair2)); Assert.IsTrue(pair1 == pair2); Assert.IsFalse(pair1 != pair2); pair1.Value = value; Assert.IsFalse(pair1.Equals(pair2)); Assert.IsFalse(pair1 == pair2); Assert.IsTrue(pair1 != pair2); pair2.Value = value; Assert.IsTrue(pair1.Equals(pair2)); Assert.IsTrue(pair1 == pair2); Assert.IsFalse(pair1 != pair2); }
public void TestEditableObjectTextAndValue() { GenericParameterHelper para1 = new GenericParameterHelper(1); GenericParameterHelper para2 = new GenericParameterHelper(2); TextValuePair <GenericParameterHelper> target = new TextValuePair <GenericParameterHelper>("AA", para1); IEditableObject obj = (IEditableObject)target; bool changing = false; bool changed = false; bool error = false; target.PropertyChanging += (sender, e) => { if (e.PropertyName == string.Empty) { changing = true; if (target.Text != "AA" || target.Value != para1) { error = true; } } }; target.PropertyChanged += (sender, e) => { if (changing && e.PropertyName == string.Empty) { changed = true; if (target.Text != "BB" || target.Value != para2) { error = true; } } }; // Test Text And Value obj.BeginEdit(); target.Text = "BB"; target.Value = para2; Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); obj.CancelEdit(); Assert.AreEqual(target.Text, "AA"); Assert.AreEqual(target.Value, para1); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); obj.EndEdit(); Assert.AreEqual(target.Text, "AA"); Assert.AreEqual(target.Value, para1); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); obj.CancelEdit(); Assert.AreEqual(target.Text, "AA"); Assert.AreEqual(target.Value, para1); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); obj.BeginEdit(); target.Text = "BB"; target.Value = para2; obj.EndEdit(); Assert.AreEqual(target.Text, "BB"); Assert.AreEqual(target.Value, para2); Assert.IsFalse(error); Assert.IsTrue(changing); Assert.IsTrue(changed); changing = false; changed = false; obj.CancelEdit(); Assert.AreEqual(target.Text, "BB"); Assert.AreEqual(target.Value, para2); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); // Test Text And Value without change changing = changed = error = false; obj.BeginEdit(); target.Text = "BB"; target.Value = para2; obj.EndEdit(); Assert.IsFalse(error); Assert.IsFalse(changing); Assert.IsFalse(changed); }
public void TestProperty() { TextValuePair<GenericParameterHelper> target = new TextValuePair<GenericParameterHelper>(); Assert.AreEqual(target.Text, default(string), "测试 Text 默认值失败。"); Assert.AreEqual(target.Value, default(GenericParameterHelper), "测试 Value 默认值失败。"); target.Text = "TT"; target.Value = new GenericParameterHelper(1); Assert.AreEqual(target.Text, "TT", "测试 Text 赋值失败。"); Assert.AreEqual(target.Value, new GenericParameterHelper(1), "测试 Value 赋值失败。"); target = new TextValuePair<GenericParameterHelper>("TT", new GenericParameterHelper(2)); Assert.AreEqual(target.Text, "TT", "测试 Text 构造函数赋值失败。"); Assert.AreEqual(target.Value, new GenericParameterHelper(2), "测试 Value 构造函数赋值失败。"); }
public void TestTextEvent() { TextValuePair<GenericParameterHelper> target = new TextValuePair<GenericParameterHelper>("AA", null); bool changing = false; bool changed = false; bool error = false; target.PropertyChanging += (sender, e) => { if (e.PropertyName == "Text") { changing = true; if (target.Text != "AA") { error = true; } } }; target.PropertyChanged += (sender, e) => { if (changing && e.PropertyName == "Text") { changed = true; if (target.Text != "BB") { error = true; } } }; target.Text = "BB"; Assert.IsFalse(error); Assert.IsTrue(changing); Assert.IsTrue(changed); }
/// <summary> /// Ctor /// </summary> public Element() { distance = null; duration = null;; status = StatusEnum.NA; }