diff --git a/Aaru.Gui/Aaru.Gui.csproj b/Aaru.Gui/Aaru.Gui.csproj index 5caea1759..40f1a5d1e 100644 --- a/Aaru.Gui/Aaru.Gui.csproj +++ b/Aaru.Gui/Aaru.Gui.csproj @@ -23,6 +23,7 @@ + diff --git a/Aaru.Gui/Dialogs/dlgStatistics.xeto b/Aaru.Gui/Dialogs/dlgStatistics.xeto deleted file mode 100644 index d275aec32..000000000 --- a/Aaru.Gui/Dialogs/dlgStatistics.xeto +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Aaru.Gui/Dialogs/dlgStatistics.xeto.cs b/Aaru.Gui/Dialogs/dlgStatistics.xeto.cs deleted file mode 100644 index 006e50e29..000000000 --- a/Aaru.Gui/Dialogs/dlgStatistics.xeto.cs +++ /dev/null @@ -1,519 +0,0 @@ -// /*************************************************************************** -// Aaru Data Preservation Suite -// ---------------------------------------------------------------------------- -// -// Filename : dlgStatistics.xeto.cs -// Author(s) : Natalia Portillo -// -// Component : Statistics dialog. -// -// --[ Description ] ---------------------------------------------------------- -// -// Implements the statistics 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 . -// -// ---------------------------------------------------------------------------- -// Copyright © 2011-2020 Natalia Portillo -// ****************************************************************************/ - -using System; -using System.Linq; -using Aaru.Database; -using Aaru.Database.Models; -using Eto.Forms; -using Eto.Serialization.Xaml; - -namespace Aaru.Gui.Dialogs -{ - public class dlgStatistics : Dialog - { - public dlgStatistics() - { - XamlReader.Load(this); - - var ctx = AaruContext.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(); - - 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 == "checksum")) - { - 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; - lblChecksum.Text = $"You have called the Checksum command {count} times"; - } - - if(ctx.Commands.Any(c => c.Name == "compare")) - { - 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; - lblCompare.Text = $"You have called the Compare command {count} times"; - } - - 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(); - - count += (ulong)ctx.Commands.LongCount(c => c.Name == "convert-image" && !c.Synchronized); - - lblConvertImage.Visible = true; - lblConvertImage.Text = $"You have called the Convert-Image command {count} times"; - } - - 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(); - - count += (ulong)ctx.Commands.LongCount(c => c.Name == "create-sidecar" && !c.Synchronized); - - lblCreateSidecar.Visible = true; - lblCreateSidecar.Text = $"You have called the Create-Sidecar command {count} times"; - } - - if(ctx.Commands.Any(c => c.Name == "decode")) - { - 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; - lblDecode.Text = $"You have called the Decode command {count} times"; - } - - 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(); - - count += (ulong)ctx.Commands.LongCount(c => c.Name == "device-info" && !c.Synchronized); - - lblDeviceInfo.Visible = true; - lblDeviceInfo.Text = $"You have called the Device-Info command {count} times"; - } - - 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(); - - count += (ulong)ctx.Commands.LongCount(c => c.Name == "device-report" && !c.Synchronized); - - lblDeviceReport.Visible = true; - lblDeviceReport.Text = $"You have called the Device-Report command {count} times"; - } - - 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(); - - count += (ulong)ctx.Commands.LongCount(c => c.Name == "dump-media" && !c.Synchronized); - - lblDumpMedia.Visible = true; - lblDumpMedia.Text = $"You have called the Dump-Media command {count} times"; - } - - if(ctx.Commands.Any(c => c.Name == "entropy")) - { - 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; - lblEntropy.Text = $"You have called the Entropy command {count} times"; - } - - if(ctx.Commands.Any(c => c.Name == "formats")) - { - 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; - lblFormats.Text = $"You have called the Formats command {count} times"; - } - - 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(); - - count += (ulong)ctx.Commands.LongCount(c => c.Name == "image-info" && !c.Synchronized); - - lblImageInfo.Visible = true; - lblImageInfo.Text = $"You have called the Image-Info command {count} times"; - } - - 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(); - - count += (ulong)ctx.Commands.LongCount(c => c.Name == "media-info" && !c.Synchronized); - - lblMediaInfo.Visible = true; - lblMediaInfo.Text = $"You have called the Media-Info command {count} times"; - } - - 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(); - - count += (ulong)ctx.Commands.LongCount(c => c.Name == "media-scan" && !c.Synchronized); - - lblMediaScan.Visible = true; - lblMediaScan.Text = $"You have called the Media-Scan command {count} times"; - } - - if(ctx.Commands.Any(c => c.Name == "printhex")) - { - 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; - lblPrintHex.Text = $"You have called the Print-Hex command {count} times"; - } - - if(ctx.Commands.Any(c => c.Name == "verify")) - { - 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 || 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; - - 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.AllowMultipleSelection = false; - treeFilters.ShowHeader = true; - treeFilters.DataStore = filterList; - - 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(); - - count += (ulong)ctx.Filters.LongCount(c => c.Name == nvs && !c.Synchronized); - - filterList.Add(new TreeGridItem - { - Values = new object[] - { - nvs, count - } - }); - } - } - - if(ctx.MediaFormats.Any()) - { - tabFormats.Visible = true; - - 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.AllowMultipleSelection = false; - treeFormats.ShowHeader = true; - treeFormats.DataStore = formatList; - - 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(); - - count += (ulong)ctx.MediaFormats.LongCount(c => c.Name == nvs && !c.Synchronized); - - formatList.Add(new TreeGridItem - { - Values = new object[] - { - nvs, count - } - }); - } - } - - if(ctx.Partitions.Any()) - { - tabPartitions.Visible = true; - - 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.AllowMultipleSelection = false; - treePartitions.ShowHeader = true; - treePartitions.DataStore = partitionList; - - 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(); - - count += (ulong)ctx.Partitions.LongCount(c => c.Name == nvs && !c.Synchronized); - - partitionList.Add(new TreeGridItem - { - Values = new object[] - { - nvs, count - } - }); - } - } - - if(ctx.Filesystems.Any()) - { - tabFilesystems.Visible = true; - - 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.AllowMultipleSelection = false; - treeFilesystems.ShowHeader = true; - treeFilesystems.DataStore = filesystemList; - - 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(); - - count += (ulong)ctx.Filesystems.LongCount(c => c.Name == nvs && !c.Synchronized); - - filesystemList.Add(new TreeGridItem - { - Values = new object[] - { - nvs, count - } - }); - } - } - - if(ctx.SeenDevices.Any()) - { - tabDevices.Visible = true; - - 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.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)) - deviceList.Add(new TreeGridItem - { - Values = new object[] - { - ds.Model, ds.Manufacturer, ds.Revision, ds.Bus - } - }); - } - - if(!ctx.Medias.Any()) - return; - - tabMedias.Visible = true; - - 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.AllowMultipleSelection = false; - treeMedias.ShowHeader = true; - treeMedias.DataStore = mediaList; - - 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(); - - 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" - } - }); - - 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; - - mediaList.Add(new TreeGridItem - { - Values = new object[] - { - media, count, "image" - } - }); - } - } - - protected void OnBtnClose(object sender, EventArgs e) => Close(); - - #region XAML controls - TabPage tabCommands; - Label lblAnalyze; - Label lblChecksum; - Label lblCompare; - Label lblConvertImage; - Label lblCreateSidecar; - Label lblDecode; - Label lblDeviceInfo; - Label lblDeviceReport; - Label lblDumpMedia; - Label lblEntropy; - Label lblFormats; - Label lblImageInfo; - Label lblMediaInfo; - Label lblMediaScan; - Label lblPrintHex; - Label lblVerify; - TabPage tabFilters; - TreeGridView treeFilters; - TabPage tabFormats; - TreeGridView treeFormats; - TabPage tabPartitions; - TreeGridView treePartitions; - TabPage tabFilesystems; - TreeGridView treeFilesystems; - TabPage tabDevices; - TreeGridView treeDevices; - TabPage tabMedias; - TreeGridView treeMedias; - #endregion - } -} \ No newline at end of file diff --git a/Aaru.Gui/Forms/frmConsole.xeto.cs b/Aaru.Gui/Forms/frmConsole.xeto.cs index e7a1f330e..c46679c27 100644 --- a/Aaru.Gui/Forms/frmConsole.xeto.cs +++ b/Aaru.Gui/Forms/frmConsole.xeto.cs @@ -186,8 +186,8 @@ namespace Aaru.Gui.Forms } catch(Exception exception) { - MessageBox.Show("Exception {0} trying to save logfile, details has been sent to console.", - exception.Message); + Eto.Forms.MessageBox.Show("Exception {0} trying to save logfile, details has been sent to console.", + exception.Message); AaruConsole.ErrorWriteLine("Console", exception.Message); AaruConsole.ErrorWriteLine("Console", exception.StackTrace); diff --git a/Aaru.Gui/Forms/frmDump.xeto.cs b/Aaru.Gui/Forms/frmDump.xeto.cs index 68967133e..128c6d88c 100644 --- a/Aaru.Gui/Forms/frmDump.xeto.cs +++ b/Aaru.Gui/Forms/frmDump.xeto.cs @@ -377,7 +377,7 @@ namespace Aaru.Gui.Forms } catch { - MessageBox.Show("Incorrect metadata sidecar file...", MessageBoxType.Error); + Eto.Forms.MessageBox.Show("Incorrect metadata sidecar file...", MessageBoxType.Error); chkExistingMetadata.Checked = false; } } @@ -404,7 +404,7 @@ namespace Aaru.Gui.Forms } catch { - MessageBox.Show("Incorrect resume file, cannot use it...", MessageBoxType.Error); + Eto.Forms.MessageBox.Show("Incorrect resume file, cannot use it...", MessageBoxType.Error); chkResume.Checked = false; return; @@ -415,8 +415,8 @@ namespace Aaru.Gui.Forms (_resume.BadBlocks.Count != 0 && !_resume.Tape)) return; - MessageBox.Show("Media already dumped correctly, please choose another destination...", - MessageBoxType.Warning); + Eto.Forms.MessageBox.Show("Media already dumped correctly, please choose another destination...", + MessageBoxType.Warning); chkResume.Checked = false; } @@ -625,7 +625,7 @@ namespace Aaru.Gui.Forms void StoppingErrorMessage(string text) => Application.Instance.Invoke(() => { ErrorMessage(text); - MessageBox.Show(text, MessageBoxType.Error); + Eto.Forms.MessageBox.Show(text, MessageBoxType.Error); WorkFinished(); }); diff --git a/Aaru.Gui/Forms/frmImageConvert.xeto.cs b/Aaru.Gui/Forms/frmImageConvert.xeto.cs index c3a5c9e37..a8c1560b9 100644 --- a/Aaru.Gui/Forms/frmImageConvert.xeto.cs +++ b/Aaru.Gui/Forms/frmImageConvert.xeto.cs @@ -112,7 +112,7 @@ namespace Aaru.Gui.Forms { if(!(cmbFormat.SelectedValue is IWritableImage plugin)) { - MessageBox.Show("Error trying to find selected plugin", MessageBoxType.Error); + Eto.Forms.MessageBox.Show("Error trying to find selected plugin", MessageBoxType.Error); return; } @@ -126,7 +126,7 @@ namespace Aaru.Gui.Forms if(!(plugin is IWritableImage outputFormat)) { - MessageBox.Show("Error trying to find selected plugin", MessageBoxType.Error); + Eto.Forms.MessageBox.Show("Error trying to find selected plugin", MessageBoxType.Error); return; } @@ -236,8 +236,8 @@ namespace Aaru.Gui.Forms Application.Instance.Invoke(() => { - MessageBox.Show($"Converting image will lose media tag {mediaTag}, not continuing...", - MessageBoxType.Error); + Eto.Forms.MessageBox.Show($"Converting image will lose media tag {mediaTag}, not continuing...", + MessageBoxType.Error); }); return; @@ -262,8 +262,8 @@ namespace Aaru.Gui.Forms Application.Instance.Invoke(() => { - MessageBox.Show($"Converting image will lose sector tag {sectorTag}, not continuing...", - MessageBoxType.Error); + Eto.Forms.MessageBox.Show($"Converting image will lose sector tag {sectorTag}, not continuing...", + MessageBoxType.Error); }); return; @@ -313,7 +313,8 @@ namespace Aaru.Gui.Forms { Application.Instance.Invoke(() => { - MessageBox.Show($"Error {outputFormat.ErrorMessage} creating output image.", MessageBoxType.Error); + Eto.Forms.MessageBox.Show($"Error {outputFormat.ErrorMessage} creating output image.", + MessageBoxType.Error); }); AaruConsole.ErrorWriteLine("Error {0} creating output image.", outputFormat.ErrorMessage); @@ -351,8 +352,9 @@ namespace Aaru.Gui.Forms { Application.Instance.Invoke(() => { - MessageBox.Show($"Error {outputFormat.ErrorMessage} setting metadata, not continuing...", - MessageBoxType.Error); + Eto.Forms.MessageBox. + Show($"Error {outputFormat.ErrorMessage} setting metadata, not continuing...", + MessageBoxType.Error); }); AaruConsole.ErrorWriteLine("not continuing..."); @@ -380,8 +382,9 @@ namespace Aaru.Gui.Forms { Application.Instance.Invoke(() => { - MessageBox.Show($"Error {outputFormat.ErrorMessage} sending tracks list to output image.", - MessageBoxType.Error); + Eto.Forms.MessageBox. + Show($"Error {outputFormat.ErrorMessage} sending tracks list to output image.", + MessageBoxType.Error); }); AaruConsole.ErrorWriteLine("Error {0} sending tracks list to output image.", @@ -422,8 +425,9 @@ namespace Aaru.Gui.Forms { Application.Instance.Invoke(() => { - MessageBox.Show($"Error {outputFormat.ErrorMessage} writing media tag, not continuing...", - MessageBoxType.Error); + Eto.Forms.MessageBox. + Show($"Error {outputFormat.ErrorMessage} writing media tag, not continuing...", + MessageBoxType.Error); }); AaruConsole.ErrorWriteLine("Error {0} writing media tag, not continuing...", @@ -530,7 +534,7 @@ namespace Aaru.Gui.Forms { Application.Instance.Invoke(() => { - MessageBox. + Eto.Forms.MessageBox. Show($"Error {outputFormat.ErrorMessage} writing sector {doneSectors}, not continuing...", MessageBoxType.Error); }); @@ -636,7 +640,7 @@ namespace Aaru.Gui.Forms { Application.Instance.Invoke(() => { - MessageBox. + Eto.Forms.MessageBox. Show($"Error {outputFormat.ErrorMessage} writing sector {doneSectors}, not continuing...", MessageBoxType.Error); }); @@ -745,7 +749,7 @@ namespace Aaru.Gui.Forms { Application.Instance.Invoke(() => { - MessageBox. + Eto.Forms.MessageBox. Show($"Error {outputFormat.ErrorMessage} writing sector {doneSectors}, not continuing...", MessageBoxType.Error); }); @@ -827,7 +831,7 @@ namespace Aaru.Gui.Forms { Application.Instance.Invoke(() => { - MessageBox. + Eto.Forms.MessageBox. Show($"Error {outputFormat.ErrorMessage} writing tag, not continuing...", MessageBoxType.Error); }); @@ -886,7 +890,7 @@ namespace Aaru.Gui.Forms { Application.Instance.Invoke(() => { - MessageBox. + Eto.Forms.MessageBox. Show($"Error {outputFormat.ErrorMessage} writing tag for sector {doneSectors}, not continuing...", MessageBoxType.Error); }); @@ -952,7 +956,9 @@ namespace Aaru.Gui.Forms { Application.Instance.Invoke(() => { - MessageBox.Show("Operation canceled, the output file is not correct.", MessageBoxType.Error); + Eto.Forms.MessageBox.Show("Operation canceled, the output file is not correct.", + MessageBoxType.Error); + btnClose.Visible = true; btnStop.Visible = false; stkProgress.Visible = false; @@ -965,7 +971,7 @@ namespace Aaru.Gui.Forms { Application.Instance.Invoke(() => { - MessageBox. + Eto.Forms.MessageBox. Show($"Error {outputFormat.ErrorMessage} closing output image... Contents are not correct.", MessageBoxType.Error); }); @@ -975,9 +981,9 @@ namespace Aaru.Gui.Forms Application.Instance.Invoke(() => { - MessageBox.Show(warning - ? "Some warnings happened. Check console for more information. Image should be correct." - : "Image converted successfully."); + Eto.Forms.MessageBox.Show(warning + ? "Some warnings happened. Check console for more information. Image should be correct." + : "Image converted successfully."); btnClose.Visible = true; btnStop.Visible = false; @@ -1224,7 +1230,7 @@ namespace Aaru.Gui.Forms } catch { - MessageBox.Show("Incorrect metadata sidecar file...", MessageBoxType.Error); + Eto.Forms.MessageBox.Show("Incorrect metadata sidecar file...", MessageBoxType.Error); } } @@ -1265,13 +1271,14 @@ namespace Aaru.Gui.Forms txtResumeFile.Text = dlgMetadata.FileName; } else - MessageBox.Show("Resume file does not contain dump hardware information...", MessageBoxType.Error); + Eto.Forms.MessageBox.Show("Resume file does not contain dump hardware information...", + MessageBoxType.Error); sr.Close(); } catch { - MessageBox.Show("Incorrect resume file...", MessageBoxType.Error); + Eto.Forms.MessageBox.Show("Incorrect resume file...", MessageBoxType.Error); } } diff --git a/Aaru.Gui/Forms/frmMain.xeto.cs b/Aaru.Gui/Forms/frmMain.xeto.cs index cc2cf28fd..eeb1c535d 100644 --- a/Aaru.Gui/Forms/frmMain.xeto.cs +++ b/Aaru.Gui/Forms/frmMain.xeto.cs @@ -43,7 +43,6 @@ using Aaru.CommonTypes.Structs.Devices.SCSI; using Aaru.Console; using Aaru.Core; using Aaru.Core.Media.Info; -using Aaru.Database; using Aaru.Devices; using Aaru.Gui.Dialogs; using Aaru.Gui.Panels; @@ -293,7 +292,7 @@ namespace Aaru.Gui.Forms } // TODO - void CloseAllImages(object sender, EventArgs eventArgs) => MessageBox.Show("Not yet implemented"); + void CloseAllImages(object sender, EventArgs eventArgs) => Eto.Forms.MessageBox.Show("Not yet implemented"); protected override void OnLoad(EventArgs e) { @@ -331,7 +330,7 @@ namespace Aaru.Gui.Forms if(inputFilter == null) { - MessageBox.Show("Cannot open specified file.", MessageBoxType.Error); + Eto.Forms.MessageBox.Show("Cannot open specified file.", MessageBoxType.Error); return; } @@ -342,7 +341,7 @@ namespace Aaru.Gui.Forms if(imageFormat == null) { - MessageBox.Show("Image format not identified.", MessageBoxType.Error); + Eto.Forms.MessageBox.Show("Image format not identified.", MessageBoxType.Error); return; } @@ -353,7 +352,7 @@ namespace Aaru.Gui.Forms { if(!imageFormat.Open(inputFilter)) { - MessageBox.Show("Unable to open image format", MessageBoxType.Error); + Eto.Forms.MessageBox.Show("Unable to open image format", MessageBoxType.Error); AaruConsole.ErrorWriteLine("Unable to open image format"); AaruConsole.ErrorWriteLine("No error given"); @@ -537,7 +536,7 @@ namespace Aaru.Gui.Forms } catch(Exception ex) { - MessageBox.Show("Unable to open image format", MessageBoxType.Error); + Eto.Forms.MessageBox.Show("Unable to open image format", MessageBoxType.Error); AaruConsole.ErrorWriteLine("Unable to open image format"); AaruConsole.ErrorWriteLine("Error: {0}", ex.Message); AaruConsole.DebugWriteLine("Image-info command", "Stack trace: {0}", ex.StackTrace); @@ -545,7 +544,7 @@ namespace Aaru.Gui.Forms } catch(Exception ex) { - MessageBox.Show("Exception reading file", MessageBoxType.Error); + Eto.Forms.MessageBox.Show("Exception reading file", MessageBoxType.Error); AaruConsole.ErrorWriteLine($"Error reading file: {ex.Message}"); AaruConsole.DebugWriteLine("Image-info command", ex.StackTrace); } @@ -684,26 +683,6 @@ namespace Aaru.Gui.Forms protected void OnMenuConsole(object sender, EventArgs e) => new frmConsole().Show(); - protected void OnMenuStatistics(object sender, EventArgs e) - { - var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); - - if(!ctx.Commands.Any() && - !ctx.Filesystems.Any() && - !ctx.Filters.Any() && - !ctx.MediaFormats.Any() && - !ctx.Medias.Any() && - !ctx.Partitions.Any() && - !ctx.SeenDevices.Any()) - { - MessageBox.Show("There are no statistics."); - - return; - } - - new dlgStatistics().ShowModal(this); - } - protected void OnTreeImagesSelectedItemChanged(object sender, EventArgs e) { if(!(sender is TreeGridView tree)) @@ -776,8 +755,8 @@ namespace Aaru.Gui.Forms if(errno != Errno.NoError) { - MessageBox.Show($"Error {errno} trying to read \"{dirPath}\" of chosen filesystem", - MessageBoxType.Error); + Eto.Forms.MessageBox.Show($"Error {errno} trying to read \"{dirPath}\" of chosen filesystem", + MessageBoxType.Error); break; } @@ -903,8 +882,8 @@ namespace Aaru.Gui.Forms if(errno != Errno.NoError) { - MessageBox.Show($"Error {errno} trying to read \"{dirPath}\" of chosen filesystem", - MessageBoxType.Error); + Eto.Forms.MessageBox.Show($"Error {errno} trying to read \"{dirPath}\" of chosen filesystem", + MessageBoxType.Error); return; } @@ -947,8 +926,8 @@ namespace Aaru.Gui.Forms if(errno != Errno.NoError) { - MessageBox.Show($"Error {errno} trying to read root directory of chosen filesystem", - MessageBoxType.Error); + Eto.Forms.MessageBox.Show($"Error {errno} trying to read root directory of chosen filesystem", + MessageBoxType.Error); return; } diff --git a/Aaru.Gui/Forms/frmMediaScan.xeto.cs b/Aaru.Gui/Forms/frmMediaScan.xeto.cs index df2efa66f..ddeca9c99 100644 --- a/Aaru.Gui/Forms/frmMediaScan.xeto.cs +++ b/Aaru.Gui/Forms/frmMediaScan.xeto.cs @@ -107,7 +107,7 @@ namespace Aaru.Gui.Forms if(dev.Error) { - MessageBox.Show($"Error {dev.LastError} opening device.", MessageBoxType.Error); + Eto.Forms.MessageBox.Show($"Error {dev.LastError} opening device.", MessageBoxType.Error); btnStop.Visible = false; btnScan.Visible = true; btnCancel.Visible = true; @@ -334,7 +334,7 @@ namespace Aaru.Gui.Forms void StoppingErrorMessage(string text) => Application.Instance.Invoke(() => { lblProgress.Text = text; - MessageBox.Show(text, MessageBoxType.Error); + Eto.Forms.MessageBox.Show(text, MessageBoxType.Error); WorkFinished(); }); diff --git a/Aaru.Gui/Models/DeviceStatsModel.cs b/Aaru.Gui/Models/DeviceStatsModel.cs new file mode 100644 index 000000000..6d3ab40b4 --- /dev/null +++ b/Aaru.Gui/Models/DeviceStatsModel.cs @@ -0,0 +1,10 @@ +namespace Aaru.Gui.Models +{ + public class DeviceStatsModel + { + public string Model { get; set; } + public string Manufacturer { get; set; } + public string Revision { get; set; } + public string Bus { get; set; } + } +} \ No newline at end of file diff --git a/Aaru.Gui/Models/MediaStatsModel.cs b/Aaru.Gui/Models/MediaStatsModel.cs new file mode 100644 index 000000000..16261255a --- /dev/null +++ b/Aaru.Gui/Models/MediaStatsModel.cs @@ -0,0 +1,9 @@ +namespace Aaru.Gui.Models +{ + public class MediaStatsModel + { + public string Name { get; set; } + public ulong Count { get; set; } + public string Type { get; set; } + } +} \ No newline at end of file diff --git a/Aaru.Gui/Models/NameCountModel.cs b/Aaru.Gui/Models/NameCountModel.cs new file mode 100644 index 000000000..4be2ebd00 --- /dev/null +++ b/Aaru.Gui/Models/NameCountModel.cs @@ -0,0 +1,8 @@ +namespace Aaru.Gui.Models +{ + public class NameCountModel + { + public string Name { get; set; } + public ulong Count { get; set; } + } +} \ No newline at end of file diff --git a/Aaru.Gui/Panels/pnlListFiles.xeto.cs b/Aaru.Gui/Panels/pnlListFiles.xeto.cs index c7c760289..3eeaa0d44 100644 --- a/Aaru.Gui/Panels/pnlListFiles.xeto.cs +++ b/Aaru.Gui/Panels/pnlListFiles.xeto.cs @@ -383,9 +383,9 @@ namespace Aaru.Gui.Panels string corrected = new string(chars); - result = MessageBox.Show(this, "Unsupported filename", - $"The file name {filename} is not supported on this platform.\nDo you want to rename it to {corrected}?", - MessageBoxButtons.YesNoCancel, MessageBoxType.Warning); + result = Eto.Forms.MessageBox.Show(this, "Unsupported filename", + $"The file name {filename} is not supported on this platform.\nDo you want to rename it to {corrected}?", + MessageBoxButtons.YesNoCancel, MessageBoxType.Warning); if(result == DialogResult.Cancel) return; @@ -400,9 +400,9 @@ namespace Aaru.Gui.Panels if(File.Exists(outputPath)) { - result = MessageBox.Show(this, "Existing file", - $"A file named {filename} already exists on the destination folder.\nDo you want to overwrite it?", - MessageBoxButtons.YesNoCancel, MessageBoxType.Question); + result = Eto.Forms.MessageBox.Show(this, "Existing file", + $"A file named {filename} already exists on the destination folder.\nDo you want to overwrite it?", + MessageBoxButtons.YesNoCancel, MessageBoxType.Question); if(result == DialogResult.Cancel) return; @@ -416,9 +416,9 @@ namespace Aaru.Gui.Panels } catch(IOException) { - result = MessageBox.Show(this, "Cannot delete", - "Could not delete existing file.\nDo you want to continue?", - MessageBoxButtons.YesNo, MessageBoxType.Warning); + result = Eto.Forms.MessageBox.Show(this, "Cannot delete", + "Could not delete existing file.\nDo you want to continue?", + MessageBoxButtons.YesNo, MessageBoxType.Warning); if(result == DialogResult.No) return; @@ -433,9 +433,9 @@ namespace Aaru.Gui.Panels if(error != Errno.NoError) { - result = MessageBox.Show(this, "Error reading file", - $"Error {error} reading file.\nDo you want to continue?", - MessageBoxButtons.YesNo, MessageBoxType.Warning); + result = Eto.Forms.MessageBox.Show(this, "Error reading file", + $"Error {error} reading file.\nDo you want to continue?", + MessageBoxButtons.YesNo, MessageBoxType.Warning); if(result == DialogResult.No) return; @@ -482,9 +482,9 @@ namespace Aaru.Gui.Panels } catch(IOException) { - result = MessageBox.Show(this, "Cannot create file", - "Could not create destination file.\nDo you want to continue?", - MessageBoxButtons.YesNo, MessageBoxType.Warning); + result = Eto.Forms.MessageBox.Show(this, "Cannot create file", + "Could not create destination file.\nDo you want to continue?", + MessageBoxButtons.YesNo, MessageBoxType.Warning); if(result == DialogResult.No) return; diff --git a/Aaru.Gui/Panels/pnlScsiInfo.xeto.cs b/Aaru.Gui/Panels/pnlScsiInfo.xeto.cs index cf284caeb..889f3249c 100644 --- a/Aaru.Gui/Panels/pnlScsiInfo.xeto.cs +++ b/Aaru.Gui/Panels/pnlScsiInfo.xeto.cs @@ -224,7 +224,7 @@ namespace Aaru.Gui.Panels if(scsiInfo.MediaType == MediaType.GDR || scsiInfo.MediaType == MediaType.GDROM) { - MessageBox.Show("GD-ROM dump support is not yet implemented.", MessageBoxType.Error); + Eto.Forms.MessageBox.Show("GD-ROM dump support is not yet implemented.", MessageBoxType.Error); return; } @@ -232,7 +232,7 @@ namespace Aaru.Gui.Panels if((scsiInfo.MediaType == MediaType.XGD || scsiInfo.MediaType == MediaType.XGD2 || scsiInfo.MediaType == MediaType.XGD3) && scsiInfo.DeviceInfo.ScsiInquiry?.KreonPresent != true) - MessageBox.Show("Dumping Xbox discs require a Kreon drive.", MessageBoxType.Error); + Eto.Forms.MessageBox.Show("Dumping Xbox discs require a Kreon drive.", MessageBoxType.Error); var dumpForm = new frmDump(devicePath, scsiInfo.DeviceInfo, scsiInfo); dumpForm.Show(); @@ -243,7 +243,7 @@ namespace Aaru.Gui.Panels if(scsiInfo.MediaType == MediaType.GDR || scsiInfo.MediaType == MediaType.GDROM) { - MessageBox.Show("GD-ROM scan support is not yet implemented.", MessageBoxType.Error); + Eto.Forms.MessageBox.Show("GD-ROM scan support is not yet implemented.", MessageBoxType.Error); return; } @@ -251,7 +251,7 @@ namespace Aaru.Gui.Panels if(scsiInfo.MediaType == MediaType.XGD || scsiInfo.MediaType == MediaType.XGD2 || scsiInfo.MediaType == MediaType.XGD3) - MessageBox.Show("Scanning Xbox discs is not yet supported.", MessageBoxType.Error); + Eto.Forms.MessageBox.Show("Scanning Xbox discs is not yet supported.", MessageBoxType.Error); var scanForm = new frmMediaScan(devicePath, scsiInfo.DeviceInfo, scsiInfo); scanForm.Show(); diff --git a/Aaru.Gui/ViewModels/MainWindowViewModel.cs b/Aaru.Gui/ViewModels/MainWindowViewModel.cs index ef7b667c9..8f0b7c29a 100644 --- a/Aaru.Gui/ViewModels/MainWindowViewModel.cs +++ b/Aaru.Gui/ViewModels/MainWindowViewModel.cs @@ -1,8 +1,11 @@ -using System.Reactive; +using System.Linq; +using System.Reactive; +using Aaru.Database; using Aaru.Gui.Views; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; +using MessageBox.Avalonia; using ReactiveUI; namespace Aaru.Gui.ViewModels @@ -13,10 +16,11 @@ namespace Aaru.Gui.ViewModels public MainWindowViewModel(MainWindow view) { - AboutCommand = ReactiveCommand.Create(ExecuteAboutCommand); - EncodingsCommand = ReactiveCommand.Create(ExecuteEncodingsCommand); - PluginsCommand = ReactiveCommand.Create(ExecutePluginsCommand); - _view = view; + AboutCommand = ReactiveCommand.Create(ExecuteAboutCommand); + EncodingsCommand = ReactiveCommand.Create(ExecuteEncodingsCommand); + PluginsCommand = ReactiveCommand.Create(ExecutePluginsCommand); + StatisticsCommand = ReactiveCommand.Create(ExecuteStatisticsCommand); + _view = view; } public string Greeting => "Welcome to Aaru!"; @@ -25,9 +29,10 @@ namespace Aaru.Gui.ViewModels !NativeMenu.GetIsNativeMenuExported((Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow); - public ReactiveCommand AboutCommand { get; } - public ReactiveCommand EncodingsCommand { get; } - public ReactiveCommand PluginsCommand { get; } + public ReactiveCommand AboutCommand { get; } + public ReactiveCommand EncodingsCommand { get; } + public ReactiveCommand PluginsCommand { get; } + public ReactiveCommand StatisticsCommand { get; } internal void ExecuteAboutCommand() { @@ -49,5 +54,27 @@ namespace Aaru.Gui.ViewModels dialog.DataContext = new PluginsDialogViewModel(dialog); dialog.ShowDialog(_view); } + + internal void ExecuteStatisticsCommand() + { + using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); + + if(!ctx.Commands.Any() && + !ctx.Filesystems.Any() && + !ctx.Filters.Any() && + !ctx.MediaFormats.Any() && + !ctx.Medias.Any() && + !ctx.Partitions.Any() && + !ctx.SeenDevices.Any()) + { + MessageBoxManager.GetMessageBoxStandardWindow("Warning", "There are no statistics.").ShowDialog(_view); + + return; + } + + var dialog = new StatisticsDialog(); + dialog.DataContext = new StatisticsDialogViewModel(dialog); + dialog.ShowDialog(_view); + } } } \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/StatisticsDialogViewModel.cs b/Aaru.Gui/ViewModels/StatisticsDialogViewModel.cs new file mode 100644 index 000000000..245334311 --- /dev/null +++ b/Aaru.Gui/ViewModels/StatisticsDialogViewModel.cs @@ -0,0 +1,636 @@ +using System.Collections.ObjectModel; +using System.Linq; +using System.Reactive; +using Aaru.Database; +using Aaru.Database.Models; +using Aaru.Gui.Models; +using Aaru.Gui.Views; +using ReactiveUI; + +namespace Aaru.Gui.ViewModels +{ + public class StatisticsDialogViewModel : ViewModelBase + { + readonly StatisticsDialog _view; + + string _analyzeText; + bool _analyzeVisible; + string _checksumText; + bool _checksumVisible; + bool _commandsVisible; + string _compareText; + bool _compareVisible; + string _convertImageText; + bool _convertImageVisible; + string _createSidecarText; + bool _createSidecarVisible; + string _decodeText; + bool _decodeVisible; + string _deviceInfoText; + bool _deviceInfoVisible; + string _deviceReportText; + bool _deviceReportVisible; + bool _devicesVisible; + string _dumpMediaText; + bool _dumpMediaVisible; + string _entropyText; + bool _entropyVisible; + bool _filesystemsVisible; + bool _filtersVisible; + bool _formatsCommandVisible; + string _formatsText; + bool _formatsVisible; + string _imageInfoText; + bool _imageInfoVisible; + string _mediaInfoText; + bool _mediaInfoVisible; + string _mediaScanText; + bool _mediaScanVisible; + bool _mediasVisible; + bool _partitionsVisible; + string _printHexText; + bool _printHexVisible; + string _verifyText; + bool _verifyVisible; + + public StatisticsDialogViewModel(StatisticsDialog view) + { + _view = view; + Filters = new ObservableCollection(); + Formats = new ObservableCollection(); + Partitions = new ObservableCollection(); + Filesystems = new ObservableCollection(); + Devices = new ObservableCollection(); + Medias = new ObservableCollection(); + CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand); + using var ctx = AaruContext.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(); + + count += (ulong)ctx.Commands.LongCount(c => c.Name == "analyze" && !c.Synchronized); + + AnalyzeVisible = true; + AnalyzeText = $"You have called the Analyze 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(); + + count += (ulong)ctx.Commands.LongCount(c => c.Name == "checksum" && !c.Synchronized); + + ChecksumVisible = true; + ChecksumText = $"You have called the Checksum command {count} times"; + } + + if(ctx.Commands.Any(c => c.Name == "compare")) + { + 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); + + CompareVisible = true; + CompareText = $"You have called the Compare command {count} times"; + } + + 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(); + + count += (ulong)ctx.Commands.LongCount(c => c.Name == "convert-image" && !c.Synchronized); + + ConvertImageVisible = true; + ConvertImageText = $"You have called the Convert-Image command {count} times"; + } + + 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(); + + count += (ulong)ctx.Commands.LongCount(c => c.Name == "create-sidecar" && !c.Synchronized); + + CreateSidecarVisible = true; + CreateSidecarText = $"You have called the Create-Sidecar command {count} times"; + } + + if(ctx.Commands.Any(c => c.Name == "decode")) + { + 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); + + DecodeVisible = true; + DecodeText = $"You have called the Decode command {count} times"; + } + + 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(); + + count += (ulong)ctx.Commands.LongCount(c => c.Name == "device-info" && !c.Synchronized); + + DeviceInfoVisible = true; + DeviceInfoText = $"You have called the Device-Info command {count} times"; + } + + 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(); + + count += (ulong)ctx.Commands.LongCount(c => c.Name == "device-report" && !c.Synchronized); + + DeviceReportVisible = true; + DeviceReportText = $"You have called the Device-Report command {count} times"; + } + + 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(); + + count += (ulong)ctx.Commands.LongCount(c => c.Name == "dump-media" && !c.Synchronized); + + DumpMediaVisible = true; + DumpMediaText = $"You have called the Dump-Media command {count} times"; + } + + if(ctx.Commands.Any(c => c.Name == "entropy")) + { + 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); + + EntropyVisible = true; + EntropyText = $"You have called the Entropy command {count} times"; + } + + if(ctx.Commands.Any(c => c.Name == "formats")) + { + 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); + + FormatsCommandVisible = true; + FormatsCommandText = $"You have called the Formats command {count} times"; + } + + 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(); + + count += (ulong)ctx.Commands.LongCount(c => c.Name == "image-info" && !c.Synchronized); + + ImageInfoVisible = true; + ImageInfoText = $"You have called the Image-Info command {count} times"; + } + + 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(); + + count += (ulong)ctx.Commands.LongCount(c => c.Name == "media-info" && !c.Synchronized); + + MediaInfoVisible = true; + MediaInfoText = $"You have called the Media-Info command {count} times"; + } + + 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(); + + count += (ulong)ctx.Commands.LongCount(c => c.Name == "media-scan" && !c.Synchronized); + + MediaScanVisible = true; + MediaScanText = $"You have called the Media-Scan command {count} times"; + } + + if(ctx.Commands.Any(c => c.Name == "printhex")) + { + 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); + + PrintHexVisible = true; + PrintHexText = $"You have called the Print-Hex command {count} times"; + } + + if(ctx.Commands.Any(c => c.Name == "verify")) + { + 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); + + VerifyVisible = true; + VerifyText = $"You have called the Verify command {count} times"; + } + + CommandsVisible = AnalyzeVisible || ChecksumVisible || CompareVisible || + ConvertImageVisible || + CreateSidecarVisible || DecodeVisible || DeviceInfoVisible || + DeviceReportVisible || + DumpMediaVisible || EntropyVisible || FormatsCommandVisible || + ImageInfoVisible || + MediaInfoVisible || MediaScanVisible || PrintHexVisible || VerifyVisible; + } + + if(ctx.Filters.Any()) + { + FiltersVisible = true; + + 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(); + + count += (ulong)ctx.Filters.LongCount(c => c.Name == nvs && !c.Synchronized); + + Filters.Add(new NameCountModel + { + Name = nvs, Count = count + }); + } + } + + if(ctx.MediaFormats.Any()) + { + FormatsVisible = true; + + 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(); + + count += (ulong)ctx.MediaFormats.LongCount(c => c.Name == nvs && !c.Synchronized); + + Formats.Add(new NameCountModel + { + Name = nvs, Count = count + }); + } + } + + if(ctx.Partitions.Any()) + { + PartitionsVisible = true; + + 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(); + + count += (ulong)ctx.Partitions.LongCount(c => c.Name == nvs && !c.Synchronized); + + Partitions.Add(new NameCountModel + { + Name = nvs, Count = count + }); + } + } + + if(ctx.Filesystems.Any()) + { + FilesystemsVisible = true; + + 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(); + + count += (ulong)ctx.Filesystems.LongCount(c => c.Name == nvs && !c.Synchronized); + + Filesystems.Add(new NameCountModel + { + Name = nvs, Count = count + }); + } + } + + if(ctx.SeenDevices.Any()) + { + DevicesVisible = true; + + foreach(DeviceStat ds in ctx.SeenDevices.OrderBy(n => n.Manufacturer).ThenBy(n => n.Manufacturer). + ThenBy(n => n.Revision).ThenBy(n => n.Bus)) + Devices.Add(new DeviceStatsModel + { + Model = ds.Model, Manufacturer = ds.Manufacturer, Revision = ds.Revision, Bus = ds.Bus + }); + } + + if(!ctx.Medias.Any()) + return; + + MediasVisible = true; + + 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(); + + count += (ulong)ctx.Medias.LongCount(c => c.Type == media && !c.Synchronized && c.Real); + + if(count > 0) + Medias.Add(new MediaStatsModel + { + Name = media, Count = count, Type = "real" + }); + + 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; + + Medias.Add(new MediaStatsModel + { + Name = media, Count = count, Type = "image" + }); + } + } + + public string AnalyzeText + { + get => _analyzeText; + set => this.RaiseAndSetIfChanged(ref _analyzeText, value); + } + + public bool AnalyzeVisible + { + get => _analyzeVisible; + set => this.RaiseAndSetIfChanged(ref _analyzeVisible, value); + } + + public string ChecksumText + { + get => _checksumText; + set => this.RaiseAndSetIfChanged(ref _checksumText, value); + } + + public bool ChecksumVisible + { + get => _checksumVisible; + set => this.RaiseAndSetIfChanged(ref _checksumVisible, value); + } + + public string CompareText + { + get => _compareText; + set => this.RaiseAndSetIfChanged(ref _compareText, value); + } + + public bool CompareVisible + { + get => _compareVisible; + set => this.RaiseAndSetIfChanged(ref _compareVisible, value); + } + + public string ConvertImageText + { + get => _convertImageText; + set => this.RaiseAndSetIfChanged(ref _convertImageText, value); + } + + public bool ConvertImageVisible + { + get => _convertImageVisible; + set => this.RaiseAndSetIfChanged(ref _convertImageVisible, value); + } + + public string CreateSidecarText + { + get => _createSidecarText; + set => this.RaiseAndSetIfChanged(ref _createSidecarText, value); + } + + public bool CreateSidecarVisible + { + get => _createSidecarVisible; + set => this.RaiseAndSetIfChanged(ref _createSidecarVisible, value); + } + + public string DecodeText + { + get => _decodeText; + set => this.RaiseAndSetIfChanged(ref _decodeText, value); + } + + public bool DecodeVisible + { + get => _decodeVisible; + set => this.RaiseAndSetIfChanged(ref _decodeVisible, value); + } + + public string DeviceInfoText + { + get => _deviceInfoText; + set => this.RaiseAndSetIfChanged(ref _deviceInfoText, value); + } + + public bool DeviceInfoVisible + { + get => _deviceInfoVisible; + set => this.RaiseAndSetIfChanged(ref _deviceInfoVisible, value); + } + + public string DeviceReportText + { + get => _deviceReportText; + set => this.RaiseAndSetIfChanged(ref _deviceReportText, value); + } + + public bool DeviceReportVisible + { + get => _deviceReportVisible; + set => this.RaiseAndSetIfChanged(ref _deviceReportVisible, value); + } + + public string DumpMediaText + { + get => _dumpMediaText; + set => this.RaiseAndSetIfChanged(ref _dumpMediaText, value); + } + + public bool DumpMediaVisible + { + get => _dumpMediaVisible; + set => this.RaiseAndSetIfChanged(ref _dumpMediaVisible, value); + } + + public string EntropyText + { + get => _entropyText; + set => this.RaiseAndSetIfChanged(ref _entropyText, value); + } + + public bool EntropyVisible + { + get => _entropyVisible; + set => this.RaiseAndSetIfChanged(ref _entropyVisible, value); + } + + public string FormatsCommandText + { + get => _formatsText; + set => this.RaiseAndSetIfChanged(ref _formatsText, value); + } + + public bool FormatsCommandVisible + { + get => _formatsCommandVisible; + set => this.RaiseAndSetIfChanged(ref _formatsCommandVisible, value); + } + + public string ImageInfoText + { + get => _imageInfoText; + set => this.RaiseAndSetIfChanged(ref _imageInfoText, value); + } + + public bool ImageInfoVisible + { + get => _imageInfoVisible; + set => this.RaiseAndSetIfChanged(ref _imageInfoVisible, value); + } + + public string MediaInfoText + { + get => _mediaInfoText; + set => this.RaiseAndSetIfChanged(ref _mediaInfoText, value); + } + + public bool MediaInfoVisible + { + get => _mediaInfoVisible; + set => this.RaiseAndSetIfChanged(ref _mediaInfoVisible, value); + } + + public string MediaScanText + { + get => _mediaScanText; + set => this.RaiseAndSetIfChanged(ref _mediaScanText, value); + } + + public bool MediaScanVisible + { + get => _mediaScanVisible; + set => this.RaiseAndSetIfChanged(ref _mediaScanVisible, value); + } + + public string PrintHexText + { + get => _printHexText; + set => this.RaiseAndSetIfChanged(ref _printHexText, value); + } + + public bool PrintHexVisible + { + get => _printHexVisible; + set => this.RaiseAndSetIfChanged(ref _printHexVisible, value); + } + + public string VerifyText + { + get => _verifyText; + set => this.RaiseAndSetIfChanged(ref _verifyText, value); + } + + public bool VerifyVisible + { + get => _verifyVisible; + set => this.RaiseAndSetIfChanged(ref _verifyVisible, value); + } + + public bool CommandsVisible + { + get => _commandsVisible; + set => this.RaiseAndSetIfChanged(ref _commandsVisible, value); + } + + public bool FiltersVisible + { + get => _filtersVisible; + set => this.RaiseAndSetIfChanged(ref _filtersVisible, value); + } + + public bool PartitionsVisible + { + get => _partitionsVisible; + set => this.RaiseAndSetIfChanged(ref _partitionsVisible, value); + } + + public bool FormatsVisible + { + get => _formatsVisible; + set => this.RaiseAndSetIfChanged(ref _formatsVisible, value); + } + + public bool FilesystemsVisible + { + get => _filesystemsVisible; + set => this.RaiseAndSetIfChanged(ref _filesystemsVisible, value); + } + + public bool DevicesVisible + { + get => _devicesVisible; + set => this.RaiseAndSetIfChanged(ref _devicesVisible, value); + } + + public bool MediasVisible + { + get => _mediasVisible; + set => this.RaiseAndSetIfChanged(ref _mediasVisible, value); + } + + public string CommandsLabel => "Commands"; + public string FilterLabel => "Filter"; + public string PartitionLabel => "Partition"; + public string PartitionsLabel => "Partitions"; + public string FiltersLabel => "Filters"; + public string FormatsLabel => "Formats"; + public string FormatLabel => "Format"; + public string FilesystemsLabel => "Filesystems"; + public string FilesystemLabel => "Filesystem"; + public string TimesFoundLabel => "Times found"; + public string DevicesLabel => "Devices"; + public string DeviceLabel => "Device"; + public string ManufacturerLabel => "Manufacturer"; + public string RevisionLabel => "Revision"; + public string BusLabel => "Bus"; + public string MediasLabel => "Medias"; + public string MediaLabel => "Media"; + public string TypeLabel => "Type"; + public string Title => "Encodings"; + public string CloseLabel => "Close"; + public ReactiveCommand CloseCommand { get; } + public ObservableCollection Filters { get; } + public ObservableCollection Formats { get; } + public ObservableCollection Partitions { get; } + public ObservableCollection Filesystems { get; } + public ObservableCollection Devices { get; } + public ObservableCollection Medias { get; } + + void ExecuteCloseCommand() => _view.Close(); + } +} \ No newline at end of file diff --git a/Aaru.Gui/Views/MainWindow.xaml b/Aaru.Gui/Views/MainWindow.xaml index e0303e487..54bf060bc 100644 --- a/Aaru.Gui/Views/MainWindow.xaml +++ b/Aaru.Gui/Views/MainWindow.xaml @@ -21,7 +21,8 @@ - + + diff --git a/Aaru.Gui/Views/StatisticsDialog.xaml b/Aaru.Gui/Views/StatisticsDialog.xaml new file mode 100644 index 000000000..012c7e150 --- /dev/null +++ b/Aaru.Gui/Views/StatisticsDialog.xaml @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Aaru.Gui/Views/StatisticsDialog.xaml.cs b/Aaru.Gui/Views/StatisticsDialog.xaml.cs new file mode 100644 index 000000000..d5036eddf --- /dev/null +++ b/Aaru.Gui/Views/StatisticsDialog.xaml.cs @@ -0,0 +1,19 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Aaru.Gui.Views +{ + public class StatisticsDialog : Window + { + public StatisticsDialog() + { + InitializeComponent(); + #if DEBUG + this.AttachDevTools(); + #endif + } + + void InitializeComponent() => AvaloniaXamlLoader.Load(this); + } +} \ No newline at end of file