// Operations (type-safe ICloneable)
		/// <summary>
/// 
/// </summary>
/// <returns></returns>
		public UndoBlockCollection Clone()
		{
			UndoBlockCollection tc = new UndoBlockCollection();
			tc.AddRange(this);
			tc.Capacity = this.m_array.Length;
			tc.m_version = this.m_version;
			return tc;
		}
Example #2
0
        /// <summary>
///
/// </summary>
/// <param name="collection"></param>
        public void AddRange(UndoBlockCollection collection)
        {
            // for (int i=0; i < collection.Count; ++i) Add(collection[i]);

            ++m_version;

            Capacity += collection.Count;
            Array.Copy(collection.m_array, 0, this.m_array, m_count, collection.m_count);
            m_count += collection.Count;
        }
Example #3
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 #4
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 #5
0
		/// <summary>
		/// Starts an Undo Capture.
		/// This method can be called if you with to collect multiple text operations into one undo action
		/// </summary>
		public void StartUndoCapture()
		{
			mCaptureMode = true;
			mCaptureBlock = new UndoBlockCollection();
		}
Example #6
0
		/// <summary>
		/// Add an action to the undo stack
		/// </summary>
		/// <param name="ActionGroup">action to add</param>
		public void AddToUndoList(UndoBlockCollection ActionGroup)
		{
			//int count=UndoBuffer.Count-UndoStep;
//			if (count>0)
//			{
//				System.Windows.Forms.MessageBox.Show (UndoStep.ToString ());
//				System.Windows.Forms.MessageBox.Show (count.ToString ());
//			}

			UndoBuffer.ClearFrom(UndoStep);

			//	System.Windows.Forms.MessageBox.Show (UndoBuffer.Count.ToString());		
			UndoBuffer.Add(ActionGroup);
			UndoStep++;
			this.OnUndoBufferChanged();
		}
Example #7
0
		public void AddToUndoList(UndoBlock undo)
		{
			//store the undo action in a actiongroup
			UndoBlockCollection ActionGroup = new UndoBlockCollection();
			ActionGroup.Add(undo);

			AddToUndoList(ActionGroup);
		}
Example #8
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 #9
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;
		}
Example #10
0
            // Construction

            public Enumerator(UndoBlockCollection tc)
            {
                m_collection = tc;
                m_index      = -1;
                m_version    = tc.m_version;
            }
Example #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="collection"></param>
 public UndoBlockCollection(UndoBlockCollection collection)
 {
     AddRange(collection);
 }
Example #12
0
			// Construction

			public Enumerator(UndoBlockCollection tc)
			{
				m_collection = tc;
				m_index = -1;
				m_version = tc.m_version;
			}
Example #13
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="collection"></param>
		public UndoBlockCollection(UndoBlockCollection collection)
		{
			AddRange(collection);
		}
Example #14
0
		/// <summary>
/// 
/// </summary>
/// <param name="collection"></param>
		public void AddRange(UndoBlockCollection collection)
		{
			// for (int i=0; i < collection.Count; ++i) Add(collection[i]);

			++m_version;

			Capacity += collection.Count;
			Array.Copy(collection.m_array, 0, this.m_array, m_count, collection.m_count);
			m_count += collection.Count;
		}