Skip to content

Commit

Permalink
Queue allow multiselect deletion #88
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkl58 committed Jan 28, 2022
1 parent 9bb24ca commit a59982a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 20 deletions.
2 changes: 1 addition & 1 deletion NotEnoughAV1Encodes/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@
<GroupBox Header="{lex:Loc TabItemQueue}" mah:ControlsHelper.ContentCharacterCasing="Normal">
<Grid>
<GroupBox Margin="0,34,0,0">
<ListBox x:Name="ListBoxQueue" Background="{Binding ElementName=ListBoxAudioTracks, Path=Background, UpdateSourceTrigger=PropertyChanged}" KeyDown="ListBoxQueue_KeyDown">
<ListBox x:Name="ListBoxQueue" Background="{Binding ElementName=ListBoxAudioTracks, Path=Background, UpdateSourceTrigger=PropertyChanged}" KeyDown="ListBoxQueue_KeyDown" SelectionMode="Multiple">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Background" Value="{Binding ElementName=ListBoxAudioTracks, Path=Background, UpdateSourceTrigger=PropertyChanged}"></Setter>
Expand Down
54 changes: 35 additions & 19 deletions NotEnoughAV1Encodes/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,7 @@ private void ButtonProgramSettings_Click(object sender, RoutedEventArgs e)

private void ButtonRemoveSelectedQueueItem_Click(object sender, RoutedEventArgs e)
{
if (ProgramState != 0) return;
if (ListBoxQueue.SelectedItem != null)
{
Queue.QueueElement tmp = (Queue.QueueElement)ListBoxQueue.SelectedItem;
ListBoxQueue.Items.Remove(ListBoxQueue.SelectedItem);
try
{
File.Delete(Path.Combine(Global.AppData, "NEAV1E", "Queue", tmp.VideoDB.InputFileName + "_" + tmp.UniqueIdentifier + ".json"));
}
catch { }
}
DeleteQueueItems();
}

private void ButtonOpenSource_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -532,6 +522,7 @@ private void ButtonSetPresetDefault_Click(object sender, RoutedEventArgs e)
private void ButtonEditSelectedItem_Click(object sender, RoutedEventArgs e)
{
if (ProgramState != 0) return;
if (ListBoxQueue.SelectedItems.Count > 1) return;
if (ListBoxQueue.SelectedItem != null)
{
Queue.QueueElement tmp = (Queue.QueueElement)ListBoxQueue.SelectedItem;
Expand Down Expand Up @@ -595,16 +586,9 @@ private void QueueMenuItemSave_Click(object sender, RoutedEventArgs e)

private void ListBoxQueue_KeyDown(object sender, KeyEventArgs e)
{
if (ListBoxQueue.SelectedItem == null) return;
if (e.Key == Key.Delete)
{
Queue.QueueElement tmp = (Queue.QueueElement)ListBoxQueue.SelectedItem;
ListBoxQueue.Items.Remove(ListBoxQueue.SelectedItem);
try
{
File.Delete(Path.Combine(Global.AppData, "NEAV1E", "Queue", tmp.VideoDB.InputFileName + "_" + tmp.UniqueIdentifier + ".json"));
}
catch { }
DeleteQueueItems();
}
}
#endregion
Expand Down Expand Up @@ -888,6 +872,7 @@ private void TextBoxCustomVideoSettings_TextChanged(object sender, System.Window
#endregion

#region Small Functions

private void ComboBoxChunkingMethod_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
if (startupLock) return;
Expand All @@ -900,6 +885,7 @@ private void ComboBoxChunkingMethod_SelectionChanged(object sender, System.Windo
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}

private void TextBoxChunkLength_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
if (startupLock) return;
Expand All @@ -912,6 +898,36 @@ private void TextBoxChunkLength_TextChanged(object sender, System.Windows.Contro
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}

private void DeleteQueueItems()
{
if (ListBoxQueue.SelectedItem == null) return;
if (ProgramState != 0) return;
if (ListBoxQueue.SelectedItems.Count > 1)
{
List<Queue.QueueElement> items = ListBoxQueue.SelectedItems.OfType<Queue.QueueElement>().ToList();
foreach (var item in items)
{
ListBoxQueue.Items.Remove(item);
try
{
File.Delete(Path.Combine(Global.AppData, "NEAV1E", "Queue", item.VideoDB.InputFileName + "_" + item.UniqueIdentifier + ".json"));
}
catch { }
}
}
else
{
Queue.QueueElement tmp = (Queue.QueueElement)ListBoxQueue.SelectedItem;
ListBoxQueue.Items.Remove(ListBoxQueue.SelectedItem);
try
{
File.Delete(Path.Combine(Global.AppData, "NEAV1E", "Queue", tmp.VideoDB.InputFileName + "_" + tmp.UniqueIdentifier + ".json"));
}
catch { }
}
}

private void LoadSettings()
{
if (settingsDB.OverrideWorkerCount)
Expand Down

0 comments on commit a59982a

Please sign in to comment.