private void ReadMsgFile() { linesMsg = new List <string>(File.ReadAllLines(msgPath, enc)); ProgressBarForm progress = null; if (linesMsg.Count > 250) { progress = new ProgressBarForm(this, linesMsg.Count); } dgvMessage.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None; SendMessage(dgvMessage.Handle, WM_SETREDRAW, false, 0); for (int i = 0; i < linesMsg.Count; i++) { Entry entry; try { entry = new Entry(linesMsg[i]); } catch (Exception) { MessageBox.Show("Message file is bad!\nLine Error: " + i.ToString()); break; } while (Entry.IsWrap && ++i < linesMsg.Count) { entry.Append(linesMsg[i]); } AddRow(entry); if (progress != null) { progress.SetProgress = i; } } //if (dgvMessage.VirtualMode) dgvMessage.RowCount = rowsEntry.Count; SendMessage(dgvMessage.Handle, WM_SETREDRAW, true, 0); dgvMessage.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders; if (progress != null) { progress.Dispose(); } this.Text = Path.GetFileName(msgPath) + this.Tag; groupBox.Text = msgPath; msgSaveButton.Enabled = false; }
public CFG(string filepath) { List <Element> contents = new List <Element>(); using (StreamReader reader = new StreamReader(filepath)) { string line; while ((line = reader.ReadLine()) != null) { LineType lineType = IdentifyLine(line); switch (lineType) { case LineType.Comment: contents.Add(new Comment(line)); break; case LineType.RegularEntry: contents.Add(new Entry(line)); break; case LineType.EmptyEntry: contents.Add(new Entry(line.Replace("=", "").Trim(), new List <string>())); break; case LineType.EmptyLine: contents.Add(new Empty()); break; case LineType.AvulseEntry: if (contents.Count > 0) { Entry lastElement = (Entry)contents[contents.Count - 1]; lastElement.Append(line); contents[contents.Count - 1] = (Element)lastElement; } else { throw new Exception("Invalid CFG file"); } break; } } } this.Elements = contents; }
protected override void HandleCore(KeyEventArgs e) { string key = ""; if (_numericKeys.FirstOrDefault(x => x == e.Key) != Key.None) { key = e.Key.ToString().Substring(1); } else if (e.Key == Key.Space) { key = " "; } else { key = e.Key.ToProperCaseString(); } Entry.Append(key); }
protected override void HandleCore(KeyEventArgs e) { Entry.Append(Clipboard.GetText()); }