Refactor TestStartEndForm - Remove unused methods and comments, simplify image grouping logic.
This commit is contained in:
parent
2fa212e6ff
commit
693cf7e4e2
@ -727,11 +727,17 @@ namespace TBF.Rig.DataEntry.StandartCameraPurchaseOrder
|
||||
Close();
|
||||
}
|
||||
|
||||
/**
|
||||
* preparation for previous button
|
||||
*/
|
||||
private void previousButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
ShowPreviousImageFromGroup();
|
||||
}
|
||||
|
||||
/**
|
||||
* preparation for next button
|
||||
*/
|
||||
private void nextButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
ShowNextImageFromGroup();
|
||||
@ -1498,23 +1504,6 @@ namespace TBF.Rig.DataEntry.StandartCameraPurchaseOrder
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int GetRepetitionIndex(string fileName)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(fileName))
|
||||
{
|
||||
return int.MaxValue;
|
||||
}
|
||||
|
||||
Match match = Regex.Match(Path.GetFileNameWithoutExtension(fileName), @"\((?<repetition>\d+)_\d+\)",
|
||||
RegexOptions.IgnoreCase);
|
||||
|
||||
int repetition;
|
||||
|
||||
return match.Success && int.TryParse(match.Groups["repetition"].Value, out repetition)
|
||||
? repetition
|
||||
: int.MaxValue;
|
||||
}
|
||||
|
||||
private void AddImageToCurrentGroup(
|
||||
string imageFileName)
|
||||
@ -1550,97 +1539,7 @@ namespace TBF.Rig.DataEntry.StandartCameraPurchaseOrder
|
||||
// previousButton.Visible = canSwitch;
|
||||
// nextButton.Visible = canSwitch;
|
||||
}
|
||||
|
||||
private void AddTimedImagesToCurrentGroup(string baseImageFileName)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(baseImageFileName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string directory = Path.GetDirectoryName(baseImageFileName);
|
||||
string baseName = Path.GetFileNameWithoutExtension(baseImageFileName);
|
||||
string extension = Path.GetExtension(baseImageFileName);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(directory) ||
|
||||
string.IsNullOrWhiteSpace(baseName) ||
|
||||
!Directory.Exists(directory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string searchPattern = string.Format(
|
||||
"{0}_img*{1}",
|
||||
baseName,
|
||||
extension);
|
||||
|
||||
List<string> timedImages =
|
||||
Directory
|
||||
.GetFiles(
|
||||
directory,
|
||||
searchPattern,
|
||||
SearchOption.TopDirectoryOnly)
|
||||
.OrderBy(GetTimedImageIndex)
|
||||
.ThenBy(
|
||||
fileName => fileName,
|
||||
StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
|
||||
foreach (string timedImage in timedImages)
|
||||
{
|
||||
AddImageToCurrentGroup(timedImage);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddTimedImagesFromDirectory( string directory, string searchPattern)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(directory) ||
|
||||
string.IsNullOrWhiteSpace(searchPattern) ||
|
||||
!Directory.Exists(directory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List<string> timedImages = Directory .GetFiles( directory, searchPattern, SearchOption.TopDirectoryOnly)
|
||||
.OrderBy(GetTimedImageIndex)
|
||||
.ThenBy(
|
||||
fileName => fileName,
|
||||
StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
|
||||
foreach (string timedImage in timedImages)
|
||||
{
|
||||
AddImageToCurrentGroup(timedImage);
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetCorrespondingTempImageDirectory( string directory)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(directory))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
const string normalImagesPart = @"\Tbf\Images\";
|
||||
const string tempImagesPart = @"\Tbf\Images\Temp\";
|
||||
|
||||
/*
|
||||
* Ak už sme v Temp adresári, nič nemeníme.
|
||||
*/
|
||||
if (directory.IndexOf( tempImagesPart, StringComparison.OrdinalIgnoreCase) >= 0)
|
||||
{
|
||||
return directory;
|
||||
}
|
||||
|
||||
int imagesIndex = directory.IndexOf( normalImagesPart, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (imagesIndex < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return directory.Substring( 0, imagesIndex) + tempImagesPart + directory.Substring( imagesIndex + normalImagesPart.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// grouping by time
|
||||
|
||||
Loading…
Reference in New Issue
Block a user