Skip to content

Commit 74c4a27

Browse files
committed
Button to sort file list entries (bug? sorting creates ghost entries)
1 parent 1b75117 commit 74c4a27

19 files changed

+273
-136
lines changed

ff-utils-winforms/Data/AudioConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public AudioConfiguration (MediaFile file, List<AudioConfigurationEntry> cfg)
2020

2121
public List<AudioConfigurationEntry> GetConfig (MediaFile file)
2222
{
23-
if (file.TruePath != CreationFile.TruePath || file.Size != CreationFile.Size)
23+
if (file.ImportPath != CreationFile.ImportPath || file.Size != CreationFile.Size)
2424
return null; // Return null if the file has changed
2525
else
2626
return _config;

ff-utils-winforms/Data/MediaFile.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class MediaFile
2222
public int FileCount;
2323
public string Name;
2424
public string SourcePath;
25-
public string TruePath;
25+
public string ImportPath;
2626
public string Format;
2727
public string Title;
2828
public string Language;
@@ -65,7 +65,7 @@ public MediaFile(string path)
6565
File = new FileInfo(path);
6666
Name = File.Name;
6767
SourcePath = File.FullName;
68-
TruePath = File.FullName;
68+
ImportPath = File.FullName;
6969
Format = File.Extension.Remove(".").ToUpper();
7070
FileCount = 1;
7171
InputRate = new Fraction(-1, 1);
@@ -82,7 +82,7 @@ private void PrepareFrameSeq()
8282
string seqPath = Path.Combine(Paths.GetFrameSeqPath(), CreationTime.ToString(), "frames.concat");
8383
string chosenExt = IoUtils.GetUniqueExtensions(SourcePath).FirstOrDefault();
8484
int fileCount = FfmpegUtils.CreateConcatFile(SourcePath, seqPath, new string[] { chosenExt });
85-
TruePath = seqPath;
85+
ImportPath = seqPath;
8686
FileCount = fileCount;
8787
Logger.Log($"Created concat file with {fileCount} files.", true);
8888
}
@@ -99,8 +99,8 @@ public async Task Initialize(bool progressBar = true)
9999

100100
try
101101
{
102-
await LoadFormatInfo(TruePath);
103-
AllStreams = await FfmpegUtils.GetStreams(TruePath, progressBar, StreamCount, InputRate);
102+
await LoadFormatInfo(ImportPath);
103+
AllStreams = await FfmpegUtils.GetStreams(ImportPath, progressBar, StreamCount, InputRate);
104104
VideoStreams = AllStreams.Where(x => x.Type == Stream.StreamType.Video).Select(x => (VideoStream)x).ToList();
105105
AudioStreams = AllStreams.Where(x => x.Type == Stream.StreamType.Audio).Select(x => (AudioStream)x).ToList();
106106
SubtitleStreams = AllStreams.Where(x => x.Type == Stream.StreamType.Subtitle).Select(x => (SubtitleStream)x).ToList();

ff-utils-winforms/Data/Ui/MediaStreamListEntry.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public override string ToString()
3535

3636
if (MediaFile.IsDirectory)
3737
{
38-
List<string> exts = File.ReadAllLines(MediaFile.TruePath).Select(x => x.Remove("file '").Remove("'").Split('.').LastOrDefault()).ToList();
38+
List<string> exts = File.ReadAllLines(MediaFile.ImportPath).Select(x => x.Remove("file '").Remove("'").Split('.').LastOrDefault()).ToList();
3939
int formatsCount = exts.Select(x => x).Distinct().Count();
4040
fileCountStr = formatsCount > 1 ? $" ({MediaFile.FileCount} Files, {formatsCount} Formats)" : $" ({MediaFile.FileCount} Files)";
4141
}
@@ -82,7 +82,7 @@ int GetFileIndex ()
8282
{
8383
for(int i = 0; i < Program.mainForm.fileListBox.Items.Count; i++)
8484
{
85-
if (((FileListEntry)Program.mainForm.fileListBox.Items[i]).File.TruePath == MediaFile.TruePath)
85+
if (((FileListEntry)Program.mainForm.fileListBox.Items[i]).File.ImportPath == MediaFile.ImportPath)
8686
return i;
8787
}
8888

ff-utils-winforms/Forms/MainForm.Designer.cs

Lines changed: 186 additions & 98 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ff-utils-winforms/Forms/MainForm.FileList.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,10 @@ private void fileList_DoubleClick(object sender, EventArgs e)
118118
if (fileList.SelectedItem != null)
119119
addTracksFromFileBtn_Click(null, null);
120120
}
121+
122+
private void fileListSortBtn_Click(object sender, EventArgs e)
123+
{
124+
sortFileListContextMenu.Show(Cursor.Position);
125+
}
121126
}
122127
}

ff-utils-winforms/Forms/MainForm.QuickConvert.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private void encAudConfMode_VisibleChanged(object sender, EventArgs e)
145145
bool noEnc = !Program.mainForm.encAudQualUpDown.Enabled;
146146
bool noAudTracks = streamListBox.Items.OfType<MediaStreamListEntry>().Where(x => x.Stream.Type == Data.Streams.Stream.StreamType.Audio).Count() < 1;
147147

148-
if (TrackList.current == null || TrackList.currentAudioConfig == null || TrackList.currentAudioConfig.CreationFile.TruePath != TrackList.current.File.TruePath || noAudTracks || noEnc)
148+
if (TrackList.current == null || TrackList.currentAudioConfig == null || TrackList.currentAudioConfig.CreationFile.ImportPath != TrackList.current.File.ImportPath || noAudTracks || noEnc)
149149
{
150150
TrackList.currentAudioConfig = null;
151151
encAudConfMode.SelectedIndex = 0;

ff-utils-winforms/Forms/MainForm.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,5 +248,41 @@ private void encAudChannels_SelectedIndexChanged(object sender, EventArgs e)
248248
{
249249
QuickConvertUi.AudEncoderSelected(encAudCodecBox.SelectedIndex);
250250
}
251+
252+
private void SetFileListItems(object[] objectCollection)
253+
{
254+
fileList.Items.Clear();
255+
fileList.Items.AddRange(new ListBox.ObjectCollection(fileListBox, objectCollection));
256+
}
257+
258+
private void sortMenuAbcDesc_Click(object sender, EventArgs e)
259+
{
260+
SetFileListItems(fileList.Items.OfType<FileListEntry>().OrderBy(x => x.File.SourcePath).ToArray());
261+
}
262+
263+
private void sortMenuAbcAsc_Click(object sender, EventArgs e)
264+
{
265+
SetFileListItems(fileList.Items.OfType<FileListEntry>().OrderByDescending(x => x.File.SourcePath).ToArray());
266+
}
267+
268+
private void sortMenuSizeDesc_Click(object sender, EventArgs e)
269+
{
270+
SetFileListItems(fileList.Items.OfType<FileListEntry>().OrderByDescending(x => x.File.File.Length).ToArray());
271+
}
272+
273+
private void sortMenuSizeAsc_Click(object sender, EventArgs e)
274+
{
275+
SetFileListItems(fileList.Items.OfType<FileListEntry>().OrderBy(x => x.File.File.Length).ToArray());
276+
}
277+
278+
private void sortMenuRecentDesc_Click(object sender, EventArgs e)
279+
{
280+
SetFileListItems(fileList.Items.OfType<FileListEntry>().OrderByDescending(x => x.File.File.LastWriteTime).ToArray());
281+
}
282+
283+
private void sortMenuRecentAsc_Click(object sender, EventArgs e)
284+
{
285+
SetFileListItems(fileList.Items.OfType<FileListEntry>().OrderBy(x => x.File.File.LastWriteTime).ToArray());
286+
}
251287
}
252288
}

ff-utils-winforms/Forms/MainForm.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@
137137
nzTNA2Frs24HzQdqAAAAAElFTkSuQmCC
138138
</value>
139139
</data>
140+
<metadata name="sortFileListContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
141+
<value>280, 23</value>
142+
</metadata>
140143
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
141144
<value>
142145
AAABAA0AAAAAAAEAIAAFnQAA1gAAAICAAAABACAAKAgBANudAACAgAAAAQAIAChMAAADpgEAQEAAAAEA

ff-utils-winforms/Forms/Utils/UtilsColorDataForm.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ private void LoadVideoBox (ComboBox box, string videoPath)
5454
{
5555
for (int i = 0; i < fileList.Items.Count; i++)
5656
{
57-
if((((FileListEntry)fileList.Items[i])).File.TruePath == videoPath)
57+
if((((FileListEntry)fileList.Items[i])).File.ImportPath == videoPath)
5858
{
5959
box.SelectedIndex = i;
6060
return;
@@ -110,10 +110,10 @@ private void confirmBtn_Click(object sender, EventArgs e)
110110
TransferHdrData = copyHdrData.Checked;
111111

112112
if(sourceVideo.SelectedItem != null)
113-
VideoSrc = ((MediaFile)sourceVideo.SelectedItem).TruePath;
113+
VideoSrc = ((MediaFile)sourceVideo.SelectedItem).ImportPath;
114114

115115
if (targetVideo.SelectedItem != null)
116-
VideoTarget = ((MediaFile)targetVideo.SelectedItem).TruePath;
116+
VideoTarget = ((MediaFile)targetVideo.SelectedItem).ImportPath;
117117

118118
DialogResult = DialogResult.OK;
119119
pressedOk = true;

ff-utils-winforms/Forms/Utils/UtilsMetricsForm.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private void LoadVideoBox (ComboBox box, string videoPath)
5050
{
5151
for (int i = 0; i < fileList.Items.Count; i++)
5252
{
53-
if((((FileListEntry)fileList.Items[i])).File.TruePath == videoPath)
53+
if((((FileListEntry)fileList.Items[i])).File.ImportPath == videoPath)
5454
{
5555
box.SelectedIndex = i;
5656
return;
@@ -94,8 +94,8 @@ private void confirmBtn_Click(object sender, EventArgs e)
9494
AlignMode = align.SelectedIndex;
9595
VmafModel = vmafMdl.SelectedIndex;
9696
CheckedBoxes = new bool[] { vmaf.Checked, ssim.Checked, psnr.Checked };
97-
VideoLq = ((MediaFile)encodedVideo.SelectedItem).TruePath;
98-
VideoHq = ((MediaFile)referenceVideo.SelectedItem).TruePath;
97+
VideoLq = ((MediaFile)encodedVideo.SelectedItem).ImportPath;
98+
VideoHq = ((MediaFile)referenceVideo.SelectedItem).ImportPath;
9999
DialogResult = DialogResult.OK;
100100
pressedOk = true;
101101
Close();

0 commit comments

Comments
 (0)