Files
Aaru/DiscImageChef.Gui/Forms/frmDump.xeto.cs

684 lines
24 KiB
C#
Raw Normal View History

2018-09-30 22:29:52 +01:00
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
2018-12-29 15:26:00 +00:00
// Filename : frmDump.xeto.cs
2018-09-30 22:29:52 +01:00
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
2018-12-29 15:26:00 +00:00
// Component : Media dump window.
2018-09-30 22:29:52 +01:00
//
// --[ Description ] ----------------------------------------------------------
//
2018-12-29 15:26:00 +00:00
// Implements the media dump GUI window.
2018-09-30 22:29:52 +01:00
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General public License for more details.
//
// You should have received a copy of the GNU General public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
2018-12-29 17:34:38 +00:00
// Copyright © 2011-2019 Natalia Portillo
2018-09-30 22:29:52 +01:00
// ****************************************************************************/
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
2018-09-30 22:29:52 +01:00
using System.Xml.Serialization;
using DiscImageChef.CommonTypes;
2018-11-27 00:09:53 +00:00
using DiscImageChef.CommonTypes.Enums;
2018-09-30 22:29:52 +01:00
using DiscImageChef.CommonTypes.Interfaces;
using DiscImageChef.CommonTypes.Metadata;
using DiscImageChef.Core;
using DiscImageChef.Core.Devices.Dumping;
using DiscImageChef.Core.Logging;
using DiscImageChef.Core.Media.Info;
using DiscImageChef.Devices;
using Eto.Forms;
using Eto.Serialization.Xaml;
using Schemas;
using DeviceInfo = DiscImageChef.Core.Devices.Info.DeviceInfo;
using MediaType = DiscImageChef.CommonTypes.MediaType;
2019-12-25 18:07:05 +00:00
// ReSharper disable UnusedMember.Local
2018-09-30 22:29:52 +01:00
namespace DiscImageChef.Gui.Forms
{
public class frmDump : Form
{
2019-12-25 18:07:05 +00:00
readonly string _devicePath;
Device _dev;
Dump _dumper;
string _outputPrefix;
Resume _resume;
CICMMetadataType _sidecar;
2018-09-30 22:29:52 +01:00
public frmDump(string devicePath, DeviceInfo deviceInfo, ScsiInfo scsiInfo = null)
{
MediaType mediaType;
XamlReader.Load(this);
// Defaults
chkStopOnError.Checked = false;
chkForce.Checked = false;
chkPersistent.Checked = true;
chkResume.Checked = true;
chkTrack1Pregap.Checked = false;
chkSidecar.Checked = true;
chkTrim.Checked = true;
chkExistingMetadata.Checked = false;
stpRetries.Value = 5;
stpSkipped.Value = 512;
2019-12-07 19:54:27 +00:00
if(scsiInfo != null)
mediaType = scsiInfo.MediaType;
2018-09-30 22:29:52 +01:00
else
switch(deviceInfo.Type)
{
case DeviceType.SecureDigital:
mediaType = MediaType.SecureDigital;
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
break;
case DeviceType.MMC:
mediaType = MediaType.MMC;
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
break;
default:
2019-12-07 19:54:27 +00:00
if(deviceInfo.IsPcmcia)
mediaType = MediaType.PCCardTypeII;
else if(deviceInfo.IsCompactFlash)
mediaType = MediaType.CompactFlash;
else
mediaType = MediaType.GENERIC_HDD;
2018-09-30 22:29:52 +01:00
break;
}
ObservableCollection<IWritableImage> lstPlugins = new ObservableCollection<IWritableImage>();
PluginBase plugins = GetPluginBase.Instance;
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
foreach(IWritableImage plugin in
plugins.WritableImages.Values.Where(p => p.SupportedMediaTypes.Contains(mediaType)))
lstPlugins.Add(plugin);
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
cmbFormat.ItemTextBinding = Binding.Property((IWritableImage p) => p.Name);
cmbFormat.ItemKeyBinding = Binding.Property((IWritableImage p) => p.Id.ToString());
cmbFormat.DataStore = lstPlugins;
2019-12-07 19:54:27 +00:00
List<CommonEncodingInfo> encodings = Encoding.GetEncodings().Select(info => new CommonEncodingInfo
{
Name = info.Name, DisplayName = info.GetEncoding().EncodingName
}).ToList();
encodings.AddRange(Claunia.Encoding.Encoding.GetEncodings().Select(info => new CommonEncodingInfo
{
Name = info.Name, DisplayName = info.DisplayName
}));
2018-09-30 22:29:52 +01:00
ObservableCollection<CommonEncodingInfo> lstEncodings = new ObservableCollection<CommonEncodingInfo>();
2019-12-07 19:54:27 +00:00
foreach(CommonEncodingInfo info in encodings.OrderBy(t => t.DisplayName))
lstEncodings.Add(info);
2018-09-30 22:29:52 +01:00
cmbEncoding.ItemTextBinding = Binding.Property((CommonEncodingInfo p) => p.DisplayName);
cmbEncoding.ItemKeyBinding = Binding.Property((CommonEncodingInfo p) => p.Name);
cmbEncoding.DataStore = lstEncodings;
switch(mediaType)
{
case MediaType.CD:
case MediaType.CDDA:
case MediaType.CDG:
case MediaType.CDEG:
case MediaType.CDI:
case MediaType.CDROM:
case MediaType.CDROMXA:
case MediaType.CDPLUS:
case MediaType.CDMO:
case MediaType.CDR:
case MediaType.CDRW:
case MediaType.CDMRW:
case MediaType.VCD:
case MediaType.SVCD:
case MediaType.PCD:
case MediaType.DDCD:
case MediaType.DDCDR:
case MediaType.DDCDRW:
case MediaType.DTSCD:
case MediaType.CDMIDI:
case MediaType.CDV:
case MediaType.CDIREADY:
case MediaType.FMTOWNS:
case MediaType.PS1CD:
case MediaType.PS2CD:
case MediaType.MEGACD:
case MediaType.SATURNCD:
case MediaType.GDROM:
case MediaType.GDR:
case MediaType.MilCD:
case MediaType.SuperCDROM2:
case MediaType.JaguarCD:
case MediaType.ThreeDO:
case MediaType.PCFX:
case MediaType.NeoGeoCD:
case MediaType.CDTV:
case MediaType.CD32:
case MediaType.Playdia:
case MediaType.Pippin:
2019-02-11 20:05:00 +00:00
case MediaType.VideoNow:
case MediaType.VideoNowColor:
case MediaType.VideoNowXp:
2018-09-30 22:29:52 +01:00
chkTrack1Pregap.Visible = true;
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
break;
default:
chkTrack1Pregap.Visible = false;
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
break;
}
2019-12-25 18:07:05 +00:00
_devicePath = devicePath;
2018-09-30 22:29:52 +01:00
}
void OnCmbFormatSelectedIndexChanged(object sender, EventArgs e)
{
txtDestination.Text = "";
if(!(cmbFormat.SelectedValue is IWritableImage plugin))
{
grpOptions.Visible = false;
btnDestination.Enabled = false;
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
return;
}
btnDestination.Enabled = true;
if(!plugin.SupportedOptions.Any())
{
grpOptions.Content = null;
grpOptions.Visible = false;
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
return;
}
grpOptions.Visible = true;
2019-12-07 19:54:27 +00:00
var stkOptions = new StackLayout
{
Orientation = Orientation.Vertical
};
2018-09-30 22:29:52 +01:00
foreach((string name, Type type, string description, object @default) option in plugin.SupportedOptions)
switch(option.type.ToString())
{
2019-12-07 19:54:27 +00:00
case"System.Boolean":
var optBoolean = new CheckBox();
2018-09-30 22:29:52 +01:00
optBoolean.ID = "opt" + option.name;
optBoolean.Text = option.description;
optBoolean.Checked = (bool)option.@default;
stkOptions.Items.Add(optBoolean);
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
break;
2019-12-07 19:54:27 +00:00
case"System.SByte":
case"System.Int16":
case"System.Int32":
case"System.Int64":
var stkNumber = new StackLayout();
2018-09-30 22:29:52 +01:00
stkNumber.Orientation = Orientation.Horizontal;
2019-12-07 19:54:27 +00:00
var optNumber = new NumericStepper();
2018-09-30 22:29:52 +01:00
optNumber.ID = "opt" + option.name;
optNumber.Value = Convert.ToDouble(option.@default);
stkNumber.Items.Add(optNumber);
2019-12-07 19:54:27 +00:00
var lblNumber = new Label();
2018-09-30 22:29:52 +01:00
lblNumber.Text = option.description;
stkNumber.Items.Add(lblNumber);
stkOptions.Items.Add(stkNumber);
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
break;
2019-12-07 19:54:27 +00:00
case"System.Byte":
case"System.UInt16":
case"System.UInt32":
case"System.UInt64":
var stkUnsigned = new StackLayout();
2018-09-30 22:29:52 +01:00
stkUnsigned.Orientation = Orientation.Horizontal;
2019-12-07 19:54:27 +00:00
var optUnsigned = new NumericStepper();
2018-09-30 22:29:52 +01:00
optUnsigned.ID = "opt" + option.name;
optUnsigned.MinValue = 0;
optUnsigned.Value = Convert.ToDouble(option.@default);
stkUnsigned.Items.Add(optUnsigned);
2019-12-07 19:54:27 +00:00
var lblUnsigned = new Label();
2018-09-30 22:29:52 +01:00
lblUnsigned.Text = option.description;
stkUnsigned.Items.Add(lblUnsigned);
stkOptions.Items.Add(stkUnsigned);
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
break;
2019-12-07 19:54:27 +00:00
case"System.Single":
case"System.Double":
var stkFloat = new StackLayout();
2018-09-30 22:29:52 +01:00
stkFloat.Orientation = Orientation.Horizontal;
2019-12-07 19:54:27 +00:00
var optFloat = new NumericStepper();
2018-09-30 22:29:52 +01:00
optFloat.ID = "opt" + option.name;
optFloat.DecimalPlaces = 2;
optFloat.Value = Convert.ToDouble(option.@default);
stkFloat.Items.Add(optFloat);
2019-12-07 19:54:27 +00:00
var lblFloat = new Label();
2018-09-30 22:29:52 +01:00
lblFloat.Text = option.description;
stkFloat.Items.Add(lblFloat);
stkOptions.Items.Add(stkFloat);
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
break;
2019-12-07 19:54:27 +00:00
case"System.Guid":
2018-09-30 22:29:52 +01:00
// TODO
break;
2019-12-07 19:54:27 +00:00
case"System.String":
var stkString = new StackLayout();
2018-09-30 22:29:52 +01:00
stkString.Orientation = Orientation.Horizontal;
2019-12-07 19:54:27 +00:00
var lblString = new Label();
2018-09-30 22:29:52 +01:00
lblString.Text = option.description;
stkString.Items.Add(lblString);
2019-12-07 19:54:27 +00:00
var optString = new TextBox();
2018-09-30 22:29:52 +01:00
optString.ID = "opt" + option.name;
optString.Text = (string)option.@default;
stkString.Items.Add(optString);
stkOptions.Items.Add(stkString);
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
break;
}
grpOptions.Content = stkOptions;
}
void OnBtnDestinationClick(object sender, EventArgs e)
{
2019-12-07 19:54:27 +00:00
if(!(cmbFormat.SelectedValue is IWritableImage plugin))
return;
var dlgDestination = new SaveFileDialog
{
Title = "Choose destination file"
};
2018-09-30 22:29:52 +01:00
dlgDestination.Filters.Add(new FileFilter(plugin.Name, plugin.KnownExtensions.ToArray()));
DialogResult result = dlgDestination.ShowDialog(this);
if(result != DialogResult.Ok)
{
txtDestination.Text = "";
2019-12-25 18:07:05 +00:00
_outputPrefix = null;
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
return;
}
if(string.IsNullOrEmpty(Path.GetExtension(dlgDestination.FileName)))
dlgDestination.FileName += plugin.KnownExtensions.First();
txtDestination.Text = dlgDestination.FileName;
2019-12-07 19:54:27 +00:00
2019-12-25 18:07:05 +00:00
_outputPrefix = Path.Combine(Path.GetDirectoryName(dlgDestination.FileName),
Path.GetFileNameWithoutExtension(dlgDestination.FileName));
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
chkResume.Checked = true;
}
void OnChkSidecarCheckedChanged(object sender, EventArgs e)
{
cmbEncoding.Visible = chkSidecar.Checked.Value;
lblEncoding.Visible = chkSidecar.Checked.Value;
}
void OnChkExistingMetadataCheckedChanged(object sender, EventArgs e)
{
if(chkExistingMetadata.Checked == false)
{
2019-12-25 18:07:05 +00:00
_sidecar = null;
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
return;
}
2019-12-07 19:54:27 +00:00
var dlgMetadata = new OpenFileDialog
{
Title = "Choose existing metadata sidecar", CheckFileExists = true
};
2018-09-30 22:29:52 +01:00
dlgMetadata.Filters.Add(new FileFilter("CICM XML metadata", ".xml"));
DialogResult result = dlgMetadata.ShowDialog(this);
if(result != DialogResult.Ok)
{
chkExistingMetadata.Checked = false;
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
return;
}
2019-12-07 19:54:27 +00:00
var sidecarXs = new XmlSerializer(typeof(CICMMetadataType));
2018-09-30 22:29:52 +01:00
try
{
2019-12-07 19:54:27 +00:00
var sr = new StreamReader(dlgMetadata.FileName);
2019-12-25 18:07:05 +00:00
_sidecar = (CICMMetadataType)sidecarXs.Deserialize(sr);
2018-09-30 22:29:52 +01:00
sr.Close();
}
catch
{
MessageBox.Show("Incorrect metadata sidecar file...", MessageBoxType.Error);
chkExistingMetadata.Checked = false;
}
}
void OnChkResumeCheckedChanged(object sender, EventArgs e)
{
2019-12-07 19:54:27 +00:00
if(chkResume.Checked == false)
return;
2018-09-30 22:29:52 +01:00
2019-12-25 18:07:05 +00:00
if(_outputPrefix != null)
2019-12-07 19:54:27 +00:00
CheckResumeFile();
2018-09-30 22:29:52 +01:00
}
void CheckResumeFile()
{
2019-12-25 18:07:05 +00:00
_resume = null;
2019-12-07 19:54:27 +00:00
var xs = new XmlSerializer(typeof(Resume));
2018-09-30 22:29:52 +01:00
try
{
2019-12-25 18:07:05 +00:00
var sr = new StreamReader(_outputPrefix + ".resume.xml");
_resume = (Resume)xs.Deserialize(sr);
2018-09-30 22:29:52 +01:00
sr.Close();
}
catch
{
MessageBox.Show("Incorrect resume file, cannot use it...", MessageBoxType.Error);
chkResume.Checked = false;
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
return;
}
2019-12-25 18:07:05 +00:00
if(_resume == null ||
_resume.NextBlock <= _resume.LastBlock ||
(_resume.BadBlocks.Count != 0 && !_resume.Tape))
2019-12-07 19:54:27 +00:00
return;
2018-09-30 22:29:52 +01:00
MessageBox.Show("Media already dumped correctly, please choose another destination...",
MessageBoxType.Warning);
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
chkResume.Checked = false;
}
2019-12-07 19:54:27 +00:00
void OnBtnCloseClick(object sender, EventArgs e) => Close();
2018-09-30 22:29:52 +01:00
void OnBtnStopClick(object sender, EventArgs e)
2019-04-20 16:40:12 +01:00
{
btnStop.Enabled = false;
2019-12-25 18:07:05 +00:00
_dumper.Abort();
2019-04-20 16:40:12 +01:00
}
2018-09-30 22:29:52 +01:00
void OnBtnDumpClick(object sender, EventArgs e)
{
txtLog.Text = "";
btnClose.Visible = false;
btnStart.Visible = false;
btnStop.Visible = true;
btnStop.Enabled = true;
stkProgress.Visible = true;
btnDestination.Visible = false;
stkOptions.Visible = false;
UpdateStatus("Opening device...");
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
try
{
2019-12-25 18:07:05 +00:00
_dev = new Device(_devicePath);
2018-09-30 22:29:52 +01:00
2019-12-25 18:07:05 +00:00
if(_dev.IsRemote)
Statistics.AddRemote(_dev.RemoteApplication, _dev.RemoteVersion, _dev.RemoteOperatingSystem,
_dev.RemoteOperatingSystemVersion, _dev.RemoteArchitecture);
2019-12-07 19:54:27 +00:00
2019-12-25 18:07:05 +00:00
if(_dev.Error)
2018-09-30 22:29:52 +01:00
{
2019-12-25 18:07:05 +00:00
StoppingErrorMessage($"Error {_dev.LastError} opening device.");
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
return;
}
}
catch(Exception exception)
{
StoppingErrorMessage($"Exception {exception.Message} opening device.");
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
return;
}
2019-12-25 18:07:05 +00:00
Statistics.AddDevice(_dev);
Statistics.AddCommand("dump-media");
2018-09-30 22:29:52 +01:00
if(!(cmbFormat.SelectedValue is IWritableImage outputFormat))
{
StoppingErrorMessage("Cannot open output plugin.");
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
return;
}
2019-04-21 22:15:39 +01:00
Encoding encoding = null;
2018-09-30 22:29:52 +01:00
if(cmbEncoding.SelectedValue is CommonEncodingInfo encodingInfo)
2019-12-07 19:54:27 +00:00
try
{
encoding = Claunia.Encoding.Encoding.GetEncoding(encodingInfo.Name);
}
2018-09-30 22:29:52 +01:00
catch(ArgumentException)
{
StoppingErrorMessage("Specified encoding is not supported.");
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
return;
}
2019-04-21 22:15:39 +01:00
Dictionary<string, string> parsedOptions = new Dictionary<string, string>();
2018-09-30 22:29:52 +01:00
if(grpOptions.Content is StackLayout stkFormatOptions)
foreach(Control option in stkFormatOptions.Children)
2018-09-30 22:29:52 +01:00
{
string value;
switch(option)
{
case CheckBox optBoolean:
value = optBoolean.Checked?.ToString();
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
break;
case NumericStepper optNumber:
value = optNumber.Value.ToString(CultureInfo.CurrentCulture);
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
break;
case TextBox optString:
value = optString.Text;
2019-12-07 19:54:27 +00:00
2018-09-30 22:29:52 +01:00
break;
default: continue;
}
string key = option.ID.Substring(3);
parsedOptions.Add(key, value);
}
2019-12-25 18:07:05 +00:00
var dumpLog = new DumpLog(_outputPrefix + ".log", _dev);
2019-04-21 21:48:26 +01:00
dumpLog.WriteLine("Output image format: {0}.", outputFormat.Name);
2019-12-25 18:07:05 +00:00
_dumper = new Dump(chkResume.Checked == true, _dev, _devicePath, outputFormat,
(ushort)stpRetries.Value,
chkForce.Checked == true, false, chkPersistent.Checked == true,
chkStopOnError.Checked == true, _resume, dumpLog, encoding, _outputPrefix,
txtDestination.Text, parsedOptions, _sidecar, (uint)stpSkipped.Value,
chkExistingMetadata.Checked == false, chkTrim.Checked == false,
chkTrack1Pregap.Checked == true);
2019-04-21 22:15:39 +01:00
new Thread(DoWork).Start();
}
void DoWork()
{
2019-12-25 18:07:05 +00:00
_dumper.UpdateStatus += UpdateStatus;
_dumper.ErrorMessage += ErrorMessage;
_dumper.StoppingErrorMessage += StoppingErrorMessage;
_dumper.PulseProgress += PulseProgress;
_dumper.InitProgress += InitProgress;
_dumper.UpdateProgress += UpdateProgress;
_dumper.EndProgress += EndProgress;
_dumper.InitProgress2 += InitProgress2;
_dumper.UpdateProgress2 += UpdateProgress2;
_dumper.EndProgress2 += EndProgress2;
2019-12-25 18:07:05 +00:00
_dumper.Start();
2018-09-30 22:29:52 +01:00
2019-12-25 18:07:05 +00:00
_dev.Close();
WorkFinished();
}
2019-12-07 19:54:27 +00:00
void WorkFinished() => Application.Instance.Invoke(() =>
{
2019-12-07 19:54:27 +00:00
btnClose.Visible = true;
btnStop.Visible = false;
stkProgress1.Visible = false;
stkProgress2.Visible = false;
});
2019-12-07 19:54:27 +00:00
void EndProgress2() => Application.Instance.Invoke(() =>
{
2019-12-07 19:54:27 +00:00
stkProgress2.Visible = false;
});
2019-12-07 19:54:27 +00:00
void UpdateProgress2(string text, long current, long maximum) => Application.Instance.Invoke(() =>
{
2019-12-07 19:54:27 +00:00
lblProgress2.Text = text;
prgProgress2.Indeterminate = false;
prgProgress2.MinValue = 0;
if(maximum > int.MaxValue)
{
2019-12-07 19:54:27 +00:00
prgProgress2.MaxValue = (int)(maximum / int.MaxValue);
prgProgress2.Value = (int)(current / int.MaxValue);
}
else
{
prgProgress2.MaxValue = (int)maximum;
prgProgress2.Value = (int)current;
}
});
2019-12-07 19:54:27 +00:00
void InitProgress2() => Application.Instance.Invoke(() =>
{
2019-12-07 19:54:27 +00:00
stkProgress2.Visible = true;
});
2019-12-07 19:54:27 +00:00
void EndProgress() => Application.Instance.Invoke(() =>
{
2019-12-07 19:54:27 +00:00
stkProgress1.Visible = false;
});
2019-12-07 19:54:27 +00:00
void UpdateProgress(string text, long current, long maximum) => Application.Instance.Invoke(() =>
{
2019-12-07 19:54:27 +00:00
lblProgress.Text = text;
prgProgress.Indeterminate = false;
prgProgress.MinValue = 0;
if(maximum > int.MaxValue)
{
2019-12-07 19:54:27 +00:00
prgProgress.MaxValue = (int)(maximum / int.MaxValue);
prgProgress.Value = (int)(current / int.MaxValue);
}
else
{
prgProgress.MaxValue = (int)maximum;
prgProgress.Value = (int)current;
}
});
2019-12-07 19:54:27 +00:00
void InitProgress() => Application.Instance.Invoke(() =>
{
2019-12-07 19:54:27 +00:00
stkProgress1.Visible = true;
});
2019-12-07 19:54:27 +00:00
void PulseProgress(string text) => Application.Instance.Invoke(() =>
{
2019-12-07 19:54:27 +00:00
lblProgress.Text = text;
prgProgress.Indeterminate = true;
});
2019-12-07 19:54:27 +00:00
void StoppingErrorMessage(string text) => Application.Instance.Invoke(() =>
{
2019-12-07 19:54:27 +00:00
ErrorMessage(text);
MessageBox.Show(text, MessageBoxType.Error);
WorkFinished();
});
2019-12-07 19:54:27 +00:00
void ErrorMessage(string text) => Application.Instance.Invoke(() =>
{
2019-12-07 19:54:27 +00:00
txtLog.Append(text + Environment.NewLine, true);
});
2019-12-07 19:54:27 +00:00
void UpdateStatus(string text) => Application.Instance.Invoke(() =>
{
2019-12-07 19:54:27 +00:00
txtLog.Append(text + Environment.NewLine, true);
});
2018-09-30 22:29:52 +01:00
class CommonEncodingInfo
{
public string Name { get; set; }
public string DisplayName { get; set; }
}
#region XAML IDs
2019-12-25 18:07:05 +00:00
// ReSharper disable InconsistentNaming
2018-09-30 22:29:52 +01:00
ComboBox cmbFormat;
TextBox txtDestination;
Button btnDestination;
CheckBox chkStopOnError;
CheckBox chkForce;
CheckBox chkPersistent;
CheckBox chkResume;
CheckBox chkTrack1Pregap;
CheckBox chkSidecar;
CheckBox chkTrim;
CheckBox chkExistingMetadata;
ComboBox cmbEncoding;
GroupBox grpOptions;
NumericStepper stpRetries;
NumericStepper stpSkipped;
Label lblEncoding;
Button btnClose;
Button btnStart;
Button btnStop;
StackLayout stkProgress;
Label lblDestinationLabel;
Label lblDestination;
TextArea txtLog;
StackLayout stkProgress1;
Label lblProgress;
ProgressBar prgProgress;
StackLayout stkProgress2;
Label lblProgress2;
ProgressBar prgProgress2;
StackLayout stkOptions;
2019-12-25 18:07:05 +00:00
// ReSharper restore InconsistentNaming
2018-09-30 22:29:52 +01:00
#endregion
}
}