Skip to content

Commit

Permalink
Merge branch 'release/1.0.6.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
tautcony committed Feb 12, 2020
2 parents 7d4a758 + de4c412 commit d0914ba
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 65 deletions.
82 changes: 38 additions & 44 deletions RPChecker/Forms/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 55 additions & 13 deletions RPChecker/Forms/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ namespace RPChecker.Forms
public partial class Form1 : Form
{
#region Form init
public Form1()

private readonly IReadOnlyCollection<string> _rpcCollection;

public Form1(IReadOnlyCollection<string> args)
{
InitializeComponent();
AddCommand();

_rpcCollection = args;
}

private void Form1_Load(object sender, EventArgs e)
Expand All @@ -41,6 +46,10 @@ private void Form1_Load(object sender, EventArgs e)
btnAnalyze.Enabled = false;

Updater.Utils.CheckUpdateWeekly("RPChecker");
if (_rpcCollection.Any())
{
LoadRPCFile(_rpcCollection);
}
}

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
Expand All @@ -57,7 +66,7 @@ private void Form1_FormClosing(object sender, FormClosingEventArgs e)
private IProcess _coreProcess = new FFmpegPSNRProcess();

private ReSulT CurrentData => _fullData[cbFileList.SelectedIndex];
private double FrameRate => _frameRate[cbFPS.SelectedIndex];
private double FrameRate => _frameRate[cbFPS.SelectedIndex < 0 ? 0 : cbFPS.SelectedIndex];

#region SystemMenu
private SystemMenu _systemMenu;
Expand Down Expand Up @@ -106,6 +115,48 @@ void Set2FFSSIM()
UpdateText();
}

void LoadRPCFile(IEnumerable<string> rpcCollection)
{
_fullData.Clear();
cbFileList.Items.Clear();
try
{
foreach (var rpc in rpcCollection)
{
var json = File.ReadAllText(rpc);

_fullData.AddRange(Jil.JSON.Deserialize<IEnumerable<ReSulT>>(json));
}

_fullData.ForEach(item =>
{
cbFileList.Items.Add(Path.GetFileName(item.FileNamePair.src) ?? "");
item.Data.Sort(delegate((int, double) lhs, (int, double) rhs)
{
if (Math.Abs(lhs.Item2 - rhs.Item2) > 1e-5)
{
return lhs.Item2 - rhs.Item2 < 0 ? -1 : 1;
}

return lhs.Item1 - rhs.Item1;
});
});
if (_fullData.Count > 0)
{
cbFileList.SelectedIndex = 0;
ChangeClipDisplay();
}
}
catch (Jil.DeserializationException ex)
{
MessageBox.Show($"JSON解析失败:\n{ex.Message}", @"RPChecker Error");
}
catch (Exception ex)
{
MessageBox.Show($"载入失败:{ex.GetType()}\n{ex.Message}", @"RPChecker Error");
}

}

private void AddCommand()
{
Expand Down Expand Up @@ -141,16 +192,7 @@ private void AddCommand()
{
return;
}
var json = File.ReadAllText(openFileDialog1.FileName);
_fullData.Clear();
cbFileList.Items.Clear();
_fullData.AddRange(Jil.JSON.Deserialize<IEnumerable<ReSulT>>(json));
_fullData.ForEach(item => cbFileList.Items.Add(Path.GetFileName(item.FileNamePair.src) ?? ""));
if (_fullData.Count > 0)
{
cbFileList.SelectedIndex = 0;
ChangeClipDisplay();
}
LoadRPCFile(new []{ openFileDialog1.FileName });
}, false);
_systemMenu.AddCommand("重置路径", () =>
{
Expand Down Expand Up @@ -283,7 +325,7 @@ private void UpdateGridView(ReSulT info, double frameRate)
if ((item.value > _threshold && dataGridView1.RowCount > 450) || dataGridView1.RowCount > 2048) break;
var newRow = new DataGridViewRow {Tag = item};
var temp = ToolKits.Second2Time(item.index / frameRate);
newRow.CreateCells(dataGridView1, item.index, $"{item.value:F4}", temp.Time2String());
newRow.CreateCells(dataGridView1, item.index, Math.Round(item.value, 4), temp.Time2String());
newRow.DefaultCellStyle.BackColor = item.value < _threshold
? Color.FromArgb(233, 76, 60) : Color.FromArgb(46, 205, 112);
dataGridView1.Rows.Add(newRow);
Expand Down
Loading

0 comments on commit d0914ba

Please sign in to comment.