1:   //  UndoableReplace.cs 
2:   //  Copyright (c) 2000 Mike Krueger
3:   //
4:   //  This program is free software; you can redistribute it and/or modify
5:   //  it under the terms of the GNU General Public License as published by
6:   //  the Free Software Foundation; either version 2 of the License, or
7:   //  (at your option) any later version.
8:   //
9:   //  This program is distributed in the hope that it will be useful,
10:   //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11:   //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12:   //  GNU General Public License for more details.
13:   //
14:   //  You should have received a copy of the GNU General Public License
15:   //  along with this program; if not, write to the Free Software
16:   //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17:  
18:   using System;
19:   using System.Diagnostics;
20:   using System.Drawing;
21:   using SharpDevelop.DefaultEditor.Text;
22:   using SharpDevelop.Internal.Undo;
23:       
24:   namespace SharpDevelop.DefaultEditor.Undo {
25:       
26:       /// <summary>
27:       /// This class is for the undo of Document insert operations
28:       /// </summary>
29:       public class UndoableReplace : IUndoableOperation
30:       {
31:           IDocument document;
32:           int       offset;
33:           string    text;
34:           string    origText;
35:           
36:           public UndoableReplace(IDocument documentint offsetstring origTextstring text)
37:           {
38:               if (document == null) {
39:                   throw new ArgumentNullException("document");
40:               }
41:               if (offset || offset document.TextLength) {
42:                   throw new ArgumentOutOfRangeException("offset");
43:               }
44:               
45:               Debug.Assert(text != null"text can't be null");
46:               this.document document;
47:               this.offset   offset;
48:               this.text     text;
49:               this.origText origText;
50:           }
51:           
52:           public void Undo()
53:           {
54:               document.UndoStack.AcceptChanges false;
55:               document.Replace(offsettext.LengthorigText);
56:               document.UndoStack.AcceptChanges true;
57:           }
58:           public void Redo()
59:           {
60:               document.UndoStack.AcceptChanges false;
61:               document.Replace(offsetorigText.Lengthtext);
62:               document.UndoStack.AcceptChanges true;
63:           }
64:       }
65:   }

This page was automatically generated by SharpDevelop.