Skip to content

Commit

Permalink
给desktop增加播放窗口弹幕的展示、字号、速度相关的配置菜单和功能;修复缩小操作默认为托盘模式的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
CHKZL committed Jun 22, 2024
1 parent ac60ba0 commit 9bc8f9e
Show file tree
Hide file tree
Showing 8 changed files with 309 additions and 46 deletions.
55 changes: 50 additions & 5 deletions Core/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1485,10 +1485,10 @@ public string _PlayWindowDanmaColor
}
}

private static string PlayWindowSubtitleFontSize = "26";
private static string PlayWindowSubtitleFontSize = "30";
/// <summary>
/// 播放窗口字幕字号
/// 默认值:1250
/// 默认值:30
/// </summary>
public int _PlayWindowSubtitleFontSize
{
Expand All @@ -1507,10 +1507,10 @@ public int _PlayWindowSubtitleFontSize
}
}

private static string PlayWindowDanmaFontSize = "26";
private static string PlayWindowDanmaFontSize = "30";
/// <summary>
/// 播放窗口弹幕字号
/// 默认值:1250
/// 默认值:30
/// </summary>
public int _PlayWindowDanmaFontSize
{
Expand Down Expand Up @@ -1551,7 +1551,7 @@ public double _PlayWindowDanMuFontOpacity
}
}

private static string PlayWindowDanmaSpeed = "15";
private static string PlayWindowDanmaSpeed = "6";
/// <summary>
/// 播放窗口弹幕速度
/// 默认值:15
Expand All @@ -1572,6 +1572,51 @@ public int _PlayWindowDanmaSpeed
}
}
}

private static string PlayDanmaSpeed_Dynamically = "false";
/// <summary>
/// 播放窗口弹幕速度是否跟随窗口变化变化
/// 默认值:false
/// </summary>
public bool _PlayDanmaSpeed_Dynamically
{
get
{
return bool.Parse(PlayDanmaSpeed_Dynamically);
}
set
{
if (value.ToString() != PlayDanmaSpeed_Dynamically)
{
PlayDanmaSpeed_Dynamically = value.ToString();
OnPropertyChanged();
ModifyConfig(value);
}
}
}

private static string PlayWindowDanmaSwitch = "false";
/// <summary>
/// 打开播放窗时,是否默认打开弹幕
/// 默认值:false
/// </summary>
public bool _PlayWindowDanmaSwitch
{
get
{
return bool.Parse(PlayWindowDanmaSwitch);
}
set
{
if (value.ToString() != PlayWindowDanmaSwitch)
{
PlayWindowDanmaSwitch = value.ToString();
OnPropertyChanged();
ModifyConfig(value);
}
}
}

}
#endregion
}
Expand Down
2 changes: 1 addition & 1 deletion Desktop/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private void notify()
/// <exception cref="NotImplementedException"></exception>
private void MainWindow_StateChanged(object? sender, EventArgs e)
{
if (this.WindowState == WindowState.Minimized)
if (Config.Core_RunConfig._ZoomOutMode!=0 && this.WindowState == WindowState.Minimized)
{
this.Hide();
}
Expand Down
100 changes: 99 additions & 1 deletion Desktop/Views/Pages/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,105 @@

</StackPanel>
</ui:CardExpander>

<ui:CardExpander Grid.Row="4" Icon="{ui:SymbolIcon CalendarPlay20}">
<ui:CardExpander.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Row="0" Grid.Column="0" FontSize="16" FontTypography="Body" Text="播放窗设置" />
<ui:TextBlock Grid.Row="1" Grid.Column="0" FontSize="12" Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}" Text="在线播放功能相关设置" />
</Grid>
</ui:CardExpander.Header>
<StackPanel Margin="24,0,24,0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
</Grid>

<ui:CardExpander Icon="{ui:SymbolIcon Chat20}">
<ui:CardExpander.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Row="0" Grid.Column="0" FontSize="16" FontTypography="Body" Text="播放窗弹幕" />
<ui:TextBlock Grid.Row="1" Grid.Column="0" FontSize="12" Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}" Text="针对标准播放窗口的弹幕相关设置内容" />
</Grid>

</Grid>
</ui:CardExpander.Header>
<StackPanel Margin="24,0.5,24,0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Grid.Row="0" Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Margin="10,0,0,0" Content="打开播放器时默认开关" />
<CheckBox Name="PlayWindowDanmaSwitch_CheckBox" Grid.Row="1" HorizontalAlignment="Left" Margin="10,0,0,0" Content="默认打开弹幕" IsChecked="{Binding _PlayWindowDanmaSwitch, Mode=OneWay}"/>
</Grid>
<Grid Grid.Row="0" Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Margin="10,0,0,0" Content="弹幕字体大小" />
<ui:NumberBox Name="PlayWindowDanmaSize" Grid.Row="1" Width="200" HorizontalAlignment="Left" Margin="10,0,0,0" PlaceholderText="15" Minimum="1" Maximum="100" Text="{Binding _PlayWindowDanmaFontSize, Mode=OneWay}"/>
</Grid>
<Grid Grid.Row="0" Grid.Column="2">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Margin="10,0,0,0" Content="弹幕速度" />
<ui:NumberBox Name="PlayWindowDanmaSpeed_InputBox" Grid.Row="1" Width="200" HorizontalAlignment="Left" Margin="10,0,0,0" PlaceholderText="15" Minimum="1" Maximum="100" Text="{Binding _PlayWindowDanmaSpeed, Mode=OneWay}"/>
</Grid>
<Grid Grid.Row="0" Grid.Column="3">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Margin="10,0,0,0" Content="弹幕速度是否跟随播放大小变化动态变化" />
<CheckBox Name="PlayWindowDanmaSpeed_CheckBox" Grid.Row="1" HorizontalAlignment="Left" Margin="10,0,0,0" Content="跟随" IsChecked="{Binding _PlayDanmaSpeed_Dynamically, Mode=OneWay}"/>
</Grid>


</Grid>

</StackPanel>
</ui:CardExpander>

</StackPanel>

</ui:CardExpander>
</Grid>

</StackPanel>
Expand Down
71 changes: 62 additions & 9 deletions Desktop/Views/Pages/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,30 +99,42 @@ public bool CheckConfiguration(ref bool Reboot)
{
if (string.IsNullOrEmpty(DesktopIP_InputControl.Text) || string.IsNullOrEmpty(DesktopPort_InputControl.Text) || string.IsNullOrEmpty(DesktopAccessKeyId_InputControl.Text) || string.IsNullOrEmpty(DesktopAccessKeySecret_InputControl.Text))
{
MainWindow.SnackbarService.Show("保存失败", "请检查基础设置中远程服务器相关配置正确且不为空", ControlAppearance.Danger, new SymbolIcon(SymbolRegular.SaveSearch20), TimeSpan.FromSeconds(8));
MainWindow.SnackbarService.Show("保存失败", "请检查确保基础设置中远程服务器相关配置正确且不为空", ControlAppearance.Danger, new SymbolIcon(SymbolRegular.SaveSearch20), TimeSpan.FromSeconds(8));
return false;
}
string url = DesktopIP_InputControl.Text;
Uri uriResult;
bool result = Uri.TryCreate(url, UriKind.Absolute, out uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
if (!result)
{
MainWindow.SnackbarService.Show("保存失败", "请检查填写的远端服务地址是否符合Url格式,例如:“http://example.com”或者“http://127.0.0.1”,Url字符串请勿携带端口", ControlAppearance.Danger, new SymbolIcon(SymbolRegular.SaveSearch20), TimeSpan.FromSeconds(8));
MainWindow.SnackbarService.Show("保存失败", "请检查确保填写的远端服务地址是否符合Url格式,例如:“http://example.com”或者“http://127.0.0.1”,Url字符串请勿携带端口", ControlAppearance.Danger, new SymbolIcon(SymbolRegular.SaveSearch20), TimeSpan.FromSeconds(8));
return false;
}
}
//API地址检测
//远程地址检测
if (string.IsNullOrEmpty(DesktopIP_InputControl.Text) || string.IsNullOrEmpty(DesktopPort_InputControl.Text))
{
MainWindow.SnackbarService.Show("保存失败", "API地址配置正确且不为空", ControlAppearance.Danger, new SymbolIcon(SymbolRegular.SaveSearch20), TimeSpan.FromSeconds(8));
MainWindow.SnackbarService.Show("保存失败", "请检查确保远程服务器地址配置正确且不为空", ControlAppearance.Danger, new SymbolIcon(SymbolRegular.SaveSearch20), TimeSpan.FromSeconds(8));
return false;
}
//API_Url配置保存
if (string.IsNullOrEmpty(MainDomainName_TextBox.Text) || string.IsNullOrEmpty(LiveDomainName_TextBox.Text))
{
MainWindow.SnackbarService.Show("保存失败", "请检查确保API地址配置正确且不为空", ControlAppearance.Danger, new SymbolIcon(SymbolRegular.SaveSearch20), TimeSpan.FromSeconds(8));
return false;
}
//WebHook配置保存
if ((bool)WebHook_SwitchControl.IsChecked && string.IsNullOrEmpty(WebHookUrl_InputControl.Text))
{
MainWindow.SnackbarService.Show("保存失败", "请检查确保WebHook地址配置正确且不为空", ControlAppearance.Danger, new SymbolIcon(SymbolRegular.SaveSearch20), TimeSpan.FromSeconds(8));
return false;
}
#endregion

#region 文件路径相关设置检查
if (string.IsNullOrEmpty(RecPathInputBox.Text) || string.IsNullOrEmpty(DefaultLiverFolderNameInputBox.Text) || string.IsNullOrEmpty(DefaulFileNameFormatInputBox.Text))
{
MainWindow.SnackbarService.Show("保存失败", "请检查录制文件夹保存路径相关配置格式正确且不为空", ControlAppearance.Danger, new SymbolIcon(SymbolRegular.SaveSearch20), TimeSpan.FromSeconds(5));
MainWindow.SnackbarService.Show("保存失败", "请检查确保录制文件夹保存路径相关配置格式正确且不为空", ControlAppearance.Danger, new SymbolIcon(SymbolRegular.SaveSearch20), TimeSpan.FromSeconds(5));
return false;
}
try
Expand All @@ -134,22 +146,41 @@ public bool CheckConfiguration(ref bool Reboot)
bool containsInvalidChars = RecPath.IndexOfAny(Path.GetInvalidPathChars()) >= 0;
if (containsInvalidChars)
{
MainWindow.SnackbarService.Show("保存失败", "请检查录制文件夹保存路径相关配置格式正确且不为空", ControlAppearance.Danger, new SymbolIcon(SymbolRegular.SaveSearch20), TimeSpan.FromSeconds(5));
MainWindow.SnackbarService.Show("保存失败", "请检查确保录制文件夹保存路径相关配置格式正确且不为空", ControlAppearance.Danger, new SymbolIcon(SymbolRegular.SaveSearch20), TimeSpan.FromSeconds(5));
return false;
}
}
catch (Exception)
{
MainWindow.SnackbarService.Show("保存失败", "请检查录制文件夹保存路径相关配置格式正确且不为空", ControlAppearance.Danger, new SymbolIcon(SymbolRegular.SaveSearch20), TimeSpan.FromSeconds(5));
MainWindow.SnackbarService.Show("保存失败", "请检查确保录制文件夹保存路径相关配置格式正确且不为空", ControlAppearance.Danger, new SymbolIcon(SymbolRegular.SaveSearch20), TimeSpan.FromSeconds(5));
return false;
}
#endregion

#region 录制功能设置

//录制模式
if (RecordingMode_ComboBox.SelectedIndex != 1 && string.IsNullOrEmpty(HlsWaitingTime_InputControl.Text))
{
MainWindow.SnackbarService.Show("保存失败", "请检查确保HLS等待时间配置正确且不为空", ControlAppearance.Danger, new SymbolIcon(SymbolRegular.SaveSearch20), TimeSpan.FromSeconds(8));
return false;
}

//自动转码参数检查
if (string.IsNullOrEmpty(AutomaticRepair_Arguments_InputBox.Text))
{
MainWindow.SnackbarService.Show("保存失败", "亲检查修复和转码的执行参数配置正确且不为空", ControlAppearance.Danger, new SymbolIcon(SymbolRegular.SaveSearch20), TimeSpan.FromSeconds(8));
MainWindow.SnackbarService.Show("保存失败", "请检查确保修复和转码的执行参数配置正确且不为空", ControlAppearance.Danger, new SymbolIcon(SymbolRegular.SaveSearch20), TimeSpan.FromSeconds(8));
return false;
}


#endregion

#region 播放窗口设置
//弹幕速度设置
if (string.IsNullOrEmpty(PlayWindowDanmaSpeed_InputBox.Text) && int.Parse(PlayWindowDanmaSpeed_InputBox.Text)>0)
{
MainWindow.SnackbarService.Show("保存失败", "请检查确播放窗口弹幕速度参数配置正确且不为空", ControlAppearance.Danger, new SymbolIcon(SymbolRegular.SaveSearch20), TimeSpan.FromSeconds(8));
return false;
}
#endregion
Expand Down Expand Up @@ -219,7 +250,7 @@ public async void SaveConfiguration()
{
Config.Core_RunConfig._SystemCardReminder = (bool)SystemCardReminder_ToggleSwitch.IsChecked;
}
//API配置保存
//API_Url配置保存
Config.Core_RunConfig._MainDomainName = MainDomainName_TextBox.Text;
Config.Core_RunConfig._LiveDomainName = LiveDomainName_TextBox.Text;
//开发版更新配置
Expand Down Expand Up @@ -277,6 +308,28 @@ public async void SaveConfiguration()
}
#endregion

#region 播放窗口设置
//弹幕默认开关设置
if (Config.Core_RunConfig._PlayWindowDanmaSwitch != PlayWindowDanmaSwitch_CheckBox.IsChecked)
{
Config.Core_RunConfig._PlayWindowDanmaSwitch = (bool)PlayWindowDanmaSwitch_CheckBox.IsChecked;
}
//弹幕速度设置
if (Config.Core_RunConfig._PlayWindowDanmaSpeed != int.Parse(PlayWindowDanmaSpeed_InputBox.Text))
{
Config.Core_RunConfig._PlayWindowDanmaSpeed = int.Parse(PlayWindowDanmaSpeed_InputBox.Text);
}
if (Config.Core_RunConfig._PlayDanmaSpeed_Dynamically != PlayWindowDanmaSpeed_CheckBox.IsChecked)
{
Config.Core_RunConfig._PlayDanmaSpeed_Dynamically = (bool)PlayWindowDanmaSpeed_CheckBox.IsChecked;
}
//弹幕字号设置
if (Config.Core_RunConfig._PlayWindowDanmaFontSize != int.Parse(PlayWindowDanmaSize.Text))
{
Config.Core_RunConfig._PlayWindowDanmaFontSize = int.Parse(PlayWindowDanmaSize.Text);
}
#endregion

if (IsReboot)
{
MainWindow.SnackbarService.Show("保存成功", "多项配置需要重启后生效,5秒后自动重启DDTV", ControlAppearance.Caution, new SymbolIcon(SymbolRegular.SaveSync20), TimeSpan.FromSeconds(30));
Expand Down
Loading

0 comments on commit 9bc8f9e

Please sign in to comment.