diff --git a/osrepodbmgr.Eto.Desktop/Program.cs b/osrepodbmgr.Eto.Desktop/Program.cs index 38bafd6..8b160a5 100644 --- a/osrepodbmgr.Eto.Desktop/Program.cs +++ b/osrepodbmgr.Eto.Desktop/Program.cs @@ -28,6 +28,7 @@ using System; using Eto; using Eto.Forms; +using osrepodbmgr.Core; namespace osrepodbmgr.Eto.Desktop { @@ -36,7 +37,9 @@ namespace osrepodbmgr.Eto.Desktop [STAThread] public static void Main(string[] args) { - new Application(Platform.Detect).Run(new MainForm()); + Settings.LoadSettings(); + Context.CheckUnar(); + new Application(Platform.Detect).Run(new frmMain()); } } } diff --git a/osrepodbmgr.Eto.Desktop/packages.config b/osrepodbmgr.Eto.Desktop/packages.config index 7c00dac..b2b9942 100644 --- a/osrepodbmgr.Eto.Desktop/packages.config +++ b/osrepodbmgr.Eto.Desktop/packages.config @@ -1,4 +1,8 @@  + + + + \ No newline at end of file diff --git a/osrepodbmgr.Eto.XamMac2/Program.cs b/osrepodbmgr.Eto.XamMac2/Program.cs index 520d1c1..9e2a704 100644 --- a/osrepodbmgr.Eto.XamMac2/Program.cs +++ b/osrepodbmgr.Eto.XamMac2/Program.cs @@ -28,6 +28,7 @@ using System; using Eto; using Eto.Forms; +using osrepodbmgr.Core; namespace osrepodbmgr.Eto.XamMac2 { @@ -36,7 +37,9 @@ namespace osrepodbmgr.Eto.XamMac2 [STAThread] public static void Main(string[] args) { - new Application(Platforms.XamMac2).Run(new MainForm()); + Settings.LoadSettings(); + Context.CheckUnar(); + new Application(Platforms.XamMac2).Run(new frmMain()); } } } diff --git a/osrepodbmgr.Eto.XamMac2/packages.config b/osrepodbmgr.Eto.XamMac2/packages.config index 7c00dac..47fc874 100644 --- a/osrepodbmgr.Eto.XamMac2/packages.config +++ b/osrepodbmgr.Eto.XamMac2/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file diff --git a/osrepodbmgr.Eto/WrappersForEto.cs b/osrepodbmgr.Eto/WrappersForEto.cs index b0129ab..99958b7 100644 --- a/osrepodbmgr.Eto/WrappersForEto.cs +++ b/osrepodbmgr.Eto/WrappersForEto.cs @@ -1,10 +1,59 @@ using System; +using osrepodbmgr.Core; +using Schemas; + namespace osrepodbmgr.Eto { - public class WrappersForEto + class DBEntryForEto { - public WrappersForEto() + 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; } } } diff --git a/osrepodbmgr.Eto/dlgAdd.xeto b/osrepodbmgr.Eto/dlgAdd.xeto index e309770..e626108 100644 --- a/osrepodbmgr.Eto/dlgAdd.xeto +++ b/osrepodbmgr.Eto/dlgAdd.xeto @@ -1,6 +1,132 @@  - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + oem + + + update + + + + + upgrade + + + files + + + + + source + + + netinstall + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/osrepodbmgr.Eto/dlgAdd.xeto.cs b/osrepodbmgr.Eto/dlgAdd.xeto.cs index d4c1f63..65a5f4a 100644 --- a/osrepodbmgr.Eto/dlgAdd.xeto.cs +++ b/osrepodbmgr.Eto/dlgAdd.xeto.cs @@ -30,14 +30,1145 @@ using System.Collections.Generic; using Eto.Forms; using Eto.Drawing; using Eto.Serialization.Xaml; +using System.Threading; +using osrepodbmgr.Core; +using System.Collections.ObjectModel; +using Schemas; +using System.IO; +using System.Xml.Serialization; +using Newtonsoft.Json; +using System.ComponentModel; namespace osrepodbmgr.Eto { - public class dlgAdd : Panel + public class dlgAdd : Dialog { + Thread thdFindFiles; + Thread thdHashFiles; + Thread thdCheckFiles; + Thread thdAddFiles; + Thread thdPackFiles; + Thread thdOpenArchive; + Thread thdExtractArchive; + Thread thdRemoveTemp; + bool stopped; + ObservableCollection fileView; + ObservableCollection osView; + + class FileEntry + { + public string path { get; set; } + public string hash { get; set; } + public bool known { 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; +#pragma warning restore 0649 + #endregion XAML UI elements + + public delegate void OnAddedOSDelegate(DBEntry os, bool existsInRepo, string pathInRepo); + public event OnAddedOSDelegate OnAddedOS; + 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 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) => { + if(((FileEntry)e.Item).known) + e.BackgroundColor = Colors.Green; + else + e.BackgroundColor = 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; + } + + 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(); + dlgFolder.Title = "Open folder"; + + if(dlgFolder.ShowDialog(this) == DialogResult.Ok) + { + 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; + 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; + thdHashFiles = null; + }); + } + + void HashFilesFinished() + { + Application.Instance.Invoke(delegate + { + lblProgress.Visible = false; + prgProgress.Visible = false; + 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; + + prgProgress.Visible = true; + + thdCheckFiles = new Thread(Workers.CheckDbForFiles); + Workers.Failed += ChkFilesFailed; + Workers.Finished += ChkFilesFinished; + Workers.UpdateProgress += UpdateProgress; + Workers.UpdateProgress2 += UpdateProgress2; + Workers.AddFile += AddFile; + Workers.AddOS += AddOS; + thdCheckFiles.Start(); + }); + } + + void ChkFilesFailed(string text) + { + Application.Instance.Invoke(delegate + { + if(!stopped) + MessageBox.Show(text, MessageBoxType.Error); + if(thdCheckFiles != null) + thdCheckFiles.Abort(); + 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.AddFile -= AddFile; + Workers.AddOS -= AddOS; + thdHashFiles = null; + if(fileView != null) + fileView.Clear(); + if(osView != null) + { + tabOSes.Visible = false; + osView.Clear(); + } + }); + } + + void ChkFilesFinished() + { + Application.Instance.Invoke(delegate + { + if(thdCheckFiles != null) + thdCheckFiles.Abort(); + + Workers.Failed -= ChkFilesFailed; + Workers.Finished -= ChkFilesFinished; + Workers.UpdateProgress -= UpdateProgress; + Workers.UpdateProgress2 -= UpdateProgress2; + Workers.AddFile -= AddFile; + Workers.AddOS -= AddOS; + + thdHashFiles = null; + prgProgress.Visible = false; + btnStop.Visible = false; + btnClose.Visible = true; + btnExit.Enabled = true; + btnPack.Visible = true; + btnPack.Enabled = true; + btnRemoveFile.Visible = 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; + }); + } + + void AddFile(string filename, string hash, bool known) + { + Application.Instance.Invoke(delegate + { + Color color = known ? Colors.Green : Colors.Red; + fileView.Add(new FileEntry { path = filename, hash = hash, known = known }); + btnPack.Enabled |= !known; + }); + } + + void AddOS(DBEntry os, bool existsInRepo, string pathInRepo) + { + Application.Instance.Invoke(delegate + { + Color color = existsInRepo ? Colors.Green : Colors.Red; + 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; + if(fileView != null) + 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; + } + + public void UpdateProgress(string text, string inner, long current, long maximum) + { + Application.Instance.Invoke(delegate + { + if(!string.IsNullOrWhiteSpace(inner)) + lblProgress.Text = inner; + else + lblProgress.Text = text; + if(maximum > 0) + { + prgProgress.Indeterminate = false; + prgProgress.MinValue = 0; + prgProgress.MaxValue = (int)maximum; + prgProgress.Value = (int)current; + } + else + prgProgress.Indeterminate = true; + }); + } + + public void UpdateProgress2(string text, string inner, long current, long maximum) + { + Application.Instance.Invoke(delegate + { + if(!string.IsNullOrWhiteSpace(inner)) + lblProgress2.Text = inner; + else + lblProgress2.Text = text; + if(maximum > 0) + { + 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; + + 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(); + } + + public 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; + if(fileView != null) + fileView.Clear(); + if(osView != null) + { + tabOSes.Visible = false; + osView.Clear(); + } + } + + public 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(); + }); + } + + public void RemoveTempFilesFinished() + { + Application.Instance.Invoke(delegate + { + Workers.Failed -= RemoveTempFilesFailed; + Workers.Finished -= RemoveTempFilesFinished; + Context.path = null; + Context.tmpFolder = null; + RestoreUI(); + }); + } + + void AddToDatabase() + { + btnRemoveFile.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(); + } + + public void AddFilesToDbFinished() + { + Application.Instance.Invoke(delegate + { + if(thdAddFiles != null) + thdAddFiles.Abort(); + + Workers.UpdateProgress -= UpdateProgress; + Workers.Finished -= AddFilesToDbFinished; + Workers.Failed -= AddFilesToDbFailed; + + 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 + + if(OnAddedOS != null) + OnAddedOS(Context.dbInfo, true, System.IO.Path.Combine(osrepodbmgr.Core.Settings.Current.RepositoryPath, + Context.dbInfo.mdid[0].ToString(), + Context.dbInfo.mdid[1].ToString(), + Context.dbInfo.mdid[2].ToString(), + Context.dbInfo.mdid[3].ToString(), + Context.dbInfo.mdid[4].ToString(), + Context.dbInfo.mdid) + ".zip"); + + prgProgress.Visible = false; + btnClose.Enabled = true; + }); + } + + public void AddFilesToDbFailed(string text) + { + Application.Instance.Invoke(delegate + { + if(!stopped) + MessageBox.Show(text, MessageBoxType.Error); + + if(thdAddFiles != null) + thdAddFiles.Abort(); + + Workers.UpdateProgress -= UpdateProgress; + Workers.Finished -= AddFilesToDbFinished; + Workers.Failed -= AddFilesToDbFailed; + + ChkFilesFinished(); + }); + } + + protected void OnBtnPackClicked(object sender, EventArgs e) + { + btnRemoveFile.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(); + } + + public void PackFilesFinished(string text) + { + Application.Instance.Invoke(delegate + { + if(thdPackFiles != null) + thdPackFiles.Abort(); + + Workers.UpdateProgress -= UpdateProgress; + Workers.UpdateProgress2 -= UpdateProgress2; + Workers.FinishedWithText -= PackFilesFinished; + Workers.Failed -= PackFilesFailed; + prgProgress2.Visible = false; + lblProgress2.Visible = false; + + AddToDatabase(); + + MessageBox.Show(text); + }); + } + + public void PackFilesFailed(string text) + { + Application.Instance.Invoke(delegate + { + if(!stopped) + MessageBox.Show(text, MessageBoxType.Error); + + if(thdPackFiles != null) + thdPackFiles.Abort(); + + Workers.UpdateProgress -= UpdateProgress; + Workers.UpdateProgress2 -= UpdateProgress2; + Workers.FinishedWithText -= PackFilesFinished; + Workers.Failed -= PackFilesFailed; + + btnRemoveFile.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(); + dlgFile.Title = "Open archive"; + dlgFile.MultiSelect = false; + + if(dlgFile.ShowDialog(this) == DialogResult.Ok) + { + 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(); + } + } + + public 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; + Workers.Failed -= OpenArchiveFailed; + Workers.Finished -= OpenArchiveFinished; + thdOpenArchive = null; + }); + } + + public 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(); + }); + } + + public 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) + { + btnStop.Visible = false; + lblProgress.Text = "Removing temporary files"; + prgProgress.Indeterminate = true; + Workers.Failed += RemoveTempFilesFailed; + Workers.Finished += RemoveTempFilesFinished; + thdRemoveTemp = new Thread(Workers.RemoveTempFolder); + thdRemoveTemp.Start(); + } + }); + } + + public void ExtractArchiveFinished() + { + Application.Instance.Invoke(delegate + { + if(thdExtractArchive != null) + thdExtractArchive.Abort(); + 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; + + 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(); + _dlgMetadata.Metadata = Context.metadata; + _dlgMetadata.FillFields(); + + _dlgMetadata.ShowModal(this); + + if(_dlgMetadata.Modified) + { + Context.metadata = _dlgMetadata.Metadata; + + if(string.IsNullOrWhiteSpace(txtDeveloper.Text)) + { + 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) + { + 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(System.IO.Path.Combine(filesPath, name)); + fileView.Remove((FileEntry)treeFiles.SelectedItem); + } } } -} +} \ No newline at end of file diff --git a/osrepodbmgr.Eto/dlgBlockMedia.xeto b/osrepodbmgr.Eto/dlgBlockMedia.xeto index e309770..6e35368 100644 --- a/osrepodbmgr.Eto/dlgBlockMedia.xeto +++ b/osrepodbmgr.Eto/dlgBlockMedia.xeto @@ -1,6 +1,405 @@  - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/osrepodbmgr.Eto/dlgBlockMedia.xeto.cs b/osrepodbmgr.Eto/dlgBlockMedia.xeto.cs index ea88ad6..0e4384f 100644 --- a/osrepodbmgr.Eto/dlgBlockMedia.xeto.cs +++ b/osrepodbmgr.Eto/dlgBlockMedia.xeto.cs @@ -27,17 +27,1643 @@ // using System; using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; using Eto.Forms; -using Eto.Drawing; using Eto.Serialization.Xaml; +using Schemas; namespace osrepodbmgr.Eto { - public class dlgBlockMedia : Panel + public class dlgBlockMedia : Dialog { + public BlockMediaType Metadata; + public bool Modified; + + #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 + + PartitionType partitionIter; + FileSystemType filesystemIter; + DumpHardwareType dumpHwIter; + + ObservableCollection lstAta; + ObservableCollection lstPCIConfiguration; + ObservableCollection lstPCIOptionROM; + ObservableCollection lstPCMCIACIS; + ObservableCollection lstCID; + ObservableCollection lstCSD; + ObservableCollection lstECSD; + ObservableCollection lstInquiry; + ObservableCollection lstModeSense; + ObservableCollection lstModeSense10; + ObservableCollection lstLogSense; + ObservableCollection lstEVPDs; + ObservableCollection lstUSBDescriptors; + ObservableCollection lstMAM; + ObservableCollection lstTracks; + ObservableCollection lstPartitions; + ObservableCollection lstDumpHw; + ObservableCollection lstAdditionalInformation; + + class StringEntry + { + public string str; + } + + bool editingPartition; + bool editingDumpHw; + + // Non-editable fields + ChecksumType[] checksums; + BlockSizeType[] variableBlockSize; + TapePartitionType[] tapeInformation; + ScansType scans; + 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 == null ? null : v.Name) }, + HeaderText = "Software" + }); + treeDumpHardware.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Software).Convert(v => v == null ? null : v.Version) }, + HeaderText = "Version" + }); + treeDumpHardware.Columns.Add(new GridColumn + { + DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Software).Convert(v => v == null ? null : 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 + + GridColumn fileColumn = new GridColumn + { + DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Image) }, + HeaderText = "File" + }; + GridColumn sizeColumn = new GridColumn + { + DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Size).Convert(v => v.ToString()) }, + HeaderText = "Size" + }; + + #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; + 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 != null && 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 = string.Format("0x{0:X4}", Metadata.PCI.VendorID); + txtPCIProduct.Text = string.Format("0x{0:X4}", Metadata.PCI.DeviceID); + 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 = string.Format("0x{0:X4}", Metadata.PCMCIA.ManufacturerCode); + if(Metadata.PCMCIA.CardCodeSpecified) + txtCardCode.Text = string.Format("0x{0:X4}", Metadata.PCMCIA.CardCode); + 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 != null && 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.SecureDigital.ExtendedCSD != null) + { + chkECSD.Checked = true; + treeECSD.Visible = true; + lstECSD.Add(Metadata.SecureDigital.ExtendedCSD); + } + } + if(Metadata.SCSI != null && 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 = string.Format("0x{0:X4}", Metadata.USB.VendorID); + txtUSBProduct.Text = string.Format("0x{0:X4}", Metadata.USB.ProductID); + 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; + 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) + { + int temp, temp2; + + if(!int.TryParse(txtPartitionStart.Text, out temp)) + { + MessageBox.Show("Partition start must be a number", MessageBoxType.Error); + return; + } + + if(!int.TryParse(txtPartitionEnd.Text, out 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(); + partitionIter.Sequence = (int)spPartitionSequence.Value; + partitionIter.StartSector = int.Parse(txtPartitionStart.Text); + partitionIter.EndSector = int.Parse(txtPartitionEnd.Text); + partitionIter.Type = txtPartitionType.Text; + partitionIter.Name = txtPartitionName.Text; + partitionIter.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(); + _dlgFilesystem.Metadata = filesystemIter; + _dlgFilesystem.FillFields(); + _dlgFilesystem.ShowModal(this); + + if(_dlgFilesystem.Modified) + { + ((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; + + btnCancelHardware.Visible = false; + btnEditHardware.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(); + dumpHwIter.Manufacturer = txtHWManufacturer.Text; + dumpHwIter.Model = txtHWModel.Text; + dumpHwIter.Revision = txtHWRevision.Text; + dumpHwIter.Firmware = txtHWFirmware.Text; + dumpHwIter.Serial = txtHWSerial.Text; + if(!string.IsNullOrWhiteSpace(txtDumpName.Text) || !string.IsNullOrWhiteSpace(txtDumpVersion.Text) || !string.IsNullOrWhiteSpace(txtDumpOS.Text)) + { + dumpHwIter.Software = new SoftwareType(); + dumpHwIter.Software.Name = txtDumpName.Text; + dumpHwIter.Software.Version = txtDumpVersion.Text; + dumpHwIter.Software.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 = (int)spExtentStart.Value, End = (int)spExtentEnd.Value }); + } + + protected void OnBtnCancelClicked(object sender, EventArgs e) + { + Close(); + } + + protected void OnBtnSaveClicked(object sender, EventArgs e) + { + long ltmp; + + #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 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(); + + Metadata.Image = new Schemas.ImageType(); + Metadata.Image.Value = txtImage.Text; + Metadata.Image.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; + + if(chkSequence.Checked.Value) + { + Metadata.Sequence = new SequenceType(); + Metadata.Sequence.MediaTitle = txtMediaTitle.Text; + Metadata.Sequence.MediaSequence = (int)spSequence.Value; + Metadata.Sequence.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(); + Metadata.ATA.Identify = lstAta[0]; + } + + if(chkPCI.Checked.Value) + { + Metadata.PCI = new PCIType(); + Metadata.PCI.VendorID = Convert.ToUInt16(txtPCIVendor.Text, 16); + Metadata.PCI.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.SecureDigital.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(); + Metadata.USB.VendorID = Convert.ToUInt16(txtUSBVendor.Text, 16); + Metadata.USB.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(); } } -} +} \ No newline at end of file diff --git a/osrepodbmgr.Eto/dlgFilesystem.xeto b/osrepodbmgr.Eto/dlgFilesystem.xeto index e309770..fac59b8 100644 --- a/osrepodbmgr.Eto/dlgFilesystem.xeto +++ b/osrepodbmgr.Eto/dlgFilesystem.xeto @@ -1,6 +1,81 @@  - - - + + + + + + + + + + Bootable + Dirty + + + + + + + + + + + Creation date + + + + Modification date + + + + Effective date + + + + Expiration date + + + + Last backup date + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/osrepodbmgr.Eto/dlgFilesystem.xeto.cs b/osrepodbmgr.Eto/dlgFilesystem.xeto.cs index e788485..a4727a7 100644 --- a/osrepodbmgr.Eto/dlgFilesystem.xeto.cs +++ b/osrepodbmgr.Eto/dlgFilesystem.xeto.cs @@ -26,18 +26,229 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // using System; -using System.Collections.Generic; using Eto.Forms; -using Eto.Drawing; using Eto.Serialization.Xaml; +using Schemas; namespace osrepodbmgr.Eto { - public class dlgFilesystem : Panel + public class dlgFilesystem : Dialog { + public FileSystemType Metadata; + public bool Modified; + + #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 + 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) + { + long temp; + + 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 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(); + Metadata.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(); } } -} +} \ No newline at end of file diff --git a/osrepodbmgr.Eto/dlgHelp.xeto b/osrepodbmgr.Eto/dlgHelp.xeto index e309770..6c66d6c 100644 --- a/osrepodbmgr.Eto/dlgHelp.xeto +++ b/osrepodbmgr.Eto/dlgHelp.xeto @@ -1,6 +1,11 @@  - - - + + + +