internal void CreateList(IEnumerable <GPXLoader.Cache> caches, RichTextBoxLinks.RichTextBoxEx textBox) { if (caches.Count() > 1000 && !suppressDialog) { var result = MessageBox.Show(this, string.Format("Showing {0} caches might take a while. Are you sure?\n\nCancel to suppress this message for now.", caches.Count()), "Annoying Dialog", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); switch (result) { case DialogResult.No: return; case DialogResult.Cancel: suppressDialog = true; break; } } if (caches.Count() > 400) { this.Cursor = Cursors.WaitCursor; } btnExport.Enabled = caches.Count() > 0; listedCaches = caches; textBox.Text = string.Empty; //clear formatting textBox.SelectedText = gridPurpose.TitleFormatter(caches) + "\n"; //internal links will be in the form directive:GC0000 Regex hyper = new Regex("(\\w+):(GC\\w+)"); foreach (var c in caches.OrderByDescending(a => a.sFoundDate)) { string s; if (filterControl1.simpleListing) { s = ACacheFormatter.SimpleCacheFormatter(c); } else { s = gridPurpose.CacheFormatter(c); } int idx = 0; var matches = hyper.Matches(s); for (int i = 0; i < matches.Count; i++) { var match = matches[i]; textBox.SelectedText = s.Substring(idx, match.Index - idx); textBox.InsertLink(match.Groups[1].Value, match.Groups[2].Value + " "); //had to add space due to buggy custom rich text control. idx = match.Index + match.Length; } textBox.SelectedText = s.Substring(idx, s.Length - idx); } //embolden the first line textBox.Select(0, textBox.Text.IndexOf('\n')); textBox.SelectionFont = new Font(textBox.Font, FontStyle.Bold); this.Cursor = Cursors.Default; }
public RichIDLFormatter(RichTextBoxLinks.RichTextBoxEx rtb) { _sb = new StringBuilder(); _rtb = rtb; _bPendingApplyTabs = false; }