// 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);
        }
        /// <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;
        }
Пример #3
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();
		}
Пример #4
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();
		}
Пример #5
0
		public void AddToUndoList(UndoBlock undo)
		{
			//store the undo action in a actiongroup
			UndoBlockCollection ActionGroup = new UndoBlockCollection();
			ActionGroup.Add(undo);

			AddToUndoList(ActionGroup);
		}
		public 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 ();

		}
		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);
		}
Пример #8
0
			// Construction

			public Enumerator(UndoBlockCollection tc)
			{
				m_collection = tc;
				m_index = -1;
				m_version = tc.m_version;
			}
Пример #9
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="collection"></param>
		public UndoBlockCollection(UndoBlockCollection collection)
		{
			AddRange(collection);
		}
Пример #10
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;
		}
Пример #11
0
		// 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;
		}
Пример #12
0
            // Construction

            public Enumerator(UndoBlockCollection tc)
            {
                m_collection = tc;
                m_index      = -1;
                m_version    = tc.m_version;
            }
Пример #13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="collection"></param>
 public UndoBlockCollection(UndoBlockCollection collection)
 {
     AddRange(collection);
 }
Пример #14
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;
		}
Пример #15
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;
		}