1
0

feat: add CanExecute for command

This commit is contained in:
2026-04-19 15:35:01 +08:00
parent 5b230e40fc
commit b938fe6acc
3 changed files with 78 additions and 16 deletions

View File

@@ -17,7 +17,9 @@ namespace BallanceTasEditor.Frontend.Shared {
bool ShowConfirmExitWhenOpeningFileDialog();
bool ShowFileChangedDialog();
GotoDialogResult? ShowGotoDialog();
bool ShowConfirmClearKeysDialog();
EditFpsDialogResult? ShowEditFpsDialog();
bool ShowConfirmUniformFpsDialog();
AddFrameDialogResult? ShowAddFrameDialog();
PreferenceDialogResult? ShowPreferenceDialog();
void ShowManuallyReportBugDialog();
@@ -133,6 +135,14 @@ namespace BallanceTasEditor.Frontend.Shared {
}
}
public bool ShowConfirmClearKeysDialog() {
var rv = MessageBox.Show(
"Do you really want to clear keys for all frames?\nThis operation can not be revoked.",
"Clear Keys",
MessageBoxButton.YesNo, MessageBoxImage.Question);
return rv == MessageBoxResult.Yes;
}
public EditFpsDialogResult? ShowEditFpsDialog() {
var dialog = new Views.EditFpsDialog();
dialog.Owner = m_Parent;
@@ -144,6 +154,14 @@ namespace BallanceTasEditor.Frontend.Shared {
}
}
public bool ShowConfirmUniformFpsDialog() {
var rv = MessageBox.Show(
"Do you really want to set an uniform FPS value for all frames?\nThis operation can not be revoked.",
"Uniform FPS",
MessageBoxButton.YesNo, MessageBoxImage.Question);
return rv == MessageBoxResult.Yes;
}
public AddFrameDialogResult? ShowAddFrameDialog() {
var dialog = new Views.AddFrameDialog();
dialog.Owner = m_Parent;

View File

@@ -181,86 +181,130 @@ namespace BallanceTasEditor.Frontend.ViewModels {
#region Undo and Redo
[RelayCommand]
[RelayCommand(CanExecute = nameof(CanUndo))]
private void Undo() {
}
[RelayCommand]
private bool CanUndo() {
return true;
}
[RelayCommand(CanExecute = nameof(CanRedo))]
private void Redo() {
}
private bool CanRedo() {
return true;
}
#endregion
#region Viewer Operation
[RelayCommand]
[RelayCommand(CanExecute = nameof(CanPreviousPage))]
private void PreviousPage() {
}
private bool CanPreviousPage() {
return true;
}
[RelayCommand]
[RelayCommand(CanExecute = nameof(CanPreviousItem))]
private void PreviousItem() {
}
private bool CanPreviousItem() {
return true;
}
[RelayCommand]
[RelayCommand(CanExecute = nameof(CanNextPage))]
private void NextPage() {
}
private bool CanNextPage() {
return true;
}
[RelayCommand]
[RelayCommand(CanExecute = nameof(CanNextItem))]
private void NextItem() {
}
private bool CanNextItem() {
return true;
}
[RelayCommand]
[RelayCommand(CanExecute = nameof(CanGoto))]
private void Goto() {
}
private bool CanGoto() {
return true;
}
#endregion
#region Tool Mode
[RelayCommand]
[RelayCommand(CanExecute = nameof(CanSelectMode))]
private void SelectMode() {
}
private bool CanSelectMode() {
return true;
}
[RelayCommand]
[RelayCommand(CanExecute = nameof(CanFillMode))]
private void FillMode() {
}
private bool CanFillMode() {
return true;
}
[RelayCommand]
[RelayCommand(CanExecute = nameof(CanDrawMode))]
private void DrawMode() {
}
private bool CanDrawMode() {
return true;
}
#endregion
#region Misc Edit Operations
[RelayCommand]
[RelayCommand(CanExecute = nameof(CanUniformFps))]
private void ClearKeys() {
m_DialogService.ShowConfirmClearKeysDialog();
}
private bool CanClearKeys() {
return true;
}
[RelayCommand]
[RelayCommand(CanExecute = nameof(CanUniformFps))]
private void UniformFps() {
var rv = m_DialogService.ShowEditFpsDialog();
if (rv is not null) {
m_DialogService.ShowConfirmUniformFpsDialog();
}
}
private bool CanUniformFps() {
return true;
}
#endregion
#region Preference