public Bookmark(FastColouredTextBox tb, string name, int lineIndex) { this.TB = tb; this.Name = name; this.LineIndex = lineIndex; Colour = tb.BookmarkColour; }
/// <summary> /// Occurs when user click on StyleVisualMarker joined to this style /// </summary> public virtual void OnVisualMarkerClick(FastColouredTextBox tb, VisualMarkerEventArgs args) { if (VisualMarkerClick != null) { VisualMarkerClick(tb, args); } }
public Hints(FastColouredTextBox tb) { this.tb = tb; tb.TextChanged += OnTextBoxTextChanged; tb.KeyDown += OnTextBoxKeyDown; tb.VisibleRangeChanged += OnTextBoxVisibleRangeChanged; }
public string GetHtml(FastColouredTextBox tb) { this.tb = tb; Range sel = new Range(tb); sel.SelectAll(); return(GetHtml(sel)); }
public FileTextSource(FastColouredTextBox currentTB) : base(currentTB) { timer.Interval = 10000; timer.Tick += new EventHandler(timer_Tick); timer.Enabled = true; SaveEOL = Environment.NewLine; }
internal AutoCompleteListView(FastColouredTextBox tb) { SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true); base.Font = new Font(FontFamily.GenericSansSerif, 9); visibleItems = new List <AutoCompleteItem>(); VerticalScroll.SmallChange = ItemHeight; MaximumSize = new Size(Size.Width, 180); toolTip.ShowAlways = false; AppearInterval = 500; timer.Tick += new EventHandler(timer_Tick); SelectedColour = Color.Orange; HoveredColour = Color.Red; ToolTipDuration = 3000; toolTip.Popup += ToolTip_Popup; this.tb = tb; tb.KeyDown += new KeyEventHandler(tb_KeyDown); tb.SelectionChanged += new EventHandler(tb_SelectionChanged); tb.KeyPressed += new KeyPressEventHandler(tb_KeyPressed); Form form = tb.FindForm(); if (form != null) { form.LocationChanged += delegate { SafetyClose(); }; form.ResizeBegin += delegate { SafetyClose(); }; form.FormClosing += delegate { SafetyClose(); }; form.LostFocus += delegate { SafetyClose(); }; } tb.LostFocus += (o, e) => { if (Menu != null && !Menu.IsDisposed) { if (!Menu.Focused) { SafetyClose(); } } }; tb.Scroll += delegate { SafetyClose(); }; this.VisibleChanged += (o, e) => { if (this.Visible) { DoSelectedVisible(); } }; }
public override void Draw(Graphics gr, Point position, Range range) { //draw background if (BackgroundBrush != null) { gr.FillRectangle(BackgroundBrush, position.X, position.Y, (range.End.iChar - range.Start.iChar) * range.tb.CharWidth, range.tb.CharHeight); } //draw chars using (var f = new Font(range.tb.Font, FontStyle)) { Line line = range.tb[range.Start.iLine]; float dx = range.tb.CharWidth; float y = position.Y + range.tb.LineInterval / 2; float x = position.X - range.tb.CharWidth / 3; if (ForeBrush == null) { ForeBrush = new SolidBrush(range.tb.ForeColor); } if (range.tb.ImeAllowed) { //IME mode for (int i = range.Start.iChar; i < range.End.iChar; i++) { SizeF size = FastColouredTextBox.GetCharSize(f, line[i].c); var gs = gr.Save(); float k = size.Width > range.tb.CharWidth + 1 ? range.tb.CharWidth / size.Width : 1; gr.TranslateTransform(x, y + (1 - k) * range.tb.CharHeight / 2); gr.ScaleTransform(k, (float)Math.Sqrt(k)); gr.DrawString(line[i].c.ToString(), f, ForeBrush, 0, 0, stringFormat); gr.Restore(gs); x += dx; } } else { //classic mode for (int i = range.Start.iChar; i < range.End.iChar; i++) { //draw char gr.DrawString(line[i].c.ToString(), f, ForeBrush, x, y, stringFormat); x += dx; } } } }
public TextSource(FastColouredTextBox currentTB) { this.CurrentTB = currentTB; linesAccessor = new LinesAccessor(this); Manager = new CommandManager(this); if (Enum.GetUnderlyingType(typeof(StyleIndex)) == typeof(UInt32)) { Styles = new Style[32]; } else { Styles = new Style[16]; } InitDefaultStyle(); }
public AutoCompleteMenu(FastColouredTextBox tb) { // create a new popup and add the list view to it AutoClose = false; AutoSize = false; Margin = Padding.Empty; Padding = Padding.Empty; BackColor = Color.White; listView = new AutoCompleteListView(tb); host = new ToolStripControlHost(listView); host.Margin = new Padding(2, 2, 2, 2); host.Padding = Padding.Empty; host.AutoSize = false; host.AutoToolTip = false; CalcSize(); base.Items.Add(host); listView.Parent = this; SearchPattern = @"[\w\.]"; MinFragmentLength = 2; }
public Bookmarks(FastColouredTextBox tb) { this.tb = tb; tb.LineInserted += tb_LineInserted; tb.LineRemoved += tb_LineRemoved; }
public FindWindow(FastColouredTextBox textBox) { InitializeComponent(); _textBox = textBox; }
public string GetRtf(Range r) { this.tb = r.tb; var styles = new Dictionary <StyleIndex, object>(); var sb = new StringBuilder(); var tempSB = new StringBuilder(); var currentStyleId = StyleIndex.None; r.Normalize(); int currentLine = r.Start.iLine; styles[currentStyleId] = null; colourTable.Clear(); // var lineNumberColor = GetColourTableNumber(r.tb.LineNumberColour); if (IncludeLineNumbers) { tempSB.AppendFormat(@"{{\cf{1} {0}}}\tab", currentLine + 1, lineNumberColor); } // foreach (Place p in r) { InternalChar c = r.tb[p.iLine][p.iChar]; if (c.style != currentStyleId) { Flush(sb, tempSB, currentStyleId); currentStyleId = c.style; styles[currentStyleId] = null; } if (p.iLine != currentLine) { for (int i = currentLine; i < p.iLine; i++) { tempSB.AppendLine(@"\line"); if (IncludeLineNumbers) { tempSB.AppendFormat(@"{{\cf{1} {0}}}\tab", i + 2, lineNumberColor); } } currentLine = p.iLine; } switch (c.c) { case '\\': tempSB.Append(@"\\"); break; case '{': tempSB.Append(@"\{"); break; case '}': tempSB.Append(@"\}"); break; default: var ch = c.c; var code = (int)ch; if (code < 128) { tempSB.Append(c.c); } else { tempSB.AppendFormat(@"{{\u{0}}}", code); } break; } } Flush(sb, tempSB, currentStyleId); //build color table var list = new SortedList <int, Color>(); foreach (var pair in colourTable) { list.Add(pair.Value, pair.Key); } tempSB.Length = 0; tempSB.AppendFormat(@"{{\colortbl;"); foreach (var pair in list) { tempSB.Append(GetColourAsString(pair.Value) + ";"); } tempSB.AppendLine("}"); // if (UseOriginalFont) { sb.Insert(0, string.Format(@"{{\fonttbl{{\f0\fmodern {0};}}}}{{\fs{1} ", tb.Font.Name, (int)(2 * tb.Font.SizeInPoints), tb.CharHeight)); sb.AppendLine(@"}"); } sb.Insert(0, tempSB.ToString()); sb.Insert(0, @"{\rtf1\ud\deff0"); sb.AppendLine(@"}"); return(sb.ToString()); }
/// <summary> /// Shows VisualMarker /// Call this method in Draw method, when you need to show VisualMarker for your style /// </summary> protected virtual void AddVisualMarker(FastColouredTextBox tb, StyleVisualMarker marker) { tb.AddVisualMarker(marker); }
public ReplaceWindow(FastColouredTextBox box) { InitializeComponent(); tb = box; }
protected virtual void UnSubscribe(FastColouredTextBox target) { target.Scroll -= new ScrollEventHandler(Target_Scroll); target.SelectionChangedDelayed -= new EventHandler(Target_SelectionChanged); target.VisibleRangeChanged -= new EventHandler(Target_VisibleRangeChanged); }
public string GetHtml(Range r) { this.tb = r.tb; Dictionary <StyleIndex, object> styles = new Dictionary <StyleIndex, object>(); StringBuilder sb = new StringBuilder(); StringBuilder tempSB = new StringBuilder(); StyleIndex currentStyleId = StyleIndex.None; r.Normalize(); int currentLine = r.Start.iLine; styles[currentStyleId] = null; // if (UseOriginalFont) { sb.AppendFormat("<font style=\"font-family: {0}, monospace; font-size: {1}pt; line-height: {2}px;\">", r.tb.Font.Name, r.tb.Font.SizeInPoints, r.tb.CharHeight); } // if (IncludeLineNumbers) { tempSB.AppendFormat("<span class=lineNumber>{0}</span> ", currentLine + 1); } // bool hasNonSpace = false; foreach (Place p in r) { Char c = r.tb[p.iLine][p.iChar]; if (c.style != currentStyleId) { Flush(sb, tempSB, currentStyleId); currentStyleId = c.style; styles[currentStyleId] = null; } if (p.iLine != currentLine) { for (int i = currentLine; i < p.iLine; i++) { tempSB.Append(UseBr ? "<br>" : "\r\n"); if (IncludeLineNumbers) { tempSB.AppendFormat("<span class=lineNumber>{0}</span> ", i + 2); } } currentLine = p.iLine; hasNonSpace = false; } switch (c.c) { case ' ': if ((hasNonSpace || !UseForwardNbsp) && !UseNbsp) { goto default; } tempSB.Append(" "); break; case '<': tempSB.Append("<"); break; case '>': tempSB.Append(">"); break; case '&': tempSB.Append("&"); break; default: hasNonSpace = true; tempSB.Append(c.c); break; } } Flush(sb, tempSB, currentStyleId); if (UseOriginalFont) { sb.Append("</font>"); } //build styles if (UseStyleTag) { tempSB.Length = 0; tempSB.Append("<style type=\"text/css\">"); foreach (var styleId in styles.Keys) { tempSB.AppendFormat(".fctb{0}{{ {1} }}\r\n", GetStyleName(styleId), GetCss(styleId)); } tempSB.Append("</style>"); sb.Insert(0, tempSB.ToString()); } if (IncludeLineNumbers) { sb.Insert(0, LineNumbersCSS); } return(sb.ToString()); }
internal MacrosManager(FastColouredTextBox ctrl) { UnderlayingControl = ctrl; AllowMacroRecordingByUser = true; }