Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/ui/Features/Main/Layout/InitLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -997,16 +997,6 @@ private static void CleanupControl(Control? control)
{
audioVisualizer.MenuFlyout = new MenuFlyout();
}
// Handle DataGrid - clear data bindings and sources
else if (control is DataGrid dataGrid)
{
// Clear data bindings to prevent event handlers from being retained
dataGrid.ItemsSource = null;
dataGrid.SelectedItem = null;
dataGrid.SelectedItems?.Clear();
dataGrid.Columns.Clear();
dataGrid.ContextFlyout = null;
}
// Handle TableView (the main subtitle grid) - clear data bindings and sources
else if (control is TableView tableView)
{
Expand Down
6 changes: 1 addition & 5 deletions src/ui/Features/Main/MainHelpers/RightToLeftHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,7 @@ private static void SetFlowDirectionRecursive(Visual visual, FlowDirection flowD
return;
}

if (visual is DataGrid dataGrid)
{
dataGrid.FlowDirection = flowDirection;
}
else if (visual is TableView tableView)
if (visual is TableView tableView)
{
tableView.FlowDirection = flowDirection;
}
Expand Down
12 changes: 6 additions & 6 deletions src/ui/Features/Options/Settings/GridLinesVisibilityDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace Nikse.SubtitleEdit.Features.Options.Settings;

public class GridLinesVisibilityDisplay
{
public DataGridGridLinesVisibility Type { get; }
public SeGridLinesVisibility Type { get; }
public string DisplayName { get; }
public GridLinesVisibilityDisplay(DataGridGridLinesVisibility type, string displayName)
public GridLinesVisibilityDisplay(SeGridLinesVisibility type, string displayName)
{
Type = type;
DisplayName = displayName;
Expand All @@ -18,10 +18,10 @@ public static GridLinesVisibilityDisplay[] GetAll()
{
return
[
new GridLinesVisibilityDisplay(DataGridGridLinesVisibility.None, Se.Language.General.None),
new GridLinesVisibilityDisplay(DataGridGridLinesVisibility.Horizontal, Se.Language.General.Horizontal),
new GridLinesVisibilityDisplay(DataGridGridLinesVisibility.Vertical, Se.Language.General.Vertical),
new GridLinesVisibilityDisplay(DataGridGridLinesVisibility.All, Se.Language.General.All),
new GridLinesVisibilityDisplay(SeGridLinesVisibility.None, Se.Language.General.None),
new GridLinesVisibilityDisplay(SeGridLinesVisibility.Horizontal, Se.Language.General.Horizontal),
new GridLinesVisibilityDisplay(SeGridLinesVisibility.Vertical, Se.Language.General.Vertical),
new GridLinesVisibilityDisplay(SeGridLinesVisibility.All, Se.Language.General.All),
];
}
}
4 changes: 2 additions & 2 deletions src/ui/Features/Options/Shortcuts/ShortcutsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ private static bool KeyMatchesSearchToken(string key, string token)
ShortcutManager.GetKeyDisplayName(key).Contains(normalizedToken, StringComparison.OrdinalIgnoreCase);
}

internal void ShortcutsDataGrid_SelectionChanged(object? sender, SelectionChangedEventArgs e)
internal void ShortcutsGrid_SelectionChanged(object? sender, SelectionChangedEventArgs e)
{
if (e.AddedItems == null || e.AddedItems.Count == 0 || e.AddedItems[0] is not ShortcutTreeNode node ||
node.ShortCut == null)
Expand Down Expand Up @@ -1317,7 +1317,7 @@ internal void ComboBoxFilter_SelectionChanged(object? sender, SelectionChangedEv
UpdateVisibleShortcuts(SearchText);
}

internal void ShortcutsDataGridDoubleTapped(object? sender, TappedEventArgs e)
internal void ShortcutsGridDoubleTapped(object? sender, TappedEventArgs e)
{
_ = ShowGetKey();
}
Expand Down
380 changes: 215 additions & 165 deletions src/ui/Features/Options/Shortcuts/ShortcutsWindow.cs

Large diffs are not rendered by default.

24 changes: 15 additions & 9 deletions src/ui/Features/Tools/BatchConvert/BatchConvertViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public partial class BatchConvertViewModel : ObservableObject, IClosingCleanup
[ObservableProperty] private bool _sortByDescending;

public Window? Window { get; set; }
public DataGrid FileGrid { get; set; } = new();
public TableView FileGrid { get; set; } = new();

public bool OkPressed { get; private set; }
public ScrollViewer FunctionContainer { get; internal set; }
Expand Down Expand Up @@ -960,15 +960,20 @@ private async Task Convert()
IsProgressVisible = true;
IsConverting = true;
AreControlsEnabled = false;
ProgressMaxValue = BatchItems.Count;
// Snapshot the job list: the loop below runs on a background thread while
// BatchItems stays live in the UI, where header-click sorting (and re-filtering)
// rebuilds the collection in place - enumerating the live collection there
// could throw mid-run. Status updates still reach the grid per item.
var itemsToConvert = BatchItems.ToList();
ProgressMaxValue = itemsToConvert.Count;
_ = Task.Run(async () =>
{
var count = 1;
foreach (var batchItem in BatchItems)
foreach (var batchItem in itemsToConvert)
{
var countDisplay = count;
ProgressText = string.Format(Se.Language.General.ConvertingXofYDotDoDot, countDisplay, BatchItems.Count);
ProgressValue = countDisplay / (double)BatchItems.Count;
ProgressText = string.Format(Se.Language.General.ConvertingXofYDotDoDot, countDisplay, itemsToConvert.Count);
ProgressValue = countDisplay / (double)itemsToConvert.Count;

if (batchItem.Format!.StartsWith("Transport Stream", StringComparison.Ordinal))
{
Expand Down Expand Up @@ -1003,7 +1008,7 @@ private async Task Convert()

var end = DateTime.UtcNow.Ticks;
var elapsed = new TimeSpan(end - start).TotalMilliseconds;
var message = string.Format(Se.Language.General.XFilesConvertedInY, BatchItems.Count, elapsed);
var message = string.Format(Se.Language.General.XFilesConvertedInY, itemsToConvert.Count, elapsed);
if (_cancellationToken.IsCancellationRequested)
{
message += Environment.NewLine + Se.Language.General.ConversionCancelledByUser;
Expand Down Expand Up @@ -1859,7 +1864,7 @@ private async Task RemoveSelectedFiles()
return;
}

var selectedItems = FileGrid.SelectedItems.Cast<BatchConvertItem>().ToList();
var selectedItems = FileGrid.SelectedItems?.Cast<BatchConvertItem>().ToList() ?? new List<BatchConvertItem>();
if (selectedItems.Count == 0)
{
return;
Expand Down Expand Up @@ -2678,8 +2683,9 @@ internal void FilterTextChanged()

internal void FileGridContextMenuOpening()
{
IsRemoveVisible = FileGrid.SelectedItems.Count > 0;
IsOpenContainingFolderVisible = FileGrid.SelectedItems.Count == 1;
var selectedCount = FileGrid.SelectedItems?.Count ?? 0;
IsRemoveVisible = selectedCount > 0;
IsOpenContainingFolderVisible = selectedCount == 1;
}

internal void FileGridKeyDown(object? sender, KeyEventArgs e)
Expand Down
Loading