Skip to content

Commit

Permalink
Save Custom Worker Count #93
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkl58 committed Mar 10, 2022
1 parent a60c887 commit d6c7c47
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion NotEnoughAV1Encodes/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
</Grid.ColumnDefinitions>
<Label x:Name="LabelWorkerCount" Grid.Column="0" Content="{lex:Loc}" MinWidth="100" MaxWidth="150" VerticalContentAlignment="Center" HorizontalContentAlignment="Left" FontWeight="Bold" HorizontalAlignment="Left"/>
<ComboBox Grid.Column="1" x:Name="ComboBoxWorkerCount" Height="28" MinWidth="90" MaxWidth="110" HorizontalAlignment="Left" SelectionChanged="ComboBoxWorkerCount_SelectionChanged"/>
<TextBox Grid.Column="1" Visibility="Hidden" x:Name="TextBoxWorkerCount" PreviewTextInput="NumberValidationTextBox" Height="28" MinWidth="90" MaxWidth="110" HorizontalAlignment="Left" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
<TextBox Grid.Column="1" Visibility="Hidden" x:Name="TextBoxWorkerCount" PreviewTextInput="NumberValidationTextBox" Height="28" MinWidth="90" MaxWidth="110" HorizontalAlignment="Left" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" TextChanged="TextBoxWorkerCount_TextChanged"/>
<Label x:Name="LabelSplittingMethod" Grid.Column="2" Content="{lex:Loc}" MinWidth="100" MaxWidth="150" VerticalContentAlignment="Center" HorizontalContentAlignment="Left" FontWeight="Bold" HorizontalAlignment="Left"/>
<ComboBox Grid.Column="3" x:Name="ComboBoxChunkingMethod" Height="28" MinWidth="100" MaxWidth="140" HorizontalAlignment="Left" SelectedIndex="1" SelectionChanged="ComboBoxChunkingMethod_SelectionChanged">
<ComboBoxItem Content="Equal Chunking" IsSelected="True"/>
Expand Down
30 changes: 16 additions & 14 deletions NotEnoughAV1Encodes/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -590,20 +590,6 @@ private void ButtonEditSelectedItem_Click(object sender, RoutedEventArgs e)

Dispatcher.BeginInvoke((Action)(() => TabControl.SelectedIndex = 0));
}
else if(ListBoxQueue.SelectedItems.Count > 1)
{
return;


// Editing multiple entries

// Get all Selected Queue Items
List<Queue.QueueElement> items = ListBoxQueue.SelectedItems.OfType<Queue.QueueElement>().ToList();

// Open Queue Items Edit Window
Views.EditQueueItems editQueueItems = new(settingsDB.Theme, items);
editQueueItems.ShowDialog();
}
}
}

Expand Down Expand Up @@ -947,6 +933,7 @@ private void TextBoxChunkLength_TextChanged(object sender, System.Windows.Contro
private void ComboBoxWorkerCount_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
if (startupLock) return;
if (settingsDB.OverrideWorkerCount) return;
settingsDB.WorkerCount = ComboBoxWorkerCount.SelectedIndex;
try
{
Expand All @@ -956,6 +943,19 @@ private void ComboBoxWorkerCount_SelectionChanged(object sender, System.Windows.
catch (Exception ex) { MessageBox.Show(ex.Message); }
}

private void TextBoxWorkerCount_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
if (startupLock) return;
if (!settingsDB.OverrideWorkerCount) return;
settingsDB.WorkerCount = int.Parse(TextBoxWorkerCount.Text);
try
{
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 ToggleSwitchQueueParallel_Toggled(object sender, RoutedEventArgs e)
{
if (startupLock) return;
Expand Down Expand Up @@ -1003,6 +1003,8 @@ private void LoadSettings()
{
ComboBoxWorkerCount.Visibility = Visibility.Hidden;
TextBoxWorkerCount.Visibility = Visibility.Visible;
if (settingsDB.WorkerCount != 99999999)
TextBoxWorkerCount.Text = settingsDB.WorkerCount.ToString();
}
else
{
Expand Down

0 comments on commit d6c7c47

Please sign in to comment.