public FormatRange(TextRange Bounds, Color ForeColor, Color BackColor) { this.BackColor = BackColor; this.ForeColor = ForeColor; this.Bounds = Bounds; this.Bounds.Change += new EventHandler(this.BoundsChanged); }
/// <summary> /// Selection Constructor. /// </summary> /// <param name="control">Control that will use this selection</param> public Selection(EditViewControl control) { Control = control; Bounds = new TextRange(); }
public void Shrink(TextRange Range) { string Text = this.Document.GetRange(Range); string tmp = Text.Replace(Environment.NewLine, "\n"); int l = tmp.Length; string[] tmplines = tmp.Split('\n'); foreach (FormatRange fr in this) { int res = fr.Contains(Range.FirstColumn, Range.FirstRow); int res2 = fr.Contains(Range.LastColumn, Range.LastRow); int rows = Range.LastRow - Range.FirstRow; if (res == - 1 && res2 == - 1) { fr.Bounds.FirstRow -= rows; fr.Bounds.LastRow -= rows; if (fr.Bounds.FirstRow == Range.FirstRow + tmplines.Length - 1) { if (tmplines.Length > 1) fr.Bounds.FirstColumn -= Range.FirstColumn; fr.Bounds.FirstColumn -= tmplines[tmplines.Length - 1].Length; } else if (fr.Bounds.FirstRow == Range.FirstRow) { if (tmplines.Length > 1) fr.Bounds.FirstColumn += Range.FirstColumn; fr.Bounds.FirstColumn -= tmplines[tmplines.Length - 1].Length; } } if (res == - 1 && res2 == 0) { fr.Bounds.FirstRow -= rows; fr.Bounds.LastRow -= rows; fr.Bounds.FirstColumn = Range.FirstColumn; } if (res == 0 && res2 == 0) { fr.Bounds.LastRow -= rows; if (fr.Bounds.LastRow == Range.FirstRow) { if (rows == 0) fr.Bounds.LastColumn -= tmplines[tmplines.Length - 1].Length; else fr.Bounds.LastColumn = Range.FirstColumn + fr.Bounds.LastColumn; } } if (res == 0 && res2 == 1) { //delete end of range fr.Bounds.LastColumn = Range.FirstColumn - 1; fr.Bounds.LastRow = Range.FirstRow; } if (res == - 1 && res2 == 1) { //delete this range fr.Bounds.SetBounds(- 1, - 1, - 1, - 1); } if (res == 1) { //ignore } } }
/// <summary> /// Assigns a new text to the row. /// </summary> /// <param name="text"></param> public void SetText(string text) { Document.StartUndoCapture(); var tp = new TextPoint(0, Index); var tr = new TextRange {FirstColumn = 0, FirstRow = tp.Y, LastColumn = Text.Length, LastRow = tp.Y}; Document.StartUndoCapture(); //delete the current line Document.PushUndoBlock(UndoAction.DeleteRange, Document.GetRange(tr), tr.FirstColumn, tr.FirstRow); //alter the text Document.PushUndoBlock(UndoAction.InsertRange, text, tp.X, tp.Y); Text = text; Document.EndUndoCapture(); Document.InvokeChange(); }
/// <summary> /// Assigns a new text to the row. /// </summary> /// <param name="Text"></param> public void SetText(string Text) { this.Document.StartUndoCapture(); TextPoint tp = new TextPoint(0, this.Index); TextRange tr = new TextRange(); tr.FirstColumn = 0; tr.FirstRow = tp.Y; tr.LastColumn = this.Text.Length; tr.LastRow = tp.Y; this.Document.StartUndoCapture(); //delete the current line this.Document.PushUndoBlock(UndoAction.DeleteRange, this.Document.GetRange(tr), tr.FirstColumn, tr.FirstRow); //alter the text this.Document.PushUndoBlock(UndoAction.InsertRange, Text, tp.X, tp.Y); this.Text = Text; this.Document.EndUndoCapture(); this.Document.InvokeChange(); }
public FormatRange(TextRange Bounds, Color WaveColor) { this.WaveColor = WaveColor; this.Bounds = Bounds; this.Bounds.Change += new EventHandler(this.BoundsChanged); }