Add database file name to the app title

References #165
This commit is contained in:
chylex 2022-02-20 20:03:59 +01:00
parent 47b106503d
commit 77aa15e557
No known key found for this signature in database
GPG Key ID: 4DE42C8F19A80548
2 changed files with 8 additions and 1 deletions

View File

@ -5,7 +5,7 @@
xmlns:main="clr-namespace:DHT.Desktop.Main"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="DHT.Desktop.Main.MainWindow"
Title="Discord History Tracker"
Title="{Binding Title}"
Icon="avares://DiscordHistoryTracker/Resources/icon.ico"
Width="800" Height="500"
MinWidth="480" MinHeight="240"

View File

@ -11,6 +11,10 @@ using DHT.Server.Database;
namespace DHT.Desktop.Main {
public class MainWindowModel : BaseModel {
private const string DefaultTitle = "Discord History Tracker";
public string Title { get; private set; } = DefaultTitle;
public WelcomeScreen WelcomeScreen { get; }
private WelcomeScreenModel WelcomeScreenModel { get; }
@ -76,10 +80,12 @@ namespace DHT.Desktop.Main {
db = WelcomeScreenModel.Db;
if (db == null) {
Title = DefaultTitle;
MainContentScreenModel = null;
MainContentScreen = null;
}
else {
Title = Path.GetFileName(db.Path) + " - " + DefaultTitle;
MainContentScreenModel = new MainContentScreenModel(window, db);
MainContentScreenModel.Initialize();
MainContentScreenModel.DatabaseClosed += MainContentScreenModelOnDatabaseClosed;
@ -89,6 +95,7 @@ namespace DHT.Desktop.Main {
OnPropertyChanged(nameof(ShowWelcomeScreen));
OnPropertyChanged(nameof(ShowMainContentScreen));
OnPropertyChanged(nameof(Title));
window.Focus();
}