Skip to content

Commit

Permalink
Add Option to set Default Preset
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkl58 committed Dec 28, 2021
1 parent c104af1 commit 1332c93
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 1 deletion.
3 changes: 2 additions & 1 deletion NotEnoughAV1Encodes/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,13 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition MinWidth="100" MaxWidth="160"/>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="400"/>
</Grid.ColumnDefinitions>
<Label x:Name="LabelPreset" Grid.Column="0" Content="{lex:Loc}" HorizontalAlignment="Left" VerticalAlignment="Center" FontWeight="Bold"/>
<ComboBox x:Name="ComboBoxPresets" Grid.Column="1" Height="28" HorizontalAlignment="Left" VerticalAlignment="Center" Width="150" SelectionChanged="ComboBoxPresets_SelectionChanged"/>
<Button x:Name="ButtonSavePreset" Content="{lex:Loc}" Grid.Column="2" HorizontalAlignment="Left" Margin="7,0,0,0" VerticalAlignment="Center" mah:ControlsHelper.ContentCharacterCasing="Normal" Width="90" Click="ButtonSavePreset_Click"/>
<Button x:Name="ButtonDeletePreset" Content="{lex:Loc}" Grid.Column="2" HorizontalAlignment="Left" Margin="102,0,0,0" VerticalAlignment="Center" mah:ControlsHelper.ContentCharacterCasing="Normal" Width="90" Click="ButtonDeletePreset_Click"/>
<Button x:Name="ButtonSetPresetDefault" Content="{lex:Loc}" Grid.Column="2" HorizontalAlignment="Left" Margin="197,0,0,0" VerticalAlignment="Center" mah:ControlsHelper.ContentCharacterCasing="Normal" Click="ButtonSetPresetDefault_Click"/>
</Grid>
</GroupBox>
<GroupBox x:Name="GroupBoxCurrentSettings" Header="{lex:Loc}" Margin="10,192,10,0" mah:ControlsHelper.ContentCharacterCasing="Normal" Height="67" VerticalAlignment="Top">
Expand Down
13 changes: 13 additions & 0 deletions NotEnoughAV1Encodes/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ private void Initialize()
}

LoadPresets();

try { ComboBoxPresets.SelectedItem = settingsDB.DefaultPreset; } catch { }
}

private void LoadPresets()
Expand Down Expand Up @@ -451,6 +453,17 @@ private void ButtonDeletePreset_Click(object sender, RoutedEventArgs e)

}

private void ButtonSetPresetDefault_Click(object sender, RoutedEventArgs e)
{
try
{
settingsDB.DefaultPreset = ComboBoxPresets.Text;
Directory.CreateDirectory(Path.Combine(Global.AppData, "NEAV1E"));
File.WriteAllText(Path.Combine(Global.AppData, "NEAV1E", "settings.json"), JsonConvert.SerializeObject(settingsDB, Formatting.Indented));
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}

private void ButtonEditSelectedItem_Click(object sender, RoutedEventArgs e)
{
if (ProgramState != 0) return;
Expand Down
2 changes: 2 additions & 0 deletions NotEnoughAV1Encodes/SettingsDB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ public class SettingsDB
public bool PriorityNormal { get; set; } = true;
/// <summary>CultureInfo for Language (Default: en-US)</summary>
public CultureInfo CultureInfo { get; set; } = new("en");
/// <summary>Default Preset to load on startup</summary>
public string DefaultPreset { get; set; }
}
}
9 changes: 9 additions & 0 deletions NotEnoughAV1Encodes/resources/lang/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions NotEnoughAV1Encodes/resources/lang/Strings.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@
<data name="ButtonSelectBGImage" xml:space="preserve">
<value>Auswählen</value>
</data>
<data name="ButtonSetPresetDefault" xml:space="preserve">
<value>Als Standard festlegen</value>
</data>
<data name="ButtonTestSettings" xml:space="preserve">
<value>Einstellungen testen</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions NotEnoughAV1Encodes/resources/lang/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@
<data name="ButtonSelectBGImage" xml:space="preserve">
<value>Select</value>
</data>
<data name="ButtonSetPresetDefault" xml:space="preserve">
<value>Set as Default</value>
</data>
<data name="ButtonTestSettings" xml:space="preserve">
<value>Test Settings</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions NotEnoughAV1Encodes/resources/lang/Strings.ru-RU.resx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@
<data name="ButtonSelectBGImage" xml:space="preserve">
<value>Выбрать</value>
</data>
<data name="ButtonSetPresetDefault" xml:space="preserve">
<value>Установить по умолчанию</value>
</data>
<data name="ButtonTestSettings" xml:space="preserve">
<value>Проверить настройки</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions NotEnoughAV1Encodes/resources/lang/Strings.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@
<data name="ButtonSelectBGImage" xml:space="preserve">
<value>选择</value>
</data>
<data name="ButtonSetPresetDefault" xml:space="preserve">
<value>设为默认</value>
</data>
<data name="ButtonTestSettings" xml:space="preserve">
<value>测试设置</value>
</data>
Expand Down

0 comments on commit 1332c93

Please sign in to comment.