-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
title show current editor display name
- Loading branch information
1 parent
376e63d
commit eb0958c
Showing
7 changed files
with
94 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,78 @@ | ||
using Gemini.Framework.Services; | ||
using Caliburn.Micro; | ||
using Gemini.Framework.Services; | ||
using OngekiFumenEditor.Modules.FumenVisualEditor.ViewModels; | ||
using System.ComponentModel.Composition; | ||
using System.Windows.Media; | ||
|
||
namespace OngekiFumenEditor.Utils | ||
{ | ||
[Export(typeof(WindowTitleHelper))] | ||
[PartCreationPolicy(CreationPolicy.Shared)] | ||
public class WindowTitleHelper | ||
{ | ||
[Import(typeof(IMainWindow))] | ||
private IMainWindow window = default; | ||
|
||
public string TitlePrefix { get; set; } = "Ongeki Fumen Editor"; | ||
|
||
public string TitleContent | ||
{ | ||
get | ||
{ | ||
return window.Title; | ||
} | ||
set | ||
{ | ||
var title = value; | ||
if (!(title?.StartsWith(TitlePrefix) ?? false)) | ||
{ | ||
title = TitlePrefix + (string.IsNullOrWhiteSpace(title) ? string.Empty : (" - " + title)); | ||
} | ||
window.Title = title; | ||
} | ||
} | ||
|
||
public ImageSource Icon | ||
{ | ||
get | ||
{ | ||
return window.Icon; | ||
} | ||
set | ||
{ | ||
window.Icon = value; | ||
} | ||
} | ||
} | ||
[Export(typeof(WindowTitleHelper))] | ||
[PartCreationPolicy(CreationPolicy.Shared)] | ||
public class WindowTitleHelper | ||
{ | ||
[Import(typeof(IMainWindow))] | ||
private IMainWindow window = default; | ||
|
||
private string titlePrefix = "Ongeki Fumen Editor"; | ||
public string TitlePrefix | ||
{ | ||
get => titlePrefix; | ||
set | ||
{ | ||
titlePrefix = value; | ||
UpdateWindowTitle(); | ||
} | ||
} | ||
|
||
private string titleSuffix = string.Empty; | ||
public string TitleSuffix | ||
{ | ||
get => titleSuffix; | ||
set | ||
{ | ||
titleSuffix = value; | ||
UpdateWindowTitle(); | ||
} | ||
} | ||
|
||
private string titleContent = string.Empty; | ||
public string TitleContent | ||
{ | ||
get | ||
{ | ||
return titleContent; | ||
} | ||
set | ||
{ | ||
titleContent = value; | ||
UpdateWindowTitle(); | ||
} | ||
} | ||
|
||
public string ActualFormattedWindowTitle => window.Title; | ||
|
||
public ImageSource Icon | ||
{ | ||
get | ||
{ | ||
return window.Icon; | ||
} | ||
set | ||
{ | ||
window.Icon = value; | ||
} | ||
} | ||
|
||
public void UpdateWindowTitle() | ||
{ | ||
var actualTitle = TitlePrefix + TitleContent + TitleSuffix; | ||
window.Title = actualTitle; | ||
} | ||
|
||
public void UpdateWindowTitleByEditor(FumenVisualEditorViewModel editor) | ||
{ | ||
var titleContent = editor != null ? $" - {editor.DisplayName} " : string.Empty; | ||
TitleContent = titleContent; | ||
} | ||
} | ||
} |