Code cleanup and reformatting.

This commit is contained in:
2018-07-31 00:14:45 +01:00
parent 978ea811a0
commit ebde6d67e1
5 changed files with 758 additions and 772 deletions

View File

@@ -28,9 +28,10 @@
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
using System;
using Eto;
using Eto.Forms;
using Eto.Drawing;
namespace CICMMetadataEditor.Desktop
{
@@ -39,7 +40,7 @@ namespace CICMMetadataEditor.Desktop
[STAThread]
static void Main(string[] args)
{
new Application(Eto.Platform.Detect).Run(new dlgMetadata());
new Application(Platform.Detect).Run(new dlgMetadata());
}
}
}

View File

@@ -41,16 +41,13 @@ namespace CICMMetadataEditor
{
public class dlgBlockMedia : Dialog
{
// Non-editable fields
ChecksumType[] checksums;
ChecksumType[] contentChks;
DumpHardwareType dumpHwIter;
bool editingDumpHw;
bool editingPartition;
FileSystemType filesystemIter;
ObservableCollection<StringEntry> lstAdditionalInformation;
ObservableCollection<DumpType> lstAta;
ObservableCollection<DumpType> lstCID;
ObservableCollection<DumpType> lstCSD;
@@ -70,7 +67,6 @@ namespace CICMMetadataEditor
ObservableCollection<DumpType> lstUSBDescriptors;
public BlockMediaType Metadata;
public bool Modified;
PartitionType partitionIter;
ScansType scans;
TapePartitionType[] tapeInformation;
@@ -612,7 +608,8 @@ namespace CICMMetadataEditor
spSequence.ToolTip = "Number of this disk in the sequence.";
spTotalMedia.ToolTip = "How many disks make the sequence.";
spSide.ToolTip = "On flippy disks, which side of the disk is represented by this dump.";
spLayer.ToolTip = "On PTP layered disks, which layer of the side of the disk is represented by this dump.";
spLayer.ToolTip =
"On PTP layered disks, which layer of the side of the disk is represented by this dump.";
txtBlocks.ToolTip = "How many individual blocks (sectors) are in this dump.";
spPhysicalBlockSize.ToolTip = "Size of the biggest physical block in bytes.";
spLogicalBlockSize.ToolTip = "Size of the biggest logical block in bytes.";
@@ -721,14 +718,11 @@ namespace CICMMetadataEditor
if(Metadata.PCMCIA.Compliance != null) txtCompliance.Text = Metadata.PCMCIA.Compliance;
if(Metadata.PCMCIA.ManufacturerCodeSpecified)
txtMfgCode.Text =
$"0x{Metadata.PCMCIA.ManufacturerCode:X4}";
txtMfgCode.Text = $"0x{Metadata.PCMCIA.ManufacturerCode:X4}";
if(Metadata.PCMCIA.CardCodeSpecified)
txtCardCode.Text = $"0x{Metadata.PCMCIA.CardCode:X4}";
if(Metadata.PCMCIA.Manufacturer != null)
txtPCMCIAManufacturer.Text = Metadata.PCMCIA.Manufacturer;
if(Metadata.PCMCIA.ProductName != null)
txtPCMCIAProductName.Text = Metadata.PCMCIA.ProductName;
if(Metadata.PCMCIA.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;
@@ -1045,7 +1039,8 @@ namespace CICMMetadataEditor
}
protected void OnBtnEditFilesystemClicked(object sender, EventArgs e)
{/*
{
/*
if(treeFilesystems.SelectedItem == null) return;
filesystemIter = (FileSystemType)treeFilesystems.SelectedItem;
@@ -1061,7 +1056,8 @@ namespace CICMMetadataEditor
}
protected void OnBtnAddFilesystemClicked(object sender, EventArgs e)
{/*
{
/*
dlgFilesystem _dlgFilesystem = new dlgFilesystem();
_dlgFilesystem.ShowModal(this);

View File

@@ -36,9 +36,10 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Xml;
using Eto.Threading;
using System.Xml.Serialization;
using Eto.Forms;
using Eto.Serialization.Xaml;
using Eto.Threading;
using Schemas;
using BorderType = Schemas.BorderType;
@@ -49,17 +50,16 @@ namespace CICMMetadataEditor
AdvertisementType[] adverts;
AudioMediaType[] audiomedias;
BookType[] books;
string currentFile;
LinearMediaType[] linearmedias;
ObservableCollection<StringEntry> lstArchitectures;
ObservableCollection<string> lstArchitecturesTypes;
ObservableCollection<BarcodeEntry> lstBarcodes;
ObservableCollection<string> lstBarcodeTypes;
ObservableCollection<StringEntry> lstCategories;
ObservableCollection<DiscEntry> lstDiscs;
ObservableCollection<DiskEntry> lstDisks;
ObservableCollection<string> lstFilesForMedia;
ObservableCollection<StringEntry> lstKeywords;
ObservableCollection<StringEntry> lstLanguages;
ObservableCollection<string> lstLanguageTypes;
@@ -77,7 +77,6 @@ namespace CICMMetadataEditor
Thread thdDisc;
Thread thdDisk;
UserManualType[] usermanuals;
string currentFile;
public dlgMetadata()
{
@@ -217,8 +216,7 @@ namespace CICMMetadataEditor
try
{
System.Xml.Serialization.XmlSerializer reader =
new System.Xml.Serialization.XmlSerializer(typeof(CICMMetadataType));
XmlSerializer reader = new XmlSerializer(typeof(CICMMetadataType));
FileStream fs = new FileStream(dlgOpen.FileName, FileMode.Open, FileAccess.Read);
metadata = (CICMMetadataType)reader.Deserialize(fs);
fs.Dispose();
@@ -239,11 +237,7 @@ namespace CICMMetadataEditor
protected void OnSaveAsClicked(object sender, EventArgs e)
{
SaveFileDialog dlgSave = new SaveFileDialog
{
CheckFileExists = true,
Title = "Choose new metadata file"
};
SaveFileDialog dlgSave = new SaveFileDialog {CheckFileExists = true, Title = "Choose new metadata file"};
dlgSave.Filters.Add(new FileFilter("Metadata files", ".xml"));
DialogResult result = dlgSave.ShowDialog(this);
@@ -254,11 +248,9 @@ namespace CICMMetadataEditor
void Save(string destination)
{
try
{
System.Xml.Serialization.XmlSerializer writer =
new System.Xml.Serialization.XmlSerializer(typeof(CICMMetadataType));
XmlSerializer writer = new XmlSerializer(typeof(CICMMetadataType));
FileStream fs = new FileStream(destination, FileMode.Create, FileAccess.Write);
writer.Serialize(fs, metadata);
fs.Dispose();
@@ -266,8 +258,7 @@ namespace CICMMetadataEditor
}
catch(Exception)
{
if(Debugger.IsAttached)
throw;
if(Debugger.IsAttached) throw;
MessageBox.Show("Could not save metadata.", MessageBoxType.Error);
}
@@ -287,7 +278,6 @@ namespace CICMMetadataEditor
lstDiscs = new ObservableCollection<DiscEntry>();
lstDisks = new ObservableCollection<DiskEntry>();
treeKeywords.DataStore = lstKeywords;
treeBarcodes.DataStore = lstBarcodes;
treeCategories.DataStore = lstCategories;
@@ -906,69 +896,69 @@ namespace CICMMetadataEditor
thdDisk = new Thread(Workers.AddMedia);
thdDisk.Start();
*/
}
}
protected void OnBtnStopAddDiskClicked(object sender, EventArgs e)
{
thdDisk?.Abort();
stopped = true;
OnDiskAddFailed(null);
}
protected void OnBtnStopAddDiskClicked(object sender, EventArgs e)
{
thdDisk?.Abort();
stopped = true;
OnDiskAddFailed(null);
}
void UpdateDiskProgress1(string text, string inner, long current, long maximum)
{
Application.Instance.Invoke(delegate
{
lblAddDisk1.Text = !string.IsNullOrWhiteSpace(inner) ? inner : text;
if(maximum > 0)
{
if(current < int.MinValue || current > int.MaxValue || maximum < int.MinValue ||
void UpdateDiskProgress1(string text, string inner, long current, long maximum)
{
Application.Instance.Invoke(delegate
{
lblAddDisk1.Text = !string.IsNullOrWhiteSpace(inner) ? inner : text;
if(maximum > 0)
{
if(current < int.MinValue || current > int.MaxValue || maximum < int.MinValue ||
maximum > int.MaxValue)
{
{
current /= 100;
maximum /= 100;
}
}
prgAddDisk1.Indeterminate = false;
prgAddDisk1.MinValue = 0;
prgAddDisk1.MaxValue = (int)maximum;
prgAddDisk1.Value = (int)current;
}
else prgAddDisk1.Indeterminate = true;
});
}
prgAddDisk1.Indeterminate = false;
prgAddDisk1.MinValue = 0;
prgAddDisk1.MaxValue = (int)maximum;
prgAddDisk1.Value = (int)current;
}
else prgAddDisk1.Indeterminate = true;
});
}
void UpdateDiskProgress2(string text, string inner, long current, long maximum)
{
Application.Instance.Invoke(delegate
{
lblAddDisk2.Text = !string.IsNullOrWhiteSpace(inner) ? inner : text;
if(maximum > 0)
{
if(current < int.MinValue || current > int.MaxValue || maximum < int.MinValue ||
void UpdateDiskProgress2(string text, string inner, long current, long maximum)
{
Application.Instance.Invoke(delegate
{
lblAddDisk2.Text = !string.IsNullOrWhiteSpace(inner) ? inner : text;
if(maximum > 0)
{
if(current < int.MinValue || current > int.MaxValue || maximum < int.MinValue ||
maximum > int.MaxValue)
{
{
current /= 100;
maximum /= 100;
}
}
prgAddDisk2.Indeterminate = false;
prgAddDisk2.MinValue = 0;
prgAddDisk2.MaxValue = (int)maximum;
prgAddDisk2.Value = (int)current;
}
else prgAddDisk2.Indeterminate = true;
});
}
prgAddDisk2.Indeterminate = false;
prgAddDisk2.MinValue = 0;
prgAddDisk2.MaxValue = (int)maximum;
prgAddDisk2.Value = (int)current;
}
else prgAddDisk2.Indeterminate = true;
});
}
void OnDiskAddFailed(string text)
{
Application.Instance.Invoke(delegate
{
if(!stopped) MessageBox.Show(text, MessageBoxType.Error);
/* TODO
Context.SelectedFile = "";
*/
void OnDiskAddFailed(string text)
{
Application.Instance.Invoke(delegate
{
if(!stopped) MessageBox.Show(text, MessageBoxType.Error);
/* TODO
Context.SelectedFile = "";
*/
tabGeneral.Visible = true;
tabKeywords.Visible = true;
tabBarcodes.Visible = true;

View File

@@ -41,11 +41,9 @@ namespace CICMMetadataEditor
{
public class dlgOpticalDisc : Dialog
{
// Non-editable fields
ChecksumType[] checksums;
DumpHardwareType dumpHwIter;
bool editingDumpHw;
bool editingPartition;
FileSystemType filesystemIter;
ObservableCollection<DumpType> lstADIP;
@@ -57,7 +55,6 @@ namespace CICMMetadataEditor
ObservableCollection<DumpType> lstDDS;
ObservableCollection<DumpType> lstDI;
ObservableCollection<DumpType> lstDMI;
ObservableCollection<DumpHardwareType> lstDumpHw;
ObservableCollection<DumpType> lstLastRMD;
ObservableCollection<SectorsType> lstLayers;
@@ -82,7 +79,6 @@ namespace CICMMetadataEditor
public bool Modified;
PartitionType partitionIter;
ScansType scans;
TrackType trackIter;
XboxType xbox;
@@ -841,7 +837,8 @@ namespace CICMMetadataEditor
spSequence.ToolTip = "Number of this disc in the sequence.";
spTotalMedia.ToolTip = "How many diskc make the sequence.";
spSide.ToolTip = "On double sided discs, which side of the disc is represented by this dump.";
spLayer.ToolTip = "On PTP layered discs, which layer of the side of the disc is represented by this dump.";
spLayer.ToolTip =
"On PTP layered discs, which layer of the side of the disc is represented by this dump.";
chkDimensions.ToolTip = "If checked, physical dimensions of disk are known.";
chkRound.ToolTip = "If checked, disk is physicaly round.";
spDiameter.ToolTip = "Diameter in milimeters of disk.";
@@ -1271,7 +1268,8 @@ namespace CICMMetadataEditor
}
protected void OnBtnEditFilesystemClicked(object sender, EventArgs e)
{/*
{
/*
if(treeFilesystems.SelectedItem == null) return;
filesystemIter = (FileSystemType)treeFilesystems.SelectedItem;
@@ -1287,7 +1285,8 @@ namespace CICMMetadataEditor
}
protected void OnBtnAddFilesystemClicked(object sender, EventArgs e)
{/*
{
/*
dlgFilesystem _dlgFilesystem = new dlgFilesystem();
_dlgFilesystem.ShowModal(this);