feat: add status message
This commit is contained in:
@@ -8,6 +8,7 @@ using System.Runtime.InteropServices;
|
|||||||
using System.Security.Policy;
|
using System.Security.Policy;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
|
||||||
namespace BallanceTasEditor.Frontend.ViewModels {
|
namespace BallanceTasEditor.Frontend.ViewModels {
|
||||||
public partial class MainWindow : ObservableObject {
|
public partial class MainWindow : ObservableObject {
|
||||||
@@ -16,6 +17,12 @@ namespace BallanceTasEditor.Frontend.ViewModels {
|
|||||||
|
|
||||||
this.TasFile = null;
|
this.TasFile = null;
|
||||||
this.TasFilePath = null;
|
this.TasFilePath = null;
|
||||||
|
|
||||||
|
this.StatusMessage = "";
|
||||||
|
m_StatusMessageDimmer = new DispatcherTimer();
|
||||||
|
m_StatusMessageDimmer.Interval = TimeSpan.FromSeconds(5);
|
||||||
|
m_StatusMessageDimmer.Tick += StatusMessageDimmer_Tick;
|
||||||
|
UpdateStatusMessage("Ready");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Shared.IDialogService m_DialogService;
|
private Shared.IDialogService m_DialogService;
|
||||||
@@ -49,6 +56,7 @@ namespace BallanceTasEditor.Frontend.ViewModels {
|
|||||||
// Set members
|
// Set members
|
||||||
this.TasFile = seq;
|
this.TasFile = seq;
|
||||||
this.TasFilePath = null;
|
this.TasFilePath = null;
|
||||||
|
UpdateStatusMessage($"New TAS file is created.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CanNewFile() {
|
private bool CanNewFile() {
|
||||||
@@ -73,6 +81,7 @@ namespace BallanceTasEditor.Frontend.ViewModels {
|
|||||||
// Set members
|
// Set members
|
||||||
this.TasFile = seq;
|
this.TasFile = seq;
|
||||||
this.TasFilePath = dialog.Path;
|
this.TasFilePath = dialog.Path;
|
||||||
|
UpdateStatusMessage($"TAS file {this.TasFilePath} is loaded.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CanOpenFile() {
|
private bool CanOpenFile() {
|
||||||
@@ -100,6 +109,7 @@ namespace BallanceTasEditor.Frontend.ViewModels {
|
|||||||
}
|
}
|
||||||
// Update member
|
// Update member
|
||||||
this.TasFilePath = filePath;
|
this.TasFilePath = filePath;
|
||||||
|
UpdateStatusMessage($"TAS file {this.TasFilePath} is saved.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CanSaveFile() {
|
private bool CanSaveFile() {
|
||||||
@@ -121,6 +131,7 @@ namespace BallanceTasEditor.Frontend.ViewModels {
|
|||||||
}
|
}
|
||||||
// Set file path
|
// Set file path
|
||||||
TasFilePath = dialog.Path;
|
TasFilePath = dialog.Path;
|
||||||
|
UpdateStatusMessage($"TAS file {this.TasFilePath} is saved.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CanSaveFileAs() {
|
private bool CanSaveFileAs() {
|
||||||
@@ -131,6 +142,7 @@ namespace BallanceTasEditor.Frontend.ViewModels {
|
|||||||
private void CloseFile() {
|
private void CloseFile() {
|
||||||
this.TasFile = null;
|
this.TasFile = null;
|
||||||
this.TasFilePath = null;
|
this.TasFilePath = null;
|
||||||
|
UpdateStatusMessage($"TAS file is closed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CanCloseFile() {
|
private bool CanCloseFile() {
|
||||||
@@ -189,6 +201,29 @@ namespace BallanceTasEditor.Frontend.ViewModels {
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Status Bar
|
||||||
|
|
||||||
|
#region Status Message
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private string statusMessage;
|
||||||
|
|
||||||
|
private DispatcherTimer m_StatusMessageDimmer;
|
||||||
|
|
||||||
|
private void UpdateStatusMessage(string msg) {
|
||||||
|
m_StatusMessageDimmer.Stop();
|
||||||
|
StatusMessage = msg;
|
||||||
|
m_StatusMessageDimmer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StatusMessageDimmer_Tick(object? sender, EventArgs e) {
|
||||||
|
StatusMessage = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region UI Only
|
#region UI Only
|
||||||
|
|
||||||
public string WindowTitle {
|
public string WindowTitle {
|
||||||
|
|||||||
@@ -162,7 +162,7 @@
|
|||||||
<StatusBarItem Content="$ToolMode" DockPanel.Dock="Right"/>
|
<StatusBarItem Content="$ToolMode" DockPanel.Dock="Right"/>
|
||||||
<Separator DockPanel.Dock="Right"/>
|
<Separator DockPanel.Dock="Right"/>
|
||||||
|
|
||||||
<StatusBarItem Content="$Status" HorizontalAlignment="Stretch"/>
|
<StatusBarItem Content="{Binding StatusMessage, Mode=OneWay}" HorizontalAlignment="Stretch"/>
|
||||||
</StatusBar>
|
</StatusBar>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
Reference in New Issue
Block a user