This is a migrated thread and some comments may be shown as answers.

MultipleRedoControl

11 Answers 89 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 11 Apr 2012, 07:34 PM
I am using the MultipleUndoControl; is there a MultipleRedoControl? Or is there a way to use the MultipleUndoControl with Redo?

11 Answers, 1 is accepted

Sort by
0
Steve
Top achievements
Rank 1
answered on 12 Apr 2012, 12:29 AM
Upon further investigation, apparently there is NO redo support beyond the single redo command.  What was the thinking in developing multiple undo without developing the redo counterpart.
0
Kammen
Telerik team
answered on 12 Apr 2012, 12:38 PM
Hi Steve,

We do not have a multiple redo control because most feature requests we get are for functionality that MS Word offers. As you may notice, there is no multiple redo control in MS Word either.

However, if it is a requirement of your project, you can create your own custom multiple redo control. All you should do is to create your own custom command that inherits from RichTextBoxCommandBase. Then, pass the number of redoes that you want to perform as a command parameter, and in ExecuteOverride method call:

int undoStackIndex = Convert.ToInt32(parameter);
for (int i = 0; i <= undoStackIndex; i++)
{
    this.AssociatedRichTextBox.Undo();
}

Then you must create your own control and implement the logic the way you would like it to work. 

If you have a license for RadControls for WPF, you can download the source of the controls and take a look at the MultipleUndoCommand and MultipleUndoControl for reference. 

Hope this answer your question.

Greetings,

Kammen
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Steve
Top achievements
Rank 1
answered on 12 Apr 2012, 04:34 PM
You know, I rarely use Word, and didn't realize it suffers from the same deficiency.  I, of course use VS 2010 which has both multi-undo and multi-redo, so I assumed this was a standard implementation.  I appreciate your direction on how to create my own!
Best and thank you,
Steve
0
Steve
Top achievements
Rank 1
answered on 12 Apr 2012, 05:23 PM
It looks like the only way to access the redoStack of the DocumentHistory class will be through reflection. There is no GetLastRedoCommands method. Do you know of any othere way?Thanks in advance,
Steve
0
Mihail
Telerik team
answered on 17 Apr 2012, 09:32 AM
Hi Steve,
You don't actually need to access DocumentHistory class - instead you can just call the RadRichTextBox.Redo method as many times as you need it:
int redoAcationCount = 4;
for (int i = 0; i < redoAcationCount; i++)
{
    this.radRichTextBox1.Redo();
}

If you have further questions do not hesitate to contact us again.

All the best,
Mihail
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Steve
Top achievements
Rank 1
answered on 17 Apr 2012, 04:45 PM
How else can I get a list of the actions to display in the drop down?  Other limitations include...

Each time a character is typed, it counts as one undo or redo Typing action.  With a limit of 20 actions each time the drop down is displayed, this is not a very good implementation.  Just to undo the typing of the first sentence in this message would require 4 drop downs (60+ characters).  Typing actions in Word are grouped together.

Rather than considering backspaces as Typing as it does in Word, each backspace is considered a separate Delete action.

So much of the Undo/Redo mechanism is private or internal.  The only way I can see to modify the behavior to mimic that of Word, is to use reflection, clearly violating the spirit of OOD.

Since in your original response, you indicated that the intent was to provide the same functionality as Word, are there plans to enhance the undo/redo architecture to match that of Word?

Thanks,
Steve
0
Mihail
Telerik team
answered on 19 Apr 2012, 06:15 PM
Hello Steve,

Unfortunately there isn't any other way for you to implement multiple redo.
Regarding your question whether we planned to enhance this functionality, the answer is yes, we planned to implement the so-called smart undo which includes grouping of some commands of similar type. However, this task is not an easy one and has not been scheduled yet. I have created a PITS issue, which you can use to track our development plans:  http://www.telerik.com/support/pits.aspx#/public/silverlight/10790 

About the limitation of how much actions you can revert, this will depend on the performance of the commands contained in those actions.

Kind regards,
Mihail
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Steve
Top achievements
Rank 1
answered on 19 Apr 2012, 06:32 PM
Hi Mihail,
 Although I had to use quite a bit of reflection, it really wasn't that hard to implement and I was able to handle the multiple redo and grouping of the Typing actions.  If you're interested, or anyone else is interested, I provided the source in the Code Library in the General and Integration Section under the title -

RadRichTextBox Multiple Undo/Redo

Thanks again for your responses,
Steve
0
Mihail
Telerik team
answered on 23 Apr 2012, 11:29 AM
Hello Steve,

Thank you for sharing your work with us.
We will review your code and will implement or modify it to fit our needs.

If you have other questions do not hesitate to contact us again.

Regards,
Mihail
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Steve
Top achievements
Rank 1
answered on 22 Feb 2013, 08:08 PM

Hello again,

Apparently the Undo/Redo implementation has been completely refactored in the Q1 2013 release.  Classes that I made use of...

 

  •     HistoryAction
  •     HistoryCommandAction

 

have been removed breaking my current implementation of MultiRedo (see my previous post indicating that I posted the code in the Code Library).  I have searched all over for documentation on the new..

 

  • Undo/Redo Command grouping (assemble custom undo-redo actions) 

feature.  Could you provide or direct me to documentation on this new feature, and suggest a way I can refactor my own code to work with the Q1 2013 release?

Thanks in advance,
Steve

0
Boby
Telerik team
answered on 25 Feb 2013, 12:50 PM
Hello Steve,
We refactored the internal commanding mechanism, which allowed us to expose some additional methods through the IDocumentEditor interface, enabling grouping of the execution of the IDocumentEditor's methods in undoable commands, for example:
// RadRichTextBox itself implements IDocumentEditor
IDocumentEditor documentEditor = this.radRichTextBox;
  
// You can also use RadDocumentEditor class, initializing it with any document;
//IDocumentEditor documentEditor = new RadDocumentEditor(this.radRichTextBox.Document);
  
documentEditor.BeginUndoGroup();
  
documentEditor.InsertTableRow();
documentEditor.InsertTableRow();
documentEditor.InsertTableRow();
  
documentEditor.EndUndoGroup("Insert 3 table rows");
  
// You can also cancel the execution of the undo group, and it won't be recored in the history.
//documentEditor.CancelUndoGroup();


All the best,
Boby
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
RichTextBox
Asked by
Steve
Top achievements
Rank 1
Answers by
Steve
Top achievements
Rank 1
Kammen
Telerik team
Mihail
Telerik team
Boby
Telerik team
Share this question
or