From 189e889df7b4983fcfd48302f4b09645e2354fb6 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Fri, 23 Feb 2018 02:14:58 +0000 Subject: [PATCH] Rename solution, project, files and namespaces. --- ChangeLog | 145 +++ Properties/AssemblyInfo.cs | 53 + WrappersForEto.cs | 163 +++ apprepodbmgr.Eto.csproj | 95 ++ dlgAdd.xeto | 159 +++ dlgAdd.xeto.cs | 1182 ++++++++++++++++++++++ dlgBlockMedia.xeto | 617 ++++++++++++ dlgBlockMedia.xeto.cs | 1738 ++++++++++++++++++++++++++++++++ dlgFilesystem.xeto | 145 +++ dlgFilesystem.xeto.cs | 245 +++++ dlgHelp.xeto | 11 + dlgHelp.xeto.cs | 168 ++++ dlgMetadata.xeto | 313 ++++++ dlgMetadata.xeto.cs | 1097 ++++++++++++++++++++ dlgOpticalDisc.xeto | 696 +++++++++++++ dlgOpticalDisc.xeto.cs | 1954 ++++++++++++++++++++++++++++++++++++ dlgSettings.xeto | 145 +++ dlgSettings.xeto.cs | 329 ++++++ frmMain.xeto | 86 ++ frmMain.xeto.cs | 1110 ++++++++++++++++++++ packages.config | 7 + 21 files changed, 10458 insertions(+) create mode 100644 ChangeLog create mode 100644 Properties/AssemblyInfo.cs create mode 100644 WrappersForEto.cs create mode 100644 apprepodbmgr.Eto.csproj create mode 100644 dlgAdd.xeto create mode 100644 dlgAdd.xeto.cs create mode 100644 dlgBlockMedia.xeto create mode 100644 dlgBlockMedia.xeto.cs create mode 100644 dlgFilesystem.xeto create mode 100644 dlgFilesystem.xeto.cs create mode 100644 dlgHelp.xeto create mode 100644 dlgHelp.xeto.cs create mode 100644 dlgMetadata.xeto create mode 100644 dlgMetadata.xeto.cs create mode 100644 dlgOpticalDisc.xeto create mode 100644 dlgOpticalDisc.xeto.cs create mode 100644 dlgSettings.xeto create mode 100644 dlgSettings.xeto.cs create mode 100644 frmMain.xeto create mode 100644 frmMain.xeto.cs create mode 100644 packages.config diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..60c0184 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,145 @@ +* packages.config: +* osrepodbmgr.Eto.csproj: + Updated nuget packages. + +* dlgAdd.xeto.cs: +* frmMain.xeto.cs: +* dlgMetadata.xeto.cs: + Corrected progress bars when value is outside of int bounds. + +* dlgMetadata.xeto: +* dlgMetadata.xeto.cs: +* dlgOpticalDisc.xeto: +* dlgBlockMedia.xeto.cs: +* dlgOpticalDisc.xeto.cs: + Updated DIC and Metadata code. + +2017-05-21 Natalia Portillo + + * dlgAdd.xeto.cs: + * dlgOpticalDisc.xeto.cs: + Corrected some NULL exceptions on GUI. + +2017-05-19 Natalia Portillo + + * frmMain.xeto.cs: + Don't readd delegates every time. + +2017-05-19 Natalia Portillo + + * dlgAdd.xeto: + * frmMain.xeto: + * dlgAdd.xeto.cs: + * frmMain.xeto.cs: + * packages.config: + * dlgSettings.xeto.cs: + Refactor: Format document. + +2017-05-19 Natalia Portillo + + * dlgAdd.xeto.cs: + * frmMain.xeto.cs: + Corrected delegate. + +2017-05-19 Natalia Portillo + + * dlgAdd.xeto: + * frmMain.xeto: + * dlgAdd.xeto.cs: + * frmMain.xeto.cs: + Added status fields. + +2017-05-19 Natalia Portillo + + * dlgAdd.xeto.cs: + * dlgBlockMedia.xeto: + * dlgBlockMedia.xeto.cs: + * dlgOpticalDisc.xeto.cs: + Corrected GUI behaviour. + +2017-05-19 Natalia Portillo + + * dlgAdd.xeto: + * dlgHelp.xeto: + * frmMain.xeto: + * dlgMetadata.xeto: + * dlgSettings.xeto: + * dlgFilesystem.xeto: + Added window titles. + +2017-05-19 Natalia Portillo + + * dlgAdd.xeto.cs: + * frmMain.xeto.cs: + Do not color OS tables. Has no sense to be on the opaque + repo. + +2017-05-19 Natalia Portillo + + * frmMain.xeto: + * frmMain.xeto.cs: + Added code to clean database and repository. + +2017-05-19 Natalia Portillo + + * frmMain.xeto.cs: + Make sure the OnBtnPopulateFilesClicked() is called. + +2017-05-19 Natalia Portillo + + * frmMain.xeto: + * frmMain.xeto.cs: + Added an option to scan all pending files with clamd. + +2017-05-19 Natalia Portillo + + * dlgAdd.xeto.cs: + * frmMain.xeto.cs: + Corrected GUI behaviour. + +2017-05-19 Natalia Portillo + + * frmMain.xeto.cs: + + +2017-05-19 Natalia Portillo + + * frmMain.xeto.cs: + Added progress messages to clamd core. + +2017-05-19 Natalia Portillo + + * frmMain.xeto.cs: + * dlgSettings.xeto: + * dlgSettings.xeto.cs: + Added support for VirusTotal. + +2017-05-18 Natalia Portillo + + * frmMain.xeto: + * frmMain.xeto.cs: + * dlgSettings.xeto: + * dlgSettings.xeto.cs: + Added support for clamd scanning. + +2017-05-18 Natalia Portillo + + * dlgAdd.xeto: + * frmMain.xeto: + * dlgAdd.xeto.cs: + * frmMain.xeto.cs: + Added support for marking/unmarking/detecting cracks. + +2017-05-18 Natalia Portillo + + * frmMain.xeto: + * dlgAdd.xeto.cs: + * frmMain.xeto.cs: + + +2017-05-18 Natalia Portillo + + * dlgSettings.xeto.cs: + If program files folder does not exist do not try to create + an Uri from null. + diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..587a685 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,53 @@ +// +// Author: +// Natalia Portillo claunia@claunia.com +// +// Copyright (c) 2017, © Claunia.com +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in +// the documentation and/or other materials provided with the distribution. +// * Neither the name of the [ORGANIZATION] nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("apprepodbmgr.Eto")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Claunia.com")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("© Claunia.com")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] diff --git a/WrappersForEto.cs b/WrappersForEto.cs new file mode 100644 index 0000000..d5cf9d0 --- /dev/null +++ b/WrappersForEto.cs @@ -0,0 +1,163 @@ +// +// Author: +// Natalia Portillo claunia@claunia.com +// +// Copyright (c) 2017, © Claunia.com +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in +// the documentation and/or other materials provided with the distribution. +// * Neither the name of the [ORGANIZATION] nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// + +using apprepodbmgr.Core; +using Schemas; + +namespace apprepodbmgr.Eto +{ + class DBEntryForEto + { + DbEntry _item; + + public DBEntryForEto(DbEntry item) + { + _item = item; + } + + public long id + { + get { return _item.Id; } + set { } + } + public string developer + { + get { return _item.Developer; } + set { } + } + public string product + { + get { return _item.Product; } + set { } + } + public string version + { + get { return _item.Version; } + set { } + } + public string languages + { + get { return _item.Languages; } + set { } + } + public string architecture + { + get { return _item.Architecture; } + set { } + } + public string machine + { + get { return _item.Machine; } + set { } + } + public string format + { + get { return _item.Format; } + set { } + } + public string description + { + get { return _item.Description; } + set { } + } + public bool oem + { + get { return _item.Oem; } + set { } + } + public bool upgrade + { + get { return _item.Upgrade; } + set { } + } + public bool update + { + get { return _item.Update; } + set { } + } + public bool source + { + get { return _item.Source; } + set { } + } + public bool files + { + get { return _item.Files; } + set { } + } + public bool netinstall + { + get { return _item.Netinstall; } + set { } + } + public byte[] xml + { + get { return _item.Xml; } + set { } + } + public byte[] json + { + get { return _item.Json; } + set { } + } + public string mdid + { + get { return _item.Mdid; } + set { } + } + + public DbEntry original + { + get { return _item; } + set { } + } + } + + class StringEntry + { + public string str { get; set; } + } + + class BarcodeEntry + { + public string code { get; set; } + public BarcodeTypeType type { get; set; } + } + + class DiscEntry + { + public string path { get; set; } + public OpticalDiscType disc { get; set; } + } + + class DiskEntry + { + public string path { get; set; } + public BlockMediaType disk { get; set; } + } +} \ No newline at end of file diff --git a/apprepodbmgr.Eto.csproj b/apprepodbmgr.Eto.csproj new file mode 100644 index 0000000..4448922 --- /dev/null +++ b/apprepodbmgr.Eto.csproj @@ -0,0 +1,95 @@ + + + + Debug + AnyCPU + {E805559F-89AE-47B4-926D-5B63A4F3A123} + Library + apprepodbmgr.Eto + apprepodbmgr.Eto + v4.5 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + + + true + bin\Release + prompt + 4 + + + + + frmMain.xeto + + + dlgHelp.xeto + + + dlgSettings.xeto + + + dlgAdd.xeto + + + dlgMetadata.xeto + + + dlgFilesystem.xeto + + + dlgBlockMedia.xeto + + + dlgOpticalDisc.xeto + + + + + + ..\packages\Eto.Forms.2.3.0\lib\net45\Eto.dll + + + ..\packages\Eto.Serialization.Xaml.2.3.0\lib\net45\Eto.Serialization.Xaml.dll + + + ..\packages\Portable.Xaml.0.17.0\lib\portable-net45+win8+wpa81+wp8\Portable.Xaml.dll + + + + + ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + {076D5C4D-9601-4164-B979-0DABACB56BB8} + apprepodbmgr.Core + + + {9F213318-5CB8-4066-A757-074489C9F818} + DiscImageChef.Metadata + + + + \ No newline at end of file diff --git a/dlgAdd.xeto b/dlgAdd.xeto new file mode 100644 index 0000000..570796c --- /dev/null +++ b/dlgAdd.xeto @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + oem + + + update + + + + + + + upgrade + + + files + + + + + + + source + + + netinstall + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dlgAdd.xeto.cs b/dlgAdd.xeto.cs new file mode 100644 index 0000000..19970ac --- /dev/null +++ b/dlgAdd.xeto.cs @@ -0,0 +1,1182 @@ +// +// Author: +// Natalia Portillo claunia@claunia.com +// +// Copyright (c) 2017, © Claunia.com +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in +// the documentation and/or other materials provided with the distribution. +// * Neither the name of the [ORGANIZATION] nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.IO; +using System.Threading; +using System.Xml.Serialization; +using apprepodbmgr.Core; +using Eto.Drawing; +using Eto.Forms; +using Eto.Serialization.Xaml; +using Newtonsoft.Json; +using Schemas; + +namespace apprepodbmgr.Eto +{ + public class dlgAdd : Dialog + { + public delegate void OnAddedOSDelegate(DbEntry os); + + ObservableCollection fileView; + int knownFiles; + ObservableCollection osView; + bool stopped; + Thread thdAddFiles; + Thread thdCheckFiles; + Thread thdExtractArchive; + Thread thdFindFiles; + Thread thdHashFiles; + Thread thdOpenArchive; + Thread thdPackFiles; + Thread thdRemoveTemp; + + public dlgAdd() + { + XamlReader.Load(this); + + Context.UnarChangeStatus += UnarChangeStatus; + Context.CheckUnar(); + + fileView = new ObservableCollection(); + + treeFiles.DataStore = fileView; + + treeFiles.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Path)}, + HeaderText = "Path" + }); + treeFiles.Columns.Add(new GridColumn + { + DataCell = new CheckBoxCell {Binding = Binding.Property(r => r.IsCrack)}, + HeaderText = "Crack?" + }); + treeFiles.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Hash)}, + HeaderText = "SHA256" + }); + treeFiles.Columns.Add(new GridColumn + { + DataCell = new CheckBoxCell {Binding = Binding.Property(r => r.Known)}, + HeaderText = "Known?" + }); + + treeFiles.AllowMultipleSelection = false; + + treeFiles.CellFormatting += (sender, e) => + { + e.BackgroundColor = ((FileEntry)e.Item).Known ? Colors.Green : Colors.Red; + }; + + osView = new ObservableCollection(); + + treeOSes.DataStore = osView; + + treeOSes.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.developer)}, + HeaderText = "Developer" + }); + treeOSes.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.product)}, + HeaderText = "Product" + }); + treeOSes.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.version)}, + HeaderText = "Version" + }); + treeOSes.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.languages)}, + HeaderText = "Languages" + }); + treeOSes.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.architecture)}, + HeaderText = "Architecture" + }); + treeOSes.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.machine)}, + HeaderText = "Machine" + }); + treeOSes.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.format)}, + HeaderText = "Format" + }); + treeOSes.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.description)}, + HeaderText = "Description" + }); + treeOSes.Columns.Add(new GridColumn + { + DataCell = new CheckBoxCell {Binding = Binding.Property(r => r.oem)}, + HeaderText = "OEM?" + }); + treeOSes.Columns.Add(new GridColumn + { + DataCell = new CheckBoxCell {Binding = Binding.Property(r => r.upgrade)}, + HeaderText = "Upgrade?" + }); + treeOSes.Columns.Add(new GridColumn + { + DataCell = new CheckBoxCell {Binding = Binding.Property(r => r.update)}, + HeaderText = "Update?" + }); + treeOSes.Columns.Add(new GridColumn + { + DataCell = new CheckBoxCell {Binding = Binding.Property(r => r.source)}, + HeaderText = "Source?" + }); + treeOSes.Columns.Add(new GridColumn + { + DataCell = new CheckBoxCell {Binding = Binding.Property(r => r.files)}, + HeaderText = "Files?" + }); + treeOSes.Columns.Add(new GridColumn + { + DataCell = new CheckBoxCell {Binding = Binding.Property(r => r.netinstall)}, + HeaderText = "NetInstall?" + }); + + treeOSes.AllowMultipleSelection = false; + } + + public event OnAddedOSDelegate OnAddedOS; + + void UnarChangeStatus() + { + Application.Instance.Invoke(delegate { btnArchive.Enabled = Context.UnarUsable; }); + } + + protected void OnDeleteEvent(object sender, CancelEventArgs e) + { + if(btnStop.Visible) btnStop.PerformClick(); + if(btnClose.Enabled) btnClose.PerformClick(); + } + + protected void OnBtnFolderClicked(object sender, EventArgs e) + { + SelectFolderDialog dlgFolder = new SelectFolderDialog {Title = "Open folder"}; + + if(dlgFolder.ShowDialog(this) != DialogResult.Ok) return; + + knownFiles = 0; + stopped = false; + lblProgress.Text = "Finding files"; + lblProgress.Visible = true; + prgProgress.Visible = true; + btnExit.Enabled = false; + btnFolder.Visible = false; + btnArchive.Visible = false; + thdFindFiles = new Thread(Workers.FindFiles); + Context.Path = dlgFolder.Directory; + Workers.Failed += FindFilesFailed; + Workers.Finished += FindFilesFinished; + btnStop.Visible = true; + thdFindFiles.Start(); + } + + void FindFilesFailed(string text) + { + Application.Instance.Invoke(delegate + { + if(!stopped) MessageBox.Show(text, MessageBoxType.Error); + lblProgress.Visible = false; + prgProgress.Visible = false; + btnExit.Enabled = true; + btnFolder.Visible = true; + btnArchive.Visible = true; + btnStop.Visible = false; + Workers.Failed -= FindFilesFailed; + Workers.Finished -= FindFilesFinished; + thdFindFiles = null; + }); + } + + void FindFilesFinished() + { + Application.Instance.Invoke(delegate + { + Workers.Failed -= FindFilesFailed; + Workers.Finished -= FindFilesFinished; + + lblProgress.Visible = true; + prgProgress.Visible = true; + lblProgress2.Visible = true; + prgProgress2.Visible = true; + + thdFindFiles = null; + thdHashFiles = new Thread(Workers.HashFiles); + Workers.Failed += HashFilesFailed; + Workers.Finished += HashFilesFinished; + Workers.UpdateProgress += UpdateProgress; + Workers.UpdateProgress2 += UpdateProgress2; + thdHashFiles.Start(); + }); + } + + void HashFilesFailed(string text) + { + Application.Instance.Invoke(delegate + { + if(!stopped) MessageBox.Show(text, MessageBoxType.Error); + lblProgress.Visible = false; + prgProgress.Visible = false; + lblProgress2.Visible = false; + prgProgress2.Visible = false; + Workers.Failed -= HashFilesFailed; + Workers.Finished -= HashFilesFinished; + Workers.UpdateProgress -= UpdateProgress; + Workers.UpdateProgress2 -= UpdateProgress2; + btnExit.Enabled = true; + btnFolder.Visible = true; + btnArchive.Visible = true; + btnStop.Visible = false; + thdHashFiles = null; + }); + } + + void HashFilesFinished() + { + Application.Instance.Invoke(delegate + { + lblProgress.Visible = false; + prgProgress.Visible = false; + lblProgress2.Visible = false; + prgProgress2.Visible = false; + Workers.Failed -= HashFilesFailed; + Workers.Finished -= HashFilesFinished; + Workers.UpdateProgress -= UpdateProgress; + Workers.UpdateProgress2 -= UpdateProgress2; + thdHashFiles = null; + + lblProgress.Visible = true; + prgProgress.Visible = true; + + thdCheckFiles = new Thread(Workers.CheckDbForFiles); + Workers.Failed += ChkFilesFailed; + Workers.Finished += ChkFilesFinished; + Workers.UpdateProgress += UpdateProgress; + Workers.UpdateProgress2 += UpdateProgress2; + Workers.AddFileForOS += AddFile; + Workers.AddOS += AddOs; + thdCheckFiles.Start(); + }); + } + + void ChkFilesFailed(string text) + { + Application.Instance.Invoke(delegate + { + if(!stopped) MessageBox.Show(text, MessageBoxType.Error); + prgProgress.Visible = false; + btnStop.Visible = false; + btnClose.Visible = false; + btnExit.Enabled = true; + Workers.Failed -= ChkFilesFailed; + Workers.Finished -= ChkFilesFinished; + Workers.UpdateProgress -= UpdateProgress; + Workers.UpdateProgress2 -= UpdateProgress2; + Workers.AddFileForOS -= AddFile; + Workers.AddOS -= AddOs; + thdCheckFiles?.Abort(); + thdHashFiles = null; + fileView?.Clear(); + if(osView == null) return; + + tabOSes.Visible = false; + osView.Clear(); + }); + } + + void ChkFilesFinished() + { + Application.Instance.Invoke(delegate + { + Workers.Failed -= ChkFilesFailed; + Workers.Finished -= ChkFilesFinished; + Workers.UpdateProgress -= UpdateProgress; + Workers.UpdateProgress2 -= UpdateProgress2; + Workers.AddFileForOS -= AddFile; + Workers.AddOS -= AddOs; + + thdCheckFiles?.Abort(); + + thdHashFiles = null; + lblProgress.Visible = false; + prgProgress.Visible = false; + btnStop.Visible = false; + btnClose.Visible = true; + btnExit.Enabled = true; + btnPack.Visible = true; + btnPack.Enabled = true; + btnRemoveFile.Visible = true; + btnToggleCrack.Visible = true; + btnRemoveFile.Enabled = true; + btnToggleCrack.Enabled = true; + + txtFormat.ReadOnly = false; + txtMachine.ReadOnly = false; + txtProduct.ReadOnly = false; + txtVersion.ReadOnly = false; + txtLanguages.ReadOnly = false; + txtDeveloper.ReadOnly = false; + txtDescription.ReadOnly = false; + txtArchitecture.ReadOnly = false; + chkOem.Enabled = true; + chkFiles.Enabled = true; + chkUpdate.Enabled = true; + chkUpgrade.Enabled = true; + chkNetinstall.Enabled = true; + chkSource.Enabled = true; + + btnMetadata.Visible = true; + if(Context.Metadata != null) + { + if(Context.Metadata.Developer != null) + foreach(string developer in Context.Metadata.Developer) + { + if(!string.IsNullOrWhiteSpace(txtDeveloper.Text)) txtDeveloper.Text += ","; + txtDeveloper.Text += developer; + } + + if(!string.IsNullOrWhiteSpace(Context.Metadata.Name)) txtProduct.Text = Context.Metadata.Name; + if(!string.IsNullOrWhiteSpace(Context.Metadata.Version)) txtVersion.Text = Context.Metadata.Version; + + if(Context.Metadata.Languages != null) + foreach(LanguagesTypeLanguage language in Context.Metadata.Languages) + { + if(!string.IsNullOrWhiteSpace(txtLanguages.Text)) txtLanguages.Text += ","; + txtLanguages.Text += language; + } + + if(Context.Metadata.Architectures != null) + foreach(ArchitecturesTypeArchitecture architecture in Context.Metadata.Architectures) + { + if(!string.IsNullOrWhiteSpace(txtArchitecture.Text)) txtArchitecture.Text += ","; + txtArchitecture.Text += architecture; + } + + if(Context.Metadata.Systems != null) + foreach(string machine in Context.Metadata.Systems) + { + if(!string.IsNullOrWhiteSpace(txtMachine.Text)) txtMachine.Text += ","; + txtMachine.Text += machine; + } + + btnMetadata.BackgroundColor = Colors.Green; + } + else btnMetadata.BackgroundColor = Colors.Red; + + lblStatus.Visible = true; + lblStatus.Text = $"{fileView.Count} files ({knownFiles} already known)"; + }); + } + + void AddFile(string filename, string hash, bool known, bool isCrack) + { + Application.Instance.Invoke(delegate + { + fileView.Add(new FileEntry {Path = filename, Hash = hash, Known = known, IsCrack = isCrack}); + btnPack.Enabled |= !known; + if(known) knownFiles++; + }); + } + + void AddOs(DbEntry os) + { + Application.Instance.Invoke(delegate + { + tabOSes.Visible = true; + osView.Add(new DBEntryForEto(os)); + }); + } + + protected void OnBtnExitClicked(object sender, EventArgs e) + { + if(btnClose.Enabled) OnBtnCloseClicked(sender, e); + + Close(); + } + + protected void OnBtnCloseClicked(object sender, EventArgs e) + { + btnFolder.Visible = true; + btnArchive.Visible = true; + Context.Path = ""; + Context.Files = null; + Context.Hashes = null; + btnStop.Visible = false; + btnPack.Visible = false; + btnClose.Visible = false; + btnRemoveFile.Visible = false; + btnToggleCrack.Visible = false; + fileView?.Clear(); + if(osView != null) + { + tabOSes.Visible = false; + osView.Clear(); + } + + txtFormat.ReadOnly = true; + txtMachine.ReadOnly = true; + txtProduct.ReadOnly = true; + txtVersion.ReadOnly = true; + txtLanguages.ReadOnly = true; + txtDeveloper.ReadOnly = true; + txtDescription.ReadOnly = true; + txtArchitecture.ReadOnly = true; + chkOem.Enabled = false; + chkFiles.Enabled = false; + chkUpdate.Enabled = false; + chkUpgrade.Enabled = false; + chkNetinstall.Enabled = false; + chkSource.Enabled = false; + txtFormat.Text = ""; + txtMachine.Text = ""; + txtProduct.Text = ""; + txtVersion.Text = ""; + txtLanguages.Text = ""; + txtDeveloper.Text = ""; + txtDescription.Text = ""; + txtArchitecture.Text = ""; + chkOem.Checked = false; + chkFiles.Checked = false; + chkUpdate.Checked = false; + chkUpgrade.Checked = false; + chkNetinstall.Checked = false; + chkSource.Checked = false; + + if(Context.TmpFolder != null) + { + btnStop.Visible = false; + prgProgress.Visible = true; + lblProgress.Visible = true; + lblProgress.Text = "Removing temporary files"; + prgProgress.Indeterminate = true; + Workers.Failed += RemoveTempFilesFailed; + Workers.Finished += RemoveTempFilesFinished; + thdRemoveTemp = new Thread(Workers.RemoveTempFolder); + thdRemoveTemp.Start(); + } + + btnMetadata.Visible = false; + Context.Metadata = null; + lblStatus.Visible = false; + } + + void UpdateProgress(string text, string inner, long current, long maximum) + { + Application.Instance.Invoke(delegate + { + if(!string.IsNullOrWhiteSpace(text) && !string.IsNullOrWhiteSpace(inner)) + lblProgress.Text = $"{text}: {inner}"; + else if(!string.IsNullOrWhiteSpace(inner)) + lblProgress.Text = inner; + else + lblProgress.Text = text; + if(maximum > 0) + { + if(current < int.MinValue || current > int.MaxValue || maximum < int.MinValue || + maximum > int.MaxValue) + { + current /= 100; + maximum /= 100; + } + + prgProgress.Indeterminate = false; + prgProgress.MinValue = 0; + prgProgress.MaxValue = (int)maximum; + prgProgress.Value = (int)current; + } + else prgProgress.Indeterminate = true; + }); + } + + void UpdateProgress2(string text, string inner, long current, long maximum) + { + Application.Instance.Invoke(delegate + { + if(!string.IsNullOrWhiteSpace(text) && !string.IsNullOrWhiteSpace(inner)) + lblProgress2.Text = $"{text}: {inner}"; + else if(!string.IsNullOrWhiteSpace(inner)) + lblProgress2.Text = inner; + else + lblProgress2.Text = text; + if(maximum > 0) + { + if(current < int.MinValue || current > int.MaxValue || maximum < int.MinValue || + maximum > int.MaxValue) + { + current /= 100; + maximum /= 100; + } + + prgProgress2.Indeterminate = false; + prgProgress2.MinValue = 0; + prgProgress2.MaxValue = (int)maximum; + prgProgress2.Value = (int)current; + } + else prgProgress2.Indeterminate = true; + }); + } + + protected void OnBtnStopClicked(object sender, EventArgs e) + { + stopped = true; + + Workers.AddFileForOS -= AddFile; + Workers.AddOS -= AddOs; + Workers.Failed -= AddFilesToDbFailed; + Workers.Failed -= ChkFilesFailed; + Workers.Failed -= ExtractArchiveFailed; + Workers.Failed -= FindFilesFailed; + Workers.Failed -= HashFilesFailed; + Workers.Failed -= OpenArchiveFailed; + Workers.Failed -= PackFilesFailed; + Workers.Failed -= RemoveTempFilesFailed; + Workers.Finished -= AddFilesToDbFinished; + Workers.Finished -= ChkFilesFinished; + Workers.Finished -= ExtractArchiveFinished; + Workers.Finished -= FindFilesFinished; + Workers.Finished -= HashFilesFinished; + Workers.Finished -= OpenArchiveFinished; + Workers.Finished -= RemoveTempFilesFinished; + Workers.FinishedWithText -= PackFilesFinished; + Workers.UpdateProgress -= UpdateProgress; + Workers.UpdateProgress2 -= UpdateProgress2; + + if(thdFindFiles != null) + { + thdFindFiles.Abort(); + thdFindFiles = null; + } + + if(thdHashFiles != null) + { + thdHashFiles.Abort(); + thdHashFiles = null; + } + + if(thdCheckFiles != null) + { + thdCheckFiles.Abort(); + thdCheckFiles = null; + } + + if(thdAddFiles != null) + { + thdAddFiles.Abort(); + thdAddFiles = null; + } + + if(thdPackFiles != null) + { + thdPackFiles.Abort(); + thdPackFiles = null; + } + + if(thdOpenArchive != null) + { + thdOpenArchive.Abort(); + thdOpenArchive = null; + } + + if(Context.UnarProcess != null) + { + Context.UnarProcess.Kill(); + Context.UnarProcess = null; + } + + if(Context.TmpFolder != null) + { + btnStop.Visible = false; + lblProgress.Text = "Removing temporary files"; + prgProgress.Indeterminate = true; + Workers.Failed += RemoveTempFilesFailed; + Workers.Finished += RemoveTempFilesFinished; + thdRemoveTemp = new Thread(Workers.RemoveTempFolder); + thdRemoveTemp.Start(); + } + else RestoreUi(); + } + + void RestoreUi() + { + lblProgress.Visible = false; + prgProgress.Visible = false; + lblProgress2.Visible = false; + prgProgress2.Visible = false; + btnExit.Enabled = true; + btnFolder.Visible = true; + btnArchive.Visible = true; + lblProgress.Visible = false; + prgProgress.Visible = false; + btnExit.Enabled = true; + btnFolder.Visible = true; + btnArchive.Visible = true; + Workers.Failed -= FindFilesFailed; + Workers.Failed -= HashFilesFailed; + Workers.Failed -= ChkFilesFailed; + Workers.Failed -= OpenArchiveFailed; + Workers.Failed -= AddFilesToDbFailed; + Workers.Failed -= PackFilesFailed; + Workers.Failed -= ExtractArchiveFailed; + Workers.Failed -= RemoveTempFilesFailed; + Workers.Finished -= FindFilesFinished; + Workers.Finished -= HashFilesFinished; + Workers.Finished -= ChkFilesFinished; + Workers.Finished -= OpenArchiveFinished; + Workers.Finished -= AddFilesToDbFinished; + Workers.Finished -= ExtractArchiveFinished; + Workers.Finished -= RemoveTempFilesFinished; + Workers.FinishedWithText -= PackFilesFinished; + Workers.UpdateProgress -= UpdateProgress; + Workers.UpdateProgress2 -= UpdateProgress2; + btnStop.Visible = false; + fileView?.Clear(); + if(osView == null) return; + + tabOSes.Visible = false; + osView.Clear(); + } + + void RemoveTempFilesFailed(string text) + { + Application.Instance.Invoke(delegate + { + MessageBox.Show(text, MessageBoxType.Error); + Workers.Failed -= RemoveTempFilesFailed; + Workers.Finished -= RemoveTempFilesFinished; + Context.Path = null; + Context.TmpFolder = null; + RestoreUi(); + }); + } + + void RemoveTempFilesFinished() + { + Application.Instance.Invoke(delegate + { + Workers.Failed -= RemoveTempFilesFailed; + Workers.Finished -= RemoveTempFilesFinished; + Context.Path = null; + Context.TmpFolder = null; + RestoreUi(); + }); + } + + void AddToDatabase() + { + btnRemoveFile.Enabled = false; + btnToggleCrack.Enabled = false; + btnPack.Enabled = false; + btnClose.Enabled = false; + prgProgress.Visible = true; + txtFormat.ReadOnly = true; + txtMachine.ReadOnly = true; + txtProduct.ReadOnly = true; + txtVersion.ReadOnly = true; + txtLanguages.ReadOnly = true; + txtDeveloper.ReadOnly = true; + txtDescription.ReadOnly = true; + txtArchitecture.ReadOnly = true; + chkOem.Enabled = false; + chkFiles.Enabled = false; + chkUpdate.Enabled = false; + chkUpgrade.Enabled = false; + chkNetinstall.Enabled = false; + chkSource.Enabled = false; + + Workers.UpdateProgress += UpdateProgress; + Workers.Finished += AddFilesToDbFinished; + Workers.Failed += AddFilesToDbFailed; + + Context.DbInfo.Architecture = txtArchitecture.Text; + Context.DbInfo.Description = txtDescription.Text; + Context.DbInfo.Developer = txtDeveloper.Text; + Context.DbInfo.Format = txtFormat.Text; + Context.DbInfo.Languages = txtLanguages.Text; + Context.DbInfo.Machine = txtMachine.Text; + Context.DbInfo.Product = txtProduct.Text; + Context.DbInfo.Version = txtVersion.Text; + Context.DbInfo.Files = chkFiles.Checked.Value; + Context.DbInfo.Netinstall = chkNetinstall.Checked.Value; + Context.DbInfo.Oem = chkOem.Checked.Value; + Context.DbInfo.Source = chkSource.Checked.Value; + Context.DbInfo.Update = chkUpdate.Checked.Value; + Context.DbInfo.Upgrade = chkUpgrade.Checked.Value; + + if(Context.Metadata != null) + { + MemoryStream ms = new MemoryStream(); + XmlSerializer xs = new XmlSerializer(typeof(CICMMetadataType)); + xs.Serialize(ms, Context.Metadata); + Context.DbInfo.Xml = ms.ToArray(); + JsonSerializer js = new JsonSerializer(); + ms = new MemoryStream(); + StreamWriter sw = new StreamWriter(ms); + js.Serialize(sw, Context.Metadata, typeof(CICMMetadataType)); + Context.DbInfo.Json = ms.ToArray(); + } + else + { + Context.DbInfo.Xml = null; + Context.DbInfo.Json = null; + } + + thdAddFiles = new Thread(Workers.AddFilesToDb); + thdAddFiles.Start(); + } + + void AddFilesToDbFinished() + { + Application.Instance.Invoke(delegate + { + Workers.UpdateProgress -= UpdateProgress; + Workers.Finished -= AddFilesToDbFinished; + Workers.Failed -= AddFilesToDbFailed; + + thdAddFiles?.Abort(); + + long counter = 0; + fileView.Clear(); + foreach(KeyValuePair kvp in Context.Hashes) + { + UpdateProgress(null, "Updating table", counter, Context.Hashes.Count); + fileView.Add(new FileEntry {Path = kvp.Key, Hash = kvp.Value.Sha256, Known = true}); + counter++; + } + + // TODO: Update OS table + + OnAddedOS?.Invoke(Context.DbInfo); + + lblProgress.Visible = false; + prgProgress.Visible = false; + btnClose.Enabled = true; + }); + } + + void AddFilesToDbFailed(string text) + { + Application.Instance.Invoke(delegate + { + if(!stopped) MessageBox.Show(text, MessageBoxType.Error); + + Workers.UpdateProgress -= UpdateProgress; + Workers.Finished -= AddFilesToDbFinished; + Workers.Failed -= AddFilesToDbFailed; + + thdAddFiles?.Abort(); + + ChkFilesFinished(); + }); + } + + protected void OnBtnPackClicked(object sender, EventArgs e) + { + btnRemoveFile.Enabled = false; + btnToggleCrack.Enabled = false; + btnPack.Enabled = false; + btnClose.Enabled = false; + prgProgress.Visible = true; + prgProgress2.Visible = true; + lblProgress.Visible = true; + lblProgress2.Visible = true; + txtFormat.ReadOnly = true; + txtMachine.ReadOnly = true; + txtProduct.ReadOnly = true; + txtVersion.ReadOnly = true; + txtLanguages.ReadOnly = true; + txtDeveloper.ReadOnly = true; + txtDescription.ReadOnly = true; + txtArchitecture.ReadOnly = true; + chkOem.Enabled = false; + chkFiles.Enabled = false; + chkUpdate.Enabled = false; + chkUpgrade.Enabled = false; + chkNetinstall.Enabled = false; + chkSource.Enabled = false; + + Workers.UpdateProgress += UpdateProgress; + Workers.UpdateProgress2 += UpdateProgress2; + Workers.FinishedWithText += PackFilesFinished; + Workers.Failed += PackFilesFailed; + + Context.DbInfo.Architecture = txtArchitecture.Text; + Context.DbInfo.Description = txtDescription.Text; + Context.DbInfo.Developer = txtDeveloper.Text; + Context.DbInfo.Format = txtFormat.Text; + Context.DbInfo.Languages = txtLanguages.Text; + Context.DbInfo.Machine = txtMachine.Text; + Context.DbInfo.Product = txtProduct.Text; + Context.DbInfo.Version = txtVersion.Text; + Context.DbInfo.Files = chkFiles.Checked.Value; + Context.DbInfo.Netinstall = chkNetinstall.Checked.Value; + Context.DbInfo.Oem = chkOem.Checked.Value; + Context.DbInfo.Source = chkSource.Checked.Value; + Context.DbInfo.Update = chkUpdate.Checked.Value; + Context.DbInfo.Upgrade = chkUpgrade.Checked.Value; + + thdPackFiles = new Thread(Workers.CompressFiles); + thdPackFiles.Start(); + } + + void PackFilesFinished(string text) + { + Application.Instance.Invoke(delegate + { + Workers.UpdateProgress -= UpdateProgress; + Workers.UpdateProgress2 -= UpdateProgress2; + Workers.FinishedWithText -= PackFilesFinished; + Workers.Failed -= PackFilesFailed; + prgProgress2.Visible = false; + lblProgress2.Visible = false; + + thdPackFiles?.Abort(); + + AddToDatabase(); + + MessageBox.Show(text); + }); + } + + void PackFilesFailed(string text) + { + Application.Instance.Invoke(delegate + { + if(!stopped) MessageBox.Show(text, MessageBoxType.Error); + + Workers.UpdateProgress -= UpdateProgress; + Workers.UpdateProgress2 -= UpdateProgress2; + Workers.FinishedWithText -= PackFilesFinished; + Workers.Failed -= PackFilesFailed; + + thdPackFiles?.Abort(); + + btnRemoveFile.Enabled = true; + btnToggleCrack.Enabled = true; + btnPack.Enabled = true; + btnClose.Enabled = true; + prgProgress.Visible = false; + prgProgress2.Visible = false; + lblProgress.Visible = false; + lblProgress2.Visible = false; + txtFormat.ReadOnly = false; + txtMachine.ReadOnly = false; + txtProduct.ReadOnly = false; + txtVersion.ReadOnly = false; + txtLanguages.ReadOnly = false; + txtDeveloper.ReadOnly = false; + txtDescription.ReadOnly = false; + txtArchitecture.ReadOnly = false; + chkOem.Enabled = true; + chkFiles.Enabled = true; + chkUpdate.Enabled = true; + chkUpgrade.Enabled = true; + chkNetinstall.Enabled = true; + chkSource.Enabled = true; + }); + } + + protected void OnBtnArchiveClicked(object sender, EventArgs e) + { + if(!Context.UnarUsable) + { + MessageBox.Show("Cannot open archives without a working unar installation.", MessageBoxType.Error); + return; + } + + OpenFileDialog dlgFile = new OpenFileDialog {Title = "Open archive", MultiSelect = false}; + + if(dlgFile.ShowDialog(this) != DialogResult.Ok) return; + + knownFiles = 0; + stopped = false; + lblProgress.Text = "Opening archive"; + lblProgress.Visible = false; + prgProgress.Visible = true; + btnExit.Enabled = false; + btnFolder.Visible = false; + btnArchive.Visible = false; + prgProgress.Indeterminate = true; + + thdOpenArchive = new Thread(Workers.OpenArchive); + Context.Path = dlgFile.FileName; + Workers.Failed += OpenArchiveFailed; + Workers.Finished += OpenArchiveFinished; + btnStop.Visible = true; + thdOpenArchive.Start(); + } + + void OpenArchiveFailed(string text) + { + Application.Instance.Invoke(delegate + { + if(!stopped) MessageBox.Show(text, MessageBoxType.Error); + lblProgress.Visible = false; + prgProgress.Visible = false; + btnExit.Enabled = true; + btnFolder.Visible = true; + btnArchive.Visible = true; + btnStop.Visible = false; + Workers.Failed -= OpenArchiveFailed; + Workers.Finished -= OpenArchiveFinished; + thdOpenArchive = null; + }); + } + + void OpenArchiveFinished() + { + Application.Instance.Invoke(delegate + { + stopped = false; + lblProgress.Text = "Extracting archive"; + prgProgress.Visible = true; + prgProgress2.Visible = true; + btnExit.Enabled = false; + btnFolder.Visible = false; + btnArchive.Visible = false; + Workers.UpdateProgress += UpdateProgress; + lblProgress.Visible = true; + lblProgress2.Visible = true; + Workers.Failed -= OpenArchiveFailed; + Workers.Finished -= OpenArchiveFinished; + thdOpenArchive = null; + Workers.Failed += ExtractArchiveFailed; + Workers.Finished += ExtractArchiveFinished; + Workers.UpdateProgress2 += UpdateProgress2; + thdExtractArchive = new Thread(Workers.ExtractArchive); + thdExtractArchive.Start(); + }); + } + + void ExtractArchiveFailed(string text) + { + Application.Instance.Invoke(delegate + { + if(!stopped) MessageBox.Show(text, MessageBoxType.Error); + lblProgress2.Visible = false; + prgProgress2.Visible = false; + btnExit.Enabled = true; + btnFolder.Visible = true; + btnArchive.Visible = true; + Workers.Failed -= ExtractArchiveFailed; + Workers.Finished -= ExtractArchiveFinished; + Workers.UpdateProgress -= UpdateProgress; + Workers.UpdateProgress2 -= UpdateProgress2; + thdExtractArchive = null; + if(Context.TmpFolder == null) return; + + btnStop.Visible = false; + lblProgress.Text = "Removing temporary files"; + prgProgress.Indeterminate = true; + Workers.Failed += RemoveTempFilesFailed; + Workers.Finished += RemoveTempFilesFinished; + thdRemoveTemp = new Thread(Workers.RemoveTempFolder); + thdRemoveTemp.Start(); + }); + } + + void ExtractArchiveFinished() + { + Application.Instance.Invoke(delegate + { + stopped = false; + lblProgress.Text = "Finding files"; + lblProgress.Visible = true; + lblProgress2.Visible = false; + prgProgress.Visible = true; + btnExit.Enabled = false; + btnFolder.Visible = false; + btnArchive.Visible = false; + Workers.Failed -= ExtractArchiveFailed; + Workers.Finished -= ExtractArchiveFinished; + Workers.UpdateProgress -= UpdateProgress; + Workers.UpdateProgress2 -= UpdateProgress2; + prgProgress.Indeterminate = true; + + thdExtractArchive = null; + thdFindFiles = new Thread(Workers.FindFiles); + Workers.Failed += FindFilesFailed; + Workers.Finished += FindFilesFinished; + btnStop.Visible = true; + thdFindFiles.Start(); + }); + } + + protected void OnBtnMetadataClicked(object sender, EventArgs e) + { + dlgMetadata _dlgMetadata = new dlgMetadata {Metadata = Context.Metadata}; + _dlgMetadata.FillFields(); + + _dlgMetadata.ShowModal(this); + + if(!_dlgMetadata.Modified) return; + + Context.Metadata = _dlgMetadata.Metadata; + + if(string.IsNullOrWhiteSpace(txtDeveloper.Text)) + if(Context.Metadata.Developer != null) + foreach(string developer in Context.Metadata.Developer) + { + if(!string.IsNullOrWhiteSpace(txtDeveloper.Text)) txtDeveloper.Text += ","; + txtDeveloper.Text += developer; + } + + if(string.IsNullOrWhiteSpace(txtProduct.Text)) + if(!string.IsNullOrWhiteSpace(Context.Metadata.Name)) + txtProduct.Text = Context.Metadata.Name; + + if(string.IsNullOrWhiteSpace(txtVersion.Text)) + if(!string.IsNullOrWhiteSpace(Context.Metadata.Version)) + txtVersion.Text = Context.Metadata.Version; + + if(string.IsNullOrWhiteSpace(txtLanguages.Text)) + if(Context.Metadata.Languages != null) + foreach(LanguagesTypeLanguage language in Context.Metadata.Languages) + { + if(!string.IsNullOrWhiteSpace(txtLanguages.Text)) txtLanguages.Text += ","; + txtLanguages.Text += language; + } + + if(string.IsNullOrWhiteSpace(txtArchitecture.Text)) + if(Context.Metadata.Architectures != null) + foreach(ArchitecturesTypeArchitecture architecture in Context.Metadata.Architectures) + { + if(!string.IsNullOrWhiteSpace(txtArchitecture.Text)) txtArchitecture.Text += ","; + txtArchitecture.Text += architecture; + } + + if(string.IsNullOrWhiteSpace(txtMachine.Text)) + if(Context.Metadata.Systems != null) + foreach(string machine in Context.Metadata.Systems) + { + if(!string.IsNullOrWhiteSpace(txtMachine.Text)) txtMachine.Text += ","; + txtMachine.Text += machine; + } + + btnMetadata.BackgroundColor = Colors.Green; + } + + protected void OnBtnRemoveFileClicked(object sender, EventArgs e) + { + if(treeFiles.SelectedItem == null) return; + + string name = ((FileEntry)treeFiles.SelectedItem).Path; + string filesPath; + + if(!string.IsNullOrEmpty(Context.TmpFolder) && Directory.Exists(Context.TmpFolder)) + filesPath = Context.TmpFolder; + else filesPath = Context.Path; + + Context.Hashes.Remove(name); + Context.Files.Remove(Path.Combine(filesPath, name)); + fileView.Remove((FileEntry)treeFiles.SelectedItem); + } + + protected void OnBtnToggleCrackClicked(object sender, EventArgs e) + { + if(treeFiles.SelectedItem == null) return; + + string name = ((FileEntry)treeFiles.SelectedItem).Path; + bool known = ((FileEntry)treeFiles.SelectedItem).Known; + + if(!Context.Hashes.TryGetValue(name, out DbOsFile osfile)) return; + + osfile.Crack = !osfile.Crack; + Context.Hashes.Remove(name); + Context.Hashes.Add(name, osfile); + ((FileEntry)treeFiles.SelectedItem).IsCrack = osfile.Crack; + fileView.Remove((FileEntry)treeFiles.SelectedItem); + fileView.Add(new FileEntry {Path = name, Hash = osfile.Sha256, Known = known, IsCrack = osfile.Crack}); + } + + void treeFilesSelectionChanged(object sender, EventArgs e) + { + if(treeFiles.SelectedItem == null) return; + + btnToggleCrack.Text = ((FileEntry)treeFiles.SelectedItem).IsCrack ? "Mark as not crack" : "Mark as crack"; + } + + class FileEntry + { + public string Path { get; set; } + public string Hash { get; set; } + public bool Known { get; set; } + public bool IsCrack { get; set; } + } + + #region XAML UI elements + #pragma warning disable 0649 + TextBox txtDeveloper; + TextBox txtProduct; + TextBox txtVersion; + TextBox txtLanguages; + TextBox txtArchitecture; + TextBox txtMachine; + TextBox txtFormat; + TextBox txtDescription; + CheckBox chkOem; + CheckBox chkUpdate; + CheckBox chkUpgrade; + CheckBox chkFiles; + CheckBox chkSource; + CheckBox chkNetinstall; + GridView treeFiles; + TabPage tabOSes; + GridView treeOSes; + Label lblProgress; + ProgressBar prgProgress; + Label lblProgress2; + ProgressBar prgProgress2; + Button btnRemoveFile; + Button btnMetadata; + Button btnStop; + Button btnFolder; + Button btnArchive; + Button btnPack; + Button btnClose; + Button btnExit; + Button btnToggleCrack; + Label lblStatus; + #pragma warning restore 0649 + #endregion XAML UI elements + } +} \ No newline at end of file diff --git a/dlgBlockMedia.xeto b/dlgBlockMedia.xeto new file mode 100644 index 0000000..a5d2d87 --- /dev/null +++ b/dlgBlockMedia.xeto @@ -0,0 +1,617 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Sequenced + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Known dimensions + + + Round? + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Has ATA IDENTIFY information? + + + + + + + + Is PCI? + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Is PCMCIA? + Has CIS? + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Is Secure Digital or MMC? + + + + + + + Has CSD? + + + + Has Extended CSD? + + + + + + + + Is SCSI? + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Is USB? + + + + + + + + + + + + + + + + + + + + + + + + + + Has MAM? + + + + + + + + Has tracks? + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Known dumping hardware + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dlgBlockMedia.xeto.cs b/dlgBlockMedia.xeto.cs new file mode 100644 index 0000000..0add99b --- /dev/null +++ b/dlgBlockMedia.xeto.cs @@ -0,0 +1,1738 @@ +// +// Author: +// Natalia Portillo claunia@claunia.com +// +// Copyright (c) 2017, © Claunia.com +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in +// the documentation and/or other materials provided with the distribution. +// * Neither the name of the [ORGANIZATION] nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using Eto.Forms; +using Eto.Serialization.Xaml; +using Schemas; + +namespace apprepodbmgr.Eto +{ + public class dlgBlockMedia : Dialog + { + // Non-editable fields + ChecksumType[] checksums; + ChecksumType[] contentChks; + DumpHardwareType dumpHwIter; + bool editingDumpHw; + + bool editingPartition; + FileSystemType filesystemIter; + ObservableCollection lstAdditionalInformation; + + ObservableCollection lstAta; + ObservableCollection lstCID; + ObservableCollection lstCSD; + ObservableCollection lstDumpHw; + ObservableCollection lstECSD; + ObservableCollection lstEVPDs; + ObservableCollection lstInquiry; + ObservableCollection lstLogSense; + ObservableCollection lstMAM; + ObservableCollection lstModeSense; + ObservableCollection lstModeSense10; + ObservableCollection lstPartitions; + ObservableCollection lstPCIConfiguration; + ObservableCollection lstPCIOptionROM; + ObservableCollection lstPCMCIACIS; + ObservableCollection lstTracks; + ObservableCollection lstUSBDescriptors; + public BlockMediaType Metadata; + public bool Modified; + + PartitionType partitionIter; + ScansType scans; + TapePartitionType[] tapeInformation; + BlockSizeType[] variableBlockSize; + + public dlgBlockMedia() + { + XamlReader.Load(this); + + Modified = false; + + #region Set partitions table + lstPartitions = new ObservableCollection(); + + treePartitions.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Sequence).Convert(v => v.ToString()) + }, + HeaderText = "Sequence" + }); + treePartitions.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.StartSector).Convert(v => v.ToString()) + }, + HeaderText = "Start" + }); + treePartitions.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.EndSector).Convert(v => v.ToString()) + }, + HeaderText = "End" + }); + treePartitions.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Type)}, + HeaderText = "Type" + }); + treePartitions.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Name)}, + HeaderText = "Name" + }); + treePartitions.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Description)}, + HeaderText = "Description" + }); + + treePartitions.DataStore = lstPartitions; + + treePartitions.AllowMultipleSelection = false; + #endregion Set partitions table + + #region Set filesystems table + treeFilesystems.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Type)}, + HeaderText = "Type" + }); + treeFilesystems.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.VolumeName)}, + HeaderText = "Name" + }); + + treeFilesystems.AllowMultipleSelection = false; + #endregion Set filesystems table + + #region Set dump hardware table + lstDumpHw = new ObservableCollection(); + + treeDumpHardware.Columns.Add(new GridColumn + { + DataCell = + new TextBoxCell {Binding = Binding.Property(r => r.Manufacturer)}, + HeaderText = "Manufacturer" + }); + treeDumpHardware.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Model)}, + HeaderText = "Model" + }); + treeDumpHardware.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Revision)}, + HeaderText = "Revision" + }); + treeDumpHardware.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Firmware)}, + HeaderText = "Firmware" + }); + treeDumpHardware.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Serial)}, + HeaderText = "Serial" + }); + treeDumpHardware.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Software).Convert(v => v?.Name) + }, + HeaderText = "Software" + }); + treeDumpHardware.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Software).Convert(v => v?.Version) + }, + HeaderText = "Version" + }); + treeDumpHardware.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Software) + .Convert(v => v?.OperatingSystem) + }, + HeaderText = "Operating system" + }); + + treeDumpHardware.DataStore = lstDumpHw; + + treeDumpHardware.AllowMultipleSelection = false; + + treeExtents.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Start).Convert(v => v.ToString()) + }, + HeaderText = "Start" + }); + treeExtents.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.End).Convert(v => v.ToString()) + }, + HeaderText = "End" + }); + #endregion Set dump hardware table + + #region Set ATA IDENTIFY table + lstAta = new ObservableCollection(); + treeATA.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Image)}, + HeaderText = "File" + }); + treeATA.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Size).Convert(v => v.ToString()) + }, + HeaderText = "Size" + }); + treeATA.DataStore = lstAta; + #endregion Set ATA IDENTIFY table + + #region Set PCI configuration table + lstPCIConfiguration = new ObservableCollection(); + treeConfiguration.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Image)}, + HeaderText = "File" + }); + treeConfiguration.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Size).Convert(v => v.ToString()) + }, + HeaderText = "Size" + }); + treeConfiguration.DataStore = lstPCIConfiguration; + #endregion Set PCI configuration table + + #region Set PCMCIA CIS table + lstPCMCIACIS = new ObservableCollection(); + treeCIS.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Image)}, + HeaderText = "File" + }); + treeCIS.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Size).Convert(v => v.ToString()) + }, + HeaderText = "Size" + }); + treeCIS.DataStore = lstPCMCIACIS; + #endregion Set PCI option ROM table + + #region Set CID table + lstCID = new ObservableCollection(); + treeCID.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Image)}, + HeaderText = "File" + }); + treeCID.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Size).Convert(v => v.ToString()) + }, + HeaderText = "Size" + }); + treeCID.DataStore = lstCID; + #endregion Set CID table + + #region Set CSD table + lstCSD = new ObservableCollection(); + treeCSD.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Image)}, + HeaderText = "File" + }); + treeCSD.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Size).Convert(v => v.ToString()) + }, + HeaderText = "Size" + }); + treeCSD.DataStore = lstCSD; + #endregion Set CSD table + + #region Set Extended CSD table + lstECSD = new ObservableCollection(); + treeECSD.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Image)}, + HeaderText = "File" + }); + treeECSD.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Size).Convert(v => v.ToString()) + }, + HeaderText = "Size" + }); + treeECSD.DataStore = lstECSD; + #endregion Set Extended CSD table + + #region Set SCSI INQUIRY table + lstInquiry = new ObservableCollection(); + treeInquiry.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Image)}, + HeaderText = "File" + }); + treeInquiry.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Size).Convert(v => v.ToString()) + }, + HeaderText = "Size" + }); + treeInquiry.DataStore = lstInquiry; + #endregion Set SCSI INQUIRY table + + #region Set SCSI MODE SENSE table + lstModeSense = new ObservableCollection(); + treeModeSense.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Image)}, + HeaderText = "File" + }); + treeModeSense.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Size).Convert(v => v.ToString()) + }, + HeaderText = "Size" + }); + treeModeSense.DataStore = lstModeSense; + #endregion Set SCSI MODE SENSE table + + #region Set SCSI MODE SENSE (10) table + lstModeSense10 = new ObservableCollection(); + treeModeSense10.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Image)}, + HeaderText = "File" + }); + treeModeSense10.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Size).Convert(v => v.ToString()) + }, + HeaderText = "Size" + }); + treeModeSense10.DataStore = lstModeSense10; + #endregion Set SCSI MODE SENSE (10) table + + #region Set SCSI LOG SENSE table + lstLogSense = new ObservableCollection(); + treeLogSense.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Image)}, + HeaderText = "File" + }); + treeLogSense.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Size).Convert(v => v.ToString()) + }, + HeaderText = "Size" + }); + treeLogSense.DataStore = lstLogSense; + #endregion Set SCSI MODE SENSE (10) table + + #region Set SCSI EVPDs table + lstEVPDs = new ObservableCollection(); + + treeEVPDs.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.page).Convert(v => v.ToString()) + }, + HeaderText = "Page" + }); + treeEVPDs.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Image)}, + HeaderText = "File" + }); + treeEVPDs.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Size).Convert(v => v.ToString()) + }, + HeaderText = "Size" + }); + + treeEVPDs.DataStore = lstEVPDs; + + treeEVPDs.AllowMultipleSelection = false; + #endregion Set SCSI EVPDs table + + #region Set USB descriptors table + lstUSBDescriptors = new ObservableCollection(); + treeDescriptors.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Image)}, + HeaderText = "File" + }); + treeDescriptors.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Size).Convert(v => v.ToString()) + }, + HeaderText = "Size" + }); + treeDescriptors.DataStore = lstUSBDescriptors; + #endregion Set USB descriptors table + + #region Set MAM table + lstMAM = new ObservableCollection(); + treeMAM.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Image)}, + HeaderText = "File" + }); + treeMAM.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Size).Convert(v => v.ToString()) + }, + HeaderText = "Size" + }); + treeMAM.DataStore = lstMAM; + #endregion Set MAM table + + #region Set Option ROM table + lstPCIOptionROM = new ObservableCollection(); + + treeOptionROM.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Image.Value)}, + HeaderText = "File" + }); + treeOptionROM.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Image.offset).Convert(v => v.ToString()) + }, + HeaderText = "Offset" + }); + treeOptionROM.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Size).Convert(v => v.ToString()) + }, + HeaderText = "Size" + }); + + treeOptionROM.DataStore = lstPCIOptionROM; + + treeOptionROM.AllowMultipleSelection = false; + #endregion Set Option ROM table + + #region Set tracks table + lstTracks = new ObservableCollection(); + + treeTracks.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Image.Value)}, + HeaderText = "File" + }); + treeTracks.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Image.offset).Convert(v => v.ToString()) + }, + HeaderText = "Offset" + }); + treeTracks.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Size).Convert(v => v.ToString()) + }, + HeaderText = "Size" + }); + treeTracks.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Image.format)}, + HeaderText = "Image format" + }); + treeTracks.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Head).Convert(v => v.ToString()) + }, + HeaderText = "Head" + }); + treeTracks.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Cylinder).Convert(v => v.ToString()) + }, + HeaderText = "Cylinder" + }); + treeTracks.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.StartSector).Convert(v => v.ToString()) + }, + HeaderText = "Start" + }); + treeTracks.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.EndSector).Convert(v => v.ToString()) + }, + HeaderText = "End" + }); + treeTracks.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.Sectors).Convert(v => v.ToString()) + }, + HeaderText = "Sectors" + }); + treeTracks.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell + { + Binding = Binding.Property(r => r.BytesPerSector).Convert(v => v.ToString()) + }, + HeaderText = "Bytes per sector" + }); + treeTracks.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.Format)}, + HeaderText = "Track format" + }); + + treeTracks.DataStore = lstTracks; + + treeTracks.AllowMultipleSelection = false; + #endregion Set tracks table + + lstAdditionalInformation = new ObservableCollection(); + treeAdditionalInformation.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell {Binding = Binding.Property(r => r.str)}, + HeaderText = "Information" + }); + treeAdditionalInformation.DataStore = lstAdditionalInformation; + treeAdditionalInformation.AllowMultipleSelection = false; + } + + public void FillFields() + { + if(Metadata == null) return; + + txtImage.Text = Metadata.Image.Value; + txtFormat.Text = Metadata.Image.format; + if(Metadata.Image.offsetSpecified) txtOffset.Text = Metadata.Image.offset.ToString(); + txtSize.Text = Metadata.Size.ToString(); + checksums = Metadata.Checksums; + contentChks = Metadata.ContentChecksums; + if(Metadata.Sequence != null) + { + lblMediaTitle.Visible = true; + txtMediaTitle.Visible = true; + lblSequence.Visible = true; + spSequence.Visible = true; + lblTotalMedia.Visible = true; + spTotalMedia.Visible = true; + lblSide.Visible = true; + spSide.Visible = true; + lblLayer.Visible = true; + spLayer.Visible = true; + chkSequence.Checked = true; + txtMediaTitle.Text = Metadata.Sequence.MediaTitle; + spSequence.Value = Metadata.Sequence.MediaSequence; + spTotalMedia.Value = Metadata.Sequence.TotalMedia; + if(Metadata.Sequence.SideSpecified) spSide.Value = Metadata.Sequence.Side; + if(Metadata.Sequence.LayerSpecified) spLayer.Value = Metadata.Sequence.Layer; + } + + if(Metadata.Manufacturer != null) txtManufacturer.Text = Metadata.Manufacturer; + if(Metadata.Model != null) txtModel.Text = Metadata.Model; + if(Metadata.Serial != null) txtSerial.Text = Metadata.Serial; + if(Metadata.Firmware != null) txtFirmware.Text = Metadata.Firmware; + if(Metadata.Interface != null) txtInterface.Text = Metadata.Interface; + spPhysicalBlockSize.Value = Metadata.PhysicalBlockSize; + spLogicalBlockSize.Value = Metadata.LogicalBlockSize; + txtBlocks.Text = Metadata.LogicalBlocks.ToString(); + variableBlockSize = Metadata.VariableBlockSize; + tapeInformation = Metadata.TapeInformation; + scans = Metadata.Scans; + if(Metadata.ATA?.Identify != null) + { + chkATA.Checked = true; + treeATA.Visible = true; + lstAta.Add(Metadata.ATA.Identify); + } + + if(Metadata.PCI != null) + { + chkPCI.Checked = true; + lblPCIVendor.Visible = true; + txtPCIVendor.Visible = true; + lblPCIProduct.Visible = true; + txtPCIProduct.Visible = true; + txtPCIVendor.Text = $"0x{Metadata.PCI.VendorID:X4}"; + txtPCIProduct.Text = $"0x{Metadata.PCI.DeviceID:X4}"; + if(Metadata.PCI.Configuration != null) + { + frmPCIConfiguration.Visible = true; + lstPCIConfiguration.Add(Metadata.PCI.Configuration); + } + + if(Metadata.PCI.ExpansionROM != null) + { + frmOptionROM.Visible = true; + lstPCIOptionROM.Add(Metadata.PCI.ExpansionROM); + } + } + + if(Metadata.PCMCIA != null) + { + chkPCMCIA.Checked = true; + chkCIS.Visible = true; + lblPCMCIAManufacturer.Visible = true; + txtPCMCIAManufacturer.Visible = true; + lblMfgCode.Visible = true; + txtMfgCode.Visible = true; + lblPCMCIAProductName.Visible = true; + txtPCMCIAProductName.Visible = true; + lblCardCode.Visible = true; + txtCardCode.Visible = true; + lblCompliance.Visible = true; + txtCompliance.Visible = true; + + if(Metadata.PCMCIA.CIS != null) + { + treeCIS.Visible = true; + lstPCMCIACIS.Add(Metadata.PCMCIA.CIS); + } + + if(Metadata.PCMCIA.Compliance != null) txtCompliance.Text = Metadata.PCMCIA.Compliance; + if(Metadata.PCMCIA.ManufacturerCodeSpecified) + txtMfgCode.Text = + $"0x{Metadata.PCMCIA.ManufacturerCode:X4}"; + if(Metadata.PCMCIA.CardCodeSpecified) + txtCardCode.Text = $"0x{Metadata.PCMCIA.CardCode:X4}"; + if(Metadata.PCMCIA.Manufacturer != null) + txtPCMCIAManufacturer.Text = Metadata.PCMCIA.Manufacturer; + if(Metadata.PCMCIA.ProductName != null) + txtPCMCIAProductName.Text = Metadata.PCMCIA.ProductName; + if(Metadata.PCMCIA.AdditionalInformation != null) + { + lblAdditionalInformation.Visible = true; + treeAdditionalInformation.Visible = true; + + foreach(string addinfo in Metadata.PCMCIA.AdditionalInformation) + lstAdditionalInformation.Add(new StringEntry {str = addinfo}); + } + } + + if(Metadata.SecureDigital?.CID != null) + { + chkSecureDigital.Checked = true; + chkCSD.Visible = true; + chkECSD.Visible = true; + lblCID.Visible = true; + treeCID.Visible = true; + lstCID.Add(Metadata.SecureDigital.CID); + + if(Metadata.SecureDigital.CSD != null) + { + chkCSD.Checked = true; + treeCSD.Visible = true; + lstCSD.Add(Metadata.SecureDigital.CSD); + } + + if(Metadata.MultiMediaCard.ExtendedCSD != null) + { + chkECSD.Checked = true; + treeECSD.Visible = true; + lstECSD.Add(Metadata.MultiMediaCard.ExtendedCSD); + } + } + + if(Metadata.SCSI?.Inquiry != null) + { + chkSCSI.Checked = true; + frmInquiry.Visible = true; + lstInquiry.Add(Metadata.SCSI.Inquiry); + + if(Metadata.SCSI.ModeSense != null) + { + frmModeSense.Visible = true; + lstModeSense.Add(Metadata.SCSI.ModeSense); + } + + if(Metadata.SCSI.ModeSense10 != null) + { + frmModeSense10.Visible = true; + lstModeSense10.Add(Metadata.SCSI.ModeSense10); + } + + if(Metadata.SCSI.LogSense != null) + { + frmLogSense.Visible = true; + lstLogSense.Add(Metadata.SCSI.LogSense); + } + + if(Metadata.SCSI.EVPD != null) + { + frmEVPDs.Visible = true; + lstEVPDs = new ObservableCollection(Metadata.SCSI.EVPD); + treeEVPDs.DataStore = lstEVPDs; // TODO: Really needed? + } + } + + if(Metadata.USB != null) + { + chkUSB.Checked = true; + lblUSBVendor.Visible = true; + txtUSBVendor.Visible = true; + lblUSBProduct.Visible = true; + txtUSBProduct.Visible = true; + txtUSBVendor.Text = $"0x{Metadata.USB.VendorID:X4}"; + txtUSBProduct.Text = $"0x{Metadata.USB.ProductID:X4}"; + if(Metadata.USB.Descriptors != null) + { + frmDescriptors.Visible = true; + lstUSBDescriptors.Add(Metadata.USB.Descriptors); + } + } + + if(Metadata.MAM != null) + { + chkMAM.Checked = true; + treeMAM.Visible = true; + lstMAM.Add(Metadata.MAM); + } + + if(Metadata.HeadsSpecified) spHeads.Value = Metadata.Heads; + if(Metadata.CylindersSpecified) spCylinders.Value = Metadata.Cylinders; + if(Metadata.SectorsPerTrackSpecified) spSectors.Value = Metadata.SectorsPerTrack; + if(Metadata.Track != null) + { + chkTracks.Checked = true; + treeTracks.Visible = true; + lstTracks = new ObservableCollection(Metadata.Track); + treeTracks.DataStore = lstTracks; // TODO: Really needed? + } + + if(Metadata.CopyProtection != null) txtCopyProtection.Text = Metadata.CopyProtection; + if(Metadata.Dimensions != null) + { + chkDimensions.Checked = true; + if(Metadata.Dimensions.DiameterSpecified) + { + chkRound.Checked = true; + stkDiameter.Visible = true; + stkHeight.Visible = false; + stkWidth.Visible = false; + spDiameter.Value = Metadata.Dimensions.Diameter; + } + else + { + stkDiameter.Visible = false; + stkHeight.Visible = true; + stkWidth.Visible = true; + spHeight.Value = Metadata.Dimensions.Height; + spWidth.Value = Metadata.Dimensions.Width; + } + + stkThickness.Visible = true; + spThickness.Value = Metadata.Dimensions.Thickness; + } + + if(Metadata.FileSystemInformation != null) + { + lstPartitions = new ObservableCollection(Metadata.FileSystemInformation); + treePartitions.DataStore = lstPartitions; // TODO: Really needed? + } + + if(Metadata.DumpHardwareArray != null) + { + chkDumpHardware.Checked = true; + treeDumpHardware.Visible = true; + btnAddHardware.Visible = true; + btnEditHardware.Visible = true; + btnRemoveHardware.Visible = true; + + lstDumpHw = new ObservableCollection(Metadata.DumpHardwareArray); + treeDumpHardware.DataStore = lstDumpHw; // TODO: Really needed? + } + + if(Metadata.DiskType != null) txtMediaType.Text = Metadata.DiskType; + if(Metadata.DiskSubType != null) txtMediaSubtype.Text = Metadata.DiskSubType; + } + + protected void OnChkSequenceToggled(object sender, EventArgs e) + { + lblMediaTitle.Visible = chkSequence.Checked.Value; + txtMediaTitle.Visible = chkSequence.Checked.Value; + lblSequence.Visible = chkSequence.Checked.Value; + spSequence.Visible = chkSequence.Checked.Value; + lblTotalMedia.Visible = chkSequence.Checked.Value; + spTotalMedia.Visible = chkSequence.Checked.Value; + lblSide.Visible = chkSequence.Checked.Value; + spSide.Visible = chkSequence.Checked.Value; + lblLayer.Visible = chkSequence.Checked.Value; + spLayer.Visible = chkSequence.Checked.Value; + } + + protected void OnChkDimensionsToggled(object sender, EventArgs e) + { + chkRound.Visible = chkDimensions.Checked.Value; + stkThickness.Visible = chkDimensions.Checked.Value; + if(chkDimensions.Checked.Value) OnChkRoundToggled(sender, e); + else + { + stkDiameter.Visible = false; + stkHeight.Visible = false; + stkWidth.Visible = false; + } + } + + protected void OnChkRoundToggled(object sender, EventArgs e) + { + stkDiameter.Visible = chkRound.Checked.Value; + stkHeight.Visible = !chkRound.Checked.Value; + stkWidth.Visible = !chkRound.Checked.Value; + } + + protected void OnChkPCMCIAToggled(object sender, EventArgs e) + { + chkCIS.Visible = chkPCMCIA.Checked.Value; + treeCIS.Visible = chkPCMCIA.Checked.Value; + lblPCMCIAManufacturer.Visible = chkPCMCIA.Checked.Value; + txtPCMCIAManufacturer.Visible = chkPCMCIA.Checked.Value; + lblMfgCode.Visible = chkPCMCIA.Checked.Value; + txtMfgCode.Visible = chkPCMCIA.Checked.Value; + lblPCMCIAProductName.Visible = chkPCMCIA.Checked.Value; + txtPCMCIAProductName.Visible = chkPCMCIA.Checked.Value; + lblCardCode.Visible = chkPCMCIA.Checked.Value; + txtCardCode.Visible = chkPCMCIA.Checked.Value; + lblCompliance.Visible = chkPCMCIA.Checked.Value; + txtCompliance.Visible = chkPCMCIA.Checked.Value; + lblAdditionalInformation.Visible = false; + treeAdditionalInformation.Visible = false; + } + + protected void OnBtnCancelPartitionClicked(object sender, EventArgs e) + { + btnCancelPartition.Visible = false; + btnApplyPartition.Visible = false; + btnRemovePartition.Visible = true; + btnEditPartition.Visible = true; + btnAddPartition.Visible = true; + stkPartitionFields1.Visible = false; + stkPartitionFields2.Visible = false; + frmFilesystems.Visible = false; + } + + protected void OnBtnRemovePartitionClicked(object sender, EventArgs e) + { + if(treePartitions.SelectedItem != null) lstPartitions.Remove((PartitionType)treePartitions.SelectedItem); + } + + protected void OnBtnEditPartitionClicked(object sender, EventArgs e) + { + if(treePartitions.SelectedItem == null) return; + + partitionIter = (PartitionType)treePartitions.SelectedItem; + + spPartitionSequence.Value = partitionIter.Sequence; + txtPartitionStart.Text = partitionIter.StartSector.ToString(); + txtPartitionEnd.Text = partitionIter.EndSector.ToString(); + txtPartitionType.Text = partitionIter.Type; + txtPartitionName.Text = partitionIter.Name; + txtPartitionDescription.Text = partitionIter.Description; + treeFilesystems.DataStore = new ObservableCollection(partitionIter.FileSystems); + + btnCancelPartition.Visible = true; + btnApplyPartition.Visible = true; + btnRemovePartition.Visible = false; + btnEditPartition.Visible = false; + btnAddPartition.Visible = false; + stkPartitionFields1.Visible = true; + stkPartitionFields2.Visible = true; + frmFilesystems.Visible = true; + + editingPartition = true; + } + + protected void OnBtnApplyPartitionClicked(object sender, EventArgs e) + { + if(!int.TryParse(txtPartitionStart.Text, out int temp)) + { + MessageBox.Show("Partition start must be a number", MessageBoxType.Error); + return; + } + + if(!int.TryParse(txtPartitionEnd.Text, out int temp2)) + { + MessageBox.Show("Partition end must be a number", MessageBoxType.Error); + return; + } + + if(temp2 <= temp) + { + MessageBox.Show("Partition must end after start, and be bigger than 1 sector", MessageBoxType.Error); + return; + } + + if(editingPartition) lstPartitions.Remove(partitionIter); + + partitionIter = new PartitionType + { + Sequence = (int)spPartitionSequence.Value, + StartSector = int.Parse(txtPartitionStart.Text), + EndSector = int.Parse(txtPartitionEnd.Text), + Type = txtPartitionType.Text, + Name = txtPartitionName.Text, + Description = txtPartitionDescription.Text + }; + if(((ObservableCollection)treeFilesystems.DataStore).Count > 0) + partitionIter.FileSystems = ((ObservableCollection)treeFilesystems.DataStore).ToArray(); + + btnCancelPartition.Visible = false; + btnApplyPartition.Visible = false; + btnRemovePartition.Visible = true; + btnEditPartition.Visible = true; + btnAddPartition.Visible = true; + stkPartitionFields1.Visible = false; + stkPartitionFields2.Visible = false; + frmFilesystems.Visible = false; + } + + protected void OnBtnAddPartitionClicked(object sender, EventArgs e) + { + spPartitionSequence.Value = 0; + txtPartitionStart.Text = ""; + txtPartitionEnd.Text = ""; + txtPartitionType.Text = ""; + txtPartitionName.Text = ""; + txtPartitionDescription.Text = ""; + treeFilesystems.DataStore = new ObservableCollection(); + + btnCancelPartition.Visible = true; + btnApplyPartition.Visible = true; + btnRemovePartition.Visible = false; + btnEditPartition.Visible = false; + btnAddPartition.Visible = false; + stkPartitionFields1.Visible = true; + stkPartitionFields2.Visible = true; + frmFilesystems.Visible = true; + + editingPartition = false; + } + + protected void OnBtnRemoveFilesystemClicked(object sender, EventArgs e) + { + if(treeFilesystems.SelectedItem != null) + ((ObservableCollection)treeFilesystems.DataStore).Remove((FileSystemType)treeFilesystems + .SelectedItem); + } + + protected void OnBtnEditFilesystemClicked(object sender, EventArgs e) + { + if(treeFilesystems.SelectedItem == null) return; + + filesystemIter = (FileSystemType)treeFilesystems.SelectedItem; + + dlgFilesystem _dlgFilesystem = new dlgFilesystem {Metadata = filesystemIter}; + _dlgFilesystem.FillFields(); + _dlgFilesystem.ShowModal(this); + + if(!_dlgFilesystem.Modified) return; + + ((ObservableCollection)treeFilesystems.DataStore).Remove(filesystemIter); + ((ObservableCollection)treeFilesystems.DataStore).Add(_dlgFilesystem.Metadata); + } + + protected void OnBtnAddFilesystemClicked(object sender, EventArgs e) + { + dlgFilesystem _dlgFilesystem = new dlgFilesystem(); + _dlgFilesystem.ShowModal(this); + + if(_dlgFilesystem.Modified) + ((ObservableCollection)treeFilesystems.DataStore).Add(_dlgFilesystem.Metadata); + } + + protected void OnChkDumpHardwareToggled(object sender, EventArgs e) + { + treeDumpHardware.Visible = chkDumpHardware.Checked.Value; + btnAddHardware.Visible = chkDumpHardware.Checked.Value; + btnRemoveHardware.Visible = chkDumpHardware.Checked.Value; + btnEditHardware.Visible = chkDumpHardware.Checked.Value; + + btnCancelHardware.Visible = false; + btnApplyHardware.Visible = false; + frmHardware.Visible = false; + } + + protected void OnBtnCancelHardwareClicked(object sender, EventArgs e) + { + btnAddHardware.Visible = true; + btnRemoveHardware.Visible = true; + btnCancelHardware.Visible = false; + btnEditHardware.Visible = true; + btnApplyHardware.Visible = false; + frmHardware.Visible = false; + } + + protected void OnBtnRemoveHardwareClicked(object sender, EventArgs e) + { + if(treeDumpHardware.SelectedItem != null) lstDumpHw.Remove((DumpHardwareType)treeDumpHardware.SelectedItem); + } + + protected void OnBtnEditHardwareClicked(object sender, EventArgs e) + { + if(treeDumpHardware.SelectedItem == null) return; + + dumpHwIter = (DumpHardwareType)treeDumpHardware.SelectedItem; + + txtHWManufacturer.Text = dumpHwIter.Manufacturer; + txtHWModel.Text = dumpHwIter.Model; + txtHWRevision.Text = dumpHwIter.Revision; + txtHWFirmware.Text = dumpHwIter.Firmware; + txtHWSerial.Text = dumpHwIter.Serial; + if(dumpHwIter.Software != null) + { + txtDumpName.Text = dumpHwIter.Software.Name; + txtDumpVersion.Text = dumpHwIter.Software.Version; + txtDumpOS.Text = dumpHwIter.Software.OperatingSystem; + } + + treeExtents.DataStore = new ObservableCollection(dumpHwIter.Extents); + + btnAddHardware.Visible = false; + btnRemoveHardware.Visible = false; + btnCancelHardware.Visible = true; + btnEditHardware.Visible = false; + btnApplyHardware.Visible = true; + frmHardware.Visible = true; + + editingDumpHw = true; + } + + protected void OnBtnApplyHardwareClicked(object sender, EventArgs e) + { + if(editingDumpHw) lstDumpHw.Remove(dumpHwIter); + + dumpHwIter = new DumpHardwareType + { + Manufacturer = txtHWManufacturer.Text, + Model = txtHWModel.Text, + Revision = txtHWRevision.Text, + Firmware = txtHWFirmware.Text, + Serial = txtHWSerial.Text + }; + if(!string.IsNullOrWhiteSpace(txtDumpName.Text) || !string.IsNullOrWhiteSpace(txtDumpVersion.Text) || + !string.IsNullOrWhiteSpace(txtDumpOS.Text)) + dumpHwIter.Software = new SoftwareType + { + Name = txtDumpName.Text, + Version = txtDumpVersion.Text, + OperatingSystem = txtDumpOS.Text + }; + if(((ObservableCollection)treeExtents.DataStore).Count > 0) + dumpHwIter.Extents = ((ObservableCollection)treeExtents.DataStore).ToArray(); + + lstDumpHw.Add(dumpHwIter); + + btnAddHardware.Visible = true; + btnRemoveHardware.Visible = true; + btnCancelHardware.Visible = false; + btnEditHardware.Visible = true; + btnApplyHardware.Visible = false; + frmHardware.Visible = false; + } + + protected void OnBtnAddHardwareClicked(object sender, EventArgs e) + { + txtHWManufacturer.Text = ""; + txtHWModel.Text = ""; + txtHWRevision.Text = ""; + txtHWFirmware.Text = ""; + txtHWSerial.Text = ""; + txtDumpName.Text = ""; + txtDumpVersion.Text = ""; + txtDumpOS.Text = ""; + treeExtents.DataStore = new ObservableCollection(); + + btnAddHardware.Visible = false; + btnRemoveHardware.Visible = false; + btnCancelHardware.Visible = true; + btnEditHardware.Visible = false; + btnApplyHardware.Visible = true; + frmHardware.Visible = true; + + editingDumpHw = false; + } + + protected void OnBtnRemoveExtentClicked(object sender, EventArgs e) + { + if(treeExtents.SelectedItem != null) + ((ObservableCollection)treeExtents.DataStore).Remove((ExtentType)treeExtents.SelectedItem); + } + + protected void OnBtnAddExtentClicked(object sender, EventArgs e) + { + ((ObservableCollection)treeExtents.DataStore).Add(new ExtentType + { + Start = (ulong)spExtentStart.Value, + End = (ulong)spExtentEnd.Value + }); + } + + protected void OnBtnCancelClicked(object sender, EventArgs e) + { + Close(); + } + + protected void OnBtnSaveClicked(object sender, EventArgs e) + { + #region Sanity checks + if(string.IsNullOrEmpty(txtFormat.Text)) + { + MessageBox.Show("Image format cannot be null", MessageBoxType.Error); + return; + } + + if(chkSequence.Checked.Value) + { + if(spSequence.Value < 1) + { + MessageBox.Show("Media sequence must be bigger than 0", MessageBoxType.Error); + return; + } + + if(spTotalMedia.Value < 1) + { + MessageBox.Show("Total medias must be bigger than 0", MessageBoxType.Error); + return; + } + + if(spSequence.Value > spTotalMedia.Value) + { + MessageBox.Show("Media sequence cannot be bigger than total medias", MessageBoxType.Error); + return; + } + } + + if(string.IsNullOrEmpty(txtBlocks.Text) || !long.TryParse(txtBlocks.Text, out long ltmp)) + { + MessageBox.Show("Blocks must be a number", MessageBoxType.Error); + return; + } + + if(ltmp < 1) + { + MessageBox.Show("Blocks must be bigger than 0", MessageBoxType.Error); + return; + } + + if(spPhysicalBlockSize.Value < 1) + { + MessageBox.Show("Physical Block Size must be bigger than 0", MessageBoxType.Error); + return; + } + + if(spLogicalBlockSize.Value < 1) + { + MessageBox.Show("Logical Block Size must be bigger than 0", MessageBoxType.Error); + return; + } + + if(spPhysicalBlockSize.Value < spLogicalBlockSize.Value) + { + MessageBox.Show("Physical Block Size must be bigger than Logical Block Size", MessageBoxType.Error); + return; + } + + if(chkDimensions.Checked.Value) + { + if(chkRound.Checked.Value) + { + if(spDiameter.Value <= 0) + { + MessageBox.Show("Diameter must be bigger than 0", MessageBoxType.Error); + return; + } + } + else + { + if(spHeight.Value <= 0) + { + MessageBox.Show("Height must be bigger than 0", MessageBoxType.Error); + return; + } + + if(spWidth.Value <= 0) + { + MessageBox.Show("Width must be bigger than 0", MessageBoxType.Error); + return; + } + } + + if(spThickness.Value <= 0) + { + MessageBox.Show("Thickness must be bigger than 0", MessageBoxType.Error); + return; + } + } + + if(chkPCI.Checked.Value) + { + if(string.IsNullOrWhiteSpace(txtPCIVendor.Text)) + { + MessageBox.Show("PCI Vendor ID must be set", MessageBoxType.Error); + return; + } + + if(string.IsNullOrWhiteSpace(txtPCIProduct.Text)) + { + MessageBox.Show("PCI Product ID must be set", MessageBoxType.Error); + return; + } + + try + { + if(Convert.ToInt32(txtPCIVendor.Text, 16) < 0 || Convert.ToInt32(txtPCIVendor.Text, 16) > 0xFFFF) + { + MessageBox.Show("PCI Vendor ID must be between 0x0000 and 0xFFFF", MessageBoxType.Error); + return; + } + } + catch(FormatException) + { + MessageBox.Show("PCI Vendor ID must be a number in hexadecimal format", MessageBoxType.Error); + return; + } + catch(OverflowException) + { + MessageBox.Show("PCI Vendor ID must not be negative", MessageBoxType.Error); + return; + } + + try + { + if(Convert.ToInt32(txtPCIProduct.Text, 16) < 0 || Convert.ToInt32(txtPCIProduct.Text, 16) > 0xFFFF) + { + MessageBox.Show("PCI Product ID must be between 0x0000 and 0xFFFF", MessageBoxType.Error); + return; + } + } + catch(FormatException) + { + MessageBox.Show("PCI Product ID must be a number in hexadecimal format", MessageBoxType.Error); + return; + } + catch(OverflowException) + { + MessageBox.Show("PCI Product ID must not be negative", MessageBoxType.Error); + return; + } + } + + if(chkPCMCIA.Checked.Value) + { + if(string.IsNullOrWhiteSpace(txtPCMCIAManufacturer.Text)) + { + MessageBox.Show("PCMCIA Manufacturer Code must be set", MessageBoxType.Error); + return; + } + + if(string.IsNullOrWhiteSpace(txtCardCode.Text)) + { + MessageBox.Show("PCMCIA Card Code must be set", MessageBoxType.Error); + return; + } + + try + { + if(Convert.ToInt32(txtMfgCode.Text, 16) < 0 || Convert.ToInt32(txtMfgCode.Text, 16) > 0xFFFF) + { + MessageBox.Show("PCMCIA Manufacturer Code must be between 0x0000 and 0xFFFF", + MessageBoxType.Error); + return; + } + } + catch(FormatException) + { + MessageBox.Show("PCMCIA Manufacturer Code must be a number in hexadecimal format", + MessageBoxType.Error); + return; + } + catch(OverflowException) + { + MessageBox.Show("PCMCIA Manufacturer Code must not be negative", MessageBoxType.Error); + return; + } + + try + { + if(Convert.ToInt32(txtCardCode.Text, 16) < 0 || Convert.ToInt32(txtCardCode.Text, 16) > 0xFFFF) + { + MessageBox.Show("PCMCIA Card Code must be between 0x0000 and 0xFFFF", MessageBoxType.Error); + return; + } + } + catch(FormatException) + { + MessageBox.Show("PCMCIA Card Code must be a number in hexadecimal format", MessageBoxType.Error); + return; + } + catch(OverflowException) + { + MessageBox.Show("PCMCIA Card Code must not be negative", MessageBoxType.Error); + return; + } + } + + if(chkUSB.Checked.Value) + { + if(string.IsNullOrWhiteSpace(txtUSBVendor.Text)) + { + MessageBox.Show("USB Vendor ID must be set", MessageBoxType.Error); + return; + } + + if(string.IsNullOrWhiteSpace(txtUSBProduct.Text)) + { + MessageBox.Show("USB Product ID must be set", MessageBoxType.Error); + return; + } + + try + { + if(Convert.ToInt32(txtUSBVendor.Text, 16) < 0 || Convert.ToInt32(txtUSBVendor.Text, 16) > 0xFFFF) + { + MessageBox.Show("USB Vendor ID must be between 0x0000 and 0xFFFF", MessageBoxType.Error); + return; + } + } + catch(FormatException) + { + MessageBox.Show("USB Vendor ID must be a number in hexadecimal format", MessageBoxType.Error); + return; + } + catch(OverflowException) + { + MessageBox.Show("USB Vendor ID must not be negative", MessageBoxType.Error); + return; + } + + try + { + if(Convert.ToInt32(txtUSBProduct.Text, 16) < 0 || Convert.ToInt32(txtUSBProduct.Text, 16) > 0xFFFF) + { + MessageBox.Show("USB Product ID must be between 0x0000 and 0xFFFF", MessageBoxType.Error); + return; + } + } + catch(FormatException) + { + MessageBox.Show("USB Product ID must be a number in hexadecimal format", MessageBoxType.Error); + return; + } + catch(OverflowException) + { + MessageBox.Show("USB Product ID must not be negative", MessageBoxType.Error); + return; + } + } + + if(chkDumpHardware.Checked.Value) + if(lstDumpHw.Count < 1) + { + MessageBox.Show("If dump hardware is known at least an entry must be created"); + return; + } + #endregion Sanity checks + + Metadata = new BlockMediaType {Image = new ImageType {Value = txtImage.Text, format = txtFormat.Text}}; + + if(!string.IsNullOrWhiteSpace(txtOffset.Text) && long.TryParse(txtOffset.Text, out ltmp)) + { + Metadata.Image.offsetSpecified = true; + Metadata.Image.offset = long.Parse(txtOffset.Text); + } + + Metadata.Size = long.Parse(txtSize.Text); + Metadata.Checksums = checksums; + Metadata.ContentChecksums = contentChks; + + if(chkSequence.Checked.Value) + { + Metadata.Sequence = new SequenceType + { + MediaTitle = txtMediaTitle.Text, + MediaSequence = (int)spSequence.Value, + TotalMedia = (int)spTotalMedia.Value + }; + if(spSide.Value > 0) + { + Metadata.Sequence.SideSpecified = true; + Metadata.Sequence.Side = (int)spSide.Value; + } + + if(spLayer.Value > 0) + { + Metadata.Sequence.LayerSpecified = true; + Metadata.Sequence.Layer = (int)spLayer.Value; + } + } + + if(!string.IsNullOrWhiteSpace(txtManufacturer.Text)) Metadata.Manufacturer = txtManufacturer.Text; + if(!string.IsNullOrWhiteSpace(txtModel.Text)) Metadata.Model = txtModel.Text; + if(!string.IsNullOrWhiteSpace(txtSerial.Text)) Metadata.Serial = txtSerial.Text; + if(!string.IsNullOrWhiteSpace(txtFirmware.Text)) Metadata.Firmware = txtFirmware.Text; + if(!string.IsNullOrWhiteSpace(txtInterface.Text)) Metadata.Interface = txtInterface.Text; + + Metadata.PhysicalBlockSize = (int)spPhysicalBlockSize.Value; + Metadata.LogicalBlockSize = (int)spLogicalBlockSize.Value; + Metadata.LogicalBlocks = long.Parse(txtBlocks.Text); + Metadata.VariableBlockSize = variableBlockSize; + Metadata.TapeInformation = tapeInformation; + Metadata.Scans = scans; + + if(chkATA.Checked.Value && lstAta.Count == 1) Metadata.ATA = new ATAType {Identify = lstAta[0]}; + + if(chkPCI.Checked.Value) + { + Metadata.PCI = new PCIType + { + VendorID = Convert.ToUInt16(txtPCIVendor.Text, 16), + DeviceID = Convert.ToUInt16(txtPCIProduct.Text, 16) + }; + + if(lstPCIConfiguration.Count == 1) Metadata.PCI.Configuration = lstPCIConfiguration[0]; + + if(lstPCIOptionROM.Count == 1) Metadata.PCI.ExpansionROM = lstPCIOptionROM[0]; + } + + if(chkPCMCIA.Checked.Value) + { + Metadata.PCMCIA = new PCMCIAType(); + + if(lstPCMCIACIS.Count == 1) Metadata.PCMCIA.CIS = lstPCMCIACIS[0]; + + if(!string.IsNullOrWhiteSpace(txtCompliance.Text)) Metadata.PCMCIA.Compliance = txtCompliance.Text; + if(!string.IsNullOrWhiteSpace(txtPCMCIAManufacturer.Text)) + Metadata.PCMCIA.Manufacturer = txtPCMCIAManufacturer.Text; + if(!string.IsNullOrWhiteSpace(txtPCMCIAProductName.Text)) + Metadata.PCMCIA.ProductName = txtPCMCIAProductName.Text; + if(!string.IsNullOrWhiteSpace(txtMfgCode.Text)) + { + Metadata.PCMCIA.ManufacturerCodeSpecified = true; + Metadata.PCMCIA.ManufacturerCode = Convert.ToUInt16(txtMfgCode.Text, 16); + } + + if(!string.IsNullOrWhiteSpace(txtCardCode.Text)) + { + Metadata.PCMCIA.CardCodeSpecified = true; + Metadata.PCMCIA.CardCode = Convert.ToUInt16(txtCardCode.Text, 16); + } + + if(lstAdditionalInformation.Count > 0) + { + List addinfos = new List(); + foreach(StringEntry entry in lstAdditionalInformation) addinfos.Add(entry.str); + Metadata.PCMCIA.AdditionalInformation = addinfos.ToArray(); + } + } + + if(chkSecureDigital.Checked.Value) + { + Metadata.SecureDigital = new SecureDigitalType(); + + if(lstCID.Count == 1) Metadata.SecureDigital.CID = lstCID[0]; + if(lstCSD.Count == 1) Metadata.SecureDigital.CSD = lstCSD[0]; + if(lstECSD.Count == 1) Metadata.MultiMediaCard.ExtendedCSD = lstECSD[0]; + } + + if(chkSCSI.Checked.Value) + { + Metadata.SCSI = new SCSIType(); + + if(lstInquiry.Count == 1) Metadata.SCSI.Inquiry = lstInquiry[0]; + if(lstModeSense.Count == 1) Metadata.SCSI.ModeSense = lstModeSense[0]; + if(lstModeSense10.Count == 1) Metadata.SCSI.ModeSense10 = lstModeSense10[0]; + if(lstLogSense.Count == 1) Metadata.SCSI.LogSense = lstLogSense[0]; + if(lstEVPDs.Count > 0) Metadata.SCSI.EVPD = lstEVPDs.ToArray(); + } + + if(chkUSB.Checked.Value) + { + Metadata.USB = new USBType + { + VendorID = Convert.ToUInt16(txtUSBVendor.Text, 16), + ProductID = Convert.ToUInt16(txtUSBProduct.Text, 16) + }; + + if(lstUSBDescriptors.Count == 1) Metadata.USB.Descriptors = lstUSBDescriptors[0]; + } + + if(chkMAM.Checked.Value && lstMAM.Count == 1) Metadata.MAM = lstMAM[0]; + + if(spHeads.Value > 0 && spCylinders.Value > 0 && spSectors.Value > 0) + { + Metadata.HeadsSpecified = true; + Metadata.CylindersSpecified = true; + Metadata.SectorsPerTrackSpecified = true; + Metadata.Heads = (long)spHeads.Value; + Metadata.Cylinders = (long)spCylinders.Value; + Metadata.SectorsPerTrack = (long)spSectors.Value; + } + + if(lstTracks.Count > 0) Metadata.Track = lstTracks.ToArray(); + + if(!string.IsNullOrWhiteSpace(txtCopyProtection.Text)) Metadata.CopyProtection = txtCopyProtection.Text; + + if(chkDimensions.Checked.Value) + { + Metadata.Dimensions = new DimensionsType(); + if(chkRound.Checked.Value) + { + Metadata.Dimensions.DiameterSpecified = true; + Metadata.Dimensions.Diameter = spDiameter.Value; + } + else + { + Metadata.Dimensions.HeightSpecified = true; + Metadata.Dimensions.WidthSpecified = true; + Metadata.Dimensions.Height = spHeight.Value; + Metadata.Dimensions.Width = spWidth.Value; + } + + Metadata.Dimensions.Thickness = spThickness.Value; + } + + if(lstPartitions.Count > 0) Metadata.FileSystemInformation = lstPartitions.ToArray(); + + if(chkDumpHardware.Checked.Value && lstDumpHw.Count > 0) Metadata.DumpHardwareArray = lstDumpHw.ToArray(); + + if(!string.IsNullOrWhiteSpace(txtMediaType.Text)) Metadata.DiskType = txtMediaType.Text; + if(!string.IsNullOrWhiteSpace(txtMediaSubtype.Text)) Metadata.DiskSubType = txtMediaSubtype.Text; + + Modified = true; + Close(); + } + + class StringEntry + { + public string str; + } + + #region XAML UI elements + #pragma warning disable 0649 + TextBox txtImage; + TextBox txtFormat; + TextBox txtOffset; + TextBox txtSize; + TextBox txtManufacturer; + TextBox txtModel; + TextBox txtSerial; + TextBox txtFirmware; + TextBox txtInterface; + TextBox txtCopyProtection; + TextBox txtMediaType; + TextBox txtMediaSubtype; + CheckBox chkSequence; + Label lblMediaTitle; + TextBox txtMediaTitle; + Label lblSequence; + NumericUpDown spSequence; + Label lblTotalMedia; + NumericUpDown spTotalMedia; + Label lblSide; + NumericUpDown spSide; + Label lblLayer; + NumericUpDown spLayer; + TextBox txtBlocks; + NumericUpDown spPhysicalBlockSize; + NumericUpDown spLogicalBlockSize; + NumericUpDown spCylinders; + NumericUpDown spHeads; + NumericUpDown spSectors; + CheckBox chkDimensions; + CheckBox chkRound; + StackLayout stkDiameter; + NumericUpDown spDiameter; + StackLayout stkHeight; + NumericUpDown spHeight; + StackLayout stkWidth; + NumericUpDown spWidth; + StackLayout stkThickness; + NumericUpDown spThickness; + CheckBox chkATA; + GridView treeATA; + CheckBox chkPCI; + Label lblPCIVendor; + TextBox txtPCIVendor; + Label lblPCIProduct; + TextBox txtPCIProduct; + GroupBox frmPCIConfiguration; + GridView treeConfiguration; + GroupBox frmOptionROM; + GridView treeOptionROM; + CheckBox chkPCMCIA; + CheckBox chkCIS; + GridView treeCIS; + Label lblPCMCIAManufacturer; + Label lblMfgCode; + Label lblPCMCIAProductName; + Label lblCardCode; + Label lblCompliance; + TextBox txtPCMCIAManufacturer; + TextBox txtMfgCode; + TextBox txtPCMCIAProductName; + TextBox txtCardCode; + TextBox txtCompliance; + GroupBox lblAdditionalInformation; + GridView treeAdditionalInformation; + CheckBox chkSecureDigital; + GridView treeCID; + CheckBox chkCSD; + GridView treeCSD; + CheckBox chkECSD; + GridView treeECSD; + CheckBox chkSCSI; + GroupBox frmInquiry; + GridView treeInquiry; + GroupBox frmModeSense; + GridView treeModeSense; + GroupBox frmModeSense10; + GridView treeModeSense10; + GroupBox frmLogSense; + GridView treeLogSense; + GroupBox frmEVPDs; + GridView treeEVPDs; + CheckBox chkUSB; + TextBox txtUSBVendor; + TextBox txtUSBProduct; + GridView treeDescriptors; + CheckBox chkMAM; + GridView treeMAM; + CheckBox chkTracks; + GridView treeTracks; + GridView treePartitions; + Button btnCancelPartition; + Button btnRemovePartition; + Button btnEditPartition; + Button btnApplyPartition; + Button btnAddPartition; + NumericUpDown spPartitionSequence; + TextBox txtPartitionStart; + TextBox txtPartitionEnd; + TextBox txtPartitionType; + TextBox txtPartitionName; + TextBox txtPartitionDescription; + GroupBox frmFilesystems; + GridView treeFilesystems; + CheckBox chkDumpHardware; + GridView treeDumpHardware; + Button btnCancelHardware; + Button btnRemoveHardware; + Button btnEditHardware; + Button btnApplyHardware; + Button btnAddHardware; + GroupBox frmHardware; + TextBox txtHWManufacturer; + TextBox txtHWModel; + TextBox txtHWRevision; + TextBox txtHWFirmware; + TextBox txtHWSerial; + GridView treeExtents; + NumericUpDown spExtentStart; + NumericUpDown spExtentEnd; + TextBox txtDumpName; + TextBox txtDumpVersion; + TextBox txtDumpOS; + Label lblCID; + Label lblUSBVendor; + Label lblUSBProduct; + GroupBox frmDescriptors; + StackLayout stkPartitionFields1; + StackLayout stkPartitionFields2; + #pragma warning restore 0649 + #endregion XAML UI elements + } +} \ No newline at end of file diff --git a/dlgFilesystem.xeto b/dlgFilesystem.xeto new file mode 100644 index 0000000..ddd0485 --- /dev/null +++ b/dlgFilesystem.xeto @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + Bootable + Dirty + + + + + + + + + + + + + + + + + + + Creation date + + + + + + + + Modification date + + + + + + + + Effective date + + + + + + + + Expiration date + + + + + + + + Last backup date + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dlgFilesystem.xeto.cs b/dlgFilesystem.xeto.cs new file mode 100644 index 0000000..ee68b08 --- /dev/null +++ b/dlgFilesystem.xeto.cs @@ -0,0 +1,245 @@ +// +// Author: +// Natalia Portillo claunia@claunia.com +// +// Copyright (c) 2017, © Claunia.com +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in +// the documentation and/or other materials provided with the distribution. +// * Neither the name of the [ORGANIZATION] nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// + +using System; +using Eto.Forms; +using Eto.Serialization.Xaml; +using Schemas; + +namespace apprepodbmgr.Eto +{ + public class dlgFilesystem : Dialog + { + public FileSystemType Metadata; + public bool Modified; + + public dlgFilesystem() + { + XamlReader.Load(this); + Modified = false; + } + + public void FillFields() + { + if(Metadata == null) return; + + if(Metadata.Type != null) txtType.Text = Metadata.Type; + if(Metadata.CreationDateSpecified) + { + chkCreationDate.Checked = true; + cldCreationDate.Enabled = true; + cldCreationDate.Value = Metadata.CreationDate; + } + + if(Metadata.ModificationDateSpecified) + { + chkModificationDate.Checked = true; + cldModificationDate.Enabled = true; + cldModificationDate.Value = Metadata.ModificationDate; + } + + if(Metadata.BackupDateSpecified) + { + chkBackupDate.Checked = true; + cldBackupDate.Enabled = true; + cldBackupDate.Value = Metadata.BackupDate; + } + + spClusterSize.Value = Metadata.ClusterSize; + txtClusters.Text = Metadata.Clusters.ToString(); + if(Metadata.FilesSpecified) txtFiles.Text = Metadata.Files.ToString(); + chkBootable.Checked = Metadata.Bootable; + if(Metadata.VolumeSerial != null) txtSerial.Text = Metadata.VolumeSerial; + if(Metadata.VolumeName != null) txtLabel.Text = Metadata.VolumeName; + if(Metadata.FreeClustersSpecified) txtFreeClusters.Text = Metadata.FreeClusters.ToString(); + chkDirty.Checked = Metadata.Dirty; + if(Metadata.ExpirationDateSpecified) + { + chkExpirationDate.Checked = true; + cldExpirationDate.Enabled = true; + cldExpirationDate.Value = Metadata.ExpirationDate; + } + + if(Metadata.EffectiveDateSpecified) + { + chkEffectiveDate.Checked = true; + cldEffectiveDate.Enabled = true; + cldEffectiveDate.Value = Metadata.EffectiveDate; + } + + if(Metadata.SystemIdentifier != null) txtSysId.Text = Metadata.SystemIdentifier; + if(Metadata.VolumeSetIdentifier != null) txtVolId.Text = Metadata.VolumeSetIdentifier; + if(Metadata.PublisherIdentifier != null) txtPubId.Text = Metadata.PublisherIdentifier; + if(Metadata.DataPreparerIdentifier != null) txtDataId.Text = Metadata.DataPreparerIdentifier; + if(Metadata.ApplicationIdentifier != null) txtAppId.Text = Metadata.ApplicationIdentifier; + } + + protected void OnChkCreationDateToggled(object sender, EventArgs e) + { + cldCreationDate.Enabled = chkCreationDate.Checked.Value; + } + + protected void OnChkModificationDateToggled(object sender, EventArgs e) + { + cldModificationDate.Enabled = chkModificationDate.Checked.Value; + } + + protected void OnChkEffectiveDateToggled(object sender, EventArgs e) + { + cldEffectiveDate.Enabled = chkEffectiveDate.Checked.Value; + } + + protected void OnChkExpirationDateToggled(object sender, EventArgs e) + { + cldExpirationDate.Enabled = chkExpirationDate.Checked.Value; + } + + protected void OnChkBackupDateToggled(object sender, EventArgs e) + { + cldBackupDate.Enabled = chkBackupDate.Checked.Value; + } + + protected void OnBtnCancelClicked(object sender, EventArgs e) + { + Modified = false; + Close(); + } + + protected void OnBtnSaveClicked(object sender, EventArgs e) + { + if(string.IsNullOrWhiteSpace(txtType.Text)) + MessageBox.Show("Filesystem type cannot be empty", MessageBoxType.Error); + + if(spClusterSize.Value < 1) MessageBox.Show("Clusters must be bigger than 0 bytes", MessageBoxType.Error); + + if(!long.TryParse(txtClusters.Text, out long temp)) + MessageBox.Show("Clusters must be a number", MessageBoxType.Error); + + if(temp < 1) MessageBox.Show("Filesystem must have more than 0 clusters", MessageBoxType.Error); + + if(!string.IsNullOrWhiteSpace(txtFiles.Text) && !long.TryParse(txtFiles.Text, out temp)) + MessageBox.Show("Files must be a number, or empty for unknown", MessageBoxType.Error); + + if(!string.IsNullOrWhiteSpace(txtFiles.Text) && temp < 0) + MessageBox.Show("Files must be positive", MessageBoxType.Error); + + if(!string.IsNullOrWhiteSpace(txtFreeClusters.Text) && !long.TryParse(txtFreeClusters.Text, out temp)) + MessageBox.Show("Free clusters must be a number or empty for unknown", MessageBoxType.Error); + + if(!string.IsNullOrWhiteSpace(txtFreeClusters.Text) && temp < 0) + MessageBox.Show("Free clusters must be positive", MessageBoxType.Error); + + Metadata = new FileSystemType {Type = txtType.Text}; + if(chkCreationDate.Checked.Value) + { + Metadata.CreationDateSpecified = true; + Metadata.CreationDate = cldCreationDate.Value.Value; + } + + if(chkModificationDate.Checked.Value) + { + Metadata.ModificationDateSpecified = true; + Metadata.ModificationDate = cldModificationDate.Value.Value; + } + + if(chkBackupDate.Checked.Value) + { + Metadata.BackupDateSpecified = true; + Metadata.BackupDate = cldBackupDate.Value.Value; + } + + Metadata.ClusterSize = (int)spClusterSize.Value; + Metadata.Clusters = long.Parse(txtClusters.Text); + if(!string.IsNullOrWhiteSpace(txtFiles.Text)) + { + Metadata.FilesSpecified = true; + Metadata.Files = long.Parse(txtFiles.Text); + } + + Metadata.Bootable = chkBootable.Checked.Value; + if(!string.IsNullOrWhiteSpace(txtSerial.Text)) Metadata.VolumeSerial = txtSerial.Text; + if(!string.IsNullOrWhiteSpace(txtLabel.Text)) Metadata.VolumeName = txtLabel.Text; + if(!string.IsNullOrWhiteSpace(txtFreeClusters.Text)) + { + Metadata.FreeClustersSpecified = true; + Metadata.FreeClusters = long.Parse(txtFreeClusters.Text); + } + + Metadata.Dirty = chkDirty.Checked.Value; + if(chkExpirationDate.Checked.Value) + { + Metadata.ExpirationDateSpecified = true; + Metadata.ExpirationDate = cldExpirationDate.Value.Value; + } + + if(chkEffectiveDate.Checked.Value) + { + Metadata.EffectiveDateSpecified = true; + Metadata.EffectiveDate = cldEffectiveDate.Value.Value; + } + + if(!string.IsNullOrWhiteSpace(txtSysId.Text)) Metadata.SystemIdentifier = txtSysId.Text; + if(!string.IsNullOrWhiteSpace(txtVolId.Text)) Metadata.VolumeSetIdentifier = txtVolId.Text; + if(!string.IsNullOrWhiteSpace(txtPubId.Text)) Metadata.PublisherIdentifier = txtPubId.Text; + if(!string.IsNullOrWhiteSpace(txtDataId.Text)) Metadata.DataPreparerIdentifier = txtDataId.Text; + if(!string.IsNullOrWhiteSpace(txtAppId.Text)) Metadata.ApplicationIdentifier = txtAppId.Text; + + Modified = true; + Close(); + } + + #region XAML UI elements + #pragma warning disable 0649 + TextBox txtType; + TextBox txtFiles; + CheckBox chkBootable; + CheckBox chkDirty; + NumericUpDown spClusterSize; + TextBox txtClusters; + TextBox txtFreeClusters; + CheckBox chkCreationDate; + DateTimePicker cldCreationDate; + CheckBox chkModificationDate; + DateTimePicker cldModificationDate; + CheckBox chkEffectiveDate; + DateTimePicker cldEffectiveDate; + CheckBox chkExpirationDate; + DateTimePicker cldExpirationDate; + CheckBox chkBackupDate; + DateTimePicker cldBackupDate; + TextBox txtLabel; + TextBox txtSerial; + TextBox txtSysId; + TextBox txtVolId; + TextBox txtPubId; + TextBox txtDataId; + TextBox txtAppId; + #pragma warning restore 0649 + #endregion XAML UI elements + } +} \ No newline at end of file diff --git a/dlgHelp.xeto b/dlgHelp.xeto new file mode 100644 index 0000000..f0677ee --- /dev/null +++ b/dlgHelp.xeto @@ -0,0 +1,11 @@ + + + + +