Example #1
0
		private void TextDraw(TextDrawDirectionType Direction)
		{
			TextRange r = new TextRange();
			r.FirstColumn = Caret.Position.X;
			r.FirstRow = Caret.Position.Y;
			r.LastColumn = Caret.Position.X + 1;
			r.LastRow = Caret.Position.Y;

			int Style = (int) this.TextDrawStyle;
			string OldChar = Document.GetRange(r);
			string BorderString = TextBorderStyles[Style];
			//TextBorderChars OldCharType=0;

			if (OldChar == "")
				OldChar = " ";


			UndoBlockCollection ag = new UndoBlockCollection();
			UndoBlock b;
			b = new UndoBlock();
			b.Action = UndoAction.DeleteRange;
			b.Text = Document.GetRange(r);
			b.Position = Caret.Position;
			ag.Add(b);
			Document.DeleteRange(r, false);

			b = new UndoBlock();
			b.Action = UndoAction.InsertRange;


			string NewChar = "*";


			b.Text = NewChar;
			b.Position = Caret.Position;
			ag.Add(b);
			Document.AddToUndoList(ag);
			Document.InsertText(NewChar, Caret.Position.X, Caret.Position.Y, false);
		}
Example #2
0
		private void InsertText(string text)
		{
			Caret.CropPosition();
			if (Selection.IsValid)
			{
				Selection.DeleteSelection();
				InsertText(text);
			}
			else
			{
				if (!_OverWrite || text.Length > 1)
				{
					Row xtr = Caret.CurrentRow;
					TextPoint p = Document.InsertText(text, Caret.Position.X, Caret.Position.Y);
					Caret.CurrentRow.Parse(true);
					if (text.Length == 1)
					{
						Caret.SetPos(p);
						Caret.CaretMoved(false);

					}
					else
					{
						//Document.i = true;

						Document.ResetVisibleRows();
						Caret.SetPos(p);
						Caret.CaretMoved(false);
					}
				}
				else
				{
					TextRange r = new TextRange();
					r.FirstColumn = Caret.Position.X;
					r.FirstRow = Caret.Position.Y;
					r.LastColumn = Caret.Position.X + 1;
					r.LastRow = Caret.Position.Y;
					UndoBlockCollection ag = new UndoBlockCollection();
					UndoBlock b;
					b = new UndoBlock();
					b.Action = UndoAction.DeleteRange;
					b.Text = Document.GetRange(r);
					b.Position = Caret.Position;
					ag.Add(b);
					Document.DeleteRange(r, false);
					b = new UndoBlock();
					b.Action = UndoAction.InsertRange;
					string NewChar = text;
					b.Text = NewChar;
					b.Position = Caret.Position;
					ag.Add(b);
					Document.AddToUndoList(ag);
					Document.InsertText(NewChar, Caret.Position.X, Caret.Position.Y, false);
					Caret.CurrentRow.Parse(true);

					Caret.MoveRight(false);
				}
			}
			//	this.ScrollIntoView ();

		}
Example #3
0
		/// <summary>
		/// Insert a text at the specified row index
		/// </summary>
		/// <param name="Text">Text to insert</param>
		/// <param name="index">Row index where the text should be inserted</param>
		/// <param name="StoreUndo">true if and undo action should be added to the undo stack</param>
		/// <returns>The row that was inserted</returns>
		public Row Insert(string Text, int index, bool StoreUndo)
		{
			Row xtl = new Row();
			xtl.Document = this;
			mDocument.Insert(index, xtl);
			xtl.Text = Text;
			if (StoreUndo)
			{
				UndoBlock undo = new UndoBlock();
				undo.Text = Text;
				undo.Position.Y = this.IndexOf(xtl);
				AddToUndoList(undo);
			}

			//this.ResetVisibleRows ();
			return xtl;
		}
Example #4
0
		public void AddToUndoList(UndoBlock undo)
		{
			//store the undo action in a actiongroup
			UndoBlockCollection ActionGroup = new UndoBlockCollection();
			ActionGroup.Add(undo);

			AddToUndoList(ActionGroup);
		}
Example #5
0
		public void PushUndoBlock(UndoAction Action, string Text, int x, int y)
		{
			UndoBlock undo = new UndoBlock();
			undo.Action = Action;
			undo.Text = Text;
			undo.Position.Y = y;
			undo.Position.X = x;
			//AddToUndoList(undo);

			if (mCaptureMode)
			{
				mCaptureBlock.Add(undo);
			}
			else
			{
				AddToUndoList(undo);
			}
		}
Example #6
0
		/// <summary>
		/// Outdent the active selection one step
		/// </summary>
		public void Outdent(string Pattern)
		{
			if (!this.IsValid)
				return;

			Row xtr = null;
			UndoBlockCollection ActionGroup = new UndoBlockCollection();
			for (int i = this.LogicalBounds.FirstRow; i <= this.LogicalBounds.LastRow; i++)
			{
				xtr = Control.Document[i];
				UndoBlock b = new UndoBlock();
				b.Action = UndoAction.DeleteRange;
				b.Position.X = 0;
				b.Position.Y = i;
				ActionGroup.Add(b);
				string s = xtr.Text;
				if (s.StartsWith(Pattern))
				{
					b.Text = s.Substring(0, Pattern.Length);
					s = s.Substring(Pattern.Length);
				}
				xtr.Text = s;
			}
			if (ActionGroup.Count > 0)
				Control.Document.AddToUndoList(ActionGroup);
			this.Bounds = this.LogicalBounds;
			this.Bounds.FirstColumn = 0;
			this.Bounds.LastColumn = xtr.Text.Length;
			Control.Caret.Position.X = this.LogicalBounds.LastColumn;
			Control.Caret.Position.Y = this.LogicalBounds.LastRow;
		}
Example #7
0
		public void Indent(string Pattern)
		{
			if (!this.IsValid)
				return;

			Row xtr = null;
			UndoBlockCollection ActionGroup = new UndoBlockCollection();
			for (int i = this.LogicalBounds.FirstRow; i <= this.LogicalBounds.LastRow; i++)
			{
				xtr = Control.Document[i];
				xtr.Text = Pattern + xtr.Text;
				UndoBlock b = new UndoBlock();
				b.Action = UndoAction.InsertRange;
				b.Text = Pattern;
				b.Position.X = 0;
				b.Position.Y = i;
				ActionGroup.Add(b);
			}
			if (ActionGroup.Count > 0)
				Control.Document.AddToUndoList(ActionGroup);
			this.Bounds = this.LogicalBounds;
			this.Bounds.FirstColumn = 0;
			this.Bounds.LastColumn = xtr.Text.Length;
			Control.Caret.Position.X = this.LogicalBounds.LastColumn;
			Control.Caret.Position.Y = this.LogicalBounds.LastRow;
		}