feat: 标题栏显示多选框 (#8932)

* feat: 标题栏显示多选框

* chore: 完善标题栏显示多选框

* chore: 标题滚动可选开启

* feat: 标题栏内容可选隐藏

* i18n: 标题栏多选框内容翻译

* i18n: 标题栏选项翻译

---------

Co-authored-by: 枫雨 <35213527+moomiji@users.noreply.github.com>
This commit is contained in:
uye
2024-04-29 02:04:10 +08:00
committed by GitHub
parent f3b5c3fc6b
commit 8d8ff7bb15
8 changed files with 114 additions and 67 deletions

View File

@@ -43,6 +43,7 @@ namespace MaaWpfGui.Constants
public const string CustomStageCode = "GUI.CustomStageCode";
public const string InverseClearMode = "GUI.InverseClearMode";
public const string WindowTitlePrefix = "GUI.WindowTitlePrefix";
public const string WindowTitleSelectShowList = "GUI.WindowTitleSelectShowList";
public const string SoberLanguage = "GUI.SoberLanguage";
public const string Cheers = "GUI.Cheers";
public const string Hangover = "GUI.Hangover";

View File

@@ -303,6 +303,7 @@ Please do not check it when the stage OF-1 is not unlocked.</system:String>
<system:String x:Key="SystemNotification">System Notification</system:String>
<system:String x:Key="HideCloseButton">Hide close button</system:String>
<system:String x:Key="WindowTitleScrollable">Window Title Scrolling</system:String>
<system:String x:Key="TitleBarDisplayContent">Title Bar Display Content</system:String>
<system:String x:Key="UseLogItemDateFormat">Custom log date format</system:String>
<system:String x:Key="LogItemDateFormatString">Date format string</system:String>
<system:String x:Key="PromptRestartForSettingsChange">Restart immediately to apply changes?</system:String>

View File

@@ -304,6 +304,7 @@
<system:String x:Key="SystemNotification">重要な通知をポップアップする</system:String>
<system:String x:Key="HideCloseButton">「閉じる」ボタンを隠す</system:String>
<system:String x:Key="WindowTitleScrollable">タイトルのスクロール機能</system:String>
<system:String x:Key="TitleBarDisplayContent">タイトルバー表示コンテンツ</system:String>
<system:String x:Key="UseLogItemDateFormat">カスタムログ日付形式</system:String>
<system:String x:Key="LogItemDateFormatString">日付書式文字列</system:String>
<system:String x:Key="PromptRestartForSettingsChange">変更を適用するためにすぐに再起動しますか?</system:String>

View File

@@ -304,6 +304,7 @@ OF-1을 해금하지 않았다면 선택하지 말아 주세요.</system:String>
<system:String x:Key="SystemNotification">중요 알림 팝업</system:String>
<system:String x:Key="HideCloseButton">닫기 버튼 숨기기</system:String>
<system:String x:Key="WindowTitleScrollable">창 제목 스크롤</system:String>
<system:String x:Key="TitleBarDisplayContent">타이틀 바 표시 내용</system:String>
<system:String x:Key="UseLogItemDateFormat">사용자 정의 로그 날짜 형식</system:String>
<system:String x:Key="LogItemDateFormatString">날짜 형식 문자열</system:String>
<system:String x:Key="PromptRestartForSettingsChange">변경 사항을 적용을 위해 즉시 다시 시작하시겠습니까?</system:String>

View File

@@ -303,6 +303,7 @@
<system:String x:Key="SystemNotification">重要信息弹出系统通知</system:String>
<system:String x:Key="HideCloseButton">隐藏关闭按钮</system:String>
<system:String x:Key="WindowTitleScrollable">窗口标题滚动</system:String>
<system:String x:Key="TitleBarDisplayContent">标题栏显示内容</system:String>
<system:String x:Key="UseLogItemDateFormat">自选日志日期格式</system:String>
<system:String x:Key="LogItemDateFormatString">日期格式字符串</system:String>
<system:String x:Key="PromptRestartForSettingsChange">是否立刻重启应用更改?</system:String>

View File

@@ -303,6 +303,7 @@
<system:String x:Key="SystemNotification">重要訊息彈出系統通知</system:String>
<system:String x:Key="HideCloseButton">隱藏關閉按鈕</system:String>
<system:String x:Key="WindowTitleScrollable">窗口標題滾動</system:String>
<system:String x:Key="TitleBarDisplayContent">標題欄顯示內容</system:String>
<system:String x:Key="UseLogItemDateFormat">自訂日誌日期格式</system:String>
<system:String x:Key="LogItemDateFormatString">日期格式字串</system:String>
<system:String x:Key="PromptRestartForSettingsChange">是否立刻重啟應用更改?</system:String>

View File

@@ -46,6 +46,7 @@ using MaaWpfGui.Utilities.ValueType;
using Microsoft.Win32;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using ObservableCollections;
using Serilog;
using Stylet;
using ComboBox = System.Windows.Controls.ComboBox;
@@ -3470,11 +3471,6 @@ namespace MaaWpfGui.ViewModels.UI
public void UpdateWindowTitle()
{
var rvm = (RootViewModel)this.Parent;
var connectConfigName = string.Empty;
foreach (var data in ConnectConfigList.Where(data => data.Value == ConnectConfig))
{
connectConfigName = data.Display;
}
string prefix = ConfigurationHelper.GetValue(ConfigurationKeys.WindowTitlePrefix, string.Empty);
if (!string.IsNullOrEmpty(prefix))
@@ -3482,8 +3478,40 @@ namespace MaaWpfGui.ViewModels.UI
prefix += " - ";
}
List<string> windowTitleSelectShowList = _windowTitleSelectShowList
.Where(x => _windowTitleAllShowDict.ContainsKey(x?.ToString() ?? string.Empty))
.Select(x => _windowTitleAllShowDict[x?.ToString() ?? string.Empty]).ToList();
string currentConfiguration = string.Empty;
string connectConfigName = string.Empty;
string connectAddress = string.Empty;
string clientName = string.Empty;
foreach (var select in windowTitleSelectShowList)
{
switch (select)
{
case "1": // 配置名
currentConfiguration = $" ({CurrentConfiguration})";
break;
case "2": // 连接模式
foreach (var data in ConnectConfigList.Where(data => data.Value == ConnectConfig))
{
connectConfigName = $" - {data.Display}";
}
break;
case "3": // 端口地址
connectAddress = $" ({ConnectAddress})";
break;
case "4": // 客户端类型
clientName = $" - {ClientName}";
break;
}
}
string resourceVersion = !string.IsNullOrEmpty(ResourceVersion) ? $" - {ResourceVersion}" : string.Empty;
rvm.WindowTitle = $"{prefix}MAA ({CurrentConfiguration}) - {CoreVersion}{resourceVersion} - {connectConfigName} ({ConnectAddress}) - {ClientName}";
rvm.WindowTitle = $"{prefix}MAA{currentConfiguration} - {CoreVersion}{resourceVersion}{connectConfigName}{connectAddress}{clientName}";
}
private readonly string _bluestacksConfig = GetBluestacksConfig();
@@ -3773,7 +3801,7 @@ namespace MaaWpfGui.ViewModels.UI
}
}
private bool _useLogItemDateFormat = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseLogItemDateFormat, bool.FalseString));
private bool _useLogItemDateFormat = true; // Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseLogItemDateFormat, bool.FalseString));
public bool UseLogItemDateFormat
{
@@ -3993,6 +4021,36 @@ namespace MaaWpfGui.ViewModels.UI
}
}
private static readonly Dictionary<string, string> _windowTitleAllShowDict = new()
{
{ LocalizationHelper.GetString("ConfigurationName"), "1" },
{ LocalizationHelper.GetString("ConnectionPreset"), "2" },
{ LocalizationHelper.GetString("ConnectionAddress"), "3" },
{ LocalizationHelper.GetString("ClientType"), "4" },
};
private List<string> _windowTitleAllShowList = [.. _windowTitleAllShowDict.Keys];
public List<string> WindowTitleAllShowList
{
get => _windowTitleAllShowList;
set => SetAndNotify(ref _windowTitleAllShowList, value);
}
private object[] _windowTitleSelectShowList = ConfigurationHelper.GetValue(ConfigurationKeys.WindowTitleSelectShowList, "1 2 3 4").Split(' ').Select(s => _windowTitleAllShowDict.FirstOrDefault(pair => pair.Value == s).Key).ToArray();
public object[] WindowTitleSelectShowList
{
get => _windowTitleSelectShowList;
set
{
SetAndNotify(ref _windowTitleSelectShowList, value);
UpdateWindowTitle();
var config = string.Join(' ', _windowTitleSelectShowList.Cast<string>().Select(s => _windowTitleAllShowDict[s]));
ConfigurationHelper.SetValue(ConfigurationKeys.WindowTitleSelectShowList, config);
}
}
private string _soberLanguage = ConfigurationHelper.GetValue(ConfigurationKeys.SoberLanguage, LocalizationHelper.DefaultLanguage);
public string SoberLanguage

View File

@@ -23,13 +23,9 @@
VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<UniformGrid
Grid.Row="0"
Grid.Column="0"
Rows="5">
<StackPanel Grid.Row="0" Grid.Column="0">
<CheckBox
Margin="10"
HorizontalAlignment="Left"
@@ -48,7 +44,7 @@
VerticalAlignment="Center"
Content="{DynamicResource HideCloseButton}"
IsChecked="{Binding HideCloseButton}" />
<CheckBox
<!--<CheckBox
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
@@ -59,83 +55,70 @@
HorizontalAlignment="Left"
VerticalAlignment="Center"
Content="{DynamicResource UseLogItemDateFormat}"
IsChecked="{Binding UseLogItemDateFormat}" />
</UniformGrid>
<UniformGrid
Grid.Row="0"
Grid.Column="1"
Rows="4">
<controls:TextBlock
Margin="10"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Block.TextAlignment="Center"
Text="{Binding LanguageInfo, Mode=OneTime}"
TextWrapping="Wrap" />
<controls:TextBlock
Margin="10"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Block.TextAlignment="Center"
Text="{DynamicResource UiTheme}"
TextWrapping="Wrap" />
<controls:TextBlock
Margin="10"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Block.TextAlignment="Center"
Text="{DynamicResource MainViewButtonFeature}"
TextWrapping="Wrap" />
<controls:TextBlock
Margin="10"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Block.TextAlignment="Center"
Text="{DynamicResource LogItemDateFormatString}"
TextWrapping="Wrap"
Visibility="{c:Binding UseLogItemDateFormat}" />
</UniformGrid>
<UniformGrid
Grid.Row="0"
Grid.Column="2"
Rows="4">
<ComboBox
x:Name="LanguageSelector"
Width="120"
IsChecked="{Binding UseLogItemDateFormat}" />-->
<CheckBox
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Content="{DynamicResource WindowTitleScrollable}"
IsChecked="{Binding WindowTitleScrollable}" />
<hc:CheckComboBox
x:Name="CheckComboBox"
Width="180"
Margin="10"
HorizontalAlignment="Right"
hc:ListBoxAttach.SelectedItems="{Binding WindowTitleSelectShowList}"
hc:TitleElement.Title="{DynamicResource TitleBarDisplayContent}"
ItemsSource="{Binding WindowTitleAllShowList}"
Style="{StaticResource CheckComboBoxExtend}" />
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1">
<ComboBox
x:Name="LanguageSelector"
Width="180"
Margin="10"
HorizontalAlignment="Right"
VerticalAlignment="Center"
hc:InfoElement.Title="{Binding LanguageInfo, Mode=OneTime}"
DisplayMemberPath="Display"
ItemsSource="{Binding LanguageList}"
SelectedValue="{Binding Language}"
SelectedValuePath="Value" />
SelectedValuePath="Value"
Style="{StaticResource ComboBoxExtend}" />
<ComboBox
Width="120"
Width="180"
Margin="10"
HorizontalAlignment="Left"
HorizontalAlignment="Right"
VerticalAlignment="Center"
hc:InfoElement.Title="{DynamicResource UiTheme}"
DisplayMemberPath="Display"
ItemsSource="{Binding DarkModeList}"
SelectedValue="{Binding DarkMode}"
SelectedValuePath="Value" />
SelectedValuePath="Value"
Style="{StaticResource ComboBoxExtend}" />
<ComboBox
Width="120"
Width="180"
Margin="10"
HorizontalAlignment="Left"
HorizontalAlignment="Right"
VerticalAlignment="Center"
hc:InfoElement.Title="{DynamicResource MainViewButtonFeature}"
DisplayMemberPath="Display"
IsHitTestVisible="{Binding Idle}"
ItemsSource="{Binding InverseClearModeList}"
SelectedValue="{Binding InverseClearMode}"
SelectedValuePath="Value" />
SelectedValuePath="Value"
Style="{StaticResource ComboBoxExtend}" />
<ComboBox
Width="120"
Width="180"
Margin="10"
HorizontalAlignment="Left"
HorizontalAlignment="Right"
VerticalAlignment="Center"
hc:InfoElement.Title="{DynamicResource LogItemDateFormatString}"
ItemsSource="{Binding LogItemDateFormatStringList}"
SelectedValue="{Binding LogItemDateFormatString}"
Style="{StaticResource ComboBoxExtend}"
Visibility="{c:Binding UseLogItemDateFormat}" />
</UniformGrid>
</StackPanel>
</Grid>
</UserControl>