Changeset 3 for Common/FormFind.cs
- Timestamp:
- Feb 21, 2019, 2:13:01 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/FormFind.cs
r2 r3 16 16 public RichTextBoxEx richTextBox; 17 17 public string regSubKey; 18 public int maxHistoryCount;19 18 20 19 public FormFind() … … 22 21 InitializeComponent(); 23 22 regSubKey = "Find"; 24 maxHistoryCount = 20;25 23 } 26 24 … … 60 58 private void SearchText(bool reverse = false) 61 59 { 62 if (comboBoxWhat.Text.Trim() != "") 63 { 64 string previousText = comboBoxWhat.Text; 65 int index = comboBoxWhat.Items.IndexOf(comboBoxWhat.Text); 66 if (index >= 0) comboBoxWhat.Items.RemoveAt(index); 67 comboBoxWhat.Text = previousText; 68 comboBoxWhat.Items.Insert(0, comboBoxWhat.Text); 69 70 while (comboBoxWhat.Items.Count > maxHistoryCount) 71 comboBoxWhat.Items.RemoveAt(comboBoxWhat.Items.Count - 1); 72 } 60 comboBoxWhat.UpdateHistory(); 73 61 74 62 while (true) … … 111 99 new FormDimensions().Load(this, Owner); 112 100 comboBoxWhat.Focus(); 101 comboBoxWhat.regSubKey = regSubKey + "\\History"; 113 102 LoadFromRegistry(); 114 103 UpdateInterface(); … … 153 142 checkBoxMatchCase.Checked = regKey.GetValueBool("MatchCase", false); 154 143 155 regKey = Application.UserAppDataRegistry.OpenSubKey(regSubKey + "\\History"); 156 if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(regSubKey + "\\History"); 157 int count = regKey.GetValueInt("Count", 0); 158 comboBoxWhat.BeginUpdate(); 159 while (comboBoxWhat.Items.Count > count) comboBoxWhat.Items.RemoveAt(comboBoxWhat.Items.Count - 1); 160 while (comboBoxWhat.Items.Count < count) comboBoxWhat.Items.Add(""); 161 for (int i = 0; i < count; i++) 162 { 163 comboBoxWhat.Items[i] = (string)regKey.GetValue(i.ToString(), ""); 164 } 165 comboBoxWhat.EndUpdate(); 144 comboBoxWhat.LoadFromRegistry(); 166 145 } 167 146 … … 171 150 if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(regSubKey); 172 151 152 173 153 regKey.SetValue("MatchWholeWordOnly", checkBoxMatchWholeWordOnly.Checked); 174 154 regKey.SetValue("MatchCase", checkBoxMatchCase.Checked); 175 155 176 regKey = Application.UserAppDataRegistry.OpenSubKey(regSubKey + "\\History", true); 177 if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(regSubKey + "\\History"); 178 179 int i = 0; 180 regKey.SetValue("Count", comboBoxWhat.Items.Count); 181 foreach (var item in comboBoxWhat.Items) 182 { 183 regKey.SetValue(i.ToString(), item); 184 i++; 185 } 186 187 while (true) 188 { 189 List<string> names = regKey.GetValueNames().ToList(); 190 if (names.IndexOf(i.ToString()) != -1) 191 { 192 regKey.DeleteValue(i.ToString()); 193 } 194 else break; 195 i++; 196 } 156 comboBoxWhat.SaveToRegistry(); 197 157 } 198 158 }
Note:
See TracChangeset
for help on using the changeset viewer.