Skip to content

Commit

Permalink
Extend settings to chat updater page
Browse files Browse the repository at this point in the history
  • Loading branch information
ScrubN committed Jul 16, 2024
1 parent fae7230 commit 2c446dd
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 6 deletions.
10 changes: 5 additions & 5 deletions TwitchDownloaderWPF/PageChatUpdate.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@
<RadioButton x:Name="radioHTML" Content="HTML" Checked="radioHTML_Checked" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
</hc:ButtonGroup>
<StackPanel Visibility="Visible" x:Name="compressionOptions" Margin="5,8,0,0" Orientation="Horizontal">
<RadioButton x:Name="radioCompressionNone" IsChecked="True" Content="{lex:Loc ChatCompressionNone}" Margin="3,0,0,0" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioCompressionGzip" Content="{lex:Loc ChatCompressionGzip}" Margin="3,0,0,0" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioCompressionNone" IsChecked="True" Content="{lex:Loc ChatCompressionNone}" Checked="RadioCompressionNone_OnCheckedChanged" Unchecked="RadioCompressionNone_OnCheckedChanged" Margin="3,0,0,0" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioCompressionGzip" Content="{lex:Loc ChatCompressionGzip}" Checked="RadioCompressionGzip_OnCheckedChanged" Unchecked="RadioCompressionGzip_OnCheckedChanged" Margin="3,0,0,0" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
</StackPanel>
<StackPanel Visibility="Collapsed" x:Name="timeOptions" Margin="5,8,0,0" Orientation="Horizontal">
<RadioButton x:Name="radioTimestampUTC" IsChecked="True" Content="{lex:Loc TimestampUtc}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioTimestampRelative" Content="{lex:Loc TimestampRelative}" Margin="3,0,0,0" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioTimestampNone" Content="{lex:Loc TimestampNone}" Margin="3,0,0,0" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioTimestampUTC" IsChecked="True" Content="{lex:Loc TimestampUtc}" Checked="RadioTimestampUTC_OnCheckedChanged" Unchecked="RadioTimestampUTC_OnCheckedChanged" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioTimestampRelative" Content="{lex:Loc TimestampRelative}" Margin="3,0,0,0" Checked="RadioTimestampRelative_OnCheckedChanged" Unchecked="RadioTimestampRelative_OnCheckedChanged" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioTimestampNone" Content="{lex:Loc TimestampNone}" Margin="3,0,0,0" Checked="RadioTimestampNone_OnCheckedChanged" Unchecked="RadioTimestampNone_OnCheckedChanged" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
</StackPanel>
<StackPanel Margin="5,5,0,0">
<StackPanel Orientation="Horizontal">
Expand Down
61 changes: 60 additions & 1 deletion TwitchDownloaderWPF/PageChatUpdate.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,21 @@ private void Page_Initialized(object sender, EventArgs e)
{
ChatFormat.Text => radioText.IsChecked = true,
ChatFormat.Html => radioHTML.IsChecked = true,
_ => radioJson.IsChecked = true
ChatFormat.Json => radioJson.IsChecked = true,
_ => null,
};
_ = (ChatCompression)Settings.Default.ChatJsonCompression switch
{
ChatCompression.None => radioCompressionNone.IsChecked = true,
ChatCompression.Gzip => radioCompressionGzip.IsChecked = true,
_ => null,
};
_ = (TimestampFormat)Settings.Default.ChatTextTimestampStyle switch
{
TimestampFormat.Utc => radioTimestampUTC.IsChecked = true,
TimestampFormat.Relative => radioTimestampRelative.IsChecked = true,
TimestampFormat.None => radioTimestampNone.IsChecked = true,
_ => null,
};
}

Expand Down Expand Up @@ -666,5 +680,50 @@ private void MenuItemEnqueue_Click(object sender, RoutedEventArgs e)
};
queueOptions.ShowDialog();
}

private void RadioCompressionNone_OnCheckedChanged(object sender, RoutedEventArgs e)
{
if (!IsInitialized)
return;

Settings.Default.ChatJsonCompression = (int)ChatCompression.None;
Settings.Default.Save();
}

private void RadioCompressionGzip_OnCheckedChanged(object sender, RoutedEventArgs e)
{
if (!IsInitialized)
return;

Settings.Default.ChatJsonCompression = (int)ChatCompression.Gzip;
Settings.Default.Save();
}

private void RadioTimestampUTC_OnCheckedChanged(object sender, RoutedEventArgs e)
{
if (!IsInitialized)
return;

Settings.Default.ChatTextTimestampStyle = (int)TimestampFormat.Utc;
Settings.Default.Save();
}

private void RadioTimestampRelative_OnCheckedChanged(object sender, RoutedEventArgs e)
{
if (!IsInitialized)
return;

Settings.Default.ChatTextTimestampStyle = (int)TimestampFormat.Relative;
Settings.Default.Save();
}

private void RadioTimestampNone_OnCheckedChanged(object sender, RoutedEventArgs e)
{
if (!IsInitialized)
return;

Settings.Default.ChatTextTimestampStyle = (int)TimestampFormat.None;
Settings.Default.Save();
}
}
}

0 comments on commit 2c446dd

Please sign in to comment.