Example #1
0
        /// <summary>
        /// Indent the active selection one step.
        /// </summary>
        public void Indent()
        {
            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 = "\t" + xtr.Text;
                var b = new UndoBlock();
                b.Action     = UndoAction.InsertRange;
                b.Text       = "\t";
                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;
        }
Example #2
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 #3
0
        /// <summary>
        /// Outdent the active selection one step
        /// </summary>
        public void Outdent()
        {
            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()
                {
                    Action = UndoAction.DeleteRange
                };
                b.Position.X = 0;
                b.Position.Y = i;
                ActionGroup.Add(b);
                string s = xtr.Text;
                if (s.StartsWith("\t"))
                {
                    b.Text = s.Substring(0, 1);
                    s      = s.Substring(1);
                }
                if (s.StartsWith("    "))
                {
                    b.Text = s.Substring(0, 4);
                    s      = s.Substring(4);
                }
                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;
        }
Example #4
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;
        }