Merge pull request #77 from GlenCFL/save-state

Set the state to dirty on using editing commands.
This commit is contained in:
Ben Wallis 2018-09-07 15:05:43 +01:00 committed by GitHub
commit ae38197052
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 35 additions and 16 deletions

View File

@ -1030,7 +1030,6 @@ namespace Filtration.ViewModels
{ {
_scriptCommandManager.ExecuteCommand(new MoveBlockUpCommand(Script, targetBlockViewModelBase?.BaseBlock)); _scriptCommandManager.ExecuteCommand(new MoveBlockUpCommand(Script, targetBlockViewModelBase?.BaseBlock));
SelectedBlockViewModel = ItemFilterBlockViewModels[blockIndex - 1]; SelectedBlockViewModel = ItemFilterBlockViewModels[blockIndex - 1];
RaisePropertyChanged("SelectedBlockViewModel");
} }
else else
{ {
@ -1041,8 +1040,10 @@ namespace Filtration.ViewModels
} }
_scriptCommandManager.ExecuteCommand(new MoveSectionToIndexCommand(Script, blockIndex, 1, aboveSectionStart)); _scriptCommandManager.ExecuteCommand(new MoveSectionToIndexCommand(Script, blockIndex, 1, aboveSectionStart));
SelectedBlockViewModel = ItemFilterBlockViewModels[aboveSectionStart]; SelectedBlockViewModel = ItemFilterBlockViewModels[aboveSectionStart];
RaisePropertyChanged("SelectedBlockViewModel");
} }
RaisePropertyChanged("SelectedBlockViewModel");
SetDirtyFlag();
} }
public void MoveSectionUp(IItemFilterCommentBlockViewModel targetCommentBlockViewModel) public void MoveSectionUp(IItemFilterCommentBlockViewModel targetCommentBlockViewModel)
@ -1071,6 +1072,7 @@ namespace Filtration.ViewModels
ToggleSection(ItemFilterBlockViewModels[newLocation] as IItemFilterCommentBlockViewModel); ToggleSection(ItemFilterBlockViewModels[newLocation] as IItemFilterCommentBlockViewModel);
SelectedBlockViewModel = ItemFilterBlockViewModels[newLocation]; SelectedBlockViewModel = ItemFilterBlockViewModels[newLocation];
RaisePropertyChanged("SelectedBlockViewModel"); RaisePropertyChanged("SelectedBlockViewModel");
SetDirtyFlag();
} }
private void OnMoveBlockDownCommand() private void OnMoveBlockDownCommand()
@ -1094,7 +1096,6 @@ namespace Filtration.ViewModels
{ {
_scriptCommandManager.ExecuteCommand(new MoveBlockDownCommand(Script, targetBlockViewModelBase?.BaseBlock)); _scriptCommandManager.ExecuteCommand(new MoveBlockDownCommand(Script, targetBlockViewModelBase?.BaseBlock));
SelectedBlockViewModel = ItemFilterBlockViewModels[blockIndex + 1]; SelectedBlockViewModel = ItemFilterBlockViewModels[blockIndex + 1];
RaisePropertyChanged("SelectedBlockViewModel");
} }
else else
{ {
@ -1105,8 +1106,10 @@ namespace Filtration.ViewModels
} }
_scriptCommandManager.ExecuteCommand(new MoveSectionToIndexCommand(Script, blockIndex, 1, beloveSectionEnd - 1)); _scriptCommandManager.ExecuteCommand(new MoveSectionToIndexCommand(Script, blockIndex, 1, beloveSectionEnd - 1));
SelectedBlockViewModel = ItemFilterBlockViewModels[beloveSectionEnd - 1]; SelectedBlockViewModel = ItemFilterBlockViewModels[beloveSectionEnd - 1];
RaisePropertyChanged("SelectedBlockViewModel");
} }
RaisePropertyChanged("SelectedBlockViewModel");
SetDirtyFlag();
} }
public void MoveSectionDown(IItemFilterCommentBlockViewModel targetCommentBlockViewModel) public void MoveSectionDown(IItemFilterCommentBlockViewModel targetCommentBlockViewModel)
@ -1141,6 +1144,7 @@ namespace Filtration.ViewModels
ToggleSection(ItemFilterBlockViewModels[newLocation] as IItemFilterCommentBlockViewModel); ToggleSection(ItemFilterBlockViewModels[newLocation] as IItemFilterCommentBlockViewModel);
SelectedBlockViewModel = ItemFilterBlockViewModels[newLocation]; SelectedBlockViewModel = ItemFilterBlockViewModels[newLocation];
RaisePropertyChanged("SelectedBlockViewModel"); RaisePropertyChanged("SelectedBlockViewModel");
SetDirtyFlag();
} }
private void OnMoveBlockToBottomCommand() private void OnMoveBlockToBottomCommand()
@ -1178,12 +1182,16 @@ namespace Filtration.ViewModels
public void AddBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase) public void AddBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase)
{ {
_scriptCommandManager.ExecuteCommand(new AddBlockCommand(Script, targetBlockViewModelBase?.BaseBlock)); _scriptCommandManager.ExecuteCommand(new AddBlockCommand(Script, targetBlockViewModelBase?.BaseBlock));
RaisePropertyChanged("SelectedBlockViewModel");
SetDirtyFlag();
// TODO: Expand new viewmodel // TODO: Expand new viewmodel
} }
public void AddCommentBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase) public void AddCommentBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase)
{ {
_scriptCommandManager.ExecuteCommand(new AddCommentBlockCommand(Script, targetBlockViewModelBase.BaseBlock)); _scriptCommandManager.ExecuteCommand(new AddCommentBlockCommand(Script, targetBlockViewModelBase.BaseBlock));
RaisePropertyChanged("SelectedBlockViewModel");
SetDirtyFlag();
} }
public void DeleteBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase) public void DeleteBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase)
@ -1204,11 +1212,16 @@ namespace Filtration.ViewModels
_scriptCommandManager.ExecuteCommand(new RemoveSectionCommand(Script, sectionStart, sectionEnd - sectionStart)); _scriptCommandManager.ExecuteCommand(new RemoveSectionCommand(Script, sectionStart, sectionEnd - sectionStart));
} }
RaisePropertyChanged("SelectedBlockViewModel");
SetDirtyFlag();
} }
public void MoveBlockToBottom(IItemFilterBlockViewModelBase targetBlockViewModelBase) public void MoveBlockToBottom(IItemFilterBlockViewModelBase targetBlockViewModelBase)
{ {
_scriptCommandManager.ExecuteCommand(new MoveBlockToBottomCommand(Script, targetBlockViewModelBase.BaseBlock)); _scriptCommandManager.ExecuteCommand(new MoveBlockToBottomCommand(Script, targetBlockViewModelBase.BaseBlock));
RaisePropertyChanged("SelectedBlockViewModel");
SetDirtyFlag();
} }
public void MoveSectionToBottom(IItemFilterCommentBlockViewModel targetCommentBlockViewModel) public void MoveSectionToBottom(IItemFilterCommentBlockViewModel targetCommentBlockViewModel)
@ -1225,11 +1238,15 @@ namespace Filtration.ViewModels
ToggleSection(ItemFilterBlockViewModels[newLocation] as IItemFilterCommentBlockViewModel); ToggleSection(ItemFilterBlockViewModels[newLocation] as IItemFilterCommentBlockViewModel);
SelectedBlockViewModel = ItemFilterBlockViewModels[newLocation]; SelectedBlockViewModel = ItemFilterBlockViewModels[newLocation];
RaisePropertyChanged("SelectedBlockViewModel");
SetDirtyFlag();
} }
public void MoveBlockToTop(IItemFilterBlockViewModelBase targetBlockViewModelBase) public void MoveBlockToTop(IItemFilterBlockViewModelBase targetBlockViewModelBase)
{ {
_scriptCommandManager.ExecuteCommand(new MoveBlockToTopCommand(Script, targetBlockViewModelBase.BaseBlock)); _scriptCommandManager.ExecuteCommand(new MoveBlockToTopCommand(Script, targetBlockViewModelBase.BaseBlock));
RaisePropertyChanged("SelectedBlockViewModel");
SetDirtyFlag();
} }
public void MoveSectionToTop(IItemFilterCommentBlockViewModel targetCommentBlockViewModel) public void MoveSectionToTop(IItemFilterCommentBlockViewModel targetCommentBlockViewModel)
@ -1246,6 +1263,8 @@ namespace Filtration.ViewModels
ToggleSection(ItemFilterBlockViewModels[newLocation] as IItemFilterCommentBlockViewModel); ToggleSection(ItemFilterBlockViewModels[newLocation] as IItemFilterCommentBlockViewModel);
SelectedBlockViewModel = ItemFilterBlockViewModels[newLocation]; SelectedBlockViewModel = ItemFilterBlockViewModels[newLocation];
RaisePropertyChanged("SelectedBlockViewModel");
SetDirtyFlag();
} }
private void OnBlockBecameDirty(object sender, EventArgs e) private void OnBlockBecameDirty(object sender, EventArgs e)