Esempio n. 1
0
 // plays back a command in the UI creating new commands
 private void RedoCommand(INoteViewModel note, Control sender, INoteCommand command)
 {
     if (command is CreateNoteCommand)
     {
         var createCommand = command as CreateNoteCommand;
         var text          = createCommand.Text;
         vm.CreateNote(text);
         //UpdateUI(note, sender, text);
     }
     else if (command is DeleteTextFromNoteCommand)
     {
         var deleteTextCommand = command as DeleteTextFromNoteCommand;
         note.RemoveText(deleteTextCommand.Offset, deleteTextCommand.Text.Length, true);
         //UpdateUI(note, sender, text);
     }
     else if (command is InsertTextIntoNoteCommand)
     {
         var insertTextCommand = command as InsertTextIntoNoteCommand;
         vm.InsertText(note, insertTextCommand.Offset, insertTextCommand.Text, true);
         //UpdateUI(note, sender, note.Text);
     }
     else if (command is DeleteNoteCommand)
     {
         vm.DeleteNote(command.NoteGuid);
         //UpdateUI(note, sender, note.Text);
     }
 }
Esempio n. 2
0
 // plays back the command history of a note visually
 private void PlayCommand(INoteViewModel note, Control sender, INoteCommand command, int delayCount)
 {
     Task.Delay(delayCount).Wait();
     Debug.WriteLine(command.ToString());
     if (command is CreateNoteCommand)
     {
         var createCommand = command as CreateNoteCommand;
         var text          = createCommand.Text;
         UpdateUI(note, sender, text);
         //note.Text = createCommand.Text;
     }
     else if (command is DeleteTextFromNoteCommand)
     {
         var deleteTextCommand = command as DeleteTextFromNoteCommand;
         var text = note.Text;
         text = text.Remove(deleteTextCommand.Offset, deleteTextCommand.Text.Length);
         UpdateUI(note, sender, text);
     }
     else if (command is InsertTextIntoNoteCommand)
     {
         var insertTextCommand = command as InsertTextIntoNoteCommand;
         var text = note.Text;
         if (insertTextCommand.Offset == note.Text.Length)
         {
             text += insertTextCommand.Text;
             UpdateUI(note, sender, text);
         }
         else
         {
             text = text.Insert(insertTextCommand.Offset, insertTextCommand.Text);
             UpdateUI(note, sender, text);
         }
     }
 }
Esempio n. 3
0
 private void ReplayCommand(INoteCommand command)
 {
     if (command is CreateNoteCommand)
     {
         var createNoteCmd = command as CreateNoteCommand;
         var note          = CreateNote(createNoteCmd.Text, createNoteCmd.NoteGuid) as NoteViewModel;
         note.PropertyChanged += Note_PropertyChanged;
     }
     else
     {
         var note = DisplayNotes.Single(w => w.Guid == command.NoteGuid);
         var text = note.Text;
         if (command is InsertTextIntoNoteCommand)
         {
             var insertTextCmd = command as InsertTextIntoNoteCommand;
             InsertText(note, insertTextCmd.Offset, insertTextCmd.Text, true);
         }
         else if (command is DeleteTextFromNoteCommand)
         {
             var deleteTextCmd = command as DeleteTextFromNoteCommand;
             RemoveText(note, deleteTextCmd.Offset, deleteTextCmd.Text, true);
         }
     }
 }
Esempio n. 4
0
 private void AddCommand(INoteCommand noteCommand, INoteViewModel note)
 {
     AllCommands.Insert(0, noteCommand);
     DisplayCommands.Insert(0, noteCommand);
     note.Commands.Insert(0, noteCommand);
 }