Remove benchmark command.

This commit is contained in:
2020-01-03 18:13:57 +00:00
parent 51b39da0d6
commit 56e24f1ed9
22 changed files with 420 additions and 1307 deletions

View File

@@ -1,76 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?><!--
// /***************************************************************************
// The Disc Image Chef
// ============================================================================
//
// Filename : dlgBenchmark.xeto
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Benchmark dialog.
//
// ==[ Description ] ==========================================================
//
// Defines the structure for the benchmark dialog.
//
// ==[ License ] ==============================================================
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General public License for more details.
//
// You should have received a copy of the GNU General public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ============================================================================
// Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/
-->
<Dialog xmlns="http://schema.picoe.ca/eto.forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Benchmark" ClientSize="460, 160" Padding="10" Maximizable="False" Minimizable="False" Resizable="False"
WindowStyle="None">
<StackLayout Orientation="Vertical">
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Expand="True">
<StackLayout Orientation="Vertical" ID="stkPreCalculation">
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Top">
<StackLayout Orientation="Horizontal">
<NumericStepper ID="nmuBufferSize" Value="128" MinValue="1" MaxValue="1024"/>
<Label Text="MiB of buffer"/>
</StackLayout>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Top">
<StackLayout Orientation="Horizontal">
<NumericStepper ID="nmuBlockSize" Value="512" MinValue="2" MaxValue="65536"/>
<Label Text="bytes per block"/>
</StackLayout>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Expand="True">
<StackLayout Orientation="Vertical" ID="stkProgress">
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
<Label ID="lblProgress" Size="-1, -1"/>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
<ProgressBar ID="prgProgress"/>
</StackLayoutItem>
</StackLayout>
</StackLayoutItem>
</StackLayout>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Right" VerticalAlignment="Bottom" Expand="True">
<StackLayout Orientation="Horizontal" ID="stkButtons">
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
<Button ID="btnStart" Click="OnBtnStart">Start</Button>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
<Button ID="btnClose" Click="OnBtnClose">Close</Button>
</StackLayoutItem>
</StackLayout>
</StackLayoutItem>
</StackLayout>
</Dialog>

View File

@@ -1,185 +0,0 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : dlgBenchmark.xeto.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Benchmark dialog.
//
// --[ Description ] ----------------------------------------------------------
//
// Implements the benchmark dialog.
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General public License for more details.
//
// You should have received a copy of the GNU General public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/
using System;
using System.Collections.Generic;
using System.Threading;
using DiscImageChef.Core;
using Eto.Drawing;
using Eto.Forms;
using Eto.Serialization.Xaml;
namespace DiscImageChef.Gui.Dialogs
{
public class dlgBenchmark : Dialog
{
Dictionary<string, double> checksumTimes;
int counter;
BenchmarkResults results;
int step;
public dlgBenchmark()
{
XamlReader.Load(this);
}
protected void OnBtnStart(object sender, EventArgs e)
{
checksumTimes = new Dictionary<string, double>();
Benchmark.UpdateProgressEvent += UpdateProgress;
stkProgress.Visible = true;
lblProgress.Text = "";
btnClose.Enabled = false;
btnStart.Enabled = false;
nmuBufferSize.Enabled = false;
nmuBlockSize.Enabled = false;
Thread thread = new Thread(() =>
{
counter = step = (int)(nmuBufferSize.Value * 1024 * 1024 / nmuBlockSize.Value) % 3333;
// TODO: Able to cancel!
results = Benchmark.Do((int)(nmuBufferSize.Value * 1024 * 1024), (int)nmuBlockSize.Value);
Application.Instance.Invoke(Finish);
});
thread.Start();
}
void Finish()
{
Benchmark.UpdateProgressEvent += UpdateProgress;
StackLayout stkCalculationResults = new StackLayout();
stkCalculationResults.Items.Add(new Label
{
Text =
$"Took {results.FillTime} seconds to fill buffer, {results.FillSpeed:F3} MiB/sec."
});
stkCalculationResults.Items.Add(new Label
{
Text =
$"Took {results.ReadTime} seconds to read buffer, {results.ReadSpeed:F3} MiB/sec."
});
stkCalculationResults.Items.Add(new Label
{
Text =
$"Took {results.EntropyTime} seconds to entropy buffer, {results.EntropySpeed:F3} MiB/sec."
});
foreach(KeyValuePair<string, BenchmarkEntry> entry in results.Entries)
{
checksumTimes.Add(entry.Key, entry.Value.TimeSpan);
stkCalculationResults.Items.Add(new Label
{
Text =
$"Took {entry.Value.TimeSpan} seconds to {entry.Key} buffer, {entry.Value.Speed:F3} MiB/sec."
});
;
}
stkCalculationResults.Items.Add(new Label
{
Text =
$"Took {results.TotalTime} seconds to do all algorithms at the same time, {results.TotalSpeed:F3} MiB/sec."
});
stkCalculationResults.Items.Add(new Label
{
Text =
$"Took {results.SeparateTime} seconds to do all algorithms sequentially, {results.SeparateSpeed:F3} MiB/sec."
});
stkCalculationResults.Items.Add(new Label {Text = $"Max memory used is {results.MaxMemory} bytes"});
stkCalculationResults.Items.Add(new Label {Text = $"Min memory used is {results.MinMemory} bytes"});
Statistics.AddCommand("benchmark");
stkCalculationResults.Items.Add(new StackLayoutItem(stkButtons, HorizontalAlignment.Right, true));
stkCalculationResults.Visible = true;
btnStart.Visible = false;
btnClose.Enabled = true;
Content = stkCalculationResults;
ClientSize = new Size(-1, -1);
}
void UpdateProgress(string text, long current, long maximum)
{
if(counter < step)
{
counter++;
return;
}
counter = 0;
Application.Instance.Invoke(() =>
{
lblProgress.Text = text;
if(maximum == 0)
{
prgProgress.Indeterminate = true;
return;
}
if(prgProgress.Indeterminate) prgProgress.Indeterminate = false;
if(maximum > int.MaxValue || current > int.MaxValue)
{
prgProgress.MaxValue = (int)(maximum / int.MaxValue);
prgProgress.Value = (int)(current / int.MaxValue);
}
else
{
prgProgress.MaxValue = (int)maximum;
prgProgress.Value = (int)current;
}
});
}
protected void OnBtnClose(object sender, EventArgs e)
{
Close();
}
#region XAML controls
NumericStepper nmuBufferSize;
NumericStepper nmuBlockSize;
StackLayout stkProgress;
Label lblProgress;
ProgressBar prgProgress;
Button btnStart;
Button btnClose;
StackLayout stkPreCalculation;
StackLayout stkButtons;
#endregion
}
}

View File

@@ -64,7 +64,6 @@
<Label/>
<StackLayout Orientation="Vertical" ID="stkStatistics">
<CheckBox ID="chkShareStats"/>
<CheckBox ID="chkBenchmarkStats"/>
<CheckBox ID="chkCommandStats"/>
<CheckBox ID="chkDeviceStats"/>
<CheckBox ID="chkFilesystemStats"/>

View File

@@ -47,10 +47,12 @@ namespace DiscImageChef.Gui.Dialogs
"In compliance with the European Union General Data Protection Regulation 2016/679 (GDPR),\n" +
"we must give you the following information about DiscImageChef and ask if you want to opt-in\n" +
"in some information sharing.";
lblGdpr2.Text =
"Disclaimer: Because DiscImageChef is an open source software this information, and therefore,\n" +
"compliance with GDPR only holds true if you obtained a certificated copy from its original\n" +
"authors. In case of doubt, close DiscImageChef now and ask in our IRC support channel.";
lblGdpr3.Text =
"For any information sharing your IP address may be stored in our server, in a way that is not\n" +
"possible for any person, manual, or automated process, to link with your identity, unless\n" +
@@ -70,14 +72,16 @@ namespace DiscImageChef.Gui.Dialogs
chkSaveReportsGlobally.Text =
"Do you want to save device reports in shared folder of your computer? (Y/N): ";
chkSaveReportsGlobally.Checked = Settings.Settings.Current.SaveReportsGlobally;
lblShareReports.Text =
"Sharing a report with us will send it to our server, that's in the european union territory, where it\n" +
"will be manually analized by an european union citizen to remove any trace of personal identification\n" +
"from it. Once that is done, it will be shared in our stats website, https://www.discimagechef.app\n" +
"from it. Once that is done, it will be shared in our stats website, https://www.discimagechef.app\n" +
"These report will be used to improve DiscImageChef support, and in some cases, to provide emulation of the\n" +
"devices to other open-source projects. In any case, no information linking the report to you will be stored.";
chkShareReports.Text = "Do you want to share your device reports with us? (Y/N): ";
chkShareReports.Checked = Settings.Settings.Current.ShareReports;
#endregion Device reports
@@ -88,6 +92,7 @@ namespace DiscImageChef.Gui.Dialogs
"command is executed, a filesystem, partition, or device is used, the operating system version, and other.\n" +
"In no case, any information besides pure statistical usage numbers is stored, and they're just joint to the\n" +
"pool with no way of using them to identify you.";
chkSaveStats.Text = "Do you want to save stats about your DiscImageChef usage? (Y/N): ";
if(Settings.Settings.Current.Stats != null)
@@ -98,9 +103,6 @@ namespace DiscImageChef.Gui.Dialogs
chkShareStats.Text = "Do you want to share your stats anonymously? (Y/N): ";
chkShareStats.Checked = Settings.Settings.Current.Stats.ShareStats;
chkBenchmarkStats.Text = "Do you want to gather statistics about benchmarks? (Y/N): ";
chkBenchmarkStats.Checked = Settings.Settings.Current.Stats.BenchmarkStats;
chkCommandStats.Text = "Do you want to gather statistics about command usage? (Y/N): ";
chkCommandStats.Checked = Settings.Settings.Current.Stats.CommandStats;
@@ -115,6 +117,7 @@ namespace DiscImageChef.Gui.Dialogs
chkMediaImageStats.Text =
"Do you want to gather statistics about found media image formats? (Y/N): ";
chkMediaImageStats.Checked = Settings.Settings.Current.Stats.MediaImageStats;
chkMediaScanStats.Text = "Do you want to gather statistics about scanned media? (Y/N): ";
@@ -122,6 +125,7 @@ namespace DiscImageChef.Gui.Dialogs
chkPartitionStats.Text =
"Do you want to gather statistics about found partitioning schemes? (Y/N): ";
chkPartitionStats.Checked = Settings.Settings.Current.Stats.PartitionStats;
chkMediaStats.Text = "Do you want to gather statistics about media types? (Y/N): ";
@@ -138,10 +142,7 @@ namespace DiscImageChef.Gui.Dialogs
#endregion Statistics
}
protected void OnBtnCancel(object sender, EventArgs e)
{
Close();
}
protected void OnBtnCancel(object sender, EventArgs e) => Close();
protected void OnBtnSave(object sender, EventArgs e)
{
@@ -152,18 +153,17 @@ namespace DiscImageChef.Gui.Dialogs
Settings.Settings.Current.Stats = new StatsSettings
{
ShareStats = chkShareStats.Checked == true,
BenchmarkStats = chkBenchmarkStats.Checked == true,
CommandStats = chkCommandStats.Checked == true,
DeviceStats = chkDeviceStats.Checked == true,
FilesystemStats = chkFilesystemStats.Checked == true,
FilterStats = chkFilterStats.Checked == true,
MediaImageStats = chkMediaImageStats.Checked == true,
MediaScanStats = chkMediaScanStats.Checked == true,
PartitionStats = chkPartitionStats.Checked == true,
MediaStats = chkMediaStats.Checked == true,
PartitionStats = chkPartitionStats.Checked == true, MediaStats = chkMediaStats.Checked == true,
VerifyStats = chkVerifyStats.Checked == true
};
else Settings.Settings.Current.Stats = null;
else
Settings.Settings.Current.Stats = null;
Settings.Settings.Current.GdprCompliance = DicSettings.GdprLevel;
Settings.Settings.SaveSettings();
@@ -178,7 +178,6 @@ namespace DiscImageChef.Gui.Dialogs
CheckBox chkShareReports;
CheckBox chkSaveStats;
CheckBox chkShareStats;
CheckBox chkBenchmarkStats;
CheckBox chkCommandStats;
CheckBox chkDeviceStats;
CheckBox chkFilesystemStats;

View File

@@ -38,7 +38,6 @@
<TabPage ID="tabCommands" Text="Commands" Visible="False">
<StackLayout Orientation="Vertical">
<Label ID="lblAnalyze" Visible="False"/>
<Label ID="lblBenchmark" Visible="False"/>
<Label ID="lblChecksum" Visible="False"/>
<Label ID="lblCompare" Visible="False"/>
<Label ID="lblConvertImage" Visible="False"/>

View File

@@ -45,34 +45,26 @@ namespace DiscImageChef.Gui.Dialogs
{
XamlReader.Load(this);
DicContext ctx = DicContext.Create(Settings.Settings.LocalDbPath);
var ctx = DicContext.Create(Settings.Settings.LocalDbPath);
if(ctx.Commands.Any())
{
if(ctx.Commands.Any(c => c.Name == "analyze"))
{
ulong count = ctx.Commands.Where(c => c.Name == "analyze" && c.Synchronized).Select(c => c.Count)
.FirstOrDefault();
ulong count = ctx.Commands.Where(c => c.Name == "analyze" && c.Synchronized).Select(c => c.Count).
FirstOrDefault();
count += (ulong)ctx.Commands.LongCount(c => c.Name == "analyze" && !c.Synchronized);
lblAnalyze.Visible = true;
lblAnalyze.Text = $"You have called the Analyze command {count} times";
}
if(ctx.Commands.Any(c => c.Name == "benchmark"))
{
ulong count = ctx.Commands.Where(c => c.Name == "benchmark" && c.Synchronized).Select(c => c.Count)
.FirstOrDefault();
count += (ulong)ctx.Commands.LongCount(c => c.Name == "benchmark" && !c.Synchronized);
lblBenchmark.Visible = true;
lblBenchmark.Text = $"You have called the Benchmark command {count} times";
}
if(ctx.Commands.Any(c => c.Name == "checksum"))
{
ulong count = ctx.Commands.Where(c => c.Name == "checksum" && c.Synchronized).Select(c => c.Count)
.FirstOrDefault();
ulong count = ctx.Commands.Where(c => c.Name == "checksum" && c.Synchronized).Select(c => c.Count).
FirstOrDefault();
count += (ulong)ctx.Commands.LongCount(c => c.Name == "checksum" && !c.Synchronized);
lblChecksum.Visible = true;
@@ -81,8 +73,9 @@ namespace DiscImageChef.Gui.Dialogs
if(ctx.Commands.Any(c => c.Name == "compare"))
{
ulong count = ctx.Commands.Where(c => c.Name == "compare" && c.Synchronized).Select(c => c.Count)
.FirstOrDefault();
ulong count = ctx.Commands.Where(c => c.Name == "compare" && c.Synchronized).Select(c => c.Count).
FirstOrDefault();
count += (ulong)ctx.Commands.LongCount(c => c.Name == "compare" && !c.Synchronized);
lblCompare.Visible = true;
@@ -91,8 +84,9 @@ namespace DiscImageChef.Gui.Dialogs
if(ctx.Commands.Any(c => c.Name == "convert-image"))
{
ulong count = ctx.Commands.Where(c => c.Name == "convert-image" && c.Synchronized)
.Select(c => c.Count).FirstOrDefault();
ulong count = ctx.Commands.Where(c => c.Name == "convert-image" && c.Synchronized).
Select(c => c.Count).FirstOrDefault();
count += (ulong)ctx.Commands.LongCount(c => c.Name == "convert-image" && !c.Synchronized);
lblConvertImage.Visible = true;
@@ -101,8 +95,9 @@ namespace DiscImageChef.Gui.Dialogs
if(ctx.Commands.Any(c => c.Name == "create-sidecar"))
{
ulong count = ctx.Commands.Where(c => c.Name == "create-sidecar" && c.Synchronized)
.Select(c => c.Count).FirstOrDefault();
ulong count = ctx.Commands.Where(c => c.Name == "create-sidecar" && c.Synchronized).
Select(c => c.Count).FirstOrDefault();
count += (ulong)ctx.Commands.LongCount(c => c.Name == "create-sidecar" && !c.Synchronized);
lblCreateSidecar.Visible = true;
@@ -111,8 +106,9 @@ namespace DiscImageChef.Gui.Dialogs
if(ctx.Commands.Any(c => c.Name == "decode"))
{
ulong count = ctx.Commands.Where(c => c.Name == "decode" && c.Synchronized).Select(c => c.Count)
.FirstOrDefault();
ulong count = ctx.Commands.Where(c => c.Name == "decode" && c.Synchronized).Select(c => c.Count).
FirstOrDefault();
count += (ulong)ctx.Commands.LongCount(c => c.Name == "decode" && !c.Synchronized);
lblDecode.Visible = true;
@@ -121,8 +117,9 @@ namespace DiscImageChef.Gui.Dialogs
if(ctx.Commands.Any(c => c.Name == "device-info"))
{
ulong count = ctx.Commands.Where(c => c.Name == "device-info" && c.Synchronized)
.Select(c => c.Count).FirstOrDefault();
ulong count = ctx.Commands.Where(c => c.Name == "device-info" && c.Synchronized).
Select(c => c.Count).FirstOrDefault();
count += (ulong)ctx.Commands.LongCount(c => c.Name == "device-info" && !c.Synchronized);
lblDeviceInfo.Visible = true;
@@ -131,8 +128,9 @@ namespace DiscImageChef.Gui.Dialogs
if(ctx.Commands.Any(c => c.Name == "device-report"))
{
ulong count = ctx.Commands.Where(c => c.Name == "device-report" && c.Synchronized)
.Select(c => c.Count).FirstOrDefault();
ulong count = ctx.Commands.Where(c => c.Name == "device-report" && c.Synchronized).
Select(c => c.Count).FirstOrDefault();
count += (ulong)ctx.Commands.LongCount(c => c.Name == "device-report" && !c.Synchronized);
lblDeviceReport.Visible = true;
@@ -141,8 +139,9 @@ namespace DiscImageChef.Gui.Dialogs
if(ctx.Commands.Any(c => c.Name == "dump-media"))
{
ulong count = ctx.Commands.Where(c => c.Name == "dump-media" && c.Synchronized).Select(c => c.Count)
.FirstOrDefault();
ulong count = ctx.Commands.Where(c => c.Name == "dump-media" && c.Synchronized).
Select(c => c.Count).FirstOrDefault();
count += (ulong)ctx.Commands.LongCount(c => c.Name == "dump-media" && !c.Synchronized);
lblDumpMedia.Visible = true;
@@ -151,8 +150,9 @@ namespace DiscImageChef.Gui.Dialogs
if(ctx.Commands.Any(c => c.Name == "entropy"))
{
ulong count = ctx.Commands.Where(c => c.Name == "entropy" && c.Synchronized).Select(c => c.Count)
.FirstOrDefault();
ulong count = ctx.Commands.Where(c => c.Name == "entropy" && c.Synchronized).Select(c => c.Count).
FirstOrDefault();
count += (ulong)ctx.Commands.LongCount(c => c.Name == "entropy" && !c.Synchronized);
lblEntropy.Visible = true;
@@ -161,8 +161,9 @@ namespace DiscImageChef.Gui.Dialogs
if(ctx.Commands.Any(c => c.Name == "formats"))
{
ulong count = ctx.Commands.Where(c => c.Name == "formats" && c.Synchronized).Select(c => c.Count)
.FirstOrDefault();
ulong count = ctx.Commands.Where(c => c.Name == "formats" && c.Synchronized).Select(c => c.Count).
FirstOrDefault();
count += (ulong)ctx.Commands.LongCount(c => c.Name == "formats" && !c.Synchronized);
lblFormats.Visible = true;
@@ -171,8 +172,9 @@ namespace DiscImageChef.Gui.Dialogs
if(ctx.Commands.Any(c => c.Name == "image-info"))
{
ulong count = ctx.Commands.Where(c => c.Name == "image-info" && c.Synchronized).Select(c => c.Count)
.FirstOrDefault();
ulong count = ctx.Commands.Where(c => c.Name == "image-info" && c.Synchronized).
Select(c => c.Count).FirstOrDefault();
count += (ulong)ctx.Commands.LongCount(c => c.Name == "image-info" && !c.Synchronized);
lblImageInfo.Visible = true;
@@ -181,8 +183,9 @@ namespace DiscImageChef.Gui.Dialogs
if(ctx.Commands.Any(c => c.Name == "media-info"))
{
ulong count = ctx.Commands.Where(c => c.Name == "media-info" && c.Synchronized).Select(c => c.Count)
.FirstOrDefault();
ulong count = ctx.Commands.Where(c => c.Name == "media-info" && c.Synchronized).
Select(c => c.Count).FirstOrDefault();
count += (ulong)ctx.Commands.LongCount(c => c.Name == "media-info" && !c.Synchronized);
lblMediaInfo.Visible = true;
@@ -191,8 +194,9 @@ namespace DiscImageChef.Gui.Dialogs
if(ctx.Commands.Any(c => c.Name == "media-scan"))
{
ulong count = ctx.Commands.Where(c => c.Name == "media-scan" && c.Synchronized).Select(c => c.Count)
.FirstOrDefault();
ulong count = ctx.Commands.Where(c => c.Name == "media-scan" && c.Synchronized).
Select(c => c.Count).FirstOrDefault();
count += (ulong)ctx.Commands.LongCount(c => c.Name == "media-scan" && !c.Synchronized);
lblMediaScan.Visible = true;
@@ -201,8 +205,9 @@ namespace DiscImageChef.Gui.Dialogs
if(ctx.Commands.Any(c => c.Name == "printhex"))
{
ulong count = ctx.Commands.Where(c => c.Name == "printhex" && c.Synchronized).Select(c => c.Count)
.FirstOrDefault();
ulong count = ctx.Commands.Where(c => c.Name == "printhex" && c.Synchronized).Select(c => c.Count).
FirstOrDefault();
count += (ulong)ctx.Commands.LongCount(c => c.Name == "printhex" && !c.Synchronized);
lblPrintHex.Visible = true;
@@ -211,30 +216,38 @@ namespace DiscImageChef.Gui.Dialogs
if(ctx.Commands.Any(c => c.Name == "verify"))
{
ulong count = ctx.Commands.Where(c => c.Name == "verify" && c.Synchronized).Select(c => c.Count)
.FirstOrDefault();
ulong count = ctx.Commands.Where(c => c.Name == "verify" && c.Synchronized).Select(c => c.Count).
FirstOrDefault();
count += (ulong)ctx.Commands.LongCount(c => c.Name == "verify" && !c.Synchronized);
lblVerify.Visible = true;
lblVerify.Text = $"You have called the Verify command {count} times";
}
tabCommands.Visible = lblAnalyze.Visible || lblBenchmark.Visible || lblChecksum.Visible ||
lblCompare.Visible || lblConvertImage.Visible || lblCreateSidecar.Visible ||
lblDecode.Visible || lblDeviceInfo.Visible || lblDeviceReport.Visible ||
lblDumpMedia.Visible || lblEntropy.Visible || lblFormats.Visible ||
lblImageInfo.Visible || lblMediaInfo.Visible || lblMediaScan.Visible ||
lblPrintHex.Visible || lblVerify.Visible;
tabCommands.Visible = lblAnalyze.Visible || lblChecksum.Visible || lblCompare.Visible ||
lblConvertImage.Visible || lblCreateSidecar.Visible || lblDecode.Visible ||
lblDeviceInfo.Visible || lblDeviceReport.Visible || lblDumpMedia.Visible ||
lblEntropy.Visible || lblFormats.Visible || lblImageInfo.Visible ||
lblMediaInfo.Visible || lblMediaScan.Visible || lblPrintHex.Visible ||
lblVerify.Visible;
}
if(ctx.Filters.Any())
{
tabFilters.Visible = true;
TreeGridItemCollection filterList = new TreeGridItemCollection();
var filterList = new TreeGridItemCollection();
treeFilters.Columns.Add(new GridColumn {HeaderText = "Filter", DataCell = new TextBoxCell(0)});
treeFilters.Columns.Add(new GridColumn {HeaderText = "Times found", DataCell = new TextBoxCell(1)});
treeFilters.Columns.Add(new GridColumn
{
HeaderText = "Filter", DataCell = new TextBoxCell(0)
});
treeFilters.Columns.Add(new GridColumn
{
HeaderText = "Times found", DataCell = new TextBoxCell(1)
});
treeFilters.AllowMultipleSelection = false;
treeFilters.ShowHeader = true;
@@ -242,11 +255,18 @@ namespace DiscImageChef.Gui.Dialogs
foreach(string nvs in ctx.Filters.Select(n => n.Name).Distinct())
{
ulong count = ctx.Filters.Where(c => c.Name == nvs && c.Synchronized).Select(c => c.Count)
.FirstOrDefault();
ulong count = ctx.Filters.Where(c => c.Name == nvs && c.Synchronized).Select(c => c.Count).
FirstOrDefault();
count += (ulong)ctx.Filters.LongCount(c => c.Name == nvs && !c.Synchronized);
filterList.Add(new TreeGridItem {Values = new object[] {nvs, count}});
filterList.Add(new TreeGridItem
{
Values = new object[]
{
nvs, count
}
});
}
}
@@ -254,10 +274,17 @@ namespace DiscImageChef.Gui.Dialogs
{
tabFormats.Visible = true;
TreeGridItemCollection formatList = new TreeGridItemCollection();
var formatList = new TreeGridItemCollection();
treeFormats.Columns.Add(new GridColumn {HeaderText = "Format", DataCell = new TextBoxCell(0)});
treeFormats.Columns.Add(new GridColumn {HeaderText = "Times found", DataCell = new TextBoxCell(1)});
treeFormats.Columns.Add(new GridColumn
{
HeaderText = "Format", DataCell = new TextBoxCell(0)
});
treeFormats.Columns.Add(new GridColumn
{
HeaderText = "Times found", DataCell = new TextBoxCell(1)
});
treeFormats.AllowMultipleSelection = false;
treeFormats.ShowHeader = true;
@@ -265,11 +292,18 @@ namespace DiscImageChef.Gui.Dialogs
foreach(string nvs in ctx.MediaFormats.Select(n => n.Name).Distinct())
{
ulong count = ctx.MediaFormats.Where(c => c.Name == nvs && c.Synchronized).Select(c => c.Count)
.FirstOrDefault();
ulong count = ctx.MediaFormats.Where(c => c.Name == nvs && c.Synchronized).Select(c => c.Count).
FirstOrDefault();
count += (ulong)ctx.MediaFormats.LongCount(c => c.Name == nvs && !c.Synchronized);
formatList.Add(new TreeGridItem {Values = new object[] {nvs, count}});
formatList.Add(new TreeGridItem
{
Values = new object[]
{
nvs, count
}
});
}
}
@@ -277,10 +311,17 @@ namespace DiscImageChef.Gui.Dialogs
{
tabPartitions.Visible = true;
TreeGridItemCollection partitionList = new TreeGridItemCollection();
var partitionList = new TreeGridItemCollection();
treePartitions.Columns.Add(new GridColumn {HeaderText = "Filter", DataCell = new TextBoxCell(0)});
treePartitions.Columns.Add(new GridColumn {HeaderText = "Times found", DataCell = new TextBoxCell(1)});
treePartitions.Columns.Add(new GridColumn
{
HeaderText = "Filter", DataCell = new TextBoxCell(0)
});
treePartitions.Columns.Add(new GridColumn
{
HeaderText = "Times found", DataCell = new TextBoxCell(1)
});
treePartitions.AllowMultipleSelection = false;
treePartitions.ShowHeader = true;
@@ -288,11 +329,18 @@ namespace DiscImageChef.Gui.Dialogs
foreach(string nvs in ctx.Partitions.Select(n => n.Name).Distinct())
{
ulong count = ctx.Partitions.Where(c => c.Name == nvs && c.Synchronized).Select(c => c.Count)
.FirstOrDefault();
ulong count = ctx.Partitions.Where(c => c.Name == nvs && c.Synchronized).Select(c => c.Count).
FirstOrDefault();
count += (ulong)ctx.Partitions.LongCount(c => c.Name == nvs && !c.Synchronized);
partitionList.Add(new TreeGridItem {Values = new object[] {nvs, count}});
partitionList.Add(new TreeGridItem
{
Values = new object[]
{
nvs, count
}
});
}
}
@@ -300,10 +348,17 @@ namespace DiscImageChef.Gui.Dialogs
{
tabFilesystems.Visible = true;
TreeGridItemCollection filesystemList = new TreeGridItemCollection();
var filesystemList = new TreeGridItemCollection();
treeFilesystems.Columns.Add(new GridColumn {HeaderText = "Filesystem", DataCell = new TextBoxCell(0)});
treeFilesystems.Columns.Add(new GridColumn {HeaderText = "Times found", DataCell = new TextBoxCell(1)});
treeFilesystems.Columns.Add(new GridColumn
{
HeaderText = "Filesystem", DataCell = new TextBoxCell(0)
});
treeFilesystems.Columns.Add(new GridColumn
{
HeaderText = "Times found", DataCell = new TextBoxCell(1)
});
treeFilesystems.AllowMultipleSelection = false;
treeFilesystems.ShowHeader = true;
@@ -311,11 +366,18 @@ namespace DiscImageChef.Gui.Dialogs
foreach(string nvs in ctx.Filesystems.Select(n => n.Name).Distinct())
{
ulong count = ctx.Filesystems.Where(c => c.Name == nvs && c.Synchronized).Select(c => c.Count)
.FirstOrDefault();
ulong count = ctx.Filesystems.Where(c => c.Name == nvs && c.Synchronized).Select(c => c.Count).
FirstOrDefault();
count += (ulong)ctx.Filesystems.LongCount(c => c.Name == nvs && !c.Synchronized);
filesystemList.Add(new TreeGridItem {Values = new object[] {nvs, count}});
filesystemList.Add(new TreeGridItem
{
Values = new object[]
{
nvs, count
}
});
}
}
@@ -323,35 +385,64 @@ namespace DiscImageChef.Gui.Dialogs
{
tabDevices.Visible = true;
TreeGridItemCollection deviceList = new TreeGridItemCollection();
var deviceList = new TreeGridItemCollection();
treeDevices.Columns.Add(new GridColumn {HeaderText = "Device", DataCell = new TextBoxCell(0)});
treeDevices.Columns.Add(new GridColumn {HeaderText = "Manufacturer", DataCell = new TextBoxCell(1)});
treeDevices.Columns.Add(new GridColumn {HeaderText = "Revision", DataCell = new TextBoxCell(2)});
treeDevices.Columns.Add(new GridColumn {HeaderText = "Bus", DataCell = new TextBoxCell(3)});
treeDevices.Columns.Add(new GridColumn
{
HeaderText = "Device", DataCell = new TextBoxCell(0)
});
treeDevices.Columns.Add(new GridColumn
{
HeaderText = "Manufacturer", DataCell = new TextBoxCell(1)
});
treeDevices.Columns.Add(new GridColumn
{
HeaderText = "Revision", DataCell = new TextBoxCell(2)
});
treeDevices.Columns.Add(new GridColumn
{
HeaderText = "Bus", DataCell = new TextBoxCell(3)
});
treeDevices.AllowMultipleSelection = false;
treeDevices.ShowHeader = true;
treeDevices.DataStore = deviceList;
foreach(DeviceStat ds in ctx.SeenDevices.OrderBy(n => n.Manufacturer).ThenBy(n => n.Manufacturer)
.ThenBy(n => n.Revision)
.ThenBy(n => n.Bus))
foreach(DeviceStat ds in ctx.SeenDevices.OrderBy(n => n.Manufacturer).ThenBy(n => n.Manufacturer).
ThenBy(n => n.Revision).ThenBy(n => n.Bus))
deviceList.Add(new TreeGridItem
{
Values = new object[] {ds.Model, ds.Manufacturer, ds.Revision, ds.Bus}
Values = new object[]
{
ds.Model, ds.Manufacturer, ds.Revision, ds.Bus
}
});
}
if(!ctx.Medias.Any()) return;
if(!ctx.Medias.Any())
return;
tabMedias.Visible = true;
TreeGridItemCollection mediaList = new TreeGridItemCollection();
var mediaList = new TreeGridItemCollection();
treeMedias.Columns.Add(new GridColumn {HeaderText = "Media", DataCell = new TextBoxCell(0)});
treeMedias.Columns.Add(new GridColumn {HeaderText = "Times found", DataCell = new TextBoxCell(1)});
treeMedias.Columns.Add(new GridColumn {HeaderText = "Type", DataCell = new TextBoxCell(2)});
treeMedias.Columns.Add(new GridColumn
{
HeaderText = "Media", DataCell = new TextBoxCell(0)
});
treeMedias.Columns.Add(new GridColumn
{
HeaderText = "Times found", DataCell = new TextBoxCell(1)
});
treeMedias.Columns.Add(new GridColumn
{
HeaderText = "Type", DataCell = new TextBoxCell(2)
});
treeMedias.AllowMultipleSelection = false;
treeMedias.ShowHeader = true;
@@ -359,31 +450,43 @@ namespace DiscImageChef.Gui.Dialogs
foreach(string media in ctx.Medias.OrderBy(ms => ms.Type).Select(ms => ms.Type).Distinct())
{
ulong count = ctx.Medias.Where(c => c.Type == media && c.Synchronized && c.Real).Select(c => c.Count)
.FirstOrDefault();
ulong count = ctx.Medias.Where(c => c.Type == media && c.Synchronized && c.Real).Select(c => c.Count).
FirstOrDefault();
count += (ulong)ctx.Medias.LongCount(c => c.Type == media && !c.Synchronized && c.Real);
if(count > 0) mediaList.Add(new TreeGridItem {Values = new object[] {media, count, "real"}});
if(count > 0)
mediaList.Add(new TreeGridItem
{
Values = new object[]
{
media, count, "real"
}
});
count = ctx.Medias.Where(c => c.Type == media && c.Synchronized && !c.Real).Select(c => c.Count).
FirstOrDefault();
count = ctx.Medias.Where(c => c.Type == media && c.Synchronized && !c.Real).Select(c => c.Count)
.FirstOrDefault();
count += (ulong)ctx.Medias.LongCount(c => c.Type == media && !c.Synchronized && !c.Real);
if(count == 0) continue;
if(count == 0)
continue;
mediaList.Add(new TreeGridItem {Values = new object[] {media, count, "image"}});
mediaList.Add(new TreeGridItem
{
Values = new object[]
{
media, count, "image"
}
});
}
}
protected void OnBtnClose(object sender, EventArgs e)
{
Close();
}
protected void OnBtnClose(object sender, EventArgs e) => Close();
#region XAML controls
TabPage tabCommands;
Label lblAnalyze;
Label lblBenchmark;
Label lblChecksum;
Label lblCompare;
Label lblConvertImage;