private void TextBox_custom_TextChanged(object sender, EventArgs e) { if (comboBox_src.SelectedIndex < 0) { return; } Hen_String str = comboBox_src.SelectedItem as Hen_String; string res = textBox_custom.Text; string current = textBox_custom.Text; if (current.Length > 0) { while (current.Length > 0) { res = current + str.suffix; int size = Encoding.UTF8.GetByteCount(res); if (size <= str.max_size) { break; } current = current.Substring(0, current.Length - 1); } if (current.Length < 1) { MessageBox.Show("Cannot compute the string", "error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); textBox_res.Text = str.text + str.suffix; textBox_custom.Text = str.text; return; } } else { res += str.suffix; } str.text = current; textBox_res.Text = res; if (current.Length != textBox_custom.Text.Length) { textBox_custom.Text = current; textBox_custom.SelectionStart = current.Length; label_warn.Visible = true; timer_warn_fadeOut.Enabled = true; timer_warn_fadeOut.Start(); } }
private void Form1_Load(object sender, EventArgs e) { config = new INIFile(AppDomain.CurrentDomain.BaseDirectory + "hen_locale.ini"); List <string> key_list = config.GetKeysNames(INIFile.StoreTarget.Original, CONFIG_OFFSETS); foreach (var key in key_list) { long offset = config.GetValue(CONFIG_OFFSETS, key, -1); if (offset < 0) { continue; } bool has_suffix = config.GetValue(CONFIG_SUFFIXS, key, false); var str = new Hen_String(key.Replace('_', ' '), offset, has_suffix); comboBox_src.Items.Add(str); } }