Inheritance: ICollection, IList, IEnumerable, ICloneable
コード例 #1
0
        // Operations (type-safe ICloneable)
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public UndoBlockCollection Clone()
        {
            var tc = new UndoBlockCollection();

            tc.AddRange(this);
            tc.Capacity  = m_array.Length;
            tc.m_version = m_version;
            return(tc);
        }
コード例 #2
0
        // Public helpers (just to mimic some nice features of ArrayList)

        /// <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, m_array, m_count, collection.m_count);
            m_count += collection.Count;
        }
コード例 #3
0
ファイル: SyntaxDocument.cs プロジェクト: rogerluiz/devotion
 /// <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()
 {
     captureMode = true;
     captureBlock = new UndoBlockCollection();
 }
コード例 #4
0
ファイル: SyntaxDocument.cs プロジェクト: rogerluiz/devotion
 /// <summary>
 /// Add an action to the undo stack
 /// </summary>
 /// <param name="ActionGroup">action to add</param>
 public void AddToUndoList(UndoBlockCollection ActionGroup)
 {
     UndoBuffer.ClearFrom(UndoStep);
     UndoBuffer.Add(ActionGroup);
     UndoStep++;
     OnUndoBufferChanged();
 }
コード例 #5
0
ファイル: SyntaxDocument.cs プロジェクト: rogerluiz/devotion
        public void AddToUndoList(UndoBlock undo)
        {
            //store the undo action in a actiongroup
            var ActionGroup = new UndoBlockCollection {undo};

            AddToUndoList(ActionGroup);
        }
コード例 #6
0
            // Construction

            public Enumerator(UndoBlockCollection tc)
            {
                m_collection = tc;
                m_index      = -1;
                m_version    = tc.m_version;
            }
コード例 #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="collection"></param>
 public UndoBlockCollection(UndoBlockCollection collection)
 {
     AddRange(collection);
 }
コード例 #8
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="collection"></param>
 public UndoBlockCollection(UndoBlockCollection collection)
 {
     AddRange(collection);
 }
コード例 #9
0
ファイル: EditViewControl.cs プロジェクト: westybsa/MP.LSharp
        private void InsertText(string text)
        {
            Caret.CropPosition();
            if (Selection.IsValid)
            {
                Selection.DeleteSelection();
                InsertText(text);
            }
            else
            {
                if (!_OverWrite || text.Length > 1)
                {
                    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
                {
                    var r = new TextRange
                            {
                                FirstColumn = Caret.Position.X,
                                FirstRow = Caret.Position.Y,
                                LastColumn = (Caret.Position.X + 1),
                                LastRow = Caret.Position.Y
                            };
                    var ag = new UndoBlockCollection();
                    var b = new UndoBlock
                                  {
                                      Action = UndoAction.DeleteRange,
                                      Text = Document.GetRange(r),
                                      Position = Caret.Position
                                  };
                    ag.Add(b);
                    Document.DeleteRange(r, false);
                    b = new UndoBlock
                        {
                            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 ();
        }
コード例 #10
0
            // Construction

            public Enumerator(UndoBlockCollection tc)
            {
                m_collection = tc;
                m_index = - 1;
                m_version = tc.m_version;
            }
コード例 #11
0
        // Public helpers (just to mimic some nice features of ArrayList)

        /// <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, m_array, m_count, collection.m_count);
            m_count += collection.Count;
        }
コード例 #12
0
 // Operations (type-safe ICloneable)
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 public UndoBlockCollection Clone()
 {
     var tc = new UndoBlockCollection();
     tc.AddRange(this);
     tc.Capacity = m_array.Length;
     tc.m_version = m_version;
     return tc;
 }
コード例 #13
0
ファイル: Selection.cs プロジェクト: vchelaru/FlatRedBall
        /// <summary>
        /// Outdent the active selection one step
        /// </summary>
        public void Outdent(string Pattern)
        {
            if (!IsValid)
                return;

            Row xtr = null;
            var ActionGroup = new UndoBlockCollection();
            for (int i = LogicalBounds.FirstRow;
                 i <=
                 LogicalBounds.LastRow;
                 i++)
            {
                xtr = Control.Document[i];
                var 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);
            Bounds = LogicalBounds;
            Bounds.FirstColumn = 0;
            Bounds.LastColumn = xtr.Text.Length;
            Control.Caret.Position.X = LogicalBounds.LastColumn;
            Control.Caret.Position.Y = LogicalBounds.LastRow;
        }
コード例 #14
0
ファイル: Selection.cs プロジェクト: vchelaru/FlatRedBall
        public void Indent(string Pattern)
        {
            if (!IsValid)
                return;

            Row xtr = null;
            var ActionGroup = new UndoBlockCollection();
            for (int i = LogicalBounds.FirstRow;
                 i <=
                 LogicalBounds.LastRow;
                 i++)
            {
                xtr = Control.Document[i];
                xtr.Text = Pattern + xtr.Text;
                var 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);
            Bounds = LogicalBounds;
            Bounds.FirstColumn = 0;
            Bounds.LastColumn = xtr.Text.Length;
            Control.Caret.Position.X = LogicalBounds.LastColumn;
            Control.Caret.Position.Y = LogicalBounds.LastRow;
        }