CUERipper revamp

This commit is contained in:
chudov
2010-02-28 21:04:34 +00:00
parent 31048cb63c
commit 749f96ed8a
92 changed files with 6410 additions and 440 deletions

View File

@@ -14,15 +14,17 @@
<OldToolsVersion>2.0</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<ApplicationIcon>cue2.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>..\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -103,15 +105,14 @@
<Project>{6458A13A-30EF-45A9-9D58-E5031B17BEE2}</Project>
<Name>CUETools.Codecs</Name>
</ProjectReference>
<ProjectReference Include="..\CUETools.CTDB\CUETools.CTDB.csproj">
<Project>{AA2A9A7E-45FB-4632-AD85-85B0E556F818}</Project>
<Name>CUETools.CTDB</Name>
</ProjectReference>
<ProjectReference Include="..\CUETools.Processor\CUETools.Processor.csproj">
<Project>{4911BD82-49EF-4858-8B51-5394F86739A4}</Project>
<Name>CUETools.Processor</Name>
</ProjectReference>
<ProjectReference Include="..\CUETools.Ripper.SCSI\CUETools.Ripper.SCSI.csproj">
<Project>{8CF07381-BEA2-4AFC-B3DD-9B2F21C65A3A}</Project>
<Name>CUETools.Ripper.SCSI</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\CUETools.Ripper\CUETools.Ripper.csproj">
<Project>{D2700165-3E77-4B28-928D-551F5FC11954}</Project>
<Name>CUETools.Ripper</Name>
@@ -124,6 +125,10 @@
<Project>{74C2036B-2C9B-4FC8-B7BD-AE81A8DCE533}</Project>
<Name>MusicBrainz</Name>
</ProjectReference>
<ProjectReference Include="..\ProgressODoom\ProgressODoom.csproj">
<Project>{8DD1E84B-0B03-4C0B-9B42-1E49F75E7CB1}</Project>
<Name>ProgressODoom</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="musicbrainz.ico" />
@@ -136,6 +141,8 @@
</ItemGroup>
<ItemGroup>
<Content Include="arok.ico" />
<Content Include="cue2.ico" />
<None Include="Resources\cdrepair.png" />
<None Include="Resources\accuraterip_16.bmp" />
<None Include="Resources\accuraterip.bmp" />
</ItemGroup>

View File

@@ -81,6 +81,13 @@ namespace CUERipper.Properties {
}
}
internal static System.Drawing.Bitmap cdrepair {
get {
object obj = ResourceManager.GetObject("cdrepair", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap freedb {
get {
object obj = ResourceManager.GetObject("freedb", resourceCulture);

View File

@@ -133,4 +133,7 @@
<data name="accuraterip16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\accuraterip_16.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="cdrepair" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\cdrepair.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@@ -33,9 +33,9 @@ namespace CUERipper
this.comboDrives = new System.Windows.Forms.ComboBox();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusCTDB = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusAr = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar();
this.toolStripProgressBar2 = new System.Windows.Forms.ToolStripProgressBar();
this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel();
this.listTracks = new System.Windows.Forms.ListView();
this.Title = new System.Windows.Forms.ColumnHeader();
@@ -50,8 +50,6 @@ namespace CUERipper
this.comboRelease = new System.Windows.Forms.ComboBox();
this.contextMenuStripRelease = new System.Windows.Forms.ContextMenuStrip(this.components);
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.releaseBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.numericWriteOffset = new System.Windows.Forms.NumericUpDown();
this.lblWriteOffset = new System.Windows.Forms.Label();
this.comboBoxEncoder = new System.Windows.Forms.ComboBox();
@@ -60,11 +58,28 @@ namespace CUERipper
this.radioButtonAudioLossless = new System.Windows.Forms.RadioButton();
this.checkBoxEACMode = new System.Windows.Forms.CheckBox();
this.groupBoxSettings = new System.Windows.Forms.GroupBox();
this.labelSecureMode = new System.Windows.Forms.Label();
this.labelEncoderMinMode = new System.Windows.Forms.Label();
this.labelEncoderMaxMode = new System.Windows.Forms.Label();
this.labelEncoderMode = new System.Windows.Forms.Label();
this.trackBarEncoderMode = new System.Windows.Forms.TrackBar();
this.trackBarSecureMode = new System.Windows.Forms.TrackBar();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.releaseBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.progressBarErrors = new ProgressODoom.ProgressBarEx();
this.plainBackgroundPainter1 = new ProgressODoom.PlainBackgroundPainter();
this.styledBorderPainter1 = new ProgressODoom.StyledBorderPainter();
this.plainProgressPainter1 = new ProgressODoom.PlainProgressPainter();
this.gradientGlossPainter1 = new ProgressODoom.GradientGlossPainter();
this.progressBarCD = new ProgressODoom.ProgressBarEx();
this.plainProgressPainter2 = new ProgressODoom.PlainProgressPainter();
this.statusStrip1.SuspendLayout();
this.contextMenuStripRelease.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.releaseBindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericWriteOffset)).BeginInit();
this.groupBoxSettings.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBarEncoderMode)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trackBarSecureMode)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.releaseBindingSource)).BeginInit();
this.SuspendLayout();
//
// comboDrives
@@ -81,9 +96,9 @@ namespace CUERipper
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel1,
this.toolStripStatusCTDB,
this.toolStripStatusAr,
this.toolStripProgressBar1,
this.toolStripProgressBar2,
this.toolStripStatusLabel2});
resources.ApplyResources(this.statusStrip1, "statusStrip1");
this.statusStrip1.Name = "statusStrip1";
@@ -96,8 +111,22 @@ namespace CUERipper
resources.ApplyResources(this.toolStripStatusLabel1, "toolStripStatusLabel1");
this.toolStripStatusLabel1.Spring = true;
//
// toolStripStatusCTDB
//
this.toolStripStatusCTDB.BorderSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Top)
| System.Windows.Forms.ToolStripStatusLabelBorderSides.Right)
| System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom)));
this.toolStripStatusCTDB.BorderStyle = System.Windows.Forms.Border3DStyle.SunkenInner;
this.toolStripStatusCTDB.Image = global::CUERipper.Properties.Resources.cdrepair;
this.toolStripStatusCTDB.Name = "toolStripStatusCTDB";
resources.ApplyResources(this.toolStripStatusCTDB, "toolStripStatusCTDB");
//
// toolStripStatusAr
//
this.toolStripStatusAr.BorderSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Top)
| System.Windows.Forms.ToolStripStatusLabelBorderSides.Right)
| System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom)));
this.toolStripStatusAr.BorderStyle = System.Windows.Forms.Border3DStyle.SunkenInner;
resources.ApplyResources(this.toolStripStatusAr, "toolStripStatusAr");
this.toolStripStatusAr.Name = "toolStripStatusAr";
//
@@ -109,13 +138,6 @@ namespace CUERipper
resources.ApplyResources(this.toolStripProgressBar1, "toolStripProgressBar1");
this.toolStripProgressBar1.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
//
// toolStripProgressBar2
//
this.toolStripProgressBar2.AutoToolTip = true;
this.toolStripProgressBar2.Name = "toolStripProgressBar2";
resources.ApplyResources(this.toolStripProgressBar2, "toolStripProgressBar2");
this.toolStripProgressBar2.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
//
// toolStripStatusLabel2
//
this.toolStripStatusLabel2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
@@ -229,16 +251,6 @@ namespace CUERipper
resources.ApplyResources(this.editToolStripMenuItem, "editToolStripMenuItem");
this.editToolStripMenuItem.Click += new System.EventHandler(this.editToolStripMenuItem_Click);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Image = global::CUERipper.Properties.Resources.cddb;
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
resources.ApplyResources(this.toolStripMenuItem1, "toolStripMenuItem1");
//
// releaseBindingSource
//
this.releaseBindingSource.DataSource = typeof(MusicBrainz.Release);
//
// numericWriteOffset
//
resources.ApplyResources(this.numericWriteOffset, "numericWriteOffset");
@@ -300,31 +312,151 @@ namespace CUERipper
//
// groupBoxSettings
//
this.groupBoxSettings.Controls.Add(this.labelSecureMode);
this.groupBoxSettings.Controls.Add(this.labelEncoderMinMode);
this.groupBoxSettings.Controls.Add(this.labelEncoderMaxMode);
this.groupBoxSettings.Controls.Add(this.labelEncoderMode);
this.groupBoxSettings.Controls.Add(this.trackBarEncoderMode);
this.groupBoxSettings.Controls.Add(this.trackBarSecureMode);
this.groupBoxSettings.Controls.Add(this.radioButtonAudioLossless);
this.groupBoxSettings.Controls.Add(this.comboBoxAudioFormat);
this.groupBoxSettings.Controls.Add(this.checkBoxEACMode);
this.groupBoxSettings.Controls.Add(this.lblWriteOffset);
this.groupBoxSettings.Controls.Add(this.numericWriteOffset);
this.groupBoxSettings.Controls.Add(this.checkBoxEACMode);
this.groupBoxSettings.Controls.Add(this.comboImage);
this.groupBoxSettings.Controls.Add(this.radioButtonAudioLossy);
this.groupBoxSettings.Controls.Add(this.comboBoxEncoder);
this.groupBoxSettings.Controls.Add(this.radioButtonAudioHybrid);
this.groupBoxSettings.Controls.Add(this.numericWriteOffset);
resources.ApplyResources(this.groupBoxSettings, "groupBoxSettings");
this.groupBoxSettings.Name = "groupBoxSettings";
this.groupBoxSettings.TabStop = false;
//
// labelSecureMode
//
resources.ApplyResources(this.labelSecureMode, "labelSecureMode");
this.labelSecureMode.Name = "labelSecureMode";
//
// labelEncoderMinMode
//
resources.ApplyResources(this.labelEncoderMinMode, "labelEncoderMinMode");
this.labelEncoderMinMode.Name = "labelEncoderMinMode";
//
// labelEncoderMaxMode
//
resources.ApplyResources(this.labelEncoderMaxMode, "labelEncoderMaxMode");
this.labelEncoderMaxMode.Name = "labelEncoderMaxMode";
//
// labelEncoderMode
//
resources.ApplyResources(this.labelEncoderMode, "labelEncoderMode");
this.labelEncoderMode.Name = "labelEncoderMode";
//
// trackBarEncoderMode
//
resources.ApplyResources(this.trackBarEncoderMode, "trackBarEncoderMode");
this.trackBarEncoderMode.LargeChange = 1;
this.trackBarEncoderMode.Name = "trackBarEncoderMode";
this.trackBarEncoderMode.Scroll += new System.EventHandler(this.trackBarEncoderMode_Scroll);
//
// trackBarSecureMode
//
this.trackBarSecureMode.LargeChange = 3;
resources.ApplyResources(this.trackBarSecureMode, "trackBarSecureMode");
this.trackBarSecureMode.Maximum = 2;
this.trackBarSecureMode.Name = "trackBarSecureMode";
this.trackBarSecureMode.Scroll += new System.EventHandler(this.trackBarSecureMode_Scroll);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Image = global::CUERipper.Properties.Resources.cddb;
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
resources.ApplyResources(this.toolStripMenuItem1, "toolStripMenuItem1");
//
// releaseBindingSource
//
this.releaseBindingSource.DataSource = typeof(MusicBrainz.Release);
//
// progressBarErrors
//
this.progressBarErrors.BackgroundPainter = this.plainBackgroundPainter1;
this.progressBarErrors.BorderPainter = this.styledBorderPainter1;
resources.ApplyResources(this.progressBarErrors, "progressBarErrors");
this.progressBarErrors.MarqueePercentage = 25;
this.progressBarErrors.MarqueeSpeed = 30;
this.progressBarErrors.MarqueeStep = 1;
this.progressBarErrors.Maximum = 100;
this.progressBarErrors.Minimum = 0;
this.progressBarErrors.Name = "progressBarErrors";
this.progressBarErrors.ProgressPadding = 0;
this.progressBarErrors.ProgressPainter = this.plainProgressPainter1;
this.progressBarErrors.ProgressType = ProgressODoom.ProgressType.Smooth;
this.progressBarErrors.ShowPercentage = false;
this.progressBarErrors.Value = 10;
//
// plainBackgroundPainter1
//
this.plainBackgroundPainter1.Color = System.Drawing.SystemColors.Control;
this.plainBackgroundPainter1.GlossPainter = null;
//
// styledBorderPainter1
//
this.styledBorderPainter1.Border3D = System.Windows.Forms.Border3DStyle.Etched;
//
// plainProgressPainter1
//
this.plainProgressPainter1.Color = System.Drawing.Color.Red;
this.plainProgressPainter1.GlossPainter = this.gradientGlossPainter1;
this.plainProgressPainter1.LeadingEdge = System.Drawing.Color.Transparent;
this.plainProgressPainter1.ProgressBorderPainter = null;
//
// gradientGlossPainter1
//
this.gradientGlossPainter1.AlphaHigh = 235;
this.gradientGlossPainter1.AlphaLow = 0;
this.gradientGlossPainter1.Angle = 90F;
this.gradientGlossPainter1.Color = System.Drawing.SystemColors.Control;
this.gradientGlossPainter1.PercentageCovered = 100;
this.gradientGlossPainter1.Style = ProgressODoom.GlossStyle.Top;
this.gradientGlossPainter1.Successor = null;
//
// progressBarCD
//
this.progressBarCD.BackgroundPainter = this.plainBackgroundPainter1;
this.progressBarCD.BorderPainter = this.styledBorderPainter1;
resources.ApplyResources(this.progressBarCD, "progressBarCD");
this.progressBarCD.MarqueePercentage = 25;
this.progressBarCD.MarqueeSpeed = 30;
this.progressBarCD.MarqueeStep = 1;
this.progressBarCD.Maximum = 100;
this.progressBarCD.Minimum = 0;
this.progressBarCD.Name = "progressBarCD";
this.progressBarCD.ProgressPadding = 0;
this.progressBarCD.ProgressPainter = this.plainProgressPainter2;
this.progressBarCD.ProgressType = ProgressODoom.ProgressType.Smooth;
this.progressBarCD.ShowPercentage = true;
this.progressBarCD.Value = 10;
//
// plainProgressPainter2
//
this.plainProgressPainter2.Color = System.Drawing.Color.Lime;
this.plainProgressPainter2.GlossPainter = this.gradientGlossPainter1;
this.plainProgressPainter2.LeadingEdge = System.Drawing.Color.Transparent;
this.plainProgressPainter2.ProgressBorderPainter = null;
//
// frmCUERipper
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.progressBarErrors);
this.Controls.Add(this.progressBarCD);
this.Controls.Add(this.groupBoxSettings);
this.Controls.Add(this.comboRelease);
this.Controls.Add(this.buttonPause);
this.Controls.Add(this.listTracks);
this.Controls.Add(this.buttonAbort);
this.Controls.Add(this.buttonGo);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.buttonAbort);
this.Controls.Add(this.comboDrives);
this.Controls.Add(this.buttonPause);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "frmCUERipper";
@@ -334,10 +466,12 @@ namespace CUERipper
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.contextMenuStripRelease.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.releaseBindingSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericWriteOffset)).EndInit();
this.groupBoxSettings.ResumeLayout(false);
this.groupBoxSettings.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBarEncoderMode)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.trackBarSecureMode)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.releaseBindingSource)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -349,7 +483,6 @@ namespace CUERipper
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar1;
private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar2;
private System.Windows.Forms.ListView listTracks;
private System.Windows.Forms.ColumnHeader TrackNo;
private System.Windows.Forms.ColumnHeader Title;
@@ -375,6 +508,20 @@ namespace CUERipper
private System.Windows.Forms.RadioButton radioButtonAudioLossless;
private System.Windows.Forms.CheckBox checkBoxEACMode;
private System.Windows.Forms.GroupBox groupBoxSettings;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusCTDB;
private System.Windows.Forms.TrackBar trackBarEncoderMode;
private System.Windows.Forms.Label labelEncoderMode;
private System.Windows.Forms.Label labelEncoderMaxMode;
private System.Windows.Forms.Label labelEncoderMinMode;
private System.Windows.Forms.TrackBar trackBarSecureMode;
private System.Windows.Forms.Label labelSecureMode;
private ProgressODoom.ProgressBarEx progressBarErrors;
private ProgressODoom.StyledBorderPainter styledBorderPainter1;
private ProgressODoom.PlainProgressPainter plainProgressPainter1;
private ProgressODoom.PlainBackgroundPainter plainBackgroundPainter1;
private ProgressODoom.GradientGlossPainter gradientGlossPainter1;
private ProgressODoom.ProgressBarEx progressBarCD;
private ProgressODoom.PlainProgressPainter plainProgressPainter2;
}
}

View File

@@ -5,16 +5,17 @@ using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.Configuration;
using CUETools.AccurateRip;
using CUETools.CTDB;
using CUETools.CDImage;
using CUETools.Codecs;
using CUETools.Processor;
using CUETools.Ripper;
using CUETools.Ripper.SCSI;
using MusicBrainz;
using Freedb;
@@ -23,11 +24,11 @@ namespace CUERipper
public partial class frmCUERipper : Form
{
private Thread _workThread = null;
private CDDriveReader _reader = null;
private ICDRipper _reader = null;
private StartStop _startStop;
private CUEConfig _config;
private string _format;
private CUESheet _cueSheet;
private CUESheet metadata, cueSheet;
private string _pathOut;
private string _pathFormat;
string _defaultLosslessFormat, _defaultLossyFormat, _defaultHybridFormat;
@@ -69,19 +70,31 @@ namespace CUERipper
//if (crc0a != crc0b) // || crc1a != crc1b || crc2a != crc2b)
//{
//}
SetupControls();
SettingsReader sr = new SettingsReader("CUERipper", "settings.txt", Application.ExecutablePath);
_config.Load(sr);
_defaultLosslessFormat = sr.Load("DefaultLosslessFormat") ?? "flac";
_defaultLossyFormat = sr.Load("DefaultLossyFormat") ?? "mp3";
_defaultHybridFormat = sr.Load("DefaultHybridFormat") ?? "lossy.flac";
_config.createEACLOG = sr.LoadBoolean("CreateEACLOG") ?? false;
_config.preserveHTOA = sr.LoadBoolean("PreserveHTOA") ?? false;
_config.createM3U = sr.LoadBoolean("CreateM3U") ?? true;
//_config.createEACLOG = sr.LoadBoolean("CreateEACLOG") ?? true;
//_config.preserveHTOA = sr.LoadBoolean("PreserveHTOA") ?? false;
//_config.createM3U = sr.LoadBoolean("CreateM3U") ?? true;
_pathFormat = sr.Load("PathFormat") ?? "%music%\\%artist%\\[%year% - ]%album%\\%artist% - %album%.cue";
checkBoxEACMode.Checked = _config.createEACLOG;
SelectedOutputAudioType = (AudioEncoderType?)sr.LoadInt32("OutputAudioType", null, null) ?? AudioEncoderType.Lossless;
comboBoxAudioFormat.SelectedIndex = sr.LoadInt32("ComboCodec", 0, comboBoxAudioFormat.Items.Count - 1) ?? 0;
comboImage.SelectedIndex = sr.LoadInt32("ComboImage", 0, comboImage.Items.Count - 1) ?? 0;
trackBarSecureMode.Value = sr.LoadInt32("SecureMode", 0, trackBarSecureMode.Maximum - 1) ?? 1;
trackBarSecureMode_Scroll(this, new EventArgs());
//string encoderName = sr.Load("EncoderName");
//if (encoderName != null)
// foreach (object item in comboBoxEncoder.Items)
// {
// CUEToolsUDC encoder = item as CUEToolsUDC;
// if (encoder.Name != encoderName) continue;
// comboBoxEncoder.SelectedItem = encoder;
// break;
// }
UpdateDrives();
}
@@ -119,18 +132,25 @@ namespace CUERipper
private void UpdateDrives()
{
buttonGo.Enabled = false;
foreach (object item in comboDrives.Items)
{
ICDRipper drive = item as ICDRipper;
if (drive != null)
drive.Close();
}
comboDrives.Items.Clear();
comboRelease.Items.Clear();
listTracks.Items.Clear();
foreach (char drive in CDDriveReader.DrivesAvailable())
foreach (char drive in CDDrivesList.DrivesAvailable())
{
CDDriveReader reader = new CDDriveReader();
ICDRipper reader = Activator.CreateInstance(CUEProcessorPlugins.ripper) as ICDRipper;
string arName = null;
int driveOffset;
try
{
reader.Open(drive);
arName = reader.ARName;
reader.Close();
}
catch (Exception ex)
{
@@ -165,12 +185,12 @@ namespace CUERipper
buttonGo.Visible = buttonGo.Enabled = !running;
toolStripStatusLabel1.Text = String.Empty;
toolStripProgressBar1.Value = 0;
toolStripProgressBar2.Value = 0;
progressBarErrors.Value = 0;
progressBarCD.Value = 0;
}
private void CDReadProgress(object sender, ReadProgressArgs e)
private void CheckStop()
{
CDDriveReader audioSource = (CDDriveReader)sender;
lock (_startStop)
{
if (_startStop._stop)
@@ -188,37 +208,81 @@ namespace CUERipper
Monitor.Wait(_startStop);
}
}
}
private void UploadProgress(object sender, Krystalware.UploadHelper.UploadProgressEventArgs e)
{
CheckStop();
this.BeginInvoke((MethodInvoker)delegate()
{
toolStripStatusLabel1.Text = e.uri;
toolStripProgressBar1.Value = Math.Max(0, Math.Min(100, (int)(e.percent * 100)));
});
}
private void CDReadProgress(object sender, ReadProgressArgs e)
{
CheckStop();
ICDRipper audioSource = sender as ICDRipper;
int processed = e.Position - e.PassStart;
TimeSpan elapsed = DateTime.Now - e.PassTime;
double speed = elapsed.TotalSeconds > 0 ? processed / elapsed.TotalSeconds / 75 : 1.0;
double percentDisk = (double)(e.PassStart + (processed + e.Pass * (e.PassEnd - e.PassStart)) / (audioSource.CorrectionQuality + 1)) / audioSource.TOC.AudioLength;
double percentTrck = (double)(e.Position - e.PassStart) / (e.PassEnd - e.PassStart);
string status = string.Format("Ripping @{0:00.00}x {1}", speed, e.Pass > 0 ? " (Retry " + e.Pass.ToString() + ")" : "");
this.BeginInvoke((MethodInvoker)delegate()
{
//Color color = ColorTranslator.FromWin32(e.ErrorsCount == 0 || e.Position == 0 ? (byte)0 : (byte)(Math.Log(1 + e.ErrorsCount / e.Position, 2) * 255));
toolStripStatusLabel1.Text = status;
toolStripProgressBar1.Value = Math.Max(0, Math.Min(100, (int)(percentTrck * 100)));
//toolStripProgressBar1.ProgressBar.Style = ProgressBarStyle.Blocks;
toolStripProgressBar2.Value = Math.Max(0, Math.Min(100, (int)(percentDisk * 100)));
//if (e.ErrorsCount == 0 || e.Position == 0)
//toolStripProgressBar3.Value = 0;
//else
//toolStripProgressBar3.Value = Math.Min(100, (int)(100 + Math.Log10(e.ErrorsCount / e.Position / 4 / 588) * 100));
progressBarErrors.Maximum = (int)(Math.Log(e.PassEnd - e.PassStart + 1) * 10);
progressBarErrors.Value = Math.Min(progressBarErrors.Maximum, (int)(Math.Log(e.ErrorsCount + 1) * 10));
progressBarErrors.Enabled = e.Pass >= audioSource.CorrectionQuality;
progressBarCD.Maximum = (int) audioSource.TOC.AudioLength;
progressBarCD.Value = Math.Max(0, Math.Min(progressBarCD.Maximum, (int)e.PassStart + (e.PassEnd - e.PassStart) * (Math.Min(e.Pass, audioSource.CorrectionQuality) + 1) / (audioSource.CorrectionQuality + 1)));
});
}
private void Rip(object o)
{
CDDriveReader audioSource = (CDDriveReader)o;
ICDRipper audioSource = o as ICDRipper;
audioSource.ReadProgress += new EventHandler<ReadProgressArgs>(CDReadProgress);
audioSource.DriveOffset = (int)numericWriteOffset.Value;
try
{
_cueSheet.Go();
cueSheet.Go();
bool submit = cueSheet.CTDB.AccResult == HttpStatusCode.NotFound ||
cueSheet.CTDB.AccResult == HttpStatusCode.OK;
//_cueSheet.CTDB.AccResult == HttpStatusCode.NoContent;
DBEntry confirm = null;
submit &= audioSource.CorrectionQuality > 0;
foreach (DBEntry entry in cueSheet.CTDB.Entries)
if (!entry.hasErrors)
confirm = entry;
int start = (int)cueSheet.TOC[cueSheet.TOC.FirstAudio][0].Start;
for (int iSector = 0; iSector < (int)cueSheet.TOC.AudioLength; iSector++)
if (audioSource.Errors[start + iSector])
submit = false;
if (submit)
{
if (confirm != null)
cueSheet.CTDB.Confirm(confirm);
else
cueSheet.CTDB.Submit(
(int)cueSheet.ArVerify.WorstConfidence() + 1,
(int)cueSheet.ArVerify.WorstTotal() + 1,
cueSheet.Artist,
cueSheet.Title);
}
//CUESheet.WriteText(_pathOut, _cueSheet.CUESheetContents(_style));
//CUESheet.WriteText(Path.ChangeExtension(_pathOut, ".log"), _cueSheet.LOGContents());
}
@@ -238,6 +302,8 @@ namespace CUERipper
}
#endif
audioSource.ReadProgress -= new EventHandler<ReadProgressArgs>(CDReadProgress);
audioSource.Close();
audioSource.Open(audioSource.Path[0]);
_workThread = null;
this.BeginInvoke((MethodInvoker)delegate()
{
@@ -250,18 +316,20 @@ namespace CUERipper
if (_reader == null)
return;
cueSheet.CopyMetadata(metadata);
_format = (string)comboBoxAudioFormat.SelectedItem;
_cueSheet.OutputStyle = comboImage.SelectedIndex == 0 ? CUEStyle.SingleFileWithCUE :
cueSheet.OutputStyle = comboImage.SelectedIndex == 0 ? CUEStyle.SingleFileWithCUE :
CUEStyle.GapsAppended;
_pathOut = _cueSheet.GenerateUniqueOutputPath(_pathFormat,
_cueSheet.OutputStyle == CUEStyle.SingleFileWithCUE ? "." + _format : ".cue",
_pathOut = cueSheet.GenerateUniqueOutputPath(_pathFormat,
cueSheet.OutputStyle == CUEStyle.SingleFileWithCUE ? "." + _format : ".cue",
CUEAction.Encode, null);
if (_pathOut == "")
{
MessageBox.Show(this, "Output path generation failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_cueSheet.GenerateFilenames(SelectedOutputAudioType, _format, _pathOut);
cueSheet.GenerateFilenames(SelectedOutputAudioType, _format, _pathOut);
_reader.CorrectionQuality = trackBarSecureMode.Value;
_workThread = new Thread(Rip);
_workThread.Priority = ThreadPriority.BelowNormal;
@@ -285,7 +353,7 @@ namespace CUERipper
if (e.ListItem is string)
return;
ReleaseInfo r = (ReleaseInfo)(e.ListItem);
e.Value = string.Format("{0}{1} - {2}", r.cueSheet.Year != "" ? r.cueSheet.Year + ": " : "", r.cueSheet.Artist, r.cueSheet.Title);
e.Value = string.Format("{0}{1} - {2}", r.metadata.Year != "" ? r.metadata.Year + ": " : "", r.metadata.Artist, r.metadata.Title);
}
private void UpdateRelease()
@@ -293,11 +361,11 @@ namespace CUERipper
listTracks.Items.Clear();
if (comboRelease.SelectedItem == null || comboRelease.SelectedItem is string)
return;
_cueSheet = ((ReleaseInfo)comboRelease.SelectedItem).cueSheet;
metadata = ((ReleaseInfo)comboRelease.SelectedItem).metadata;
for (int i = 1; i <= _reader.TOC.TrackCount; i++)
{
listTracks.Items.Add(new ListViewItem(new string[] {
_reader.TOC[i].IsAudio ? _cueSheet.Tracks[i - _reader.TOC.FirstAudio].Title : "Data track",
_reader.TOC[i].IsAudio ? metadata.Tracks[i - _reader.TOC.FirstAudio].Title : "Data track",
_reader.TOC[i].Number.ToString(),
_reader.TOC[i].StartMSF,
_reader.TOC[i].LengthMSF }));
@@ -311,71 +379,60 @@ namespace CUERipper
private void MusicBrainz_LookupProgress(object sender, XmlRequestEventArgs e)
{
CheckStop();
//_progress.percentDisk = (1.0 + _progress.percentDisk) / 2;
//_progress.input = e.Uri.ToString();
lock (_startStop)
{
if (_startStop._stop)
{
_startStop._stop = false;
_startStop._pause = false;
throw new StopException();
}
if (_startStop._pause)
{
this.BeginInvoke((MethodInvoker)delegate()
{
toolStripStatusLabel1.Text = "Paused...";
});
Monitor.Wait(_startStop);
}
}
this.BeginInvoke((MethodInvoker)delegate()
{
toolStripStatusLabel1.Text = "Looking up album via " + (e == null ? "FreeDB" : "MusicBrainz");
toolStripProgressBar1.Value = 0;
toolStripProgressBar2.Value = (100 + 2 * toolStripProgressBar2.Value) / 3;
toolStripProgressBar1.Value = (100 + 2 * toolStripProgressBar1.Value) / 3;
});
}
private ReleaseInfo CreateCUESheet(CDDriveReader audioSource, Release release, CDEntry cdEntry)
private ReleaseInfo CreateCUESheet(ICDRipper audioSource, Release release, CDEntry cdEntry)
{
ReleaseInfo r = new ReleaseInfo();
r.cueSheet = new CUESheet(_config);
r.cueSheet.OpenCD(audioSource);
//r.cueSheet.WriteOffset =
General.SetCUELine(r.cueSheet.Attributes, "REM", "GENRE", "", true);
General.SetCUELine(r.cueSheet.Attributes, "REM", "DATE", "", false);
General.SetCUELine(r.cueSheet.Attributes, "REM", "DISCID", AccurateRipVerify.CalculateCDDBId(audioSource.TOC), false);
General.SetCUELine(r.cueSheet.Attributes, "REM", "COMMENT", _config.createEACLOG ? "ExactAudioCopy v0.99pb4" : audioSource.RipperVersion, true);
ReleaseInfo r = new ReleaseInfo(cueSheet);
General.SetCUELine(r.metadata.Attributes, "REM", "GENRE", "", true);
General.SetCUELine(r.metadata.Attributes, "REM", "DATE", "", false);
if (release != null)
{
r.cueSheet.FillFromMusicBrainz(release);
r.metadata.FillFromMusicBrainz(release);
r.bitmap = Properties.Resources.musicbrainz;
}
else if (cdEntry != null)
{
r.cueSheet.FillFromFreedb(cdEntry);
r.metadata.FillFromFreedb(cdEntry);
r.bitmap = Properties.Resources.freedb;
}
else
{
r.cueSheet.Artist = "Unknown Artist";
r.cueSheet.Title = "Unknown Title";
r.metadata.Artist = "Unknown Artist";
r.metadata.Title = "Unknown Title";
for (int i = 0; i < audioSource.TOC.AudioTracks; i++)
r.cueSheet.Tracks[i].Title = string.Format("Track {0:00}", i + 1);
r.metadata.Tracks[i].Title = string.Format("Track {0:00}", i + 1);
}
if (r.cueSheet.Genre == "") r.cueSheet.Genre = "";
if (r.cueSheet.Year == "") r.cueSheet.Year = "";
r.cueSheet.Action = CUEAction.Encode;
r.cueSheet.UseAccurateRip();
//r.cueSheet.ArVerify.ContactAccurateRip(AccurateRipVerify.CalculateAccurateRipId(audioSource.TOC));
if (r.metadata.Genre == "") r.metadata.Genre = "";
if (r.metadata.Year == "") r.metadata.Year = "";
return r;
}
private void Lookup(object o)
{
CDDriveReader audioSource = (CDDriveReader)o;
ICDRipper audioSource = o as ICDRipper;
cueSheet = new CUESheet(_config);
cueSheet.OpenCD(audioSource);
cueSheet.CTDB.UploadHelper.onProgress += new EventHandler<Krystalware.UploadHelper.UploadProgressEventArgs>(UploadProgress);
cueSheet.Action = CUEAction.Encode;
this.BeginInvoke((MethodInvoker)delegate() { toolStripStatusLabel1.Text = "Contacting AccurateRip database..."; });
cueSheet.UseAccurateRip();
this.BeginInvoke((MethodInvoker)delegate() { toolStripStatusLabel1.Text = "Contacting CTDB database..."; });
cueSheet.UseCUEToolsDB(true, "CUERipper 205: " + _reader.ARName);
this.BeginInvoke((MethodInvoker)delegate() { toolStripStatusLabel1.Text = "Looking album info..."; });
General.SetCUELine(cueSheet.Attributes, "REM", "DISCID", AccurateRipVerify.CalculateCDDBId(audioSource.TOC), false);
General.SetCUELine(cueSheet.Attributes, "REM", "COMMENT", _config.createEACLOG ? "ExactAudioCopy v0.99pb4" : audioSource.RipperVersion, true);
ReleaseQueryParameters p = new ReleaseQueryParameters();
p.DiscId = audioSource.TOC.MusicBrainzId;
@@ -479,16 +536,19 @@ namespace CUERipper
{
SetupControls();
comboRelease.SelectedIndex = 0;
CUESheet cueSheet = ((ReleaseInfo)comboRelease.SelectedItem).cueSheet;
toolStripStatusAr.Visible = cueSheet.ArVerify.ARStatus == null;
toolStripStatusAr.Text = cueSheet.ArVerify.ARStatus == null ? cueSheet.ArVerify.Total(0).ToString() : "?";
toolStripStatusAr.ToolTipText = "AccurateRip: " + (cueSheet.ArVerify.ARStatus ?? "found") + ".";
toolStripStatusCTDB.Visible = cueSheet.CTDB.DBStatus == null;
toolStripStatusCTDB.Text = cueSheet.CTDB.DBStatus == null ? cueSheet.CTDB.Total.ToString() : "";
toolStripStatusCTDB.ToolTipText = "CUETools DB: " + (cueSheet.CTDB.DBStatus ?? "found") + ".";
});
}
private void UpdateDrive()
{
toolStripStatusAr.Visible = false;
toolStripStatusCTDB.Visible = false;
buttonGo.Enabled = false;
comboRelease.Items.Clear();
listTracks.Items.Clear();
@@ -497,16 +557,17 @@ namespace CUERipper
_reader = null;
return;
}
_reader = (CDDriveReader)comboDrives.SelectedItem;
_reader = comboDrives.SelectedItem as ICDRipper;
try
{
_reader.Close();
_reader.Open(_reader.Path[0]);
numericWriteOffset.Value = _reader.DriveOffset;
}
catch (Exception ex)
{
numericWriteOffset.Value = _reader.DriveOffset;
_reader.Close();
//_reader.Close();
comboRelease.Items.Add(ex.Message);
comboRelease.SelectedIndex = 0;
return;
@@ -559,18 +620,19 @@ namespace CUERipper
private void listTracks_AfterLabelEdit(object sender, LabelEditEventArgs e)
{
CUESheet cueSheet = ((ReleaseInfo)comboRelease.SelectedItem).cueSheet;
CUESheet metadata = ((ReleaseInfo)comboRelease.SelectedItem).metadata;
if (e.Label != null && _reader.TOC[e.Item + 1].IsAudio)
cueSheet.Tracks[e.Item].Title = e.Label;
metadata.Tracks[e.Item].Title = e.Label;
else
e.CancelEdit = true;
}
private void editToolStripMenuItem_Click(object sender, EventArgs e)
{
CUESheet cueSheet = ((ReleaseInfo)comboRelease.SelectedItem).cueSheet;
ReleaseInfo ri = comboRelease.SelectedItem as ReleaseInfo;
if (ri == null) return;
frmProperties frm = new frmProperties();
frm.CUE = cueSheet;
frm.CUE = ri.metadata;
frm.ShowDialog();
}
@@ -598,16 +660,21 @@ namespace CUERipper
private void frmCUERipper_FormClosed(object sender, FormClosedEventArgs e)
{
SettingsWriter sw = new SettingsWriter("CUERipper", "settings.txt", Application.ExecutablePath);
//CUEToolsUDC encoder = comboBoxEncoder.SelectedItem as CUEToolsUDC;
//if (encoder != null)
// sw.Save("EncoderName", encoder.Name);
_config.Save(sw);
sw.Save("DefaultLosslessFormat", _defaultLosslessFormat);
sw.Save("DefaultLossyFormat", _defaultLossyFormat);
sw.Save("DefaultHybridFormat", _defaultHybridFormat);
sw.Save("CreateEACLOG", _config.createEACLOG);
sw.Save("PreserveHTOA", _config.preserveHTOA);
sw.Save("CreateM3U", _config.createM3U);
//sw.Save("CreateEACLOG", _config.createEACLOG);
//sw.Save("PreserveHTOA", _config.preserveHTOA);
//sw.Save("CreateM3U", _config.createM3U);
sw.Save("OutputAudioType", (int)SelectedOutputAudioType);
sw.Save("ComboCodec", comboBoxAudioFormat.SelectedIndex);
sw.Save("ComboImage", comboImage.SelectedIndex);
sw.Save("PathFormat", _pathFormat);
sw.Save("SecureMode", trackBarSecureMode.Value);
sw.Close();
}
@@ -749,6 +816,41 @@ namespace CUERipper
SelectedOutputAudioFmt.encoderLossless = encoder;
else
SelectedOutputAudioFmt.encoderLossy = encoder;
string[] modes = encoder.SupportedModes;
if (modes == null || modes.Length < 2)
{
trackBarEncoderMode.Visible = false;
labelEncoderMode.Visible = false;
labelEncoderMinMode.Visible = false;
labelEncoderMaxMode.Visible = false;
}
else
{
trackBarEncoderMode.Maximum = modes.Length - 1;
trackBarEncoderMode.Value = encoder.DefaultModeIndex == -1 ? modes.Length - 1 : encoder.DefaultModeIndex;
labelEncoderMode.Text = encoder.default_mode;
labelEncoderMinMode.Text = modes[0];
labelEncoderMaxMode.Text = modes[modes.Length - 1];
trackBarEncoderMode.Visible = true;
labelEncoderMode.Visible = true;
labelEncoderMinMode.Visible = true;
labelEncoderMaxMode.Visible = true;
}
}
private void trackBarEncoderMode_Scroll(object sender, EventArgs e)
{
CUEToolsUDC encoder = comboBoxEncoder.SelectedItem as CUEToolsUDC;
string[] modes = encoder.SupportedModes;
encoder.default_mode = modes[trackBarEncoderMode.Value];
labelEncoderMode.Text = encoder.default_mode;
}
private void trackBarSecureMode_Scroll(object sender, EventArgs e)
{
string[] modes = new string[] { "Burst", "Secure", "Paranoid" };
labelSecureMode.Text = modes[trackBarSecureMode.Value];
}
}
@@ -793,7 +895,13 @@ namespace CUERipper
class ReleaseInfo
{
public CUESheet cueSheet;
public CUESheet metadata;
public Bitmap bitmap;
public ReleaseInfo(CUESheet cue)
{
metadata = new CUESheet(cue.Config);
metadata.TOC = cue.TOC;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -15,7 +15,7 @@ namespace CUETools.CTDB
public class CUEToolsDB
{
const string urlbase = "http://db.cuetools.net";
const string userAgent = "CUETools 205";
string userAgent;
private CDRepairEncode verify;
private CDImageLayout toc;
@@ -40,8 +40,9 @@ namespace CUETools.CTDB
this.uploadHelper = new HttpUploadHelper();
}
public void ContactDB(string id)
public void ContactDB(string id, string userAgent)
{
this.userAgent = userAgent;
this.id = id;
// Calculate the three disc ids used by AR
@@ -126,6 +127,23 @@ namespace CUETools.CTDB
return cpuInfo ?? "unknown";
}
public string Confirm(DBEntry entry)
{
if (fullid == null)
throw new Exception("no id");
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(urlbase + "/confirm.php");
req.Proxy = proxy;
req.UserAgent = userAgent;
NameValueCollection form = new NameValueCollection();
form.Add("id", fullid);
form.Add("ctdbid", string.Format("{0:x8}", entry.crc));
HttpWebResponse resp = uploadHelper.Upload(req, new UploadFile[0], form);
using (Stream s = resp.GetResponseStream())
using (StreamReader sr = new StreamReader(s))
subResult = sr.ReadToEnd();
return subResult;
}
public string Submit(int confidence, int total, string artist, string title)
{
if (fullid == null)
@@ -162,7 +180,7 @@ namespace CUETools.CTDB
if (artist != null && artist != "") using (DBHDR TAG = DISC.HDR("ART ")) TAG.Write(artist);
if (title != null && title != "") using (DBHDR TAG = DISC.HDR("nam ")) TAG.Write(title);
using (DBHDR USER = DISC.HDR("USER")) USER.Write(GetCPUID());
using (DBHDR TOOL = DISC.HDR("TOOL")) TOOL.Write("CUETools 205");
using (DBHDR TOOL = DISC.HDR("TOOL")) TOOL.Write(userAgent);
using (DBHDR TOOL = DISC.HDR("MBID")) TOOL.Write(toc.MusicBrainzId);
using (DBHDR DATE = DISC.HDR("DATE")) DATE.Write(DateTime.Now);
using (DBHDR CONF = DISC.HDR("CONF")) CONF.Write(confidence);

View File

@@ -0,0 +1,8 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="robots" content="noindex" />
</head>
<body>disc not present in database
</body>
</html>

BIN
CUETools.CTDB/Web/ctdb.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -1,65 +1,77 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CUETools DB</title>
<style type="text/css">
.style1 {
font-size: x-small;
font-family: Arial, Helvetica, sans-serif;
}
.style_fixed {
#font-size: x-small;
font-family: Courier;
}
</style>
</head>
<body>
<H1>CUETools Database</H1>
<?php
$listfile="parity/list.txt";
$last_modified_time = filemtime($listfile);
$etag = md5_file($listfile);
header("Last-Modified: ".gmdate("D, d M Y H:i:s", $last_modified_time)." GMT");
header("ETag: $etag");
if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified_time ||
@trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) {
header("HTTP/1.1 304 Not Modified");
exit;
}
include 'logo_start.php';
require_once( 'phpmb/mbQuery.php' );
require_once( 'phpctdb/ctdb.php' );
$lines=false;
$fp = fopen('parity/list.txt','r');
$totaldiscs=filesize($listfile)/57;
$fp = fopen($listfile,'r');
$count = 10;
fseek($fp, -57 * $count, SEEK_END);
$start = @$_GET['start'];
if ($start == "" || $start > $totaldiscs || $start < 0) $start = $totaldiscs - $count;
fseek($fp, 57 * $start, SEEK_SET);
$n = $count;
while($line=fgets($fp)) {
$name = trim($line);
if (file_exists($name))
$lines[]=$name;
if (--$count <= 0)
if (--$n <= 0)
break;
}
fclose($fp);
printf("<h3>Recent additions:</h3>");
printf("<table border=3><tr><th>Artist</th><th>Album</th><th>Disc Id</th><th>CTDB Id</th></tr>");
printf("<center><h3>Recent additions:</h3>");
include 'table_start.php';
?>
<table class=classy_table cellpadding=3 cellspacing=0><tr bgcolor=#D0D0D0><th>Artist</th><th>Album</th><th>Disc Id</th><th>CTDB Id</th></tr>
<?php
//<tr background="img/bg_top_border.jpg"><td></td><td width=8 rowspan=12 bgcolor=#FFFFFF></td><td background="img/bg_right_border.jpg" width=4 rowspan=12></td><td></td><td></td><td></td></tr>
$imgs = '';
if ($lines) foreach(array_reverse($lines) as $line) {
$ctdb = new phpCTDB($line);
$disc = $ctdb->db['discs'][0];
$id = @$disc['MBID']['value'];
$ctdb->ParseToc();
//$id = @$disc['MBID']['value'];
$artist = @$disc['ART ']['value'];
$title = @$disc['nam ']['value'];
$link = $id == "" ? "<a>" : '<a href="http://musicbrainz.org/bare/cdlookup.html?id=' . $id . '">';
//echo $line . ':' . $id . '<br>';
if ($artist == "" && $title == "" && $id != "") {
$discid = substr($line,13,30);
$ctdbid = $ctdb->db['discs'][0]['CRC ']['int'];
if ($artist == "" && $title == "")
{
//$q = new MusicBrainzQuery(new WebService('db4.cuetools.net'));
$q = new MusicBrainzQuery();
$rf = new ReleaseFilter();
try {
$rresults = $q->getReleases( $rf->discId($id) );
$rresults = $q->getReleases( $rf->discId($ctdb->mbid) );
foreach ( $rresults as $key => $rr ) {
$rr = $rr->getRelease();
$artist = $rr->getArtist()->getName();
$title = $rr->getTitle();
$imgs = $imgs . '<img src="http://ec1.images-amazon.com/images/P/' . $rr->getAsin() . '.01.MZZZZZZZ.jpg">';
}
}
catch ( ResponseError $e ) {
// echo $e->getMessage() . " ";
}
}
printf("<tr><td>%s</td><td>%s</td><td class=style_fixed>%s%s</a></td><td class=style_fixed>%x</td></tr>", $artist, $title, $link, substr($line,13,30), $ctdb->db['discs'][0]['CRC ']['int']);
printf('<tr><td class=td_artist>%s</td><td class=td_album>%s</td><td class=td_discid><a href="http://musicbrainz.org/bare/cdlookup.html?id=%s">%s</a></td><td class=td_ctdbid><a href=show.php?discid=%s&ctdbid=%08x>%08x</a></td></tr>', htmlspecialchars($artist), htmlspecialchars($title), $ctdb->mbid, $discid, $discid, $ctdbid, $ctdbid);
}
printf('<tr><td colspan=4 align=right><a class=style1 href="?start=%d">More</a></td></tr>', $count * floor(($start - 1) / $count));
printf("</table>");
printf("<h5>Status: %d unique discs.</h5>", filesize("parity/list.txt")/57);
include 'table_end.php' ;
//printf('%s', $imgs);
printf("</center>");
?>
</body>
</html>

View File

@@ -0,0 +1,62 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CUETools DB</title>
<style type="text/css">
.style1 {
font-size: x-small;
font-family: Arial, Helvetica, sans-serif;
}
.style_fixed {
#font-size: x-small;
font-family: Courier;
}
.style_logo {
font-size: x-large;
font-family: Arial, Helvetica, sans-serif;
}
.td_status {
font-size: x-small;
text-align: center;
font-family: sans-serif;
}
.td_artist {
padding: 1px 10px;
}
.td_album {
padding: 1px 10px;
}
.td_discid {
padding: 1px 5px;
font-family: Courier;
}
.td_ctdbid {
padding: 1px 5px;
font-family: Courier;
}
.classy_table {
border-style:none;
# border-color-right: #D0D0D0
# border-color-left: #D0D0D0
}
</style>
</head>
<body>
<table border=0 cellspacing=0 cellpadding=3 align=center>
<tr>
<td rowspan=3><img src=ctdb.png></td>
<td colspan=2 class=td_status>
<?php
printf("%d unique discs", filesize("parity/list.txt")/57);
?>
</td>
</tr>
<tr>
<td class=style_logo colspan=2>CUETools Database</td>
</tr>
<tr align=center>
<td>About</td>
<td><a href=http://www.cuetools.net>CUETools</a></td>
</tr>
</table>
<br clear=all>

View File

@@ -6,6 +6,8 @@ class phpCTDB{
private $fpstats;
private $atoms;
public $db;
public $fulltoc;
public $mbid;
function __construct($target_file) {
$this->fp = fopen($target_file, 'rb');
@@ -19,6 +21,32 @@ class phpCTDB{
fclose($this->fp);
}
function ParseTOC()
{
$disc = $this->db['discs'][0];
$this->fulltoc = '';
$mbtoc = '';
foreach ($disc['TOC ']['subatoms'] as $track)
{
if ($track['name']=='INFO') {
$trackcount = phpCTDB::BigEndian2Int(substr($track['value'],0,4));
$pregap = phpCTDB::BigEndian2Int(substr($track['value'],4,4));
$pos = $pregap + 150;
}
if ($track['name']=='TRAK') {
$isaudio = phpCTDB::BigEndian2Int(substr($track['value'],0,4));
$length = phpCTDB::BigEndian2Int(substr($track['value'],4,4));
$this->fulltoc = sprintf('%s %d', $this->fulltoc, $pos);
$mbtoc = sprintf('%s%08X', $mbtoc, $pos);
$pos += $length;
}
}
$this->fulltoc = sprintf('1 %d %d%s', $trackcount, $pos, $this->fulltoc);
$mbtoc = sprintf('01%02X%08X%s', $trackcount, $pos, $mbtoc);
$mbtoc = str_pad($mbtoc,804,'0');
$this->mbid = str_replace('+', '.', str_replace('/', '_', str_replace('=', '-', base64_encode(pack("H*" , sha1($mbtoc))))));
}
static function BigEndian2Int($byte_word, $signed = false) {
$int_value = 0;
@@ -56,6 +84,25 @@ class phpCTDB{
return strrev(phpCTDB::LittleEndian2String($number, $minbytes, $synchsafe));
}
static function discid2path($id)
{
$err = sscanf($id, "%03d-%04x%04x-%04x%04x-%04x%04x", $tracks, $id1a, $id1b, $id2a, $id2b, $cddbida, $cddbidb);
$parsedid = sprintf("%03d-%04x%04x-%04x%04x-%04x%04x", $tracks, $id1a, $id1b, $id2a, $id2b, $cddbida, $cddbidb);
if ($id != $parsedid)
die("bad id ". $id);
return sprintf("parity/%x/%x/%x/%s", $id1b & 15, ($id1b >> 4) & 15, ($id1b >> 8) & 15, $parsedid);
}
static function ctdbid2path($discid, $ctdbid)
{
$path = phpCTDB::discid2path($discid);
sscanf($ctdbid, "%04x%04x", $ctdbida, $ctdbidb);
$parsedctdbid = sprintf("%04x%04x", $ctdbida, $ctdbidb);
if ($ctdbid != $parsedctdbid)
die("bad id ". $ctdbid);
return sprintf("%s/%s.bin", $path, $ctdbid);
}
static function unparse_atom($fp, $atom)
{
// printf('unparse_atom(%s)<br>', $atom['name']);
@@ -105,6 +152,7 @@ class phpCTDB{
foreach ($atom['subatoms'] as $param)
switch ($param['name']) {
case 'HEAD':
case 'TOC ':
case 'CRC ':
case 'MBID':
case 'ART ':

View File

@@ -0,0 +1,55 @@
<?php
include 'logo_start.php';
require_once( 'phpmb/mbQuery.php' );
require_once( 'phpctdb/ctdb.php' );
$discid = $_GET['discid'];
$ctdbid = $_GET['ctdbid'];
$path = phpCTDB::ctdbid2path($discid, $ctdbid);
$ctdb = new phpCTDB($path);
$disc = $ctdb->db['discs'][0];
//$id = @$disc['MBID']['value'];
$ctdb->ParseTOC();
$artist = @$disc['ART ']['value'];
$title = @$disc['nam ']['value'];
$link = '<a href="http://musicbrainz.org/bare/cdlookup.html?id=' . $ctdb->mbid . '">';
$q = new MusicBrainzQuery();
$rf = new ReleaseFilter();
$mbrr = false;
try {
$rresults = $q->getReleases( $rf->discId($ctdb->mbid) );
foreach ( $rresults as $key => $rr ) {
$mbrr = $rr->getRelease();
}
}
catch ( ResponseError $e ) {
// echo $e->getMessage() . " ";
}
printf('<center>');
if ($mbrr && $mbrr->getAsin())
{
include 'table_start.php';
$imgurl = 'http://ec1.images-amazon.com/images/P/' . $mbrr->getAsin() . '.01.MZZZZZZZ.jpg';
#$imgurl = 'http://images.amazon.com/images/P/' . $mbrr->getAsin() . '.01._SCLZZZZZZZ_PU_PU-5_.jpg';
printf('<img src="%s">', $imgurl);
include 'table_end.php';
printf('<br><br>');
}
include 'table_start.php';
?>
<table border=0 cellspacing=0 cellpadding=6>
<?php
printf('<tr><td>Full TOC</td><td>%s</td></tr>', $ctdb->fulltoc);
printf('<tr><td>Artist</td><td>%s</td></tr>', $artist);
if ($mbrr && $mbrr->getArtist()->getName() != $artist)
printf('<tr><td>Artist (MB)</td><td>%s</td></tr>', $mbrr->getArtist()->getName());
printf('<tr><td>Title</td><td>%s</td></tr>', $title);
if ($mbrr && $mbrr->getTitle() != $title)
printf('<tr><td>Title (MB)</td><td>%s</td></tr>', $mbrr->getTitle());
printf('<tr><td>MusicbrainzId</td><td>%s%s</a></tr>', $link, $ctdb->mbid);
?>
</table>
<?php include 'table_end.php'; ?>
</center>
</body>
</html>

View File

@@ -75,15 +75,9 @@ if ($size == 0) {
}
$id = $_POST['id'];
$err = sscanf($id, "%03d-%04x%04x-%04x%04x-%04x%04x", $tracks, $id1a, $id1b, $id2a, $id2b, $cddbida, $cddbidb);
$parsedid = sprintf("%03d-%04x%04x-%04x%04x-%04x%04x", $tracks, $id1a, $id1b, $id2a, $id2b, $cddbida, $cddbidb);
if ($id != $parsedid)
die("bad id ". $id);
$target_path = sprintf("parity/%x/%x/%x/%s", $id1b & 15, ($id1b >> 4) & 15, ($id1b >> 8) & 15, $parsedid);
$target_file = sprintf("%s/ctdb.bin", $target_path, $parsedid);
$target_path = phpCTDB::discid2path($id);
@mkdir($target_path, 0777, true);
$target_file = sprintf("%s/ctdb.bin", $target_path);
$ctdb = new phpCTDB($tmpname);
$ctdb1 = @file_exists($target_file) ? new phpCTDB($target_file) : false;
@@ -162,7 +156,7 @@ fwrite($listfp, "\n");
fclose($listfp);
if ($merging)
printf("%s has been updated", $parsedid);
printf("%s has been updated", $id);
else
printf("%s has been uploaded", $parsedid);
printf("%s has been uploaded", $id);
?>

View File

@@ -0,0 +1,9 @@
</td>
<td background="img/bg_right_border.jpg"></td>
</tr>
<tr>
<td width="4" height="4"><img src="img/bottom_left_corner.jpg" width="4" height="4"></td>
<td background="img/bg_bottom.jpg"></td>
<td width="4" height="4"><img src="img/bottom_right_corner.jpg" width="4" height="4"></td>
</tr>
</table>

View File

@@ -0,0 +1,10 @@
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="4" height="4"><img src="img/top_left_corner.jpg" width="4" height="4"></td>
<td background="img/bg_top_border.jpg"></td>
<td width="4" height="4"><img src="img/top_right_corner.jpg" width="4" height="4"></td>
</tr>
<tr>
<td width="4" background="img/bg_left_border.jpg"></td>
<td align="center" valign="middle">

View File

@@ -1642,9 +1642,11 @@ namespace CUETools.Codecs
bool _haveData = false;
int _bufferPos = 0;
Exception _ex = null;
bool own;
public AudioPipe(IAudioSource source, int size)
public AudioPipe(IAudioSource source, int size, bool own)
{
this.own = own;
_source = source;
_readBuffer = new AudioBuffer(source, size);
_writeBuffer = new AudioBuffer(source, size);
@@ -1655,7 +1657,9 @@ namespace CUETools.Codecs
private void Decompress(object o)
{
#if !DEBUG
try
#endif
{
bool done = false;
do
@@ -1674,8 +1678,8 @@ namespace CUETools.Codecs
Monitor.Pulse(this);
}
} while (!done);
_source.Close();
}
#if !DEBUG
catch (Exception ex)
{
lock (this)
@@ -1684,6 +1688,7 @@ namespace CUETools.Codecs
Monitor.Pulse(this);
}
}
#endif
}
private void Go()
@@ -1712,6 +1717,11 @@ namespace CUETools.Codecs
_workThread.Join();
_workThread = null;
}
if (_source != null)
{
if (own) _source.Close();
_source = null;
}
if (_readBuffer != null)
{
//_readBuffer.Clear();

View File

@@ -978,7 +978,7 @@ namespace CUETools.Processor
overwriteCUEData = false;
filenamesANSISafe = true;
bruteForceDTL = false;
createEACLOG = false;
createEACLOG = true;
detectHDCD = true;
wait750FramesForHDCD = true;
decodeHDCD = false;
@@ -1030,7 +1030,7 @@ namespace CUETools.Processor
}
if (Type.GetType("Mono.Runtime", false) == null)
{
encoders.Add(new CUEToolsUDC("flake", "flac", true, "0 1 2 3 4 5 6 7 8 9 10 11", "10", "flake.exe", "-%M - -o %O -p %P"));
encoders.Add(new CUEToolsUDC("flake", "flac", true, "0 1 2 3 4 5 6 7 8 9 10 11 12", "8", "flake.exe", "-%M - -o %O -p %P"));
encoders.Add(new CUEToolsUDC("takc", "tak", true, "0 1 2 2e 2m 3 3e 3m 4 4e 4m", "2", "takc.exe", "-e -p%M -overwrite - %O"));
encoders.Add(new CUEToolsUDC("ffmpeg alac", "m4a", true, "", "", "ffmpeg.exe", "-i - -f ipod -acodec alac -y %O"));
encoders.Add(new CUEToolsUDC("lame vbr", "mp3", false, "V9 V8 V7 V6 V5 V4 V3 V2 V1 V0", "V2", "lame.exe", "--vbr-new -%M - %O"));
@@ -1159,7 +1159,7 @@ string status = processor.Go();
sw.Save("OverwriteCUEData", overwriteCUEData);
sw.Save("FilenamesANSISafe", filenamesANSISafe);
if (bruteForceDTL) sw.Save("BruteForceDTL", bruteForceDTL);
if (createEACLOG) sw.Save("CreateEACLOG", createEACLOG);
sw.Save("CreateEACLOG", createEACLOG);
sw.Save("DetectHDCD", detectHDCD);
sw.Save("Wait750FramesForHDCD", wait750FramesForHDCD);
sw.Save("DecodeHDCD", decodeHDCD);
@@ -1292,7 +1292,7 @@ string status = processor.Go();
overwriteCUEData = sr.LoadBoolean("OverwriteCUEData") ?? false;
filenamesANSISafe = sr.LoadBoolean("FilenamesANSISafe") ?? true;
bruteForceDTL = sr.LoadBoolean("BruteForceDTL") ?? false;
createEACLOG = sr.LoadBoolean("createEACLOG") ?? false;
createEACLOG = sr.LoadBoolean("CreateEACLOG") ?? createEACLOG;
detectHDCD = sr.LoadBoolean("DetectHDCD") ?? true;
wait750FramesForHDCD = sr.LoadBoolean("Wait750FramesForHDCD") ?? true;
decodeHDCD = sr.LoadBoolean("DecodeHDCD") ?? false;
@@ -2635,14 +2635,15 @@ string status = processor.Go();
_padding += _eacLog.Length;
}
public void UseCUEToolsDB()
public void UseCUEToolsDB(bool submit, string userAgent)
{
ShowProgress((string)"Contacting CUETools database...", 0, 0, null, null);
_CUEToolsDB.ContactDB(_accurateRipId ?? AccurateRipVerify.CalculateAccurateRipId(_toc));
_CUEToolsDB.ContactDB(_accurateRipId ?? AccurateRipVerify.CalculateAccurateRipId(_toc), userAgent);
ShowProgress("", 0.0, 0.0, null, null);
_useCUEToolsDB = true;
_useCUEToolsDBSibmit = submit;
}
public void UseAccurateRip()
@@ -3141,6 +3142,50 @@ string status = processor.Go();
}
}
public bool PrintErrors(StringWriter logWriter, uint tr_start, uint len)
{
uint tr_end = (len + 74) / 75;
int errCount = 0;
for (uint iSecond = 0; iSecond < tr_end; iSecond++)
{
uint sec_start = tr_start + iSecond * 75;
uint sec_end = Math.Min(sec_start + 74, tr_start + len - 1);
bool fError = false;
for (uint iSector = sec_start; iSector <= sec_end; iSector++)
if (_ripper.Errors[(int)iSector])
fError = true;
if (fError)
{
uint end = iSecond;
for (uint jSecond = iSecond + 1; jSecond < tr_end; jSecond++)
{
uint jsec_start = tr_start + jSecond * 75;
uint jsec_end = Math.Min(jsec_start + 74, tr_start + len - 1);
bool jfError = false;
for (uint jSector = jsec_start; jSector <= jsec_end; jSector++)
if (_ripper.Errors[(int)jSector])
jfError = true;
if (jfError)
end = jSecond;
}
if (errCount == 0)
logWriter.WriteLine();
if (errCount++ > 20)
break;
//"Suspicious position 0:02:20"
//" Suspicious position 0:02:23 - 0:02:24"
string s1 = CDImageLayout.TimeToString("0:{0:00}:{1:00}", iSecond * 75);
string s2 = CDImageLayout.TimeToString("0:{0:00}:{1:00}", end * 75);
if (iSecond == end)
logWriter.WriteLine(" Suspicious position {0}", s1);
else
logWriter.WriteLine(" Suspicious position {0} - {1}", s1, s2);
iSecond = end;
}
}
return errCount > 0;
}
public void CreateExactAudioCopyLOG()
{
StringWriter logWriter = new StringWriter(CultureInfo.InvariantCulture);
@@ -3163,7 +3208,7 @@ string status = processor.Go();
"Delete leading and trailing silent blocks : No\r\n" +
"Null samples used in CRC calculations : Yes\r\n" +
"Used interface : Native Win32 interface for Win NT & 2000\r\n" +
"Gap handling : Appended to previous track\r\n" +
"{6}" +
"\r\n" +
"Used output format : Internal WAV Routines\r\n" +
"Sample format : 44.100 Hz; 16 Bit; Stereo\r\n";
@@ -3173,7 +3218,8 @@ string status = processor.Go();
Artist, Title,
_ripper.EACName,
_ripper.CorrectionQuality > 0 ? "Secure" : "Burst",
_ripper.DriveOffset);
_ripper.DriveOffset,
(OutputStyle != CUEStyle.SingleFile && OutputStyle != CUEStyle.SingleFileWithCUE) ? "Gap handling : Appended to previous track\r\n" : "" );
logWriter.WriteLine();
logWriter.WriteLine("TOC of the extracted CD");
@@ -3192,6 +3238,7 @@ string status = processor.Go();
bool htoaToFile = ((OutputStyle == CUEStyle.GapsAppended) && _config.preserveHTOA &&
(_toc.Pregap != 0));
int accurateTracks = 0, knownTracks = 0;
bool wereErrors = false;
if (OutputStyle != CUEStyle.SingleFile && OutputStyle != CUEStyle.SingleFileWithCUE)
{
logWriter.WriteLine();
@@ -3206,46 +3253,7 @@ string status = processor.Go();
logWriter.WriteLine(" Pre-gap length 0:{0}.{1:00}", CDImageLayout.TimeToString("{0:00}:{1:00}", _toc[track + _toc.FirstAudio].Pregap + (track + _toc.FirstAudio == 1 ? 150U : 0U)), (_toc[track + _toc.FirstAudio].Pregap % 75) * 100 / 75);
}
int errCount = 0;
uint tr_start = _toc[track + _toc.FirstAudio].Start;
uint tr_end = (_toc[track + _toc.FirstAudio].Length + 74) / 75;
for (uint iSecond = 0; iSecond < tr_end; iSecond ++)
{
uint sec_start = tr_start + iSecond * 75;
uint sec_end = Math.Min(sec_start + 74, _toc[track + _toc.FirstAudio].End);
bool fError = false;
for (uint iSector = sec_start; iSector <= sec_end; iSector++)
if (_ripper.Errors[(int)iSector])
fError = true;
if (fError)
{
uint end = iSecond;
for (uint jSecond = iSecond + 1; jSecond < tr_end; jSecond++)
{
uint jsec_start = tr_start + jSecond * 75;
uint jsec_end = Math.Min(jsec_start + 74, _toc[track + _toc.FirstAudio].End);
bool jfError = false;
for (uint jSector = jsec_start; jSector <= jsec_end; jSector++)
if (_ripper.Errors[(int)jSector])
jfError = true;
if (jfError)
end = jSecond;
}
if (errCount == 0)
logWriter.WriteLine();
if (errCount++ > 20)
break;
//"Suspicious position 0:02:20"
//" Suspicious position 0:02:23 - 0:02:24"
string s1 = CDImageLayout.TimeToString("0:{0:00}:{1:00}", iSecond * 75);
string s2 = CDImageLayout.TimeToString("0:{0:00}:{1:00}", end * 75);
if (iSecond == end)
logWriter.WriteLine(" Suspicious position {0}", s1);
else
logWriter.WriteLine(" Suspicious position {0} - {1}", s1, s2);
iSecond = end;
}
}
wereErrors |= PrintErrors(logWriter, _toc[track + _toc.FirstAudio].Start, _toc[track + _toc.FirstAudio].Length);
logWriter.WriteLine();
logWriter.WriteLine(" Peak level {0:F1} %", (Tracks[track].PeakLevel * 1000 / 32768) * 0.1);
@@ -3277,6 +3285,7 @@ string status = processor.Go();
logWriter.WriteLine("Selected range");
logWriter.WriteLine();
logWriter.WriteLine(" Filename {0}", Path.ChangeExtension(Path.GetFullPath(_destPaths[0]), ".wav"));
wereErrors = PrintErrors(logWriter, _toc[_toc.FirstAudio][0].Start, _toc.AudioLength);
logWriter.WriteLine();
int PeakLevel = 0;
for (int track = 0; track < TrackCount; track++)
@@ -3288,7 +3297,10 @@ string status = processor.Go();
logWriter.WriteLine(" Copy CRC {0:X8}", _arVerify.CRC32(0));
logWriter.WriteLine(" Copy OK");
logWriter.WriteLine();
logWriter.WriteLine("No errors occurred");
if (wereErrors)
logWriter.WriteLine("There were errors");
else
logWriter.WriteLine("No errors occurred");
logWriter.WriteLine();
logWriter.WriteLine();
logWriter.WriteLine("AccurateRip summary");
@@ -3331,7 +3343,10 @@ string status = processor.Go();
logWriter.WriteLine();
if (OutputStyle != CUEStyle.SingleFile && OutputStyle != CUEStyle.SingleFileWithCUE)
{
logWriter.WriteLine("No errors occurred");
if (wereErrors)
logWriter.WriteLine("There were errors");
else
logWriter.WriteLine("No errors occurred");
logWriter.WriteLine();
}
logWriter.WriteLine("End of status report");
@@ -3383,24 +3398,19 @@ string status = processor.Go();
logWriter.WriteLine("Destination files");
foreach (string path in _destPaths)
logWriter.WriteLine(" {0}", path);
bool wereErrors = false;
for (int iTrack = 0; iTrack < _toc.AudioTracks; iTrack++)
bool wereErrors = PrintErrors(logWriter, _toc[_toc.FirstAudio][0].Start, _toc.AudioLength);
if (wereErrors)
{
int cdErrors = 0;
for (uint iSector = _toc[iTrack + 1].Start; iSector <= _toc[iTrack + 1].End; iSector++)
if (_ripper.Errors[(int)iSector])
cdErrors++;
if (cdErrors != 0)
{
if (!wereErrors)
{
logWriter.WriteLine();
logWriter.WriteLine("Errors detected");
logWriter.WriteLine();
}
wereErrors = true;
logWriter.WriteLine("Track {0} contains {1} errors", iTrack + 1, cdErrors);
}
logWriter.WriteLine();
if (wereErrors)
logWriter.WriteLine("There were errors");
else
logWriter.WriteLine("No errors occurred");
}
if (_useCUEToolsDB)
{
logWriter.WriteLine();
GenerateCTDBLog(logWriter);
}
if (_useAccurateRip)
{
@@ -3408,7 +3418,6 @@ string status = processor.Go();
logWriter.WriteLine("AccurateRip summary");
logWriter.WriteLine();
_arVerify.GenerateFullLog(logWriter, true);
logWriter.WriteLine();
}
logWriter.WriteLine();
logWriter.WriteLine("End of status report");
@@ -3514,6 +3523,28 @@ string status = processor.Go();
return sw.ToString();
}
public void GenerateCTDBLog(TextWriter sw)
{
if (_CUEToolsDB.DBStatus != null)
sw.WriteLine("CUETools DB: {0}.", _CUEToolsDB.DBStatus);
if (_CUEToolsDB.SubStatus != null)
sw.WriteLine("CUETools DB: {0}.", _CUEToolsDB.SubStatus);
if (_CUEToolsDB.DBStatus == null)
sw.WriteLine(" [ CTDBID ] Status");
foreach (DBEntry entry in _CUEToolsDB.Entries)
{
string confFormat = (_CUEToolsDB.Total < 10) ? "{0:0}/{1:0}" :
(_CUEToolsDB.Total < 100) ? "{0:00}/{1:00}" : "{0:000}/{1:000}";
string conf = string.Format(confFormat, entry.conf, _CUEToolsDB.Total);
string status =
(!entry.hasErrors) ? "Accurately ripped" :
entry.canRecover ? string.Format("Contains {0} correctable errors", entry.repair.CorrectableErrors) :
(entry.httpStatus == 0 || entry.httpStatus == HttpStatusCode.OK) ? "No match" :
entry.httpStatus.ToString();
sw.WriteLine(" [{0:x8}] ({1}) {2}", entry.crc, conf, status);
}
}
public void GenerateAccurateRipLog(TextWriter sw)
{
if (!_processed)
@@ -3544,26 +3575,7 @@ string status = processor.Go();
if (_useCUEToolsDBFix)// && _CUEToolsDB.SelectedEntry != null)
sw.WriteLine("CUETools DB: corrected {0} errors.", _CUEToolsDB.SelectedEntry.repair.CorrectableErrors);
else if (_useCUEToolsDB)
{
if (_CUEToolsDB.DBStatus != null)
sw.WriteLine("CUETools DB: {0}.", _CUEToolsDB.DBStatus);
if (_CUEToolsDB.SubStatus != null)
sw.WriteLine("CUETools DB: {0}.", _CUEToolsDB.SubStatus);
if (_CUEToolsDB.DBStatus == null)
sw.WriteLine(" [ CTDBID ] Status");
foreach (DBEntry entry in _CUEToolsDB.Entries)
{
string confFormat = (_CUEToolsDB.Total < 10) ? "{0:0}/{1:0}" :
(_CUEToolsDB.Total < 100) ? "{0:00}/{1:00}" : "{0:000}/{1:000}";
string conf = string.Format(confFormat, entry.conf, _CUEToolsDB.Total);
string status =
(!entry.hasErrors) ? "Accurately ripped" :
entry.canRecover ? string.Format("Contains {0} correctable errors", entry.repair.CorrectableErrors) :
(entry.httpStatus == 0 || entry.httpStatus == HttpStatusCode.OK) ? "No match" :
entry.httpStatus.ToString();
sw.WriteLine(" [{0:x8}] ({1}) {2}", entry.crc, conf, status);
}
}
GenerateCTDBLog(sw);
_arVerify.GenerateFullLog(sw, _config.arLogVerbose);
}
@@ -4706,7 +4718,7 @@ string status = processor.Go();
{
_ripper.Position = 0;
//audioSource = _ripper;
audioSource = new AudioPipe(_ripper, 0x100000);
audioSource = new AudioPipe(_ripper, 0x100000, false);
} else
if (_isArchive)
audioSource = AudioReadWrite.GetAudioSource(sourceInfo.Path, OpenArchive(sourceInfo.Path, false), _config);
@@ -4719,7 +4731,7 @@ string status = processor.Go();
//if (!(audioSource is AudioPipe) && !(audioSource is UserDefinedReader) && _config.separateDecodingThread)
if (!(audioSource is AudioPipe) && _config.separateDecodingThread)
audioSource = new AudioPipe(audioSource, 0x10000);
audioSource = new AudioPipe(audioSource, 0x10000, true);
return audioSource;
}
@@ -5226,7 +5238,7 @@ string status = processor.Go();
return "AccurateRip: confidence too low";
//if (CTDB.AccResult == HttpStatusCode.OK)
//return "CUEToolsDB: disc already present in database";
if (CTDB.AccResult != HttpStatusCode.NotFound && CTDB.AccResult != HttpStatusCode.OK)
if (CTDB.AccResult != HttpStatusCode.NotFound && CTDB.AccResult != HttpStatusCode.OK)// && CTDB.AccResult != HttpStatusCode.NoContent)
return "CUEToolsDB: " + CTDB.DBStatus;
_useCUEToolsDBSibmit = true;
string status = Go();
@@ -5240,7 +5252,7 @@ string status = processor.Go();
}
case "repair":
{
UseCUEToolsDB();
UseCUEToolsDB(false, "CUETools 205");
Action = CUEAction.Verify;
if (CTDB.DBStatus != null)
return CTDB.DBStatus;

View File

@@ -19,10 +19,11 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>..\bin\Debug\plugins\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>

View File

@@ -57,14 +57,14 @@ namespace CUETools.Ripper.SCSI
int m_max_sectors;
int _timeout = 10;
Crc16Ccitt _crc;
public long[,] UserData;
public long[,] C2Data;
public long[,,] UserData;
public byte[,] C2Count;
public byte[,] QData;
public long[] byte2long;
BitArray _errors;
int _errorsCount;
int _crcErrorsCount = 0;
byte[] _currentData = new byte[MSECTORS * 4 * 588];
AudioBuffer currentData = new AudioBuffer(AudioPCMConfig.RedBook, MSECTORS * 588);
short[] _valueScore = new short[256];
bool _debugMessages = false;
ReadCDCommand _readCDCommand = ReadCDCommand.Unknown;
@@ -183,8 +183,8 @@ namespace CUETools.Ripper.SCSI
{
m_logger = new Logger();
_crc = new Crc16Ccitt(InitialCrcValue.Zeros);
UserData = new long[MSECTORS, 4 * 588];
C2Data = new long[MSECTORS, 588 / 2];
UserData = new long[MSECTORS, 2, 4 * 588];
C2Count = new byte[MSECTORS, 294];
QData = new byte[MSECTORS, 16];
byte2long = new long[256];
for (long i = 0; i < 256; i++)
@@ -287,6 +287,8 @@ namespace CUETools.Ripper.SCSI
m_device.Close();
m_device = null;
_toc = null;
_currentStart = -1;
_currentEnd = -1;
}
public void Dispose()
@@ -511,33 +513,73 @@ namespace CUETools.Ripper.SCSI
return found;
}
//int dbg_pass;
//FileStream fs_d, fs_c;
private unsafe void ReorganiseSectors(int sector, int Sectors2Read)
{
int c2Size = _c2ErrorMode == Device.C2ErrorMode.None ? 0 : _c2ErrorMode == Device.C2ErrorMode.Mode294 ? 294 : 296;
int oldSize = 4 * 588 + c2Size + (_subChannelMode == Device.SubChannelMode.None ? 0 : 16);
fixed (byte* readBuf = _readBuffer, qBuf = _subchannelBuffer, qData = QData)
fixed (long* userData = UserData, c2Data = C2Data)
fixed (byte* readBuf = _readBuffer, qBuf = _subchannelBuffer, qData = QData, c2Count = C2Count)
fixed (long* userData = UserData)
{
for (int iSector = 0; iSector < Sectors2Read; iSector++)
{
byte* sectorPtr = readBuf + iSector * oldSize;
long* userDataPtr = userData + (sector - _currentStart + iSector) * 4 * 588;
long* c2DataPtr = c2Data + (sector - _currentStart + iSector) * 294;
long* userDataPtr = userData + (sector - _currentStart + iSector) * 8 * 588;
byte* c2CountPtr = c2Count + (sector - _currentStart + iSector) * 294;
byte* qDataPtr = qData + (sector - _currentStart + iSector) * 16;
for (int sample = 0; sample < 4 * 588; sample++)
userDataPtr[sample] += byte2long[sectorPtr[sample]] * 3;
//if (_currentStart > 0)
//{
// string nm_d = string.Format("Y:\\Temp\\dbg\\{0:x}-{1:00}.bin", _currentStart, dbg_pass);
// string nm_c = string.Format("Y:\\Temp\\dbg\\{0:x}-{1:00}.c2", _currentStart, dbg_pass);
// if (fs_d != null && fs_d.Name != nm_d) { fs_d.Close(); fs_d = null; }
// if (fs_c != null && fs_c.Name != nm_c) { fs_c.Close(); fs_c = null; }
// if (fs_d == null) fs_d = new FileStream(nm_d, FileMode.Create);
// if (fs_c == null) fs_c = new FileStream(nm_c, FileMode.Create);
// fs_d.Seek((sector - _currentStart + iSector) * 4 * 588, SeekOrigin.Begin);
// fs_d.Write(_readBuffer, iSector * oldSize, 4 * 588);
// fs_c.Seek((sector - _currentStart + iSector) * 296, SeekOrigin.Begin);
// fs_c.Write(_readBuffer, iSector * oldSize + 4 * 588, 296);
//}
if (_c2ErrorMode != Device.C2ErrorMode.None)
{
for (int c2 = 0; c2 < 294; c2++)
int offs = 0;
if (c2Size == 296)
{
byte c2val = sectorPtr[4 * 588 + c2Size - 294 + c2];
c2DataPtr[c2] += byte2long[c2val];
if (c2val != 0)
for (int b = 0; b < 8; b++)
if (((c2val >> b) & 1) != 0)
userDataPtr[c2 * 8 + b] += 0x0101010101010101 - byte2long[sectorPtr[c2 * 8 + b]] * 2;
// sometimes sector C2 byte is placed after C2 info, not before!!
int c2 = 0;
for (int pos = 2; pos < 294; pos++)
c2 |= sectorPtr[4 * 588 + pos];
if (sectorPtr[4 * 588 + 294] == (c2 | sectorPtr[4 * 588 + 0] | sectorPtr[4 * 588 + 1]))
offs = 0;
else if (sectorPtr[4 * 588] == (c2 | sectorPtr[4 * 588 + 294] | sectorPtr[4 * 588 + 295]))
offs = 2;
else
throw new Exception("invalid C2 pointers");
}
for (int pos = 0; pos < 294; pos++)
{
int c2d = sectorPtr[4 * 588 + pos + offs];
int c2 = ((-c2d) >> 31) & 1;
c2CountPtr[pos] += (byte)c2;
int sample = pos << 3;
userDataPtr[sample + c2 * 4 * 588] += byte2long[sectorPtr[sample]]; sample++;
userDataPtr[sample + c2 * 4 * 588] += byte2long[sectorPtr[sample]]; sample++;
userDataPtr[sample + c2 * 4 * 588] += byte2long[sectorPtr[sample]]; sample++;
userDataPtr[sample + c2 * 4 * 588] += byte2long[sectorPtr[sample]]; sample++;
userDataPtr[sample + c2 * 4 * 588] += byte2long[sectorPtr[sample]]; sample++;
userDataPtr[sample + c2 * 4 * 588] += byte2long[sectorPtr[sample]]; sample++;
userDataPtr[sample + c2 * 4 * 588] += byte2long[sectorPtr[sample]]; sample++;
userDataPtr[sample + c2 * 4 * 588] += byte2long[sectorPtr[sample]];
}
}
else
{
for (int sample = 0; sample < 4 * 588; sample++)
userDataPtr[sample] += byte2long[sectorPtr[sample]] * 3;
}
if (_subChannelMode != Device.SubChannelMode.None)
for (int qi = 0; qi < 16; qi++)
@@ -551,10 +593,11 @@ namespace CUETools.Ripper.SCSI
private unsafe void ClearSectors(int sector, int Sectors2Read)
{
fixed (long* userData = &UserData[sector - _currentStart, 0], c2Data = &C2Data[sector - _currentStart, 0])
fixed (long* userData = &UserData[sector - _currentStart, 0, 0])
fixed (byte* c2Count = &C2Count[sector - _currentStart, 0])
{
ZeroMemory((byte*)userData, 8 * 4 * 588 * Sectors2Read);
ZeroMemory((byte*)c2Data, 4 * 588 * Sectors2Read);
ZeroMemory((byte*)userData, 8 * 2 * 4 * 588 * Sectors2Read);
ZeroMemory(c2Count, 294 * Sectors2Read);
}
}
@@ -598,10 +641,8 @@ namespace CUETools.Ripper.SCSI
if (FetchSectors(sector + iSector, 1, false, subchannel) != Device.CommandStatus.Success)
{
iErrors ++;
for (int i = 0; i < 4 * 588; i++)
UserData[sector + iSector - _currentStart, i] += 0x0101010101010101;
for (int i = 0; i < 294; i++)
C2Data[sector + iSector - _currentStart, i] += 0x0101010101010101;
C2Count[sector + iSector - _currentStart, i] ++;
for (int i = 0; i < 16; i++)
QData[ sector + iSector - _currentStart, i] = 0;
if (_debugMessages)
@@ -745,8 +786,6 @@ namespace CUETools.Ripper.SCSI
for (int iSector = 0; iSector < Sectors2Read; iSector++)
{
int pos = sector - _currentStart + iSector;
int avg = (pass + 1) * 3 / 2;
int er_limit = 2 + pass / 2; // allow 25% minority
// avg - pass + 1
// p a l o
// 0 1 1 2
@@ -755,23 +794,30 @@ namespace CUETools.Ripper.SCSI
// 6 10 5
//16 25 10
bool fError = false;
const byte c2div = 128;
int er_limit = c2div * (1 + _correctionQuality) - 1;
// need at least 1 + _correctionQuality good passes
for (int iPar = 0; iPar < 4 * 588; iPar++)
{
long val = UserData[pos, iPar];
byte c2 = (byte)(C2Data[pos, iPar >> 3] >> ((iPar & 7) * 8));
long val = UserData[pos, 0, iPar];
long val1 = UserData[pos, 1, iPar];
byte c2 = C2Count[pos, iPar >> 3];
int ave = (pass + 1 - c2) * c2div + c2;
int bestValue = 0;
for (int i = 0; i < 8; i++)
{
int sum = avg - ((int)(val & 0xff));
int sum = ave - 2 * (int)((val & 0xff) * c2div + (val1 & 0xff));
int sig = sum >> 31; // bit value
fError |= (sum ^ sig) < er_limit;
bestValue += sig & (1 << i);
val >>= 8;
}
_currentData[pos * 4 * 588 + iPar] = (byte)bestValue;
currentData.Bytes[pos * 4 * 588 + iPar] = (byte)bestValue;
}
if (fError)
_currentErrorsCount++;
int newerr = (fError ? 1 : 0);
//_currentErrorsCount += newerr;
_currentErrorsCount += newerr - errtmp[pos];
errtmp[pos] = newerr;
if (markErrors)
{
_errors[sector + iSector] |= fError;
@@ -781,6 +827,8 @@ namespace CUETools.Ripper.SCSI
}
int[] errtmp = new int[MSECTORS];
//private unsafe int CorrectSectorsTest(int start, int end, int c2Score, byte[] realData, int worstScan)
//{
// int[] valueScore = new int[256];
@@ -837,14 +885,24 @@ namespace CUETools.Ripper.SCSI
public unsafe void PrefetchSector(int iSector)
{
if (_currentStart == MSECTORS * (iSector / MSECTORS))
if (iSector >= _currentStart && iSector < _currentEnd)
return;
if (_readCDCommand == ReadCDCommand.Unknown && !TestReadCommand())
throw new Exception("failed to autodetect read command: " + _autodetectResult);
_currentStart = MSECTORS * (iSector / MSECTORS);
_currentEnd = Math.Min(_currentStart + MSECTORS, (int)_toc.AudioLength);
_currentEnd = _currentStart + MSECTORS;
if (_currentEnd > (int)_toc.AudioLength)
{
_currentEnd = (int)_toc.AudioLength;
_currentStart = Math.Max(0, _currentEnd - MSECTORS);
}
int neededSize = (_currentEnd - _currentStart) * 588;
if (currentData.Size < neededSize)
currentData.Prepare(new byte[neededSize * 4], neededSize);
currentData.Length = neededSize;
//FileStream correctFile = new FileStream("correct.wav", FileMode.Open);
//byte[] realData = new byte[MSECTORS * 4 * 588];
@@ -853,11 +911,15 @@ namespace CUETools.Ripper.SCSI
// throw new Exception("read");
//correctFile.Close();
int max_scans = 64;
for (int pass = 0; pass <= max_scans; pass++)
_currentErrorsCount = 0;
for (int i = 0; i < MSECTORS; i++)
errtmp[i] = 0;
int max_scans = 16 << _correctionQuality;
for (int pass = 0; pass < max_scans; pass++)
{
// dbg_pass = pass;
DateTime PassTime = DateTime.Now, LastFetch = DateTime.Now;
_currentErrorsCount = 0;
for (int sector = _currentStart; sector < _currentEnd; sector += m_max_sectors)
{
@@ -875,9 +937,9 @@ namespace CUETools.Ripper.SCSI
if (pass == 0)
ProcessSubchannel(sector, Sectors2Read, true);
//DateTime LastFetched = DateTime.Now;
if ((pass & 1) == 0)
if (pass >= _correctionQuality)
{
CorrectSectors(pass, sector, Sectors2Read, pass >= max_scans);
CorrectSectors(pass, sector, Sectors2Read, pass == max_scans - 1);
PrintErrors(pass, sector, Sectors2Read, /*realData*/null);
}
//TimeSpan delay2 = DateTime.Now - LastFetched;
@@ -889,7 +951,7 @@ namespace CUETools.Ripper.SCSI
//System.Console.WriteLine();
//if (CorrectSectorsTest(start, _currentEnd, 10, realData) == 0)
// break;
if ((pass & 1) == 0 && pass >= _correctionQuality && _currentErrorsCount == 0)
if (pass >= _correctionQuality && _currentErrorsCount == 0)
break;
}
}
@@ -917,8 +979,15 @@ namespace CUETools.Ripper.SCSI
PrefetchSector(_sampleOffset / 588);
buff.Length = Math.Min(buff.Length, (int)Length - _sampleOffset);
buff.Length = Math.Min(buff.Length, _currentEnd * 588 - _sampleOffset);
fixed (byte* dest = buff.Bytes, src = &_currentData[(_sampleOffset - _currentStart * 588) * 4])
AudioSamples.MemCpy(dest, src, buff.ByteLength);
if ((_sampleOffset - _currentStart * 588) == 0 && (maxLength < 0 || (_currentEnd - _currentStart) * 588 <= buff.Length))
{
buff.Swap(currentData);
_currentStart = -1;
_currentEnd = -1;
}
else
fixed (byte* dest = buff.Bytes, src = &currentData.Bytes[(_sampleOffset - _currentStart * 588) * 4])
AudioSamples.MemCpy(dest, src, buff.ByteLength);
_sampleOffset += buff.Length;
return buff.Length;
}
@@ -982,7 +1051,9 @@ namespace CUETools.Ripper.SCSI
_currentTrack = -1;
_currentIndex = -1;
_crcErrorsCount = 0;
_errorsCount = 0;
_errorsCount = 0;
_currentStart = -1;
_currentEnd = -1;
_errors = new BitArray((int)_toc.AudioLength); // !!!
_sampleOffset = (int)value + _driveOffset;
}
@@ -1017,6 +1088,8 @@ namespace CUETools.Ripper.SCSI
}
set
{
if (value < 0 || value > 3)
throw new Exception("invalid CorrectionQuality");
_correctionQuality = value;
}
}
@@ -1046,15 +1119,6 @@ namespace CUETools.Ripper.SCSI
bcd &= 0x3f;
return bcd >= ISRC6.Length ? '#' : ISRC6[bcd];
}
public static char[] DrivesAvailable()
{
List<char> result = new List<char>();
foreach (DriveInfo info in DriveInfo.GetDrives())
if (info.DriveType == DriveType.CDRom)
result.Add(info.Name[0]);
return result.ToArray();
}
}
enum ReadCDCommand

View File

@@ -23,6 +23,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>

View File

@@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using CUETools.CDImage;
@@ -22,6 +23,18 @@ namespace CUETools.Ripper
event EventHandler<ReadProgressArgs> ReadProgress;
}
public class CDDrivesList
{
public static char[] DrivesAvailable()
{
List<char> result = new List<char>();
foreach (DriveInfo info in DriveInfo.GetDrives())
if (info.DriveType == DriveType.CDRom)
result.Add(info.Name[0]);
return result.ToArray();
}
}
public sealed class ReadProgressArgs : EventArgs
{
public int Position;

View File

@@ -153,6 +153,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CUETools.CDRepair", "..\CUE
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CUETools.CTDB", "..\CUETools.CTDB\CUETools.CTDB.csproj", "{AA2A9A7E-45FB-4632-AD85-85B0E556F818}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProgressODoom", "..\ProgressODoom\ProgressODoom.csproj", "{8DD1E84B-0B03-4C0B-9B42-1E49F75E7CB1}"
EndProject
Global
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = CUETools1.vsmdi
@@ -560,6 +562,14 @@ Global
{AA2A9A7E-45FB-4632-AD85-85B0E556F818}.Release|Any CPU.Build.0 = Release|Any CPU
{AA2A9A7E-45FB-4632-AD85-85B0E556F818}.Release|Win32.ActiveCfg = Release|Any CPU
{AA2A9A7E-45FB-4632-AD85-85B0E556F818}.Release|x64.ActiveCfg = Release|Any CPU
{8DD1E84B-0B03-4C0B-9B42-1E49F75E7CB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8DD1E84B-0B03-4C0B-9B42-1E49F75E7CB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8DD1E84B-0B03-4C0B-9B42-1E49F75E7CB1}.Debug|Win32.ActiveCfg = Debug|Any CPU
{8DD1E84B-0B03-4C0B-9B42-1E49F75E7CB1}.Debug|x64.ActiveCfg = Debug|Any CPU
{8DD1E84B-0B03-4C0B-9B42-1E49F75E7CB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8DD1E84B-0B03-4C0B-9B42-1E49F75E7CB1}.Release|Any CPU.Build.0 = Release|Any CPU
{8DD1E84B-0B03-4C0B-9B42-1E49F75E7CB1}.Release|Win32.ActiveCfg = Release|Any CPU
{8DD1E84B-0B03-4C0B-9B42-1E49F75E7CB1}.Release|x64.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -1,5 +1,6 @@
using System;
using System.Text;
using System.IO;
using System.Collections.Generic;
using CUETools.Codecs;
using CUETools.Ripper;
@@ -36,19 +37,17 @@ namespace TestRipper
}
}
const int pass = 16;
const int Sectors2Read = 10000;
const int bit_weight = 3;
const int c2_weight = 1;
const int max_pass = 64;
const int Sectors2Read = 2400;
bool markErrors = true;
int _currentStart = 0, _realErrors = 0;
byte[] _currentData = new byte[Sectors2Read * 4 * 588];
static long[,] UserData = new long[Sectors2Read, 4 * 588];
static long[,] C2Data = new long[Sectors2Read, 4 * 588 / 8];
static ulong[,,] UserData = new ulong[Sectors2Read, 2, 4 * 588];
static byte[,] C2Count = new byte[Sectors2Read, 4 * 588];
static byte[] _realData = new byte[Sectors2Read * 4 * 588];
static long[] byte2long = new long[256];
static ulong[] byte2long = new ulong[256];
#region Additional test attributes
//
@@ -58,30 +57,58 @@ namespace TestRipper
[ClassInitialize()]
public static void MyClassInitialize(TestContext testContext)
{
for (long i = 0; i < 256; i++)
for (ulong i = 0; i < 256; i++)
{
long bl = 0;
ulong bl = 0;
for (int b = 0; b < 8; b++)
bl += ((i >> b) & 1) << (b << 3);
byte2long[i] = bl;
}
Random rnd = new Random(2314);
rnd.NextBytes(_realData);
//Random rnd = new Random(2314);
//rnd.NextBytes(_realData);
for (int p = 0; p <= pass; p++)
for (int iSector = 0; iSector < Sectors2Read; iSector++)
for (int iPar = 0; iPar < 4 * 588; iPar++)
byte [] c2data = new byte[Sectors2Read * 296];
for (int p = 0; p < max_pass; p++)
{
// string nm_d = string.Format("Y:\\Temp\\dbg\\{0:x}-{1:00}.bin", _currentStart, dbg_pass);
using (FileStream fs = new FileStream(string.Format("Y:\\Temp\\dbg\\960\\960-{0:00}.bin", p), FileMode.Open))
using (FileStream fs2 = new FileStream(string.Format("Y:\\Temp\\dbg\\960\\960-{0:00}.c2", p), FileMode.Open))
{
fs.Read(_realData, 0, Sectors2Read * 4 * 588);
fs2.Read(c2data, 0, Sectors2Read * 296);
for (int iSector = 0; iSector < Sectors2Read; iSector++)
{
bool error = rnd.NextDouble() < 0.2;
byte val = error ? (byte)rnd.Next(255) : _realData[iSector * 4 * 588 + iPar];
UserData[iSector, iPar] += byte2long[val] * bit_weight;
if (error && rnd.NextDouble() < 0.5)
for (int pos = 0; pos < 294; pos++)
{
C2Data[iSector, iPar >> 3] += (iPar & 7) * 8;
UserData[iSector, iPar] += 0x0101010101010101 * (bit_weight / 2) + byte2long[val] * (c2_weight - bit_weight);
int c2d = c2data[iSector * 296 + pos];
for (int sample = (pos << 3); sample < (pos << 3) + 8; sample++)
{
//int c2 = (c2d >> (7 - (sample & 7))) & 1;
//int c2 = (c2d >> ((sample & 7))) & 1;
//int c2 = ((c2d >> ((sample & 7))) | (c2d >> (7 - (sample & 7)))) & 1;
int c2 = ((-c2d) >> 31) & 1;
C2Count[iSector, sample] += (byte)c2;
UserData[iSector, c2, sample] += byte2long[_realData[iSector * 4 * 588 + sample]];
}
}
}
}
//for (int iSector = 0; iSector < Sectors2Read; iSector++)
// for (int iPar = 0; iPar < 4 * 588; iPar++)
// {
// bool error = rnd.NextDouble() < 0.2;
// byte val = error ? (byte)rnd.Next(255) : _realData[iSector * 4 * 588 + iPar];
// UserData[iSector, iPar] += byte2long[val] * bit_weight;
// if (error && rnd.NextDouble() < 0.5)
// {
// C2Data[iSector, iPar >> 3] += (iPar & 7) * 8;
// UserData[iSector, iPar] += 0x0101010101010101 * (bit_weight / 2) + byte2long[val] * (c2_weight - bit_weight);
// }
// }
}
using (FileStream fs = new FileStream(string.Format("Y:\\Temp\\dbg\\960\\960.bin", 0), FileMode.Open))
fs.Read(_realData, 0, Sectors2Read * 4 * 588);
}
//
//Use ClassCleanup to run code after all tests in a class have run
@@ -114,36 +141,39 @@ namespace TestRipper
{
int _currentErrorsCount = 0;
int sector = 0;
_realErrors = 0;
const byte c2div = 128;
const int er_limit = c2div * 3;
int fErrCnt = 0;
for (int iSector = 0; iSector < Sectors2Read; iSector++)
{
int pos = sector - _currentStart + iSector;
int avg = (pass + 1) * bit_weight / 2;
int c2_limit = pass / 3; //
int er_limit = avg - pass; // allow 33% minority
for (int iPar = 0; iPar < 4 * 588; iPar++)
{
long val = UserData[pos, iPar];
byte c2 = (byte)(C2Data[pos, iPar >> 3] >> ((iPar & 7) * 8));
ulong val = UserData[pos, 0, iPar];
ulong val1 = 0;// UserData[pos, 1, iPar];
byte c2 = C2Count[pos, iPar];
int ave = (max_pass - c2) * c2div + c2;
int bestValue = 0;
bool fError = false;
for (int i = 0; i < 8; i++)
{
int sum = avg - ((int)(val & 0xff));
int sig = sum >> 31; // bit value
if ((sum ^ sig) < er_limit) _currentErrorsCount++;
int sum = ave - 2 * (int)((val & 0xff) * c2div + (val1 & 0xff));
int sig = sum >> 31;
fError |= (sum ^ sig) < er_limit;
bestValue += sig & (1 << i);
val >>= 8;
}
if (fError)
fErrCnt++;
//if (c2 > c2_limit)
//_currentErrorsCount++;
_currentData[pos * 4 * 588 + iPar] = (byte)bestValue;
if (_realData[iSector * 4 * 588 + iPar] != bestValue)
_realErrors++;
}
}
for (int p = 0; p <= pass; p++)
for (int iSector = 0; iSector < Sectors2Read; iSector++)
for (int iPar = 0; iPar < 4 * 588; iPar++)
if (_realData[iSector * 4 * 588 + iPar] != _currentData[iSector * 4 * 588 + iPar])
_realErrors++;
//Assert.AreEqual<int>(0, fErrCnt);
Assert.AreEqual<int>(0, _realErrors, "0 != _realErrors; _currentErrorsCount == " + _currentErrorsCount.ToString());
//CollectionAssert.AreEqual(_realData, _currentData, "_realData != _currentData");
Assert.AreEqual<int>(0, _currentErrorsCount, "_currentErrorsCount != 0");

View File

@@ -745,7 +745,7 @@ namespace JDP {
}
if (useCUEToolsDB)
{
cueSheet.UseCUEToolsDB();
cueSheet.UseCUEToolsDB(false, "CUETools 205");
}
if (_batchPaths.Count == 0 && action == CUEAction.Encode)

View File

@@ -669,6 +669,9 @@
<data name="checkBoxVerifyUseCDRepair.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="checkBoxVerifyUseCDRepair.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="checkBoxVerifyUseCDRepair.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 3</value>
</data>

View File

@@ -0,0 +1,223 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
public enum ProgressType {
Smooth, MarqueeWrap, MarqueeBounce, MarqueeBounceDeep, Animated
}
/// <summary></summary>
public abstract class AbstractProgressBar : Control {
protected int minimum = 0;
protected int maximum = 100;
protected int value = 0;
protected Rectangle borderbox;
protected Rectangle progressbox;
protected Rectangle backbox;
private bool showPercent = false;
private int padding = 0;
#region Marquee
protected ProgressType type = ProgressType.Smooth;
protected int marqueeSpeed = 30;
protected int marqueePercentage = 25;
protected int marqueeStep = 1;
#endregion
protected EventHandler OnValueChanged;
/// <summary></summary>
public event EventHandler ValueChanged {
add {
if (OnValueChanged != null) {
foreach (Delegate d in OnValueChanged.GetInvocationList()) {
if (object.ReferenceEquals(d, value)) { return; }
}
}
OnValueChanged = (EventHandler)Delegate.Combine(OnValueChanged, value);
}
remove { OnValueChanged = (EventHandler)Delegate.Remove(OnValueChanged, value); }
}
public AbstractProgressBar() {
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true);
}
/// <summary></summary>
[Category("Progress"), Description("Gets or sets whether or not to draw the percentage text"), Browsable(true)]
public bool ShowPercentage {
get { return showPercent; }
set {
showPercent = value;
Invalidate();
if (!showPercent) {
this.Text = "";
}
}
}
/// <summary></summary>
[Category("Progress"), Description("Gets or sets the minimum value"), Browsable(true)]
public virtual int Minimum {
get { return this.minimum; }
set {
if (value > maximum) { throw new ArgumentException("Minimum must be smaller than maximum."); }
this.minimum = value;
this.Invalidate();
}
}
/// <summary></summary>
[Category("Progress"), Description("Gets or sets the maximum value"), Browsable(true)]
public virtual int Maximum {
get { return this.maximum; }
set {
if (value < minimum) { throw new ArgumentException("Maximum must be larger than minimum."); }
this.maximum = value;
this.Invalidate();
}
}
/// <summary></summary>
[Category("Progress"), Description("Gets or sets the current value"), Browsable(true)]
public int Value {
get { return this.value; }
set {
if (value < minimum) { throw new ArgumentException("Value must be greater than or equal to minimum."); }
if (value > maximum) { throw new ArgumentException("Value must be less than or equal to maximum."); }
this.value = value;
if (showPercent) {
int percent = (int)(((float)this.value / (float)(this.maximum - 1f)) * 100f);
if (percent > 0) {
if (percent > 100) { percent = 100; }
this.Text = string.Format("{0}%", percent.ToString());
} else { this.Text = ""; }
}
if (OnValueChanged != null) {
OnValueChanged(this, EventArgs.Empty);
}
ResizeProgress();
this.Invalidate();
}
}
/// <summary></summary>
[Category("Progress"), Description("Gets or sets the number of pixels to pad between the border and progress"), Browsable(true)]
public int ProgressPadding {
get { return this.padding; }
set {
this.padding = value;
if (OnValueChanged != null) {
OnValueChanged(this, EventArgs.Empty);
}
//ResizeProgress();
OnResize(EventArgs.Empty);
this.Invalidate();
}
}
/// <summary></summary>
[Category("Progress"), Description("Gets or sets the type of progress"), Browsable(true)]
public virtual ProgressType ProgressType {
get { return this.type; }
set { this.type = value; }
}
#region Marquee
/// <summary></summary>
[Category("Marquee"), Description("Gets or sets the number of milliseconds between marquee steps"), Browsable(true)]
public int MarqueeSpeed {
get { return this.marqueeSpeed; }
set {
this.marqueeSpeed = value;
if (this.marqueeSpeed < 10) { this.marqueeSpeed = 10; }
}
}
/// <summary></summary>
[Category("Marquee"), Description("Gets or sets the number of pixels to progress the marquee bar"), Browsable(true)]
public int MarqueeStep {
get { return this.marqueeStep; }
set { this.marqueeStep = value; }
}
/// <summary></summary>
[Category("Marquee"), Description("Gets or sets the percentage of the width that the marquee progress fills"), Browsable(true)]
public int MarqueePercentage {
get { return this.marqueePercentage; }
set {
if (value < 5 || value > 95) {
throw new ArgumentException("Marquee percentage width must be between 5% and 95%.");
}
this.marqueePercentage = value;
}
}
#endregion
/// <summary></summary>
[Browsable(false)]
public Rectangle BorderBox {
get { return this.borderbox; }
}
/// <summary></summary>
[Browsable(false)]
public Rectangle BackBox {
get { return this.backbox; }
}
/// <summary></summary>
[Browsable(false)]
public Rectangle ProgressBox {
get { return this.progressbox; }
}
/// <summary></summary>
/// <param name="gr"></param>
protected abstract void PaintBackground(Graphics gr);
/// <summary></summary>
/// <param name="gr"></param>
protected abstract void PaintProgress(Graphics gr);
/// <summary></summary>
/// <param name="gr"></param>
protected abstract void PaintText(Graphics gr);
/// <summary></summary>
/// <param name="gr"></param>
protected abstract void PaintBorder(Graphics gr);
/// <summary></summary>
protected abstract void ResizeProgress();
/// <summary></summary>
/// <param name="e"></param>
protected override void OnResize(EventArgs e) {
base.OnResize(e);
borderbox = new Rectangle(0, 0, this.Width - 1, this.Height - 1);
backbox = new Rectangle(0, 0, this.Width - 1, this.Height - 1);
ResizeProgress();
}
/// <summary></summary>
/// <param name="e"></param>
protected override void OnPaint(PaintEventArgs e) {
base.OnPaint(e);
PaintBackground(e.Graphics);
PaintProgress(e.Graphics);
e.Graphics.Clip = new Region(new Rectangle(0, 0, this.Width, this.Height));
PaintText(e.Graphics);
PaintBorder(e.Graphics);
}
/// <summary></summary>
public abstract void MarqueeStart();
/// <summary></summary>
public abstract void MarqueePause();
/// <summary></summary>
public abstract void MarqueeStop();
}
}

View File

@@ -0,0 +1,108 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
public abstract class AbstractProgressPainter : Component, IProgressPainter {
protected IGlossPainter gloss;
protected IProgressBorderPainter border;
internal int padding = 0;
/// <summary></summary>
[Category("Painters"), Description("Gets or sets the gloss painter chain"), Browsable(true)]
public IGlossPainter GlossPainter {
get { return this.gloss; }
set {
this.gloss = value;
if (this.gloss != null) { this.gloss.PropertiesChanged += new EventHandler(component_PropertiesChanged); }
FireChange();
}
}
/// <summary></summary>
[Category("Painters"), Description("Gets or sets the border painter for this progress painter"), Browsable(true)]
public IProgressBorderPainter ProgressBorderPainter {
get { return this.border; }
set {
this.border = value;
if (this.gloss != null) { this.gloss.PropertiesChanged += new EventHandler(component_PropertiesChanged); }
FireChange();
}
}
/// <summary></summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void component_PropertiesChanged(object sender, EventArgs e) {
FireChange();
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="gr"></param>
public void PaintProgress(Rectangle box, Graphics gr) {
PaintThisProgress(box, gr);
//if (this.gloss != null && box.Width > 1) {
// Rectangle b = new Rectangle(box.X, box.Y, box.Width - 1, box.Height - 1);
// //gr.DrawRectangle(Pens.Red, b);
// this.gloss.PaintGloss(box, gr);
//}
if (this.border != null && box.Width > 1) {
int w = box.Width;
//if (padding > 0) { w += 3; } else { w += 1; }
//Rectangle b = new Rectangle(box.X - 1, box.Y - 1, w, box.Height + 3);
Rectangle b = new Rectangle(box.X, box.Y, box.Width - 1, box.Height - 1);
b.Inflate(1, 1);
this.border.PaintBorder(b, gr);
}
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="gr"></param>
protected abstract void PaintThisProgress(Rectangle box, Graphics gr);
/// <summary></summary>
/// <param name="box"></param>
public virtual void Resize(Rectangle box) {
if (gloss != null) { gloss.Resize(box); }
if (border != null) { border.Resize(box); }
ResizeThis(box);
}
/// <summary></summary>
/// <param name="box"></param>
protected virtual void ResizeThis(Rectangle box) {}
private EventHandler onPropertiesChanged;
/// <summary></summary>
public event EventHandler PropertiesChanged {
add {
if (onPropertiesChanged != null) {
foreach (Delegate d in onPropertiesChanged.GetInvocationList()) {
if (object.ReferenceEquals(d, value)) { return; }
}
}
onPropertiesChanged = (EventHandler)Delegate.Combine(onPropertiesChanged, value);
}
remove { onPropertiesChanged = (EventHandler)Delegate.Remove(onPropertiesChanged, value); }
}
/// <summary></summary>
protected void FireChange() {
if (onPropertiesChanged != null) { onPropertiesChanged(this, EventArgs.Empty); }
}
/// <summary></summary>
/// <param name="disposing"></param>
protected override void Dispose(bool disposing) {
base.Dispose(disposing);
DisposeThis(disposing);
}
/// <summary></summary>
/// <param name="disposing"></param>
protected virtual void DisposeThis(bool disposing) {
}
}
}

View File

@@ -0,0 +1,139 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.BarberPoleProgressPainter), "Icons.BarberPoleProgressPainter.ico")]
public class BarberPoleProgressPainter : AbstractProgressPainter, IProgressPainter, IDisposable {
private Color baseColor;
private Color highlightColor;
private Color stripeColor;
private Color baseShadeColor;
private Color highlightShadeColor;
private Color stripeShadeColor;
private int shadeHeight;
private int stripeWidth;
private Image img;
private Rectangle box;
/// <summary></summary>
public BarberPoleProgressPainter() {
baseColor = Color.FromArgb(226, 138, 078);
highlightColor = Color.FromArgb(225, 132, 068);
stripeColor = Color.FromArgb(222, 123, 055);
baseShadeColor = Color.FromArgb(215, 097, 020);
highlightShadeColor = Color.FromArgb(213, 087, 007);
stripeShadeColor = Color.FromArgb(210, 078, 000);
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the base progress color"), Browsable(true)]
public Color Color {
get { return baseColor; }
set {
baseColor = value;
HSV baseHsv = new HSV(baseColor);
bool change = false;
if (baseHsv.Saturation > 166) { baseHsv.Saturation = 166; change = true; }
if (baseHsv.Value > 239) { baseHsv.Value = 239; change = true; }
if (change) { baseColor = baseHsv.Color; }
highlightColor = HSV.FromHsv(baseHsv.Hue, baseHsv.Saturation + 11, baseHsv.Value);
stripeColor = HSV.FromHsv(baseHsv.Hue, baseHsv.Saturation + 25, baseHsv.Value - 4);
HSV shade = new HSV(baseHsv.Hue, baseHsv.Saturation + 65, baseHsv.Value - 11);
baseShadeColor = shade.Color;
highlightShadeColor = HSV.FromHsv(shade.Hue, shade.Saturation + 15, shade.Value - 2);
stripeShadeColor = HSV.FromHsv(shade.Hue, shade.Saturation + 24, shade.Value - 5);
try { if (box != null) { RepaintImage(box); } } catch { }
FireChange();
}
}
private void RepaintImage(Rectangle box) {
if (box.Width == 0 || box.Height == 0) { img = null; return; }
img = new Bitmap(box.Width - (box.X * 2), box.Height - (box.Y * 2));
Bitmap tile = new Bitmap(img.Height * 2, img.Height);
shadeHeight = (int)((double)box.Height * 0.4D);
stripeWidth = box.Height;
using (Graphics g = Graphics.FromImage(tile)) {
g.FillRectangle(new SolidBrush(baseColor), 0, 0, tile.Width, tile.Height);
g.FillRectangle(new SolidBrush(baseShadeColor), 0, tile.Height - shadeHeight, tile.Width, tile.Height);
Pen highlightPen = new Pen(new SolidBrush(highlightColor), 1f);
Pen highlightShadePen = new Pen(new SolidBrush(highlightShadeColor), 1f);
Pen stripePen = new Pen(new SolidBrush(stripeColor), 1f);
Pen stripeShadePen = new Pen(new SolidBrush(stripeShadeColor), 1f);
for (int y = 0; y < stripeWidth; y++) {
if (y < tile.Height - shadeHeight) {
g.DrawLine(highlightPen, stripeWidth - y - 1, y, (stripeWidth * 2) - y + 1, y);
g.DrawLine(stripePen, stripeWidth - y, y, (stripeWidth * 2) - y, y);
} else {
g.DrawLine(highlightShadePen, stripeWidth - y - 1, y, (stripeWidth * 2) - y + 1, y);
g.DrawLine(stripeShadePen, stripeWidth - y, y, (stripeWidth * 2) - y, y);
}
}
}
int x = box.X;
using (Graphics i = Graphics.FromImage(img)) {
while (true) {
if (x > img.Width) { break; }
i.DrawImageUnscaled(tile, x, box.Y);
x += tile.Width;
}
}
tile.Dispose();
}
private Point Offset(Point p, int x, int y) {
return new Point(p.X + x, p.Y + y);
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
protected override void PaintThisProgress(Rectangle box, Graphics g) {
try {
box.Width -= 1;
box.Height -= 1;
} catch { }
if (box.Width <= 1) { return; }
if (img == null) { RepaintImage(box); }
Rectangle off = new Rectangle(box.Location, box.Size);
off.Offset(box.Right - img.Width, 0);
g.DrawImageUnscaled(img, off);
if (gloss != null) {
gloss.PaintGloss(box, g);
}
}
/// <summary></summary>
/// <param name="box"></param>
protected override void ResizeThis(Rectangle box) {
this.box = box;
try {
box.Width -= 1;
box.Height -= 1;
} catch {}
shadeHeight = (int)((double)box.Height * 0.4D);
stripeWidth = box.Height;
RepaintImage(box);
}
/// <summary></summary>
protected override void DisposeThis(bool disposing) {
if (img != null) { img.Dispose(); }
}
}
}

View File

@@ -0,0 +1,118 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.BevelledGradientProgressPainter), "Icons.BevelledGradientProgressPainter.ico")]
public class BevelledGradientProgressPainter : AbstractProgressPainter, IProgressPainter, IDisposable {
private ColorRange min;
private ColorRange max;
/// <summary></summary>
public BevelledGradientProgressPainter() {
this.MinColor = Color.Cornsilk;
this.MaxColor = Color.Gold;
}
/// <summary></summary>
/// <param name="min"></param>
/// <param name="max"></param>
public BevelledGradientProgressPainter(Color min, Color max) {
this.MinColor = min;
this.MaxColor = max;
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the left progress color"), Browsable(true)]
public Color MinColor {
get { return min.BaseColor; }
set {
min = new ColorRange(value);
FireChange();
}
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the right progress color"), Browsable(true)]
public Color MaxColor {
get { return max.BaseColor; }
set {
max = new ColorRange(value);
FireChange();
}
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
protected override void PaintThisProgress(Rectangle box, Graphics g) {
try {
box.Height -= 1;
box.Width -= 1;
} catch { }
if (box.Width < 2) { return; }
Point left = new Point(box.X, box.Y);
Point right = new Point(box.Right, box.Y);
Brush bottomOuter = new System.Drawing.Drawing2D.LinearGradientBrush(left, right, min.Darker, max.Darker);
Brush bottomInner = new System.Drawing.Drawing2D.LinearGradientBrush(left, right, min.Dark, max.Dark);
Brush topInner = new System.Drawing.Drawing2D.LinearGradientBrush(left, right, min.Light, max.Light);
Brush topOuter = new System.Drawing.Drawing2D.LinearGradientBrush(left, right, min.Lighter, max.Lighter);
Brush fill = new System.Drawing.Drawing2D.LinearGradientBrush(left, right, min.BaseColor, max.BaseColor);
// fill box
g.FillRectangle(fill, box);
using (Pen p = new Pen(topInner, 1)) {
// inner top
g.DrawLine(p, box.X + 1, box.Y + 1, box.Right - 1, box.Y + 1);
}
using (Pen p = new Pen(min.Light, 1)) {
// inner left
g.DrawLine(p, box.X + 1, box.Y + 1, box.X + 1, box.Bottom - 1);
}
using (Pen p = new Pen(topOuter, 1)) {
// outer top
g.DrawLine(p, box.X, box.Y, box.Right, box.Y);
}
using (Pen p = new Pen(min.Lighter, 1)) {
// outer left
g.DrawLine(p, box.X, box.Y, box.X, box.Bottom);
}
// draw border
using (Pen p = new Pen(bottomInner, 1)) {
// inner bottom
g.DrawLine(p, box.X + 1, box.Bottom - 1, box.Right - 1, box.Bottom - 1);
}
using (Pen p = new Pen(max.Dark, 1)) {
// inner right
g.DrawLine(p, box.Right - 1, box.Y + 1, box.Right - 1, box.Bottom - 1);
}
using (Pen p = new Pen(bottomOuter, 1)) {
// outer bottom
g.DrawLine(p, box.X, box.Bottom, box.Right, box.Bottom);
}
using (Pen p = new Pen(max.Darker, 1)) {
// outer right
g.DrawLine(p, box.Right, box.Y, box.Right, box.Bottom);
}
bottomOuter.Dispose();
bottomInner.Dispose();
topInner.Dispose();
topOuter.Dispose();
fill.Dispose();
if (gloss != null) {
gloss.PaintGloss(box, g);
}
}
}
}

View File

@@ -0,0 +1,91 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.BevelledProgressPainter), "Icons.BevelledProgressPainter.ico")]
public class BevelledProgressPainter : AbstractProgressPainter, IProgressPainter, IDisposable {
private ColorRange bender;
/// <summary></summary>
public BevelledProgressPainter() {
this.Color = Color.FromArgb(151, 151, 234);
}
/// <summary></summary>
/// <param name="color"></param>
public BevelledProgressPainter(Color color) {
this.Color = color;
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the base progress color"), Browsable(true)]
public Color Color {
get { return bender.BaseColor; }
set {
bender = new ColorRange(value);
FireChange();
}
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
protected override void PaintThisProgress(Rectangle box, Graphics g) {
if (box.Width < 2) { return; }
g.PageUnit = GraphicsUnit.Pixel;
// fill box
Rectangle back = new Rectangle(box.X, box.Y, box.Width, box.Height);
try {
back.Height -= 1;
back.Width -= 1;
} catch { }
using (SolidBrush b = new SolidBrush(bender.BaseColor)) {
g.FillRectangle(b, back);
}
box = new Rectangle(box.X, box.Y, box.Width - 1, box.Height - 1);
using (Pen p = new Pen(bender.Light, 1)) {
// inner top
g.DrawLine(p, box.X + 1, box.Y + 1, box.Right - 1, box.Y + 1);
// inner left
g.DrawLine(p, box.X + 1, box.Y + 1, box.X + 1, box.Bottom - 1);
}
using (Pen p = new Pen(bender.Lighter, 1)) {
// outer top
g.DrawLine(p, box.X, box.Y, box.Right, box.Y);
// outer left
g.DrawLine(p, box.X, box.Y, box.X, box.Bottom);
}
// draw border
using (Pen p = new Pen(bender.Dark, 1)) {
// inner bottom
g.DrawLine(p, box.X + 1, box.Bottom - 1, box.Right - 1, box.Bottom - 1);
// inner right
g.DrawLine(p, box.Right - 1, box.Y + 1, box.Right - 1, box.Bottom - 1);
//g.DrawRectangle(p, box.X + 1, box.Y + 1, box.Width - 3, box.Height - 3);
}
using (Pen p = new Pen(bender.Darker, 1)) {
// outer bottom
g.DrawLine(p, box.X, box.Bottom, box.Right, box.Bottom);
// outer right
g.DrawLine(p, box.Right, box.Y, box.Right, box.Bottom);
//g.DrawRectangle(p, box.X, box.Y, box.Width - 1, box.Height - 1);
}
if (gloss != null) {
gloss.PaintGloss(box, g);
}
}
}
}

BIN
ProgressODoom/CandyCane.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B

View File

@@ -0,0 +1,123 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.CandyCaneBackgroundPainter), "Icons.CandyCaneBackgroundPainter.ico")]
public class CandyCaneBackgroundPainter : Component, IProgressBackgroundPainter, IDisposable {
private Image img;
private Rectangle box;
private IGlossPainter gloss;
private EventHandler onPropertiesChanged;
/// <summary></summary>
public event EventHandler PropertiesChanged {
add {
if (onPropertiesChanged != null) {
foreach (Delegate d in onPropertiesChanged.GetInvocationList()) {
if (object.ReferenceEquals(d, value)) { return; }
}
}
onPropertiesChanged = (EventHandler)Delegate.Combine(onPropertiesChanged, value);
}
remove { onPropertiesChanged = (EventHandler)Delegate.Remove(onPropertiesChanged, value); }
}
private void FireChange() {
if (onPropertiesChanged != null) { onPropertiesChanged(this, EventArgs.Empty); }
}
/// <summary></summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void component_PropertiesChanged(object sender, EventArgs e) {
FireChange();
}
/// <summary></summary>
[Category("Painters"), Description("Gets or sets the chain of gloss painters"), Browsable(true)]
public IGlossPainter GlossPainter {
get { return this.gloss; }
set {
this.gloss = value;
if (this.gloss != null) { this.gloss.PropertiesChanged += new EventHandler(component_PropertiesChanged); }
FireChange();
}
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
public void PaintBackground(Rectangle box, Graphics g) {
if (img == null) {
Resize(box);
}
g.DrawImageUnscaled(img, box.X, box.Y);
//g.FillRectangle(brush, box);
if (gloss != null) {
gloss.PaintGloss(box, g);
}
}
/// <summary></summary>
public void Resize(Rectangle box) {
this.box = box;
RepaintImage(box);
}
/// <summary></summary>
protected override void Dispose(bool disposing) {
base.Dispose(disposing);
if (img != null) {
img.Dispose();
}
}
private void RepaintImage(Rectangle box) {
Bitmap source = BuildTile(box.Width);
img = new Bitmap(box.Width, box.Height);
using (Graphics g = Graphics.FromImage(img)) {
g.DrawImage(source, 0, 0, box.Width, box.Height + 1); // box
}
source.Dispose();
//Bitmap source = BuildTile();
//Bitmap tile = new Bitmap((int)(((float)box.Height * (float)source.Width) / (float)source.Height), box.Height);
//using (Graphics g = Graphics.FromImage(tile)) {
// g.DrawImage(source, 0, 0, tile.Width, tile.Height);
//}
//source.Dispose();
//img = new Bitmap(box.Width, box.Height);
//using (Graphics g = Graphics.FromImage(img)) {
// int i = 0;
// while (i < box.Width) {
// g.DrawImageUnscaled(tile, i, 0);
// i += tile.Width;
// }
//}
}
private Bitmap BuildTile(int width) {
Bitmap bmp = new Bitmap(width, 9);
Graphics g = Graphics.FromImage(bmp);
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(245, 245, 245))), new Point(0, 0), new Point(width - 1, 0));
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(236, 236, 236))), new Point(0, 1), new Point(width - 1, 1));
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(234, 234, 235))), new Point(0, 2), new Point(width - 1, 2));
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(234, 234, 235))), new Point(0, 3), new Point(width - 1, 3));
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(222, 222, 222))), new Point(0, 4), new Point(width - 1, 4));
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(229, 229, 230))), new Point(0, 5), new Point(width - 1, 5));
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(239, 239, 239))), new Point(0, 6), new Point(width - 1, 6));
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(247, 247, 247))), new Point(0, 7), new Point(width - 1, 7));
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(254, 254, 255))), new Point(0, 8), new Point(width - 1, 8));
g.Dispose();
return bmp;
}
}
}

View File

@@ -0,0 +1,164 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.CandyCaneProgressPainter), "Icons.CandyCaneProgressPainter.ico")]
public class CandyCaneProgressPainter : AbstractProgressPainter, IProgressPainter, IDisposable {
private Color baseColor;
private Image img;
private Rectangle box;
/// <summary></summary>
public CandyCaneProgressPainter() {
baseColor = Color.FromArgb(049, 129, 222);
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the base progress color"), Browsable(true)]
public Color Color {
get { return baseColor; }
set {
baseColor = value;
try { if (box != null) { RepaintImage(box); } } catch { }
FireChange();
}
}
private void RepaintImage(Rectangle box) {
this.box = box;
this.img = new Bitmap(box.Width, box.Height);
// BuildTile() then resize it to fix the box.Height, then tile it.
Bitmap source = BuildTile(this.baseColor);
img = new Bitmap((int)(((float)box.Height * (float)source.Width) / (float)source.Height), box.Height + 1);
using (Graphics g = Graphics.FromImage(img)) {
g.DrawImage(source, 0, 0, img.Width, img.Height + 1);
}
source.Dispose();
}
private Point Offset(Point p, int x, int y) {
return new Point(p.X + x, p.Y + y);
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
protected override void PaintThisProgress(Rectangle box, Graphics g) {
if (img == null) { RepaintImage(box); }
if (box.Width <= 1) { return; }
int x = box.Width - img.Width;
while (x > (0 - img.Width)) {
g.DrawImageUnscaled(img, x, 0);
x -= img.Width;
}
if (gloss != null) {
gloss.PaintGloss(box, g);
}
}
/// <summary></summary>
/// <param name="box"></param>
protected override void ResizeThis(Rectangle box) {
this.box = box;
RepaintImage(box);
}
/// <summary></summary>
protected override void DisposeThis(bool disposing) {
if (img != null) {
img.Dispose();
}
}
public Bitmap BuildTile(Color color) {
HSV clr = new HSV(color);
Bitmap src = GetSource();
Bitmap bmp = new Bitmap(src.Width, src.Height);
for (int x = 0; x < bmp.Width; x++) {
for (int y = 0; y < bmp.Height; y++) {
Color original = src.GetPixel(x, y);
Color altered = Color.FromArgb(0, 255, 255, 255);
HSV orighsv = new HSV(original);
Color origrgb = orighsv.Color;
origrgb = Color.FromArgb(original.A, origrgb.R, origrgb.G, origrgb.B);
if (!origrgb.Equals(altered)) {
orighsv.Hue = clr.Hue;
//orighsv.Saturation = clr.Saturation;
//orighsv.Value = clr.Value;
altered = orighsv.Color;
altered = Color.FromArgb(original.A, altered.R, altered.G, altered.B);
}
bmp.SetPixel(x, y, altered);
}
}
src.Dispose();
return bmp;
}
private Bitmap GetSource() {
Bitmap bmp = new Bitmap(16, 9);
Graphics g = Graphics.FromImage(bmp);
g.Clear(Color.FromArgb(0, 255, 255, 255));
bmp.SetPixel(0, 0, Color.FromArgb(77, 140, 177, 225));
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(140, 177, 225))), new Point(1, 0), new Point(7, 0));
bmp.SetPixel(8, 0, Color.FromArgb(77, 140, 177, 225));
bmp.SetPixel(0, 1, Color.FromArgb(38, 99, 158, 222));
bmp.SetPixel(1, 1, Color.FromArgb(128, 99, 158, 222));
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(99, 158, 222))), new Point(2, 1), new Point(8, 1));
bmp.SetPixel(9, 1, Color.FromArgb(64, 99, 158, 222));
bmp.SetPixel(1, 2, Color.FromArgb(38, 94, 156, 222));
bmp.SetPixel(2, 2, Color.FromArgb(205, 94, 156, 222));
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(94, 156, 222))), new Point(3, 2), new Point(8, 2));
bmp.SetPixel(9, 2, Color.FromArgb(192, 94, 156, 222));
bmp.SetPixel(10, 2, Color.FromArgb(38, 94, 156, 222));
bmp.SetPixel(2, 3, Color.FromArgb(77, 93, 158, 228));
bmp.SetPixel(3, 3, Color.FromArgb(251, 93, 158, 228));
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(93, 158, 228))), new Point(4, 3), new Point(9, 3));
bmp.SetPixel(10, 3, Color.FromArgb(154, 93, 158, 228));
bmp.SetPixel(11, 3, Color.FromArgb(26, 93, 158, 228));
bmp.SetPixel(2, 4, Color.FromArgb(13, 49, 129, 222));
bmp.SetPixel(3, 4, Color.FromArgb(51, 49, 129, 222));
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(49, 129, 222))), new Point(4, 4), new Point(9, 4));
bmp.SetPixel(10, 4, Color.FromArgb(251, 49, 129, 222));
bmp.SetPixel(11, 4, Color.FromArgb(90, 49, 129, 222));
bmp.SetPixel(3, 5, Color.FromArgb(64, 81, 159, 247));
bmp.SetPixel(4, 5, Color.FromArgb(205, 81, 159, 247));
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(81, 159, 247))), new Point(5, 5), new Point(10, 5));
bmp.SetPixel(11, 5, Color.FromArgb(218, 81, 159, 247));
bmp.SetPixel(12, 5, Color.FromArgb(77, 81, 159, 247));
bmp.SetPixel(4, 6, Color.FromArgb(77, 110, 186, 255));
bmp.SetPixel(5, 6, Color.FromArgb(243, 110, 186, 255));
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(110, 186, 255))), new Point(6, 6), new Point(11, 6));
bmp.SetPixel(12, 6, Color.FromArgb(154, 110, 186, 255));
bmp.SetPixel(13, 6, Color.FromArgb(38, 110, 186, 255));
bmp.SetPixel(4, 7, Color.FromArgb(26, 121, 201, 255));
bmp.SetPixel(5, 7, Color.FromArgb(141, 121, 201, 255));
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(121, 201, 255))), new Point(6, 7), new Point(12, 7));
bmp.SetPixel(13, 7, Color.FromArgb(102, 121, 201, 255));
bmp.SetPixel(14, 7, Color.FromArgb(26, 121, 201, 255));
bmp.SetPixel(5, 8, Color.FromArgb(26, 135, 227, 255));
bmp.SetPixel(6, 8, Color.FromArgb(192, 135, 227, 255));
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(135, 227, 255))), new Point(7, 8), new Point(12, 8));
bmp.SetPixel(13, 8, Color.FromArgb(243, 135, 227, 255));
bmp.SetPixel(14, 8, Color.FromArgb(64, 135, 227, 255));
bmp.SetPixel(15, 8, Color.FromArgb(13, 135, 227, 255));
g.Dispose();
return bmp;
}
}
}

View File

@@ -0,0 +1,84 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary>Extending this class allows you to chain multiple IGlossPainters together.</summary>
public abstract class ChainedGlossPainter : Component, IGlossPainter, IDisposable {
private IGlossPainter successor = null;
/// <summary></summary>
[Category("Painters"), Description("Gets or sets the next gloss in the chain"), Browsable(true)]
public IGlossPainter Successor {
get { return successor; }
set {
IGlossPainter nextPainter = value;
while (nextPainter != null && nextPainter is ChainedGlossPainter) {
if (object.ReferenceEquals(this, nextPainter)) {
throw new ArgumentException("Gloss cannot eventually be it's own successor, an infinite loop will result");
}
nextPainter = ((ChainedGlossPainter)nextPainter).Successor;
}
successor = value;
if (successor != null) {
successor.PropertiesChanged += new EventHandler(successor_PropertiesChanged);
}
FireChange();
}
}
private void successor_PropertiesChanged(object sender, EventArgs e) {
FireChange();
}
private EventHandler onPropertiesChanged;
/// <summary></summary>
public event EventHandler PropertiesChanged {
add {
if (onPropertiesChanged != null) {
foreach (Delegate d in onPropertiesChanged.GetInvocationList()) {
if (object.ReferenceEquals(d, value)) { return; }
}
}
onPropertiesChanged = (EventHandler)Delegate.Combine(onPropertiesChanged, value);
}
remove { onPropertiesChanged = (EventHandler)Delegate.Remove(onPropertiesChanged, value); }
}
/// <summary></summary>
protected void FireChange() {
if (onPropertiesChanged != null) { onPropertiesChanged(this, EventArgs.Empty); }
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
public void PaintGloss(Rectangle box, Graphics g) {
if (box.Width < 1) { return; }
PaintThisGloss(box, g);
if (successor != null) { successor.PaintGloss(box, g); }
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
protected abstract void PaintThisGloss(Rectangle box, Graphics g);
/// <summary></summary>
/// <param name="box"></param>
public void Resize(Rectangle box) {
ResizeThis(box);
if (successor != null) { successor.Resize(box); }
}
protected abstract void ResizeThis(Rectangle box);
protected override void Dispose(bool disposing) {
base.Dispose(disposing);
if (successor != null) { successor.Dispose(); }
}
}
}

285
ProgressODoom/ColorTools.cs Normal file
View File

@@ -0,0 +1,285 @@
using System;
using System.ComponentModel;
using System.Drawing;
namespace ProgressODoom {
/// <summary></summary>
public class ColorUtility {
static ColorUtility() {
}
/// <summary></summary>
/// <param name="c"></param>
/// <returns></returns>
public static Color ReverseColor(Color c) {
return Color.FromArgb(ReverseInt(c.R), ReverseInt(c.G), ReverseInt(c.B));
}
private static int ReverseInt(int x) {
int val = x - 255;
if (val < 0) { val = val * -1; }
return val;
}
/// <summary></summary>
/// <param name="c"></param>
/// <returns></returns>
public static string ToHexString(Color c) {
string hex = string.Empty;
hex += DoHex(c.R);
hex += DoHex(c.G);
hex += DoHex(c.B);
return "#" + hex;
}
private static string DoHex(int xor) {
string hex = xor.ToString("x");
if (xor < 16) {
hex = "0" + hex;
}
if (xor == 0) {
hex = "00";
}
return hex.ToUpper();
}
private static int DeHex(string input) {
int val;
int result = 0;
for (int i = 0; i < input.Length; i++) {
string chunk = input.Substring(i, 1).ToUpper();
switch (chunk) {
case "A":
val = 10; break;
case "B":
val = 11; break;
case "C":
val = 12; break;
case "D":
val = 13; break;
case "E":
val = 14; break;
case "F":
val = 15; break;
default:
val = int.Parse(chunk); break;
}
if (i == 0) {
result += val * 16;
} else {
result += val;
}
}
return result;
}
}
// System.Drawing.Drawing2D.ColorBlend
/// <summary></summary>
public class ColorBlender {
private Color colorleft;
private Color colorright;
private int steps;
private float step;
private float stepsize;
/// <summary></summary>
/// <param name="numberofsteps"></param>
/// <param name="one"></param>
/// <param name="two"></param>
public ColorBlender(int numberofsteps, Color one, Color two) {
steps = numberofsteps;
colorleft = one;
colorright = two;
stepsize = 1.0f / Convert.ToSingle(steps);
step = 0;
}
/// <summary></summary>
/// <returns></returns>
public bool HasNext() {
return step < 1;
}
/// <summary></summary>
/// <returns></returns>
public Color Next() {
if (!HasNext()) { throw new Exception("Past threshold."); }
step += stepsize;
return Morph(step, colorleft, colorright);
}
/// <summary></summary>
/// <param name="ratio"></param>
/// <param name="c1"></param>
/// <param name="c2"></param>
/// <returns></returns>
public Color Morph(float ratio, Color c1, Color c2) {
int r = (int)(c1.R + ratio * (c2.R - c1.R));
int g = (int)(c1.G + ratio * (c2.G - c1.G));
int b = (int)(c1.B + ratio * (c2.B - c1.B));
return Color.FromArgb(r, g, b);
}
}
/// <summary></summary>
public struct ColorRange {
/// <summary></summary>
public Color Light;
/// <summary></summary>
public Color Lighter;
/// <summary></summary>
public Color BaseColor;
/// <summary></summary>
public Color Dark;
/// <summary></summary>
public Color Darker;
/// <summary></summary>
/// <param name="color"></param>
public ColorRange(Color color) {
BaseColor = color;
Light = ColorRange.Tint(0.6f, color);
Lighter = ColorRange.Tint(0.3f, color);
Dark = ColorRange.Shade(0.8f, color);
Darker = ColorRange.Shade(0.6f, color);
}
/// <summary></summary>
/// <param name="color"></param>
/// <param name="lightratio"></param>
/// <param name="lighterratio"></param>
public ColorRange(Color color, float lightratio, float lighterratio) {
BaseColor = color;
Light = ColorRange.Tint(lightratio, color);
Lighter = ColorRange.Tint(lighterratio, color);
Dark = ColorRange.Shade(lightratio, color);
Darker = ColorRange.Shade(lighterratio, color);
}
/// <summary></summary>
/// <param name="color"></param>
/// <param name="lightratio"></param>
/// <param name="lighterratio"></param>
/// <param name="darkratio"></param>
/// <param name="darkerratio"></param>
public ColorRange(Color color, float lightratio, float lighterratio, float darkratio, float darkerratio) {
BaseColor = color;
Light = ColorRange.Tint(lightratio, color);
Lighter = ColorRange.Tint(lighterratio, color);
Dark = ColorRange.Shade(darkratio, color);
Darker = ColorRange.Shade(darkerratio, color);
}
/// <summary></summary>
/// <param name="ratio"></param>
/// <param name="c1"></param>
/// <returns></returns>
public static Color Tint(float ratio, Color c1) {
return Morph(ratio, Color.White, c1);
}
/// <summary></summary>
/// <param name="ratio"></param>
/// <param name="c1"></param>
/// <returns></returns>
public static Color Shade(float ratio, Color c1) {
return Morph(ratio, Color.Black, c1);
}
/// <summary></summary>
/// <param name="ratio"></param>
/// <param name="c1"></param>
/// <param name="c2"></param>
/// <returns></returns>
public static Color Morph(float ratio, Color c1, Color c2) {
int r = (int)(c1.R + ratio * (c2.R - c1.R));
int g = (int)(c1.G + ratio * (c2.G - c1.G));
int b = (int)(c1.B + ratio * (c2.B - c1.B));
return Color.FromArgb(r, g, b);
}
}
/// <summary></summary>
public class ColorSet {
private bool shade;
private Color color;
private float factor;
private int colors;
private Color[] range;
/// <summary></summary>
/// <param name="shade"></param>
/// <param name="color"></param>
/// <param name="factor"></param>
/// <param name="colors"></param>
public ColorSet(bool shade, Color color, float factor, int colors) {
if (colors < 1) { throw new ArgumentException("Number of colors must be greater than 0."); }
if (factor < 0 || factor > 1) { throw new ArgumentException("Factor must be between 0 and 1."); }
this.shade = shade;
this.color = color;
this.factor = factor;
this.colors = colors;
Build();
}
private void Build() {
this.range = new Color[colors];
Color current = color;
range[0] = current;
for (int i = 1; i < colors; i++) {
if (shade) {
range[i] = ColorRange.Shade(factor, current);
} else {
range[i] = ColorRange.Tint(factor, current);
}
current = range[i];
}
}
/// <summary></summary>
public Color[] Colors {
get { return range; }
}
}
/// <summary></summary>
public class BlendSet {
private Color color1;
private Color color2;
private float factor;
private int colors;
private Color[] range;
/// <summary></summary>
/// <param name="one"></param>
/// <param name="two"></param>
/// <param name="factor"></param>
/// <param name="colors"></param>
public BlendSet(Color one, Color two, float factor, int colors) {
if (colors < 1) { throw new ArgumentException("Number of colors must be greater than 0."); }
if (factor < 0 || factor > 1) { throw new ArgumentException("Factor must be between 0 and 1."); }
this.color1 = one;
this.color2 = two;
this.factor = factor;
this.colors = colors;
Build();
}
private void Build() {
this.range = new Color[colors];
Color current = color1;
range[0] = current;
for (int i = 1; i < colors; i++) {
range[i] = ColorRange.Morph(factor, current, color2);
current = range[i];
}
}
/// <summary></summary>
public Color[] Colors {
get { return range; }
}
}
}

View File

@@ -0,0 +1,159 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.DualProgressBar), "Icons.DualProgressBar.ico")]
public class DualProgressBar : ProgressBarEx {
private int masterval = 0;
private int mastermax = 100;
private IProgressPainter masterpainter;
private bool masterBottom = false;
private Rectangle masterbox;
private int padding = 0;
protected EventHandler OnMasterValueChanged;
/// <summary></summary>
public event EventHandler MasterValueChanged {
add {
if (OnMasterValueChanged != null) {
foreach (Delegate d in OnMasterValueChanged.GetInvocationList()) {
if (object.ReferenceEquals(d, value)) { return; }
}
}
OnMasterValueChanged = (EventHandler)Delegate.Combine(OnMasterValueChanged, value);
}
remove { OnMasterValueChanged = (EventHandler)Delegate.Remove(OnMasterValueChanged, value); }
}
/// <summary></summary>
[Category("Progress"), Description("Gets or sets the maximum value"), Browsable(true)]
public override int Maximum {
get { return base.maximum; }
set {
base.Maximum = value;
mastermax = value;
}
}
/// <summary></summary>
[Category("Progress"), Description("Gets or sets the value of the master progress"), Browsable(true)]
public int MasterValue {
get { return this.masterval; }
set {
this.masterval = value;
if (OnMasterValueChanged != null) {
OnMasterValueChanged(this, EventArgs.Empty);
}
ResizeMasterProgress();
this.Invalidate();
}
}
/// <summary></summary>
[Category("Progress"), Description("Gets or sets the maximum value for the master progress"), Browsable(true)]
public int MasterMaximum {
get { return mastermax; }
set {
this.mastermax = value;
ResizeMasterProgress();
this.Invalidate();
}
}
/// <summary></summary>
[Category("Progress"), Description("Gets or sets the padding for the master progress"), Browsable(true)]
public int MasterProgressPadding {
get { return this.padding; }
set {
this.padding = value;
if (OnValueChanged != null) {
OnValueChanged(this, EventArgs.Empty);
}
ResizeMasterProgress();
this.Invalidate();
}
}
/// <summary></summary>
[Category("Painters"), Description("Paints this progress bar's master progress"), Browsable(true)]
public IProgressPainter MasterPainter {
get { return this.masterpainter; }
set {
this.masterpainter = value;
if (this.masterpainter is AbstractProgressPainter) {
((AbstractProgressPainter)this.masterpainter).padding = base.ProgressPadding;
}
this.masterpainter.PropertiesChanged += new EventHandler(component_PropertiesChanged);
this.Invalidate();
}
}
/// <summary></summary>
[Category("Progress"), Description("Determines whether or not the master progress is painted under the main progress"), Browsable(true)]
public bool PaintMasterFirst {
get { return this.masterBottom; }
set {
this.masterBottom = value;
this.Invalidate();
}
}
protected override void OnResize(EventArgs e) {
base.OnResize(e);
ResizeProgress();
ResizeMasterProgress();
if (this.backgroundpainter != null) { this.backgroundpainter.Resize(borderbox); }
if (masterBottom && this.masterpainter != null) { this.masterpainter.Resize(masterbox); }
if (this.progresspainter != null) { this.progresspainter.Resize(borderbox); }
if (!masterBottom && this.masterpainter != null) { this.masterpainter.Resize(masterbox); }
if (this.borderpainter != null) { this.borderpainter.Resize(borderbox); }
}
private void ResizeMasterProgress() {
Rectangle newprog = base.borderbox;
newprog.Offset(this.borderpainter.BorderWidth, this.borderpainter.BorderWidth);
newprog.Size = new Size(newprog.Size.Width - this.borderpainter.BorderWidth, newprog.Size.Height - this.borderpainter.BorderWidth);
base.backbox = newprog;
int val = masterval; if (val > 0) { val++; }
int progWidth = mastermax > 0 ? (backbox.Width * val / mastermax) : 1;
if (value >= mastermax && mastermax > 0) {
progWidth = backbox.Width;
} /*else if (value > 0) {
progWidth++;
}*/
//newprog = new Rectangle(backbox.X + base.ProgressPadding, backbox.Y + base.ProgressPadding, progWidth - (base.ProgressPadding * 2), backbox.Height - (base.ProgressPadding * 2));
//newprog = new Rectangle(backbox.X, backbox.Y, progWidth, backbox.Height);
newprog = new Rectangle(backbox.X + this.padding, backbox.Y + this.padding, progWidth - (this.padding * 2), backbox.Height - (this.padding * 2));
masterbox = newprog;
}
///// <summary></summary>
//protected override void MarqueeStart() {
//}
///// <summary></summary>
//protected override void MarqueePause() {
//}
///// <summary></summary>
//protected override void MarqueeStop() {
//}
/// <summary></summary>
/// <param name="gr"></param>
protected override void PaintProgress(Graphics g) {
if (this.progresspainter != null) {
if (masterBottom && this.masterpainter != null) {
this.masterpainter.PaintProgress(masterbox, g);
}
this.progresspainter.PaintProgress(progressbox, g);
if (!masterBottom && this.masterpainter != null) {
this.masterpainter.PaintProgress(masterbox, g);
}
}
}
}
}

View File

@@ -0,0 +1,107 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.FlatGlossPainter), "Icons.FlatGlossPainter.ico")]
public class FlatGlossPainter : ChainedGlossPainter {
private GlossStyle style = GlossStyle.Bottom;
private int percent = 50;
private Rectangle box;
private Color color = Color.White;
private int alpha = 128;
private Brush brush;
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the style for this progress gloss"), Browsable(true)]
public GlossStyle Style {
get { return this.style; }
set {
this.style = value;
this.box = new Rectangle(0, 0, 1, 1);
FireChange();
}
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the percentage of surface this gloss should cover"), Browsable(true)]
public int PercentageCovered {
get { return this.percent; }
set {
if (value < 0 || value > 100) {
throw new ArgumentException("Percentage value must be between 0 and 100.");
}
this.percent = value;
this.box = new Rectangle(0, 0, 1, 1);
FireChange();
}
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets color to gloss"), Browsable(true)]
public Color Color {
get { return this.color; }
set {
this.color = value;
box = new Rectangle(0, 0, 1, 1);
FireChange();
}
}
/// <summary></summary>
[Category("Blending"), Description("Gets or sets the alpha value"), Browsable(true)]
public int Alpha {
get { return this.alpha; }
set {
if (value < 0 || value > 255) {
throw new ArgumentException("Alpha values must be between 0 and 255.");
}
this.alpha = value;
box = new Rectangle(0, 0, 1, 1);
FireChange();
}
}
protected override void PaintThisGloss(Rectangle box, Graphics g) {
if (!this.box.Equals(box)) {
this.box = box;
}
int y = (int)(((float)box.Height * (float)percent) / 100f);
if (box.Y + y > box.Height) { y = box.Height; }
Rectangle cover = box;
switch (style) {
case GlossStyle.Bottom:
int start = box.Height + box.Y - y;
cover = new Rectangle(box.X, start, box.Width, box.Bottom - start);
break;
case GlossStyle.Top:
cover = new Rectangle(box.X, box.Y, box.Width, y + 1);
break;
case GlossStyle.Both:
cover = box;
break;
}
Color ccv = Color.FromArgb(alpha, color.R, color.G, color.B);
brush = new SolidBrush(ccv);
g.FillRectangle(brush, cover);
}
protected override void ResizeThis(Rectangle box) {
if (!this.box.Equals(box)) {
this.box = box;
}
}
protected override void Dispose(bool disposing) {
base.Dispose(disposing);
if (brush != null) { brush.Dispose(); }
}
}
}

View File

@@ -0,0 +1,209 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.FruityLoopsBackgroundPainter), "Icons.FruityLoopsBackgroundPainter.ico")]
public class FruityLoopsBackgroundPainter : Component, IProgressBackgroundPainter, IDisposable {
private IGlossPainter gloss;
private FruityLoopsProgressPainter.FruityLoopsProgressType type;
private Image img;
private Color OffLit = Color.FromArgb(49, 69, 74);
private Pen pOffLit; // = new Pen(new SolidBrush(OffLit),1f);
private Color OffLitTop = Color.FromArgb(66, 85, 90);
private Pen pOffLitTop; // = new Pen(new SolidBrush(OffLitTop),1f);
private Color OffLitBot = Color.FromArgb(24, 48, 49);
private Pen pOffLitBot; // = new Pen(new SolidBrush(OffLitBot),1f);
private Color OffMid = Color.FromArgb(24, 48, 49);
private Pen pOffMid; // = new Pen(new SolidBrush(OffMid),1f);
private Color OffMidTop = Color.FromArgb(24, 48, 49);
private Pen pOffMidTop; // = new Pen(new SolidBrush(OffMidTop),1f);
private Color OffMidBot = Color.FromArgb(8, 28, 24);
private Pen pOffMidBot; // = new Pen(new SolidBrush(OffMidBot),1f);
private Color OffDrk = Color.FromArgb(0, 24, 24);
private Pen pOffDrk; // = new Pen(new SolidBrush(OffDrk),1f);
private Color OffDrkTop = Color.FromArgb(8, 28, 24);
private Pen pOffDrkTop; // = new Pen(new SolidBrush(OffDrkTop),1f);
private Color OffDrkBot = Color.FromArgb(0, 16, 16);
private Pen pOffDrkBot; // = new Pen(new SolidBrush(OffDrkBot),1f);
private EventHandler onPropertiesChanged;
/// <summary></summary>
public event EventHandler PropertiesChanged {
add {
if (onPropertiesChanged != null) {
foreach (Delegate d in onPropertiesChanged.GetInvocationList()) {
if (object.ReferenceEquals(d, value)) { return; }
}
}
onPropertiesChanged = (EventHandler)Delegate.Combine(onPropertiesChanged, value);
}
remove { onPropertiesChanged = (EventHandler)Delegate.Remove(onPropertiesChanged, value); }
}
private void FireChange() {
if (onPropertiesChanged != null) { onPropertiesChanged(this, EventArgs.Empty); }
}
/// <summary></summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void component_PropertiesChanged(object sender, EventArgs e) {
FireChange();
}
/// <summary></summary>
[Category("Painters"), Description("Gets or sets the chain of gloss painters"), Browsable(true)]
public IGlossPainter GlossPainter {
get { return this.gloss; }
set {
this.gloss = value;
if (this.gloss != null) { this.gloss.PropertiesChanged += new EventHandler(component_PropertiesChanged); }
FireChange();
}
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the type of FruityLoops progress style"), Browsable(true)]
public FruityLoopsProgressPainter.FruityLoopsProgressType FruityType {
get { return type; }
set {
type = value;
if (type == FruityLoopsProgressPainter.FruityLoopsProgressType.DoubleLayer) {
OffLit = Color.FromArgb(49, 69, 74);
pOffLit = new Pen(new SolidBrush(OffLit), 1f);
OffLitTop = Color.FromArgb(57, 77, 82);
pOffLitTop = new Pen(new SolidBrush(OffLitTop), 1f);
OffLitBot = Color.FromArgb(24, 48, 49);
pOffLitBot = new Pen(new SolidBrush(OffLitBot), 1f);
OffDrk = Color.FromArgb(24, 48, 49);
pOffDrk = new Pen(new SolidBrush(OffDrk), 1f);
OffDrkTop = Color.FromArgb(16, 40, 41);
pOffDrkTop = new Pen(new SolidBrush(OffDrkTop), 1f);
OffDrkBot = Color.FromArgb(8, 18, 24);
pOffDrkBot = new Pen(new SolidBrush(OffDrkBot), 1f);
} else if (type == FruityLoopsProgressPainter.FruityLoopsProgressType.TripleLayer) {
OffLit = Color.FromArgb(49, 69, 74);
pOffLit = new Pen(new SolidBrush(OffLit), 1f);
OffLitTop = Color.FromArgb(66, 85, 90);
pOffLitTop = new Pen(new SolidBrush(OffLitTop), 1f);
OffLitBot = Color.FromArgb(24, 48, 49);
pOffLitBot = new Pen(new SolidBrush(OffLitBot), 1f);
OffMid = Color.FromArgb(24, 48, 49);
pOffMid = new Pen(new SolidBrush(OffMid), 1f);
OffMidTop = Color.FromArgb(24, 48, 49);
pOffMidTop = new Pen(new SolidBrush(OffMidTop), 1f);
OffMidBot = Color.FromArgb(8, 28, 24);
pOffMidBot = new Pen(new SolidBrush(OffMidBot), 1f);
OffDrk = Color.FromArgb(0, 24, 24);
pOffDrk = new Pen(new SolidBrush(OffDrk), 1f);
OffDrkTop = Color.FromArgb(8, 28, 24);
pOffDrkTop = new Pen(new SolidBrush(OffDrkTop), 1f);
OffDrkBot = Color.FromArgb(0, 16, 16);
pOffDrkBot = new Pen(new SolidBrush(OffDrkBot), 1f);
}
FireChange();
}
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
public void PaintBackground(Rectangle box, Graphics g) {
if (img == null) {
if (type == FruityLoopsProgressPainter.FruityLoopsProgressType.DoubleLayer) {
PaintDouble(box, g);
} else if (type == FruityLoopsProgressPainter.FruityLoopsProgressType.TripleLayer) {
PaintTriple(box, g);
}
}
g.DrawImageUnscaled(img, 0, 0);
if (gloss != null) {
gloss.PaintGloss(box, g);
}
}
/// <summary></summary>
/// <param name="r"></param>
/// <param name="g"></param>
protected virtual void PaintDouble(Rectangle r, Graphics g) {
bool lite = true;
img = new Bitmap(r.Width + 1, r.Height + 1);
Graphics gi = Graphics.FromImage(img);
for (int i = 1; i < r.Width + 1; i++) {
if (lite) {
gi.DrawLine(pOffLitTop, i, r.Y, i, r.Y + 1);
gi.DrawLine(pOffLitBot, i, r.Height, i, r.Height - 1);
gi.DrawLine(pOffLit, i, r.Y + 1, i, r.Height - 1);
} else {
gi.DrawLine(pOffDrkTop, i, r.Y, i, r.Y + 1);
gi.DrawLine(pOffDrkBot, i, r.Height, i, r.Height - 1);
gi.DrawLine(pOffDrk, i, r.Y + 1, i, r.Height - 1);
}
lite = !lite;
}
gi.Dispose();
}
/// <summary></summary>
/// <param name="r"></param>
/// <param name="g"></param>
protected virtual void PaintTriple(Rectangle r, Graphics g) {
int lite = 1;
img = new Bitmap(r.Width + 1, r.Height + 1);
Graphics gi = Graphics.FromImage(img);
for (int i = 1; i < r.Width + 1; i++) {
if (lite == 2) {
gi.DrawLine(pOffLitTop, i, r.Y, i, r.Y + 1);
gi.DrawLine(pOffLitBot, i, r.Height, i, r.Height - 1);
gi.DrawLine(pOffLit, i, r.Y + 1, i, r.Height - 1);
lite = 0;
} else if (lite == 1) {
gi.DrawLine(pOffMidTop, i, r.Y, i, r.Y + 1);
gi.DrawLine(pOffMidBot, i, r.Height, i, r.Height - 1);
gi.DrawLine(pOffMid, i, r.Y + 1, i, r.Height - 1);
lite = 2;
} else if (lite == 0) {
gi.DrawLine(pOffDrkTop, i, r.Y, i, r.Y + 1);
gi.DrawLine(pOffDrkBot, i, r.Height, i, r.Height - 1);
gi.DrawLine(pOffDrk, i, r.Y + 1, i, r.Height - 1);
lite = 1;
}
}
gi.Dispose();
}
/// <summary></summary>
public void Resize(Rectangle box) {
img = null;
}
/// <summary></summary>
protected override void Dispose(bool disposing) {
base.Dispose(disposing);
if (img != null) { img.Dispose(); }
if (pOffLit != null) { pOffLit.Dispose(); }
if (pOffLitTop != null) { pOffLitTop.Dispose(); }
if (pOffLitBot != null) { pOffLitBot.Dispose(); }
if (pOffMid != null) { pOffMid.Dispose(); }
if (pOffMidTop != null) { pOffMidTop.Dispose(); }
if (pOffMidBot != null) { pOffMidBot.Dispose(); }
if (pOffDrk != null) { pOffDrk.Dispose(); }
if (pOffDrkTop != null) { pOffDrkTop.Dispose(); }
if (pOffDrkBot != null) { pOffDrkBot.Dispose(); }
}
}
}

View File

@@ -0,0 +1,169 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.FruityLoopsProgressPainter), "Icons.FruityLoopsProgressPainter.ico")]
public class FruityLoopsProgressPainter : AbstractProgressPainter, IProgressPainter, IDisposable {
private FruityLoopsProgressType type;
private Color OnLit = Color.FromArgb(148, 170, 173);
private Pen pOnLit; // = new Pen(new SolidBrush(OnLit),1f);
private Color OnLitTop = Color.FromArgb(206, 227, 231);
private Pen pOnLitTop; // = new Pen(new SolidBrush(OnLitTop),1f);
private Color OnLitBot = Color.FromArgb(90, 117, 123);
private Pen pOnLitBot; // = new Pen(new SolidBrush(OnLitBot),1f);
private Color OnMid = Color.FromArgb(107, 130, 132);
private Pen pOnMid; // = new Pen(new SolidBrush(OnMid),1f);
private Color OnMidTop = Color.FromArgb(140, 154, 156);
private Pen pOnMidTop; // = new Pen(new SolidBrush(OnMidTop),1f);
private Color OnMidBot = Color.FromArgb(57, 85, 82);
private Pen pOnMidBot; // = new Pen(new SolidBrush(OnMidBot),1f);
private Color OnDrk = Color.FromArgb(57, 85, 82);
private Pen pOnDrk; // = new Pen(new SolidBrush(OnDrk),1f);
private Color OnDrkTop = Color.FromArgb(107, 125, 123);
private Pen pOnDrkTop; // = new Pen(new SolidBrush(OnDrkTop),1f);
private Color OnDrkBot = Color.FromArgb(33, 60, 66);
private Pen pOnDrkBot; // = new Pen(new SolidBrush(OnDrkBot),1f);
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the type of FruityLoops progress style"), Browsable(true)]
public FruityLoopsProgressType FruityType {
get { return type; }
set {
type = value;
if (type == FruityLoopsProgressType.DoubleLayer) {
OnLit = Color.FromArgb(148, 170, 173);
pOnLit = new Pen(new SolidBrush(OnLit), 1f);
OnLitTop = Color.FromArgb(206, 227, 231);
pOnLitTop = new Pen(new SolidBrush(OnLitTop), 1f);
OnLitBot = Color.FromArgb(90, 113, 115);
pOnLitBot = new Pen(new SolidBrush(OnLitBot), 1f);
OnDrk = Color.FromArgb(115, 142, 148);
pOnDrk = new Pen(new SolidBrush(OnDrk), 1f);
OnDrkTop = Color.FromArgb(181, 199, 198);
pOnDrkTop = new Pen(new SolidBrush(OnDrkTop), 1f);
OnDrkBot = Color.FromArgb(66, 89, 90);
pOnDrkBot = new Pen(new SolidBrush(OnDrkBot), 1f);
} else if (type == FruityLoopsProgressType.TripleLayer) {
OnLit = Color.FromArgb(148, 170, 173);
pOnLit = new Pen(new SolidBrush(OnLit), 1f);
OnLitTop = Color.FromArgb(206, 227, 231);
pOnLitTop = new Pen(new SolidBrush(OnLitTop), 1f);
OnLitBot = Color.FromArgb(90, 117, 123);
pOnLitBot = new Pen(new SolidBrush(OnLitBot), 1f);
OnMid = Color.FromArgb(107, 130, 132);
pOnMid = new Pen(new SolidBrush(OnMid), 1f);
OnMidTop = Color.FromArgb(140, 154, 156);
pOnMidTop = new Pen(new SolidBrush(OnMidTop), 1f);
OnMidBot = Color.FromArgb(57, 85, 82);
pOnMidBot = new Pen(new SolidBrush(OnMidBot), 1f);
OnDrk = Color.FromArgb(57, 85, 82);
pOnDrk = new Pen(new SolidBrush(OnDrk), 1f);
OnDrkTop = Color.FromArgb(107, 125, 123);
pOnDrkTop = new Pen(new SolidBrush(OnDrkTop), 1f);
OnDrkBot = Color.FromArgb(33, 60, 66);
pOnDrkBot = new Pen(new SolidBrush(OnDrkBot), 1f);
}
FireChange();
}
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
protected override void PaintThisProgress(Rectangle box, Graphics g) {
try {
box.Height -= 1;
} catch { }
if (box.Width <= 1) { return; }
if (type == FruityLoopsProgressType.DoubleLayer) {
PaintDouble(box, g);
} else if (type == FruityLoopsProgressType.TripleLayer) {
PaintTriple(box, g);
}
if (gloss != null) {
gloss.PaintGloss(box, g);
}
}
private void PaintDouble(Rectangle r, Graphics g) {
bool lite = true;
Brush b = new SolidBrush(pOnLit.Color);
g.FillRectangle(b, r);
g.DrawLine(pOnLitTop, r.X, r.Y, r.Right - 1, r.Y);
g.DrawLine(pOnLitBot, r.X, r.Bottom, r.Right - 1, r.Bottom);
for (int i = r.X; i < r.Right; i++) {
if (lite) {
//g.DrawLine(off ? pOffLitTop : pOnLitTop, i, r.Y, i, r.Y + 1);
//g.DrawLine(off ? pOffLitBot : pOnLitBot, i, r.Height, i, r.Height - 1);
//g.DrawLine(off ? pOffLit : pOnLit, i, r.Y + 1, i, r.Height - 1);
} else {
g.DrawLine(pOnDrkTop, i, r.Y, i, r.Y + 1);
g.DrawLine(pOnDrkBot, i, r.Bottom, i, r.Bottom - 1);
g.DrawLine(pOnDrk, i, r.Y + 1, i, r.Bottom - 1);
}
lite = !lite;
}
}
private void PaintTriple(Rectangle r, Graphics g) {
int lite = 1;
Brush b = new SolidBrush(pOnMid.Color);
g.FillRectangle(b, r);
g.DrawLine(pOnMidTop, r.X, r.Y, r.Right - 1, r.Y);
g.DrawLine(pOnMidBot, r.X, r.Bottom, r.Right - 1, r.Bottom);
for (int i = r.X; i < r.Right; i++) {
if (lite == 2) {
g.DrawLine(pOnLitTop, i, r.Y, i, r.Y + 1);
g.DrawLine(pOnLitBot, i, r.Bottom, i, r.Bottom - 1);
g.DrawLine(pOnLit, i, r.Y + 1, i, r.Bottom - 1);
lite = 0;
} else if (lite == 1) {
//g.DrawLine(pOnMidTop, i, r.Y, i, r.Y + 1);
//g.DrawLine(pOnMidBot, i, r.Height, i, r.Height - 1);
//g.DrawLine(pOnMid, i, r.Y + 1, i, r.Height - 1);
lite = 2;
} else if (lite == 0) {
g.DrawLine(pOnDrkTop, i, r.Y, i, r.Y + 1);
g.DrawLine(pOnDrkBot, i, r.Bottom, i, r.Bottom - 1);
g.DrawLine(pOnDrk, i, r.Y + 1, i, r.Bottom - 1);
lite = 1;
}
}
}
/// <summary></summary>
protected override void DisposeThis(bool disposing) {
if (pOnLit != null) { pOnLit.Dispose(); }
if (pOnLitTop != null) { pOnLitTop.Dispose(); }
if (pOnLitBot != null) { pOnLitBot.Dispose(); }
if (pOnMid != null) { pOnMid.Dispose(); }
if (pOnMidTop != null) { pOnMidTop.Dispose(); }
if (pOnMidBot != null) { pOnMidBot.Dispose(); }
if (pOnDrk != null) { pOnDrk.Dispose(); }
if (pOnDrkTop != null) { pOnDrkTop.Dispose(); }
if (pOnDrkBot != null) { pOnDrkBot.Dispose(); }
}
/// <summary></summary>
public enum FruityLoopsProgressType {
/// <summary></summary>
DoubleLayer,
/// <summary></summary>
TripleLayer
}
}
}

View File

@@ -0,0 +1,102 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.GradientBackgroundPainter), "Icons.GradientBackgroundPainter.ico")]
public class GradientBackgroundPainter : Component, IProgressBackgroundPainter, IDisposable {
private Color top;
private Color bottom;
private Brush brush;
private IGlossPainter gloss;
private EventHandler onPropertiesChanged;
/// <summary></summary>
public event EventHandler PropertiesChanged {
add {
if (onPropertiesChanged != null) {
foreach (Delegate d in onPropertiesChanged.GetInvocationList()) {
if (object.ReferenceEquals(d, value)) { return; }
}
}
onPropertiesChanged = (EventHandler)Delegate.Combine(onPropertiesChanged, value);
}
remove { onPropertiesChanged = (EventHandler)Delegate.Remove(onPropertiesChanged, value); }
}
private void FireChange() {
if (onPropertiesChanged != null) { onPropertiesChanged(this, EventArgs.Empty); }
}
/// <summary></summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void component_PropertiesChanged(object sender, EventArgs e) {
FireChange();
}
/// <summary></summary>
public GradientBackgroundPainter() {
this.top = Color.FromArgb(240, 240, 240);
this.bottom = Color.FromArgb(224, 224, 224);
}
/// <summary></summary>
/// <param name="color"></param>
public GradientBackgroundPainter(Color top, Color bottom) {
this.top = top;
this.bottom = bottom;
}
/// <summary></summary>
[Category("Painters"), Description("Gets or sets the chain of gloss painters"), Browsable(true)]
public IGlossPainter GlossPainter {
get { return this.gloss; }
set {
this.gloss = value;
if (this.gloss != null) { this.gloss.PropertiesChanged += new EventHandler(component_PropertiesChanged); }
FireChange();
}
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the top gradient color"), Browsable(true)]
public Color TopColor {
get { return top; }
set { top = value; FireChange(); }
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the bottom gradient color"), Browsable(true)]
public Color BottomColor {
get { return bottom; }
set { bottom = value; FireChange(); }
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
public void PaintBackground(Rectangle box, Graphics g) {
Resize(box);
g.FillRectangle(brush, box);
if (gloss != null) {
gloss.PaintGloss(box, g);
}
}
/// <summary></summary>
public void Resize(Rectangle box) {
brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Point(0, 0), new Point(0, box.Height), bottom, top);
}
/// <summary></summary>
protected override void Dispose(bool disposing) {
base.Dispose(disposing);
if (brush != null) { brush.Dispose(); }
}
}
}

View File

@@ -0,0 +1,119 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.GradientGlossPainter), "Icons.GradientGlossPainter.ico")]
public class GradientGlossPainter : ChainedGlossPainter {
private GlossStyle style = GlossStyle.Bottom;
private int percent = 50;
private Color color = Color.White;
private int highAlpha = 240;
private int lowAlpha = 0;
private float angle = 90f;
private Brush brush;
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the style for this progress gloss"), Browsable(true)]
public GlossStyle Style {
get { return this.style; }
set {
this.style = value;
FireChange();
}
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the percentage of surface this gloss should cover"), Browsable(true)]
public int PercentageCovered {
get { return this.percent; }
set {
this.percent = value;
FireChange();
}
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets color to gloss"), Browsable(true)]
public Color Color {
get { return this.color; }
set {
this.color = value;
FireChange();
}
}
/// <summary></summary>
[Category("Blending"), Description("Gets or sets the high alpha value"), Browsable(true)]
public int AlphaHigh {
get { return this.highAlpha; }
set {
if (value < 0 || value > 255) {
throw new ArgumentException("Alpha values must be between 0 and 255.");
}
this.highAlpha = value;
FireChange();
}
}
/// <summary></summary>
[Category("Blending"), Description("Gets or sets the low alpha value"), Browsable(true)]
public int AlphaLow {
get { return this.lowAlpha; }
set {
if (value < 0 || value > 255) {
throw new ArgumentException("Alpha values must be between 0 and 255.");
}
this.lowAlpha = value;
FireChange();
}
}
/// <summary></summary>
[Category("Blending"), Description("Gets or sets angle for the gradient"), Browsable(true)]
public float Angle {
get { return this.angle; }
set {
this.angle = value;
FireChange();
}
}
protected override void PaintThisGloss(Rectangle box, Graphics g) {
int y = (int)(((float)box.Height * (float)percent) / 100f);
if (box.Y + y > box.Height) { y = box.Height; }
Rectangle cover = box;
switch (style) {
case GlossStyle.Bottom:
int start = box.Height + box.Y - y;
cover = new Rectangle(box.X, start - 1, box.Width /*- 1*/, box.Bottom - start);
break;
case GlossStyle.Top:
cover = new Rectangle(box.X, box.Y - 1, box.Width /*- 1*/, y + 2);
break;
case GlossStyle.Both:
cover = box;
break;
}
Color hcolor = Color.FromArgb(highAlpha, color.R, color.G, color.B);
Color lcolor = Color.FromArgb(lowAlpha, color.R, color.G, color.B);
brush = new LinearGradientBrush(cover, hcolor, lcolor, angle, true);
g.FillRectangle(brush, cover);
//g.DrawRectangle(Pens.Red, cover);
}
protected override void ResizeThis(Rectangle box) {
}
protected override void Dispose(bool disposing) {
base.Dispose(disposing);
if (brush != null) { brush.Dispose(); }
}
}
}

188
ProgressODoom/HSV.cs Normal file
View File

@@ -0,0 +1,188 @@
using System;
using System.Drawing;
namespace ProgressODoom {
public struct HSV {
private int hue;
private int sat;
private int val;
public HSV(int h, int s, int v) {
hue = h;
sat = s;
val = v;
}
public HSV(Color color) {
hue = 0;
sat = 0;
val = 0;
FromRGB(color);
}
public static Color FromHsv(int h, int s, int v) {
HSV hsv = new HSV(h, s, v);
return hsv.Color;
}
public int Hue {
get { return hue; }
set { hue = value; }
}
public int Saturation {
get { return sat; }
set { sat = value; }
}
public int Value {
get { return val; }
set { val = value; }
}
public Color Color {
get { return ToRGB(); }
set { FromRGB(value); }
}
private void FromRGB(Color color) {
/*
if (max = min)
h = 0
if (max = r)
h = (60deg * (g-b)/(max-min) + 0deg) % 360deg
if (max = g)
h = (60deg * (b-r)/(max-min) + 120deg)
if (max = b)
h = (60deg * (r-g)/(max-min) + 240deg)
if (max = 0)
s = 0
else
s = 1 - min/max
v = max
*/
double min;
double max;
double delta;
double r = (double)color.R / 255D;
double g = (double)color.G / 255D;
double b = (double)color.B / 255D;
double h;
double s;
double v;
min = Math.Min(Math.Min(r, g), b);
max = Math.Max(Math.Max(r, g), b);
v = max;
delta = max - min;
if (max == 0 || delta == 0) {
s = 0;
h = 0;
} else {
s = delta / max;
if (r == max) {
h = (60D * ((g - b) / delta)) % 360D;
} else if (g == max) {
h = 60D * ((b - r) / delta) + 120D;
} else {
h = 60D * ((r - g) / delta) + 240D;
}
}
if (h < 0) {
h += 360D;
}
Hue = (int)(h / 360D * 255D);
Saturation = (int)(s * 255D);
Value = (int)(v * 255D);
}
private Color ToRGB() {
double h;
double s;
double v;
double r = 0;
double g = 0;
double b = 0;
// Scale Hue to be between 0 and 360. Saturation
// and value scale to be between 0 and 1.
h = ((double)Hue / 255D * 360D) % 360D;
s = (double)Saturation / 255D;
v = (double)Value / 255D;
if (s == 0) {
r = v;
g = v;
b = v;
} else {
double p;
double q;
double t;
double fractionalSector;
int sectorNumber;
double sectorPos;
sectorPos = h / 60D;
sectorNumber = (int)(Math.Floor(sectorPos));
fractionalSector = sectorPos - sectorNumber;
p = v * (1D - s);
q = v * (1D - (s * fractionalSector));
t = v * (1D - (s * (1D - fractionalSector)));
switch (sectorNumber) {
case 0:
r = v;
g = t;
b = p;
break;
case 1:
r = q;
g = v;
b = p;
break;
case 2:
r = p;
g = v;
b = t;
break;
case 3:
r = p;
g = q;
b = v;
break;
case 4:
r = t;
g = p;
b = v;
break;
case 5:
r = v;
g = p;
b = q;
break;
}
}
return Color.FromArgb((int)(r * 255D), (int)(g * 255D), (int)(b * 255D));
}
public static bool operator !=(HSV left, HSV right) {
return !(left == right);
}
public static bool operator ==(HSV left, HSV right) {
return (left.Hue == right.Hue && left.Value == right.Value && left.Saturation == right.Saturation);
}
public override string ToString() {
string s = string.Format("HSV({0:f2}, {1:f2}, {2:f2})", Hue, Saturation, Value);
return s;
}
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Drawing;
namespace ProgressODoom {
/// <summary></summary>
public interface IAnimatedProgressPainter : IProgressPainter {
///// <summary></summary>
///// <param name="box"></param>
///// <param name="g"></param>
///// <param name="marqueeX"></param>
//void AnimateFrame(Rectangle box, Graphics g, ref int marqueeX);
/// <summary></summary>
int AnimationSpeed { get; set; }
/// <summary></summary>
bool Animating { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Drawing;
namespace ProgressODoom {
public interface IGlossPainter : IDisposable {
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
void PaintGloss(Rectangle box, Graphics g);
/// <summary></summary>
void Resize(Rectangle box);
/// <summary></summary>
event EventHandler PropertiesChanged;
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Drawing;
namespace ProgressODoom {
/// <summary></summary>
public interface IProgressBackgroundPainter : IDisposable {
/// <summary></summary>
IGlossPainter GlossPainter { get; set; }
/// <summary></summary>
/// <param name="box"></param>
/// <param name="gr"></param>
void PaintBackground(Rectangle box, Graphics gr);
/// <summary></summary>
void Resize(Rectangle box);
/// <summary></summary>
event EventHandler PropertiesChanged;
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Drawing;
namespace ProgressODoom {
/// <summary></summary>
public interface IProgressBorderPainter : IDisposable {
/// <summary></summary>
/// <param name="box"></param>
/// <param name="gr"></param>
void PaintBorder(Rectangle box, Graphics gr);
/// <summary></summary>
void Resize(Rectangle box);
/// <summary></summary>
int BorderWidth { get; }
/// <summary></summary>
event EventHandler PropertiesChanged;
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Drawing;
namespace ProgressODoom {
/// <summary></summary>
public interface IProgressPainter : IDisposable {
/// <summary></summary>
IGlossPainter GlossPainter { get; set; }
/// <summary></summary>
IProgressBorderPainter ProgressBorderPainter { get; set; }
/// <summary></summary>
/// <param name="box"></param>
/// <param name="gr"></param>
void PaintProgress(Rectangle box, Graphics gr);
/// <summary></summary>
void Resize(Rectangle box);
/// <summary></summary>
event EventHandler PropertiesChanged;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1,138 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.JavaProgressPainter), "Icons.JavaProgressPainter.ico")]
public class JavaProgressPainter : AbstractProgressPainter, IProgressPainter, IDisposable {
private Color color;
private ColorSet colors;
/// <summary></summary>
public JavaProgressPainter() {
color = Color.SkyBlue;
colors = new ColorSet(false, color, 0.95f, 8);
}
/// <summary></summary>
/// <param name="color"></param>
public JavaProgressPainter(Color color) {
this.color = color;
colors = new ColorSet(false, color, 0.95f, 8);
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the base progress color."), Browsable(true)]
public Color Color {
get { return color; }
set {
color = value;
colors = new ColorSet(false, color, 0.95f, 8);
FireChange();
}
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
protected override void PaintThisProgress(Rectangle box, Graphics g) {
try {
box.Width -= 1;
box.Height -= 1;
} catch {}
if (box.Width <= 1) { return; }
float x = (float)box.X;
float y = (float)box.Y;
float w = (float)box.Right;
float h = (float)box.Bottom;
//Color corner
Pen p;
x += 2f; //x += 3f; //x += 2f; //x = x + 3f;
y += 4f; //y += 5f; //y += 4f; //y = y + 5f;
w -= 2f; //w -= 3f; //w -= 1f; //w = w - 2f;
h -= 4f; //h -= 6f; //h -= 4f; //h = h - 6f;
// Progress
colors = new ColorSet(true, this.color, 0.95f, (int)h);
float z = 2;
float ni;
float th = box.Height - 4;
for (int i = -2; i < th; i++) {
//for (int i = -2; i < th; i++) {
z = (i < 0 ? i * -1 : i);
Color c = colors.Colors[colors.Colors.Length - 1];
try {
c = colors.Colors[(int)z];
} catch {}
p = new Pen(c);
ni = y + i;
g.DrawLine(p, x, ni, w, ni);
}
Color progborder = ColorRange.Morph(0.2f, Color.FromArgb(98, 98, 89), this.color);
Color fade = Color.FromArgb(64, progborder.R, progborder.G, progborder.B);
p = new Pen(new SolidBrush(fade), 1);
//g.DrawRectangle(p, x - 1f, y - 3f, w - 1f, h + 1f);
Rectangle bbox = box;
bbox.Inflate(-1, -1);
g.DrawRectangle(p, bbox);
// Border
p = new Pen(progborder, 1);
////g.DrawRectangle(p, x - 1f, y - 3f, w - 1f, h + 1f);
//g.DrawLine(p, x, y - 3f, w, y - 3f);
//g.DrawLine(p, x, h + 3f, w, h + 3f);
//g.DrawLine(p, x - 1f, y - 2f, x - 1f, h + 2f);
//g.DrawLine(p, w + 1f, y - 2f, w + 1f, h + 2f);
g.DrawLine(p, x + 1f, y - 3f, w - 1f, y - 3f);
g.DrawLine(p, x + 1f, h + 3f, w - 1f, h + 3f);
g.DrawLine(p, x - 1f, y - 1f, x - 1f, h + 1f);
g.DrawLine(p, w + 1f, y - 1f, w + 1f, h + 1f);
// Border corner skirt
//Color skirt = ColorRange.Morph(0.8f, this.color, progborder);
Color skirt = Color.FromArgb(210, progborder.R, progborder.G, progborder.B);
p = new Pen(skirt, 1);
//// Upper Left
//g.DrawLine(p, x - 1f, y - 3f, x, y - 3f);
//g.DrawLine(p, x - 1f, y - 3f, x - 1f, y - 2f);
g.DrawLine(p, x, y - 3f, x - 1f, y - 2f);
//// Lower Left
//g.DrawLine(p, x - 1f, h + 3f, x - 1f, h + 2f);
//g.DrawLine(p, x - 1f, h + 3f, x, h + 3f);
g.DrawLine(p, x, h + 3f, x - 1f, h + 2f);
//// Upper Right
//g.DrawLine(p, w + 1f, y - 3f, w + 1f, y - 2f);
//g.DrawLine(p, w + 1f, y - 3f, w, y - 3f);
g.DrawLine(p, w, y - 3f, w + 1f, y - 2f);
//// Lower Right
//g.DrawLine(p, w + 1f, h + 3f, w, h + 3f);
//g.DrawLine(p, w + 1f, h + 3f, w + 1f, h + 2f);
g.DrawLine(p, w, h + 3f, w + 1f, h + 2f);
//// Border corner x-1f, y-3f, w-2f, h+1f
//Color corners = ColorRange.Morph(0.5f, this.color, progborder); //Color.FromArgb(229, 229, 222)
//p = new Pen(corners, 1);
//g.DrawLine(p, x - 1f, y - 3f, x, y - 2f); // ul
//g.DrawLine(p, x - 1f, h + 3f, x, h + 2f); // ll
//g.DrawLine(p, w + 1f, y - 3f, w, y - 2f); // ur
//g.DrawLine(p, w + 1f, h + 3f, w, h + 2f); // lr
////// Outer corner (Left side only)
////Color outcorner = ColorRange.Morph(0.5f, progborder, Color.FromArgb(229, 229, 222));
////p = new Pen(outcorner, 1);
////g.DrawLine(p, x - 2f, y - 4f, x - 1f, y - 3f);
////g.DrawLine(p, x - 2f, h + 4f, x - 1f, h + 3f);
if (gloss != null) {
gloss.PaintGloss(box, g);
}
}
}
}

View File

@@ -0,0 +1,153 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.MetalProgressPainter), "Icons.MetalProgressPainter.ico")]
public class MetalProgressPainter : AbstractProgressPainter, IProgressPainter, IDisposable {
private Color progColor = Color.FromArgb(201, 202, 201);
private Color bkColor = Color.FromArgb(240, 240, 240);
#region Default Colors
private Color backColor = Color.FromArgb(176, 177, 176);
private Color borderColor = Color.FromArgb(69, 68, 69);
private Color backtopColor = Color.FromArgb(160, 157, 160);
private Color barColor12 = Color.FromArgb(193, 194, 193);
private Color barColor3 = Color.FromArgb(201, 202, 201);
private Color barColor8 = Color.FromArgb(226, 226, 226);
private Color barBorderTopColor = Color.FromArgb(250, 250, 250);
private Color barBorderBottomColor = Color.FromArgb(176, 173, 176);
#endregion
#region Pens & Brushes
private Pen border;
private Pen backtop;
private Brush back;
private Pen bar12;
private Pen bar8;
private Pen barBorderTop;
private Pen barBorderBottom;
private Brush prog;
#endregion
/// <summary></summary>
public MetalProgressPainter() {
progColor = barColor3;
back = new SolidBrush(bkColor); //backColor);
border = new Pen(new SolidBrush(borderColor), 1f);
backtop = new Pen(new SolidBrush(backtopColor), 1f);
bar12 = new Pen(new SolidBrush(barColor12), 1f);
bar8 = new Pen(new SolidBrush(barColor8), 1f);
barBorderTop = new Pen(new SolidBrush(barBorderTopColor), 1f);
barBorderBottom = new Pen(new SolidBrush(barBorderBottomColor), 1f);
prog = new System.Drawing.Drawing2D.LinearGradientBrush(new Point(0, 0), new Point(0, 20), barColor12, barColor8);
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the base progress color"), Browsable(true)]
public Color Color {
get { return progColor; }
set {
progColor = value;
FireChange();
}
}
[Category("Appearance"), Description("Gets or sets the color that the highlights are blended with"), Browsable(true)]
public Color Highlight {
get { return backColor; }
set {
backColor = value;
FireChange();
}
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
protected override void PaintThisProgress(Rectangle box, Graphics g) {
try {
box.Width -= 1;
box.Height -= 1;
} catch {}
float x = box.X;
float y = box.Y;
float w = box.Right;
float h = box.Bottom;
if (w < 2) { return; }
RebuildBrushes(box.Bottom - 1);
//g.FillRectangle(prog, x + 1, y + 1, w - 2, h - 1);
//
//g.DrawRectangle(barBorderBottom, box.X, box.Y, box.Right, box.Height - 1);
//g.DrawLine(barBorderTop, box.X, box.Y, box.Width + 2, box.Y);
//g.DrawLine(barBorderTop, box.X, box.Y, box.X, box.Height + 2);
g.FillRectangle(prog, box);
g.DrawLine(barBorderTop, x, y, w, y); // top
g.DrawLine(barBorderTop, x, y, x, h); // left
g.DrawLine(barBorderBottom, x, h, w, h); // bottom
g.DrawLine(barBorderBottom, w, h, w, y); // right
//g.DrawRectangle(border, x + 2, y + 2, w - 3, h - 4);
if (gloss != null) {
gloss.PaintGloss(box, g);
}
}
/// <summary></summary>
protected override void ResizeThis(Rectangle box) {
//RebuildBrushes();
}
private void RebuildBrushes(int height) {
Color top = Cross(barColor3, progColor, barColor12);
Color bottom = Cross(barColor3, progColor, barColor8);
bar12 = new Pen(new SolidBrush(top), 1f);
bar8 = new Pen(new SolidBrush(bottom), 1f);
barBorderTop = new Pen(new SolidBrush(Cross(barColor3, progColor, barBorderTopColor)), 1f);
barBorderBottom = new Pen(new SolidBrush(Cross(barColor3, progColor, barBorderBottomColor)), 1f);
int h = height;
//if (h == 0) { h = 20; }
prog = new System.Drawing.Drawing2D.LinearGradientBrush(new Point(0, 1), new Point(0, h + 2), top, bottom);
backtop = new Pen(new SolidBrush(Cross(backColor, bkColor, backtopColor)), 1f);
back = new SolidBrush(bkColor);
}
private Color Cross(Color colorX, Color colorY, Color colorX2) {
int r = (int)(((float)colorY.R * (float)colorX2.R) / (float)colorX.R);
int g = (int)(((float)colorY.G * (float)colorX2.G) / (float)colorX.G);
int b = (int)(((float)colorY.B * (float)colorX2.B) / (float)colorX.B);
if (r > 255) { r = 255; } else if (r < 0) { r = 0; }
if (g > 255) { g = 255; } else if (g < 0) { g = 0; }
if (b > 255) { b = 255; } else if (b < 0) { b = 0; }
return Color.FromArgb(r, g, b);
}
/// <summary></summary>
protected override void DisposeThis(bool disposing) {
if (border != null) { border.Dispose(); }
if (backtop != null) { backtop.Dispose(); }
if (back != null) { back.Dispose(); }
if (bar12 != null) { bar12.Dispose(); }
if (bar8 != null) { bar8.Dispose(); }
if (barBorderTop != null) { barBorderTop.Dispose(); }
if (barBorderBottom != null) { barBorderBottom.Dispose(); }
if (prog != null) { prog.Dispose(); }
}
}
}

View File

@@ -0,0 +1,162 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.MiddleGlossPainter), "Icons.MiddleGlossPainter.ico")]
public class MiddleGlossPainter : ChainedGlossPainter {
private GlossStyle style = GlossStyle.Both;
private int highAlpha = 240;
private int lowAlpha = 0;
private int fadewidth = 4;
private Brush highBrush;
private Brush lowBrush;
private Brush bothBrush;
private Rectangle box;
private Color color = Color.White;
private Color topColor;
private Color botColor;
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the style for this progress gloss"), Browsable(true)]
public GlossStyle Style {
get { return this.style; }
set {
this.style = value;
this.box = new Rectangle(0, 0, 1, 1);
FireChange();
}
}
/// <summary></summary>
[Category("Blending"), Description("Gets or sets the high alpha value"), Browsable(true)]
public int AlphaHigh {
get { return this.highAlpha; }
set {
if (value < 0 || value > 255) {
throw new ArgumentException("Alpha values must be between 0 and 255.");
}
this.highAlpha = value;
this.box = new Rectangle(0, 0, 1, 1);
FireChange();
}
}
/// <summary></summary>
[Category("Blending"), Description("Gets or sets the low alpha value"), Browsable(true)]
public int AlphaLow {
get { return this.lowAlpha; }
set {
if (value < 0 || value > 255) {
throw new ArgumentException("Alpha values must be between 0 and 255.");
}
this.lowAlpha = value;
this.box = new Rectangle(0, 0, 1, 1);
FireChange();
}
}
/// <summary></summary>
[Category("Blending"), Description("Gets or sets the number of pixels to blend over"), Browsable(true)]
public int TaperHeight {
get { return this.fadewidth; }
set {
this.fadewidth = value;
this.box = new Rectangle(0, 0, 1, 1);
FireChange();
}
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets color to gloss"), Browsable(true)]
public Color Color {
get { return this.color; }
set {
this.color = value;
this.topColor = Color.FromArgb(highAlpha, this.color.R, this.color.G, this.color.B);
this.botColor = Color.FromArgb(lowAlpha, this.color.R, this.color.G, this.color.B);
box = new Rectangle(0, 0, 1, 1);
FireChange();
}
}
protected override void PaintThisGloss(Rectangle box, Graphics g) {
if (!this.box.Equals(box)) {
this.box = box;
ResetBrushes(box);
}
int midpoint = box.X + (int)((float)box.Height / 2f);
Rectangle topBox = new Rectangle(box.X, midpoint - fadewidth, box.Width - 1, fadewidth);
Rectangle botBox = new Rectangle(box.X, midpoint, box.Width - 1, fadewidth);
Rectangle fullBox = new Rectangle(box.X, midpoint - fadewidth, box.Width - 1, fadewidth * 2);
switch (style) {
case GlossStyle.Bottom:
g.FillRectangle(lowBrush, botBox);
//g.DrawRectangle(Pens.Fuchsia, botBox);
break;
case GlossStyle.Top:
g.FillRectangle(highBrush, topBox);
//g.DrawRectangle(Pens.Fuchsia, topBox);
break;
case GlossStyle.Both:
//g.FillRectangle(highBrush, topBox);
//g.FillRectangle(lowBrush, botBox);
g.FillRectangle(bothBrush, fullBox);
break;
}
//g.DrawRectangle(Pens.Purple, fullBox);
//g.DrawRectangle(new Pen(new SolidBrush(Color.FromArgb(64, 255, 255, 0))), topBox);
//g.DrawRectangle(new Pen(new SolidBrush(Color.FromArgb(64, 0, 255, 0))), botBox);
}
protected override void ResizeThis(Rectangle box) {
if (!this.box.Equals(box)) {
this.box = box;
ResetBrushes(box);
}
}
private void ResetBrushes(Rectangle box) {
int midpoint = box.X + (int)((float)box.Height / 2f);
Rectangle topBox = new Rectangle(box.X, midpoint - fadewidth, box.Width - 1, fadewidth);
Rectangle botBox = new Rectangle(box.X, midpoint, box.Width - 1, fadewidth);
Rectangle fullBox = new Rectangle(box.X, midpoint - fadewidth, box.Width - 1, fadewidth * 2);
//int midpoint = box.X + (int)((float)box.Height / 2f);
Point top = new Point(box.X, fullBox.Top);
Point topmid = new Point(box.X, topBox.Bottom);
Point botmid = new Point(box.X, botBox.Top);
Point bot = new Point(box.X, botBox.Bottom);
Color high = topColor;
Color low = botColor;
//Rectangle fullBox = new Rectangle(box.X, midpoint - fadewidth, box.Width - 1, fadewidth * 2);
switch (style) {
case GlossStyle.Top:
highBrush = new LinearGradientBrush(top, topmid, low, high);
break;
case GlossStyle.Bottom:
lowBrush = new LinearGradientBrush(botmid, bot, high, low);
break;
case GlossStyle.Both:
//highBrush = new LinearGradientBrush(top, topmid, low, high);
//lowBrush = new LinearGradientBrush(botmid, bot, high, low);
bothBrush = new LinearGradientBrush(fullBox, low, high, LinearGradientMode.Vertical);
//((LinearGradientBrush)bothBrush).SetSigmaBellShape(0.5f, 0.5f);
((LinearGradientBrush)bothBrush).SetBlendTriangularShape(0.5f);
break;
}
}
protected override void Dispose(bool disposing) {
base.Dispose(disposing);
if (highBrush != null) { highBrush.Dispose(); }
if (lowBrush != null) { lowBrush.Dispose(); }
if (bothBrush != null) { bothBrush.Dispose(); }
}
}
}

View File

@@ -0,0 +1,95 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.PlainBackgroundPainter), "Icons.PlainBackgroundPainter.ico")]
public class PlainBackgroundPainter : Component, IProgressBackgroundPainter, IDisposable {
private Color color;
private Brush brush;
private IGlossPainter gloss;
private EventHandler onPropertiesChanged;
/// <summary></summary>
public event EventHandler PropertiesChanged {
add {
if (onPropertiesChanged != null) {
foreach (Delegate d in onPropertiesChanged.GetInvocationList()) {
if (object.ReferenceEquals(d, value)) { return; }
}
}
onPropertiesChanged = (EventHandler)Delegate.Combine(onPropertiesChanged, value);
}
remove { onPropertiesChanged = (EventHandler)Delegate.Remove(onPropertiesChanged, value); }
}
private void FireChange() {
if (onPropertiesChanged != null) { onPropertiesChanged(this, EventArgs.Empty); }
}
/// <summary></summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void component_PropertiesChanged(object sender, EventArgs e) {
FireChange();
}
/// <summary></summary>
public PlainBackgroundPainter() {
this.Color = Color.FromArgb(240, 240, 240);
}
/// <summary></summary>
/// <param name="color"></param>
public PlainBackgroundPainter(Color color) {
this.Color = color;
}
/// <summary></summary>
/// <summary></summary>
[Category("Painters"), Description("Gets or sets the chain of gloss painters"), Browsable(true)]
public IGlossPainter GlossPainter {
get { return this.gloss; }
set {
this.gloss = value;
if (this.gloss != null) { this.gloss.PropertiesChanged += new EventHandler(component_PropertiesChanged); }
FireChange();
}
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the background color"), Browsable(true)]
public Color Color {
get { return color; }
set {
color = value;
brush = new SolidBrush(color);
FireChange();
}
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
public void PaintBackground(Rectangle box, Graphics g) {
g.FillRectangle(brush, box);
if (gloss != null) {
gloss.PaintGloss(box, g);
}
}
/// <summary></summary>
public void Resize(Rectangle box) {
}
/// <summary></summary>
protected override void Dispose(bool disposing) {
base.Dispose(disposing);
brush.Dispose();
}
}
}

View File

@@ -0,0 +1,158 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.PlainBorderPainter), "Icons.PlainBorderPainter.ico")]
public class PlainBorderPainter : Component, IProgressBorderPainter, IDisposable {
private Color color;
private Pen pent;
private Pen penb;
private Pen cleart;
private Pen clearb;
private bool rounded = false;
private PlainBorderStyle style = PlainBorderStyle.Flat;
private EventHandler onPropertiesChanged;
/// <summary></summary>
public event EventHandler PropertiesChanged {
add {
if (onPropertiesChanged != null) {
foreach (Delegate d in onPropertiesChanged.GetInvocationList()) {
if (object.ReferenceEquals(d, value)) { return; }
}
}
onPropertiesChanged = (EventHandler)Delegate.Combine(onPropertiesChanged, value);
}
remove { onPropertiesChanged = (EventHandler)Delegate.Remove(onPropertiesChanged, value); }
}
private void FireChange() {
if (onPropertiesChanged != null) { onPropertiesChanged(this, EventArgs.Empty); }
}
/// <summary></summary>
public PlainBorderPainter() {
this.Color = Color.Black;
//this.clear = new Pen(new SolidBrush(SystemColors.Control));
}
/// <summary></summary>
/// <param name="color"></param>
public PlainBorderPainter(Color color) {
this.Color = color;
//this.clear = new Pen(new SolidBrush(SystemColors.Control));
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the border color"), Browsable(true)]
public Color Color {
get { return color; }
set {
color = value;
if (style == PlainBorderStyle.Flat) {
pent = new Pen(new SolidBrush(color), 1f);
penb = pent;
this.cleart = new Pen(new SolidBrush(Color.FromArgb(64, color.R, color.G, color.B)));
this.clearb = cleart;
FireChange();
}
}
}
/// <summary></summary>
[Category("Appearance"), Description("Determines wether or not to make the border a flat sqaure"), Browsable(true)]
public bool RoundedCorners {
get { return rounded; }
set { rounded = value; FireChange(); }
}
[Category("Appearance"), Description("Gets or sets the border style"), Browsable(true)]
public PlainBorderStyle Style {
get { return style; }
set {
style = value;
switch (style) {
case PlainBorderStyle.Flat:
pent = new Pen(new SolidBrush(color), 1f);
penb = pent;
this.cleart = new Pen(new SolidBrush(Color.FromArgb(64, color.R, color.G, color.B)));
this.clearb = cleart;
break;
case PlainBorderStyle.Raised:
pent = new Pen(new SolidBrush(SystemColors.ControlLightLight), 1f);
penb = new Pen(new SolidBrush(SystemColors.ControlDark), 1f);
this.cleart = new Pen(new SolidBrush(Color.FromArgb(64, SystemColors.ControlLightLight.R, SystemColors.ControlLightLight.G, SystemColors.ControlLightLight.B)));
this.clearb = new Pen(new SolidBrush(Color.FromArgb(64, SystemColors.ControlDark.R, SystemColors.ControlDark.G, SystemColors.ControlDark.B)));
break;
case PlainBorderStyle.Sunken:
pent = new Pen(new SolidBrush(SystemColors.ControlDark), 1f);
penb = new Pen(new SolidBrush(SystemColors.ControlLightLight), 1f);
this.cleart = new Pen(new SolidBrush(Color.FromArgb(64, SystemColors.ControlDark.R, SystemColors.ControlDark.G, SystemColors.ControlDark.B)));
this.clearb = new Pen(new SolidBrush(Color.FromArgb(64, SystemColors.ControlLightLight.R, SystemColors.ControlLightLight.G, SystemColors.ControlLightLight.B)));
break;
}
FireChange();
}
}
/// <summary></summary>
[Browsable(false)]
public int BorderWidth {
get { return 1; }
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
public void PaintBorder(Rectangle box, Graphics g) {
//try {
// box.Width -= 1;
// box.Height -= 1;
//} catch {}
if (rounded) {
//// draws the left and right side (because they're shorter) to cover the corner pixels.
//g.DrawLine(clear, box.X, 0, box.X, box.Height);
//g.DrawLine(clear, box.Width, 0, box.Width, box.Height);
g.DrawLine(cleart, box.X, box.Y, box.Right - 1, box.Y); // top
g.DrawLine(cleart, box.X, box.Y, box.X, box.Bottom - 1); // left
g.DrawLine(clearb, box.X, box.Bottom, box.Right, box.Bottom); // bottom
g.DrawLine(clearb, box.Right, box.Y, box.Right, box.Bottom); // right
//g.DrawRectangle(clear, box);
g.DrawLine(pent, box.X + 1, box.Y, box.Right - 1, box.Y); // top
g.DrawLine(penb, box.X + 1, box.Bottom, box.Right - 1, box.Bottom); // bottom
g.DrawLine(pent, box.X, box.Y + 1, box.X, box.Bottom - 1); // left
g.DrawLine(penb, box.Right, box.Y + 1, box.Right, box.Bottom - 1); // right
} else {
//g.DrawRectangle(pen, box);
g.DrawLine(pent, box.X, box.Y, box.Right, box.Y); // top
g.DrawLine(pent, box.X, box.Y, box.X, box.Bottom); // left
g.DrawLine(penb, box.X, box.Bottom, box.Right, box.Bottom); // bottom
g.DrawLine(penb, box.Right, box.Y, box.Right, box.Bottom); // right
}
}
/// <summary></summary>
public void Resize(Rectangle box) {
}
/// <summary></summary>
protected override void Dispose(bool disposing) {
base.Dispose(disposing);
pent.Dispose();
penb.Dispose();
cleart.Dispose();
clearb.Dispose();
}
/// <summary></summary>
public enum PlainBorderStyle {
Flat, Sunken, Raised
}
}
}

View File

@@ -0,0 +1,66 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.PlainProgressPainter), "Icons.PlainProgressPainter.ico")]
public class PlainProgressPainter : AbstractProgressPainter, IProgressPainter, IDisposable {
private Color color;
private Brush brush;
private Color edge = Color.Transparent;
/// <summary></summary>
public PlainProgressPainter() {
this.Color = Color.FromArgb(151, 151, 234);
}
/// <summary></summary>
/// <param name="color"></param>
public PlainProgressPainter(Color color) {
this.Color = color;
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the color to draw the leading edge of the progress with"), Browsable(true)]
public Color LeadingEdge {
get { return this.edge; }
set { this.edge = value; FireChange(); }
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the base progress color"), Browsable(true)]
public Color Color {
get { return color; }
set {
color = value;
brush = new SolidBrush(color);
FireChange();
}
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
protected override void PaintThisProgress(Rectangle box, Graphics g) {
if (box.Width <= 1) {
return;
}
g.FillRectangle(brush, box);
if (gloss != null) {
gloss.PaintGloss(box, g);
}
if (!edge.Equals(Color.Transparent)) {
g.DrawLine(new Pen(new SolidBrush(edge), 1f), box.Right, box.Y, box.Right, box.Bottom - 1);
}
}
/// <summary></summary>
protected override void DisposeThis(bool disposing) {
brush.Dispose();
}
}
}

View File

@@ -0,0 +1,340 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.ProgressBarEx), "Icons.ProgressBarEx.ico")]
public class ProgressBarEx : AbstractProgressBar {
protected IProgressBackgroundPainter backgroundpainter;
protected IProgressPainter progresspainter;
protected IProgressBorderPainter borderpainter;
public ProgressBarEx() {
backgroundpainter = new PlainBackgroundPainter();
progresspainter = new PlainProgressPainter(Color.Gold);
borderpainter = new PlainBorderPainter();
}
/// <summary></summary>
[Category("Painters"), Description("Paints this progress bar's background"), Browsable(true)]
public IProgressBackgroundPainter BackgroundPainter {
get { return this.backgroundpainter; }
set {
this.backgroundpainter = value;
this.backgroundpainter.PropertiesChanged += new EventHandler(component_PropertiesChanged);
this.Invalidate();
}
}
/// <summary></summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void component_PropertiesChanged(object sender, EventArgs e) {
this.Invalidate();
}
/// <summary></summary>
[Category("Painters"), Description("Paints this progress bar's progress"), Browsable(true)]
public IProgressPainter ProgressPainter {
get { return this.progresspainter; }
set {
if (!(value is IAnimatedProgressPainter) && base.ProgressType == ProgressType.Animated) {
base.ProgressType = ProgressType.Smooth;
}
this.progresspainter = value;
if (this.progresspainter is AbstractProgressPainter) {
((AbstractProgressPainter)this.progresspainter).padding = base.ProgressPadding;
}
this.progresspainter.PropertiesChanged += new EventHandler(component_PropertiesChanged);
this.Invalidate();
}
}
/// <summary></summary>
[Category("Progress"), Description("Gets or sets the type of progress"), Browsable(true)]
public override ProgressType ProgressType {
get { return base.type; }
set {
if (value == ProgressType.Animated && !(progresspainter is IAnimatedProgressPainter)) {
throw new ArgumentException("Animated is not available with the current Progress Painter");
}
this.type = value;
}
}
/// <summary></summary>
[Category("Painters"), Description("Paints this progress bar's border"), Browsable(true)]
public IProgressBorderPainter BorderPainter {
get { return this.borderpainter; }
set {
this.borderpainter = value;
this.borderpainter.PropertiesChanged += new EventHandler(component_PropertiesChanged);
ResizeProgress();
this.Invalidate();
}
}
protected override void ResizeProgress() {
if (base.ProgressType != ProgressType.Smooth) { return; }
Rectangle newprog = base.borderbox;
//newprog.Inflate(this.borderpainter.BorderWidth, this.borderpainter.BorderWidth);
newprog.Offset(this.borderpainter.BorderWidth, this.borderpainter.BorderWidth);
newprog.Size = new Size(newprog.Size.Width - this.borderpainter.BorderWidth, newprog.Size.Height - this.borderpainter.BorderWidth);
base.backbox = newprog;
int val = value; if (val > 0) { val++; }
int progWidth = maximum > 0 ? (backbox.Width * val / maximum) : 1;
if (value >= maximum && maximum > 0) {
progWidth = backbox.Width;
} /*else if (value > 0) {
progWidth++;
}*/
newprog.Inflate(-base.ProgressPadding, -base.ProgressPadding);
newprog.Width = progWidth - (base.ProgressPadding * 2);
//newprog.Offset(base.ProgressPadding, base.ProgressPadding);
//newprog = new Rectangle(backbox.X + base.ProgressPadding, backbox.Y + base.ProgressPadding, progWidth - (base.ProgressPadding * 2), backbox.Height - (base.ProgressPadding * 2));
base.progressbox = newprog;
}
#region Animation
public void StartAnimation() {
if (running) { return; }
IAnimatedProgressPainter iapp = this.progresspainter as IAnimatedProgressPainter;
if (iapp == null) { return; }
iapp.Animating = true;
running = true;
timerMethod = new EventHandler(DoAnimation);
timer.Interval = iapp.AnimationSpeed;
timer.Tick += timerMethod;
timer.Enabled = true;
}
public void StopAnimation() {
timer.Enabled = false;
timer.Tick -= timerMethod;
running = false;
IAnimatedProgressPainter iapp = this.progresspainter as IAnimatedProgressPainter;
if (iapp == null) { return; }
iapp.Animating = false;
}
private void DoAnimation(object sender, EventArgs e) {
IAnimatedProgressPainter iapp = this.progresspainter as IAnimatedProgressPainter;
if (iapp == null) { return; }
//Rectangle newprog = base.borderbox;
//newprog.Offset(this.borderpainter.BorderWidth, this.borderpainter.BorderWidth);
//newprog.Size = new Size(newprog.Size.Width - this.borderpainter.BorderWidth, newprog.Size.Height - this.borderpainter.BorderWidth);
////int progWidth = (int)(((float)marqueePercentage * (float)backbox.Width) / 100f);
//int progWidth = (int)(((float)marqueePercentage * (float)backbox.Width) / 100f);
//newprog.Inflate(-base.ProgressPadding, -base.ProgressPadding);
//newprog.Width = progWidth - (base.ProgressPadding * 2);
//base.progressbox = newprog;
////iapp.AnimateFrame(newprog, g, ref marqueeX);
this.Invalidate();
this.Refresh();
}
#endregion
#region Marquee
private bool running = false;
private Timer timer = new Timer();
private EventHandler timerMethod;
/// <summary></summary>
public override void MarqueeStart() {
if (running) { return; }
running = true;
switch (base.ProgressType) {
case ProgressType.MarqueeWrap: timerMethod = new EventHandler(DoMarqueeWrap); break;
case ProgressType.MarqueeBounce: timerMethod = new EventHandler(DoMarqueeBounce); break;
case ProgressType.MarqueeBounceDeep: timerMethod = new EventHandler(DoMarqueeDeep); break;
}
timer.Interval = base.marqueeSpeed;
timer.Tick += timerMethod;
timer.Enabled = true;
}
private int marqueeX = 0;
private void DoMarqueeWrap(object sender, EventArgs e) {
Rectangle newprog = base.borderbox;
newprog.Offset(this.borderpainter.BorderWidth, this.borderpainter.BorderWidth);
newprog.Size = new Size(newprog.Size.Width - this.borderpainter.BorderWidth, newprog.Size.Height - this.borderpainter.BorderWidth);
int progWidth = (int)(((float)marqueePercentage * (float)backbox.Width) / 100f);
marqueeX += marqueeStep;
if (marqueeX > backbox.Width) {
marqueeX = 0 - progWidth;
}
newprog.Inflate(-base.ProgressPadding, -base.ProgressPadding);
newprog.Width = progWidth - (base.ProgressPadding * 2);
newprog.X += marqueeX;
int leftBoundry = backbox.X + this.borderpainter.BorderWidth + base.ProgressPadding;
int rightBoundry = backbox.X + backbox.Width - (this.borderpainter.BorderWidth + base.ProgressPadding);
if (marqueeX <= leftBoundry) {
newprog.Width -= leftBoundry - marqueeX;
newprog.X = leftBoundry;
} else if (marqueeX + newprog.Width >= rightBoundry) {
newprog.Width -= (marqueeX + newprog.Width + base.ProgressPadding) - rightBoundry;
}
base.progressbox = newprog;
this.Invalidate();
this.Refresh();
}
private bool marqueeForward = true;
private void DoMarqueeBounce(object sender, EventArgs e) {
Rectangle newprog = base.borderbox;
newprog.Offset(this.borderpainter.BorderWidth, this.borderpainter.BorderWidth);
newprog.Size = new Size(newprog.Size.Width - this.borderpainter.BorderWidth, newprog.Size.Height - this.borderpainter.BorderWidth);
int progWidth = (int)(((float)marqueePercentage * (float)backbox.Width) / 100f);
if (marqueeForward) {
marqueeX += marqueeStep;
} else {
marqueeX -= marqueeStep;
}
newprog.Inflate(-base.ProgressPadding, -base.ProgressPadding);
newprog.Width = progWidth - (base.ProgressPadding * 2);
newprog.X += marqueeX;
int leftBoundry = backbox.X + this.borderpainter.BorderWidth + base.ProgressPadding;
int rightBoundry = backbox.X + backbox.Width - (this.borderpainter.BorderWidth + base.ProgressPadding);
if (marqueeX + progWidth >= rightBoundry) {
marqueeForward = false;
} else if (marqueeX <= leftBoundry) {
marqueeForward = true;
}
base.progressbox = newprog;
this.Invalidate();
this.Refresh();
}
private void DoMarqueeDeep(object sender, EventArgs e) {
Rectangle newprog = base.borderbox;
newprog.Offset(this.borderpainter.BorderWidth, this.borderpainter.BorderWidth);
newprog.Size = new Size(newprog.Size.Width - this.borderpainter.BorderWidth, newprog.Size.Height - this.borderpainter.BorderWidth);
int progWidth = (int)(((float)marqueePercentage * (float)backbox.Width) / 100f);
if (marqueeForward) {
marqueeX += marqueeStep;
} else {
marqueeX -= marqueeStep;
}
if (marqueeX > backbox.Width) {
marqueeForward = false;
} else if (marqueeX < backbox.X - progWidth) {
marqueeForward = true;
}
newprog.Inflate(-base.ProgressPadding, -base.ProgressPadding);
newprog.Width = progWidth - (base.ProgressPadding * 2);
newprog.X += marqueeX;
int leftBoundry = backbox.X + this.borderpainter.BorderWidth + base.ProgressPadding;
int rightBoundry = backbox.X + backbox.Width - (this.borderpainter.BorderWidth + base.ProgressPadding);
if (marqueeX <= leftBoundry) {
newprog.Width -= leftBoundry - marqueeX;
newprog.X = leftBoundry;
} else if (marqueeX + newprog.Width >= rightBoundry) {
newprog.Width -= (marqueeX + newprog.Width + base.ProgressPadding) - rightBoundry;
}
base.progressbox = newprog;
this.Invalidate();
this.Refresh();
}
/// <summary></summary>
public override void MarqueePause() {
running = false;
timer.Enabled = false;
timer.Tick -= timerMethod;
}
/// <summary></summary>
public override void MarqueeStop() {
Rectangle newprog = base.borderbox;
newprog.Offset(this.borderpainter.BorderWidth, this.borderpainter.BorderWidth);
newprog.Size = new Size(newprog.Size.Width - this.borderpainter.BorderWidth, newprog.Size.Height - this.borderpainter.BorderWidth);
newprog.Inflate(-base.ProgressPadding, -base.ProgressPadding);
newprog.Width = 1;
base.progressbox = newprog;
running = false;
timer.Enabled = false;
timer.Tick -= timerMethod;
marqueeX = 0;
this.Invalidate();
}
#endregion
/// <summary></summary>
/// <param name="disposing"></param>
protected override void Dispose(bool disposing) {
base.Dispose(disposing);
if (running) { running = false; }
}
/// <summary></summary>
/// <param name="e"></param>
protected override void OnResize(EventArgs e) {
base.OnResize(e);
ResizeProgress();
if (this.backgroundpainter != null) { this.backgroundpainter.Resize(borderbox); }
if (this.progresspainter != null) { this.progresspainter.Resize(borderbox); }
if (this.borderpainter != null) { this.borderpainter.Resize(borderbox); }
}
/// <summary></summary>
/// <param name="gr"></param>
protected override void PaintBackground(Graphics g) {
if (this.backgroundpainter != null) {
this.backgroundpainter.PaintBackground(backbox, g);
}
}
/// <summary></summary>
/// <param name="gr"></param>
protected override void PaintProgress(Graphics g) {
if (this.progresspainter != null) {
this.progresspainter.PaintProgress(progressbox, g);
}
}
/// <summary></summary>
/// <param name="gr"></param>
protected override void PaintText(Graphics g) {
if (base.ProgressType != ProgressType.Smooth) { return; }
Brush b = new SolidBrush(ForeColor);
SizeF sf = g.MeasureString(Text, Font, Convert.ToInt32(Width), StringFormat.GenericDefault);
float m = sf.Width;
float x = (Width / 2) - (m / 2);
float w = (Width / 2) + (m / 2);
float h = (float)borderbox.Height - (2f * (float)this.borderpainter.BorderWidth);
float y = (float)this.borderpainter.BorderWidth + ((h - sf.Height) / 2f);
g.DrawString(Text, Font, b, RectangleF.FromLTRB(x, y, w, Height - 1), StringFormat.GenericDefault);
}
/// <summary></summary>
/// <param name="gr"></param>
protected override void PaintBorder(Graphics g) {
if (this.borderpainter != null) {
this.borderpainter.PaintBorder(borderbox, g);
}
}
}
}

View File

@@ -0,0 +1,224 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{8DD1E84B-0B03-4C0B-9B42-1E49F75E7CB1}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ProgressODoom</RootNamespace>
<AssemblyName>ProgressODoom</AssemblyName>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AbstractProgressBar.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="AbstractProgressPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BarberPoleProgressPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BevelledGradientProgressPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BevelledProgressPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="CandyCaneBackgroundPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="CandyCaneProgressPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ChainedGlossPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ColorTools.cs" />
<Compile Include="DualProgressBar.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="FlatGlossPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="FruityLoopsBackgroundPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="FruityLoopsProgressPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="GradientBackgroundPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="GradientGlossPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="HSV.cs" />
<Compile Include="IAnimatedProgressPainter.cs" />
<Compile Include="IGlossPainter.cs" />
<Compile Include="IProgressBackgroundPainter.cs" />
<Compile Include="IProgressBorderPainter.cs" />
<Compile Include="IProgressPainter.cs" />
<Compile Include="JavaProgressPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="MetalProgressPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="MiddleGlossPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="PlainBackgroundPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="PlainBorderPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="PlainProgressPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ProgressBarEx.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RarBackgroundPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="RarBorderPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="RarProgressBar.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="RarProgressPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="RoundGlossPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="StripedProgressPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="StyledBorderPainter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="WaveProgressPainter.cs">
<SubType>Component</SubType>
</Compile>
<Service Include="{94E38DFF-614B-4cbd-B67C-F211BB35CE8B}" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Icons\ProgressBarEx.ico" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Icons\BarberPoleProgressPainter.ico" />
<EmbeddedResource Include="Icons\BevelledGradientProgressPainter.ico" />
<EmbeddedResource Include="Icons\BevelledProgressPainter.ico" />
<EmbeddedResource Include="Icons\CandyCaneBackgroundPainter.ico" />
<EmbeddedResource Include="Icons\CandyCaneProgressPainter.ico" />
<EmbeddedResource Include="Icons\DualProgressBar.ico" />
<EmbeddedResource Include="Icons\FlatGlossPainter.ico" />
<EmbeddedResource Include="Icons\FruityLoopsBackgroundPainter.ico" />
<EmbeddedResource Include="Icons\FruityLoopsProgressPainter.ico" />
<EmbeddedResource Include="Icons\GradientBackgroundPainter.ico" />
<EmbeddedResource Include="Icons\GradientGlossPainter.ico" />
<EmbeddedResource Include="Icons\JavaProgressPainter.ico" />
<EmbeddedResource Include="Icons\MetalProgressPainter.ico" />
<EmbeddedResource Include="Icons\MiddleGlossPainter.ico" />
<EmbeddedResource Include="Icons\PlainBackgroundPainter.ico" />
<EmbeddedResource Include="Icons\PlainBorderPainter.ico" />
<EmbeddedResource Include="Icons\PlainProgressPainter.ico" />
<EmbeddedResource Include="Icons\RarBackgroundPainter.ico" />
<EmbeddedResource Include="Icons\RarBorderPainter.ico" />
<EmbeddedResource Include="Icons\RarProgressBar.ico" />
<EmbeddedResource Include="Icons\RarProgressPainter.ico" />
<EmbeddedResource Include="Icons\RoundGlossPainter.ico" />
<EmbeddedResource Include="Icons\StyledBorderPainter.ico" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Icons\StripedProgressPainter.ico" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Icons\WaveProgressPainter.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
<Visible>False</Visible>
<ProductName>.NET Framework 2.0 %28x86%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
<Visible>False</Visible>
<ProductName>.NET Framework 3.0 %28x86%29</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,18 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory>
</PublishUrlHistory>
<InstallUrlHistory>
</InstallUrlHistory>
<SupportUrlHistory>
</SupportUrlHistory>
<UpdateUrlHistory>
</UpdateUrlHistory>
<BootstrapperUrlHistory>
</BootstrapperUrlHistory>
<ErrorReportUrlHistory>
</ErrorReportUrlHistory>
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ProgressODoom")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ProgressODoom")]
[assembly: AssemblyCopyright("Copyright © 2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("375b7734-9e29-4ae9-8c57-d1bf00450128")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,83 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
[ToolboxBitmapAttribute(typeof(ProgressODoom.RarBackgroundPainter), "Icons.RarBackgroundPainter.ico")]
public class RarBackgroundPainter : Component, IProgressBackgroundPainter, IDisposable {
private Brush brush;
private IGlossPainter gloss;
private Pen outer, inner, border;
private EventHandler onPropertiesChanged;
/// <summary></summary>
public event EventHandler PropertiesChanged {
add {
if (onPropertiesChanged != null) {
foreach (Delegate d in onPropertiesChanged.GetInvocationList()) {
if (object.ReferenceEquals(d, value)) { return; }
}
}
onPropertiesChanged = (EventHandler)Delegate.Combine(onPropertiesChanged, value);
}
remove { onPropertiesChanged = (EventHandler)Delegate.Remove(onPropertiesChanged, value); }
}
private void FireChange() {
if (onPropertiesChanged != null) { onPropertiesChanged(this, EventArgs.Empty); }
}
/// <summary></summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void component_PropertiesChanged(object sender, EventArgs e) {
FireChange();
}
public RarBackgroundPainter() {
brush = new SolidBrush(Color.FromArgb(148, 110, 110));
inner = new Pen(new SolidBrush(Color.FromArgb(158, 128, 128)), 1f);
outer = new Pen(new SolidBrush(Color.FromArgb(180, 148, 148)), 1f);
border = new Pen(new SolidBrush(Color.FromArgb(096, 096, 096)), 1f);
}
/// <summary></summary>
public IGlossPainter GlossPainter {
get { return this.gloss; }
set {
this.gloss = value;
if (this.gloss != null) { this.gloss.PropertiesChanged += new EventHandler(component_PropertiesChanged); }
FireChange();
}
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
public void PaintBackground(Rectangle box, Graphics g) {
g.FillRectangle(brush, box);
g.DrawRectangle(inner, 2, 2, box.Width - 3, box.Height - 4);
g.DrawRectangle(outer, 1, 1, box.Width - 1, box.Height - 2);
g.DrawLine(border, 1, box.Height, box.Width, box.Height);
if (gloss != null) {
gloss.PaintGloss(box, g);
}
}
/// <summary></summary>
public void Resize(Rectangle box) {
}
/// <summary></summary>
protected override void Dispose(bool disposing) {
base.Dispose(disposing);
brush.Dispose();
inner.Dispose();
outer.Dispose();
border.Dispose();
}
}
}

View File

@@ -0,0 +1,61 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.RarBorderPainter), "Icons.RarBorderPainter.ico")]
public class RarBorderPainter : Component, IProgressBorderPainter, IDisposable {
private Pen border;
private EventHandler onPropertiesChanged;
/// <summary></summary>
public event EventHandler PropertiesChanged {
add {
if (onPropertiesChanged != null) {
foreach (Delegate d in onPropertiesChanged.GetInvocationList()) {
if (object.ReferenceEquals(d, value)) { return; }
}
}
onPropertiesChanged = (EventHandler)Delegate.Combine(onPropertiesChanged, value);
}
remove { onPropertiesChanged = (EventHandler)Delegate.Remove(onPropertiesChanged, value); }
}
private void FireChange() {
if (onPropertiesChanged != null) { onPropertiesChanged(this, EventArgs.Empty); }
}
/// <summary></summary>
public RarBorderPainter() {
border = new Pen(new SolidBrush(Color.FromArgb(064, 064, 070)), 1f);
}
/// <summary></summary>
[Browsable(false)]
public int BorderWidth {
get { return 1; }
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
public void PaintBorder(Rectangle box, Graphics g) {
g.DrawRectangle(new Pen(new SolidBrush(SystemColors.Control), 1f), 0, 0, box.Width, box.Height);
g.DrawLine(border, 2, box.Height, box.Width, box.Height);
g.DrawLine(border, box.Width, 3, box.Width, box.Height);
}
/// <summary></summary>
public void Resize(Rectangle box) {
}
/// <summary></summary>
protected override void Dispose(bool disposing) {
base.Dispose(disposing);
border.Dispose();
}
}
}

View File

@@ -0,0 +1,31 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
[ToolboxBitmapAttribute(typeof(ProgressODoom.RarProgressBar), "Icons.RarProgressBar.ico")]
public class RarProgressBar : DualProgressBar {
public RarProgressBar() {
this.MasterPainter = new RarProgressPainter(RarProgressPainter.RarProgressType.Silver);
((RarProgressPainter)this.MasterPainter).ShowEdge = false;
this.ProgressPainter = new RarProgressPainter(RarProgressPainter.RarProgressType.Gold);
((RarProgressPainter)this.ProgressPainter).ShowEdge = true;
this.BorderPainter = new RarBorderPainter();
this.BackgroundPainter = new RarBackgroundPainter();
this.PaintMasterFirst = true;
this.OnValueChanged += new EventHandler(onValueChanged);
this.OnMasterValueChanged += new EventHandler(onValueChanged);
}
private void onValueChanged(object sender, EventArgs e) {
bool masterAhead = false;
if (this.MasterValue > this.Value) {
masterAhead = true;
}
((RarProgressPainter)this.MasterPainter).ShowEdge = masterAhead;
((RarProgressPainter)this.ProgressPainter).ShowEdge = !masterAhead;
}
}
}

View File

@@ -0,0 +1,103 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.RarProgressPainter), "Icons.RarProgressPainter.ico")]
public class RarProgressPainter : AbstractProgressPainter, IProgressPainter, IDisposable {
private Brush brush;
private Pen inner, outer, edge;
private bool showEdge = false;
private RarProgressType type;
/// <summary></summary>
public RarProgressPainter() {
this.ProgressType = RarProgressType.Silver;
}
/// <summary></summary>
/// <param name="type"></param>
public RarProgressPainter(RarProgressType type) {
this.ProgressType = type;
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the type of rar progress color"), Browsable(true)]
public RarProgressType ProgressType {
get { return type; }
set {
this.type = value;
switch (type) {
case RarProgressType.Silver:
brush = new SolidBrush(Color.FromArgb(214, 214, 220));
inner = new Pen(new SolidBrush(Color.FromArgb(232, 232, 238)), 1f);
outer = new Pen(new SolidBrush(Color.FromArgb(255, 255, 255)), 1f);
edge = new Pen(new SolidBrush(Color.FromArgb(096, 096, 096)), 1f);
break;
case RarProgressType.Gold:
brush = new SolidBrush(Color.FromArgb(208, 192, 160));
inner = new Pen(new SolidBrush(Color.FromArgb(228, 212, 180)), 1f);
outer = new Pen(new SolidBrush(Color.FromArgb(255, 255, 192)), 1f);
edge = new Pen(new SolidBrush(Color.FromArgb(096, 096, 096)), 1f);
break;
}
FireChange();
}
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets whether or not this progress has a leading edge"), Browsable(true)]
public bool ShowEdge {
get { return showEdge; }
set {
showEdge = value;
FireChange();
}
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
protected override void PaintThisProgress(Rectangle box, Graphics g) {
try {
box.Width -= 1;
box.Height -= 1;
} catch {}
if (box.Width <= 1) {
return;
}
g.FillRectangle(brush, box);
Rectangle innerBox = box;
innerBox.Inflate(-1, -1);
g.DrawRectangle(inner, innerBox);
g.DrawLine(outer, box.X, box.Y, box.Right, box.Y);
g.DrawLine(outer, box.X, box.Y, box.X, box.Bottom);
g.DrawLine(edge, box.X, box.Bottom, box.Right, box.Bottom);
if (gloss != null) {
gloss.PaintGloss(box, g);
}
if (showEdge) {
g.DrawLine(edge, box.Right, box.Y, box.Right, box.Bottom);
}
}
/// <summary></summary>
protected override void DisposeThis(bool disposing) {
brush.Dispose();
inner.Dispose();
outer.Dispose();
edge.Dispose();
}
/// <summary></summary>
public enum RarProgressType {
Gold, Silver
}
}
}

View File

@@ -0,0 +1,172 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
public enum GlossStyle {
Top, Bottom, Both
}
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.RoundGlossPainter), "Icons.RoundGlossPainter.ico")]
public class RoundGlossPainter : ChainedGlossPainter {
private GlossStyle style = GlossStyle.Both;
private int highAlpha = 240;
private int lowAlpha = 0;
private int fadewidth = 4;
private Brush highBrush;
private Brush lowBrush;
private Rectangle box;
private Color color = Color.White;
private Color topColor;
private Color botColor;
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the style for this progress gloss"), Browsable(true)]
public GlossStyle Style {
get { return this.style; }
set {
this.style = value;
FireChange();
}
}
/// <summary></summary>
[Category("Blending"), Description("Gets or sets the high alpha value"), Browsable(true)]
public int AlphaHigh {
get { return this.highAlpha; }
set {
if (value < 0 || value > 255) {
throw new ArgumentException("Alpha values must be between 0 and 255.");
}
this.highAlpha = value;
FireChange();
}
}
/// <summary></summary>
[Category("Blending"), Description("Gets or sets the low alpha value"), Browsable(true)]
public int AlphaLow {
get { return this.lowAlpha; }
set {
if (value < 0 || value > 255) {
throw new ArgumentException("Alpha values must be between 0 and 255.");
}
this.lowAlpha = value;
FireChange();
}
}
/// <summary></summary>
[Category("Blending"), Description("Gets or sets the number of pixels to blend over"), Browsable(true)]
public int TaperHeight {
get { return this.fadewidth; }
set {
this.fadewidth = value;
FireChange();
}
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets color to gloss"), Browsable(true)]
public Color Color {
get { return this.color; }
set {
this.color = value;
this.topColor = Color.FromArgb(highAlpha, this.color.R, this.color.G, this.color.B);
this.botColor = Color.FromArgb(lowAlpha, this.color.R, this.color.G, this.color.B);
box = new Rectangle(0, 0, 1, 1);
FireChange();
}
}
protected override void PaintThisGloss(Rectangle box, Graphics g) {
if (!this.box.Equals(box)) {
this.box = box;
ResetBrushes(box);
}
//int midpoint = (int)((float)box.Height / 2f);
//int toppoint = midpoint > (fadewidth + 2) ? midpoint - (fadewidth / 2) : midpoint;
//int botpoint = midpoint > (fadewidth + 2) ? midpoint + (fadewidth / 2) : midpoint;
//Rectangle topBox = new Rectangle(box.X, box.Y, box.Width - 1, box.Y + fadewidth);
//Rectangle botBox = new Rectangle(box.X, box.Bottom - fadewidth - 2, box.Width - 1, fadewidth + 1);
Rectangle topBox = new Rectangle(box.X, box.Y, box.Width, fadewidth);
Rectangle botBox = new Rectangle(box.X, box.Bottom - fadewidth, box.Width, fadewidth);
//if (midpoint - fadewidth > 2) { midpoint -= fadewidth; }
switch (style) {
case GlossStyle.Bottom:
g.FillRectangle(lowBrush, botBox);
break;
case GlossStyle.Top:
g.FillRectangle(highBrush, topBox);
break;
case GlossStyle.Both:
g.FillRectangle(highBrush, topBox);
g.FillRectangle(lowBrush, botBox);
//g.DrawRectangle(Pens.Red, topBox);
//g.DrawRectangle(Pens.Blue, botBox);
break;
}
//g.DrawRectangle(new Pen(new SolidBrush(Color.FromArgb(64, 255, 0, 0))), topBox);
//g.FillRectangle(new SolidBrush(Color.FromArgb(32, 255, 0, 0)), topBox);
//g.DrawRectangle(new Pen(new SolidBrush(Color.FromArgb(64, 0, 0, 255))), botBox);
//g.FillRectangle(new SolidBrush(Color.FromArgb(32, 0, 0, 255)), botBox);
}
protected override void ResizeThis(Rectangle box) {
if (!this.box.Equals(box)) {
this.box = box;
ResetBrushes(box);
}
}
private void ResetBrushes(Rectangle box) {
//int midpoint = (int)((float)box.Height / 2f);
//int toppoint = midpoint - (fadewidth / 2);
//if (toppoint < box.Y + 2) { toppoint = box.Y + 2; }
//int botpoint = midpoint + (fadewidth / 2);
//if (botpoint > box.Height - 2) { botpoint = box.Height - 2; }
//Point top = new Point(box.X, box.Y);
//Point topmid = new Point(box.X, box.Y + fadewidth + 1);
//Point botmid = new Point(box.X, box.Height - fadewidth - 1);
//Point bot = new Point(box.X, box.Bottom);
Rectangle topBox = new Rectangle(box.X, box.Y, box.Width, fadewidth);
Rectangle botBox = new Rectangle(box.X, box.Bottom - fadewidth, box.Width, fadewidth);
Point top = new Point(box.X, topBox.Top);
Point topmid = new Point(box.X, topBox.Bottom);
Point botmid = new Point(box.X, botBox.Top - 1);
Point bot = new Point(box.X, botBox.Bottom);
Color high = topColor;
Color low = botColor;
switch (style) {
case GlossStyle.Top:
highBrush = new LinearGradientBrush(top, topmid, high, low);
break;
case GlossStyle.Bottom:
lowBrush = new LinearGradientBrush(botmid, bot, low, high);
break;
case GlossStyle.Both:
highBrush = new LinearGradientBrush(top, topmid, high, low);
lowBrush = new LinearGradientBrush(botmid, bot, low, high);
break;
}
}
protected override void Dispose(bool disposing) {
base.Dispose(disposing);
if (highBrush != null) { highBrush.Dispose(); }
if (lowBrush != null) { lowBrush.Dispose(); }
}
}
}

View File

@@ -0,0 +1,183 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.StripedProgressPainter), "Icons.StripedProgressPainter.ico")]
public class StripedProgressPainter : AbstractProgressPainter, IProgressPainter, IAnimatedProgressPainter, IDisposable {
private Color color1 = Color.FromArgb(110, 195, 248);
private Color color2 = Color.FromArgb(056, 150, 230);
private Color blend = Color.FromArgb(097, 184, 244);
private int spacing = 6;
private int marqueeSpeed = 10;
private int marqueeX = 0;
private bool isAnimated = false;
/// <summary></summary>
public StripedProgressPainter() {
}
/// <summary></summary>
public Color BaseColor {
get { return color1; }
set {
color1 = value;
blend = ColorRange.Morph(0.25f, color1, color2);
FireChange();
}
}
/// <summary></summary>
public Color StripeColor {
get { return color2; }
set {
color2 = value;
blend = ColorRange.Morph(0.25f, color1, color2);
FireChange();
}
}
/// <summary></summary>
public int StripeSpacing {
get { return spacing; }
set { spacing = value; FireChange(); }
}
/// <summary></summary>
public int AnimationSpeed {
get { return marqueeSpeed; }
set { marqueeSpeed = value; FireChange(); }
}
/// <summary></summary>
public bool Animating {
get { return isAnimated; }
set { isAnimated = value; }
}
private void AnimateFrame(Rectangle box, Graphics g, ref int marqueeX) {
if (box == null || g == null || box.Width <= 1) { return; }
Pen penb = new Pen(new SolidBrush(blend));
g.FillRectangle(new SolidBrush(color1), box);
for (int i = box.Right + marqueeX; i > box.Left; i -= ((box.Height * 2) + StripeSpacing - 1)) {
Point theoreticalRightTop = new Point(i, box.Top);
Point theoreticalRightBottom = new Point(i - box.Height, box.Bottom);
Point theoreticalLeftTop = new Point(i - box.Height, box.Top);
Point theoreticalLeftBottom = new Point(i - (box.Height * 2), box.Bottom);
Point leftTop, leftBottom, rightTop, rightBottom;
using (GraphicsPath gp = new GraphicsPath()) {
if (theoreticalLeftTop.X <= box.Left) {
// left triangle
int diff = i - box.Height;
rightTop = new Point(i, box.Top);
rightBottom = new Point(box.Left, box.Bottom + diff);
leftTop = new Point(box.Left, box.Top);
leftBottom = leftTop;
if (rightBottom.Equals(rightTop)) { continue; }
gp.AddLine(rightTop, rightBottom);
gp.AddLine(rightBottom, leftTop);
gp.AddLine(leftTop, new Point(i, box.Top));
} else if (theoreticalLeftBottom.X <= box.Left) {
// left pentagon
int diff = i - (box.Height * 2);
rightTop = new Point(i, box.Top);
rightBottom = new Point(i - box.Height, box.Bottom);
leftTop = new Point(i - box.Height, box.Top);
leftBottom = new Point(box.Left, box.Bottom + diff);
gp.AddLine(rightTop, rightBottom);
gp.AddLine(rightBottom, new Point(box.Left, box.Bottom));
gp.AddLine(new Point(box.Left, box.Bottom), leftBottom);
gp.AddLine(leftBottom, leftTop);
gp.AddLine(leftTop, rightTop);
} else if (theoreticalRightBottom.X >= box.Right) {
// right triangle
int diff = marqueeX - box.Height;
leftTop = new Point(box.Right, box.Top + diff); //= something funky
leftBottom = theoreticalLeftBottom;
rightBottom = new Point(box.Right, box.Bottom);
rightTop = rightBottom;
if (leftBottom.Equals(leftTop)) { continue; }
gp.AddLine(leftTop, rightBottom);
gp.AddLine(rightBottom, leftBottom);
gp.AddLine(leftBottom, leftTop);
} else if (theoreticalRightTop.X >= box.Right) {
// right pentagon
int diff = i - box.Right;
Point topRight = new Point(box.Right, box.Top);
rightTop = new Point(box.Right, box.Top + diff);
rightBottom = new Point(i - box.Height, box.Bottom);
leftTop = new Point(i - box.Height, box.Top);
leftBottom = new Point(i - (box.Height * 2), box.Bottom);
gp.AddLine(leftTop, topRight);
gp.AddLine(topRight, rightTop);
gp.AddLine(rightTop, rightBottom);
gp.AddLine(rightBottom, leftBottom);
gp.AddLine(leftBottom, leftTop);
} else {
// mid-range rectangle
rightTop = new Point(i, box.Top);
rightBottom = new Point(i - box.Height, box.Bottom);
leftTop = new Point(i - box.Height, box.Top);
leftBottom = new Point(i - (box.Height * 2), box.Bottom);
gp.AddLine(rightTop, rightBottom);
gp.AddLine(rightBottom, leftBottom);
gp.AddLine(leftBottom, leftTop);
gp.AddLine(leftTop, rightTop);
}
g.FillPath(new SolidBrush(color2), gp);
}
if (!leftTop.Equals(leftBottom)) {
g.DrawLine(penb, leftTop, leftBottom);
}
if (!rightTop.Equals(rightBottom)) {
g.DrawLine(penb, rightTop, rightBottom);
}
}
g.DrawLine(penb, new Point(box.Left, box.Bottom), new Point(box.Right, box.Bottom));
if (++marqueeX > (box.Height * 2) + StripeSpacing) {
marqueeX = 1;
}
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
protected override void PaintThisProgress(Rectangle box, Graphics g) {
if (box.Width <= 1) {
return;
}
if (isAnimated) {
AnimateFrame(box, g, ref marqueeX);
} else {
int x = 0;
AnimateFrame(box, g, ref x);
}
if (gloss != null) {
gloss.PaintGloss(box, g);
}
}
/// <summary></summary>
protected override void DisposeThis(bool disposing) {
}
}
}

View File

@@ -0,0 +1,66 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
/// <summary></summary>
[ToolboxBitmapAttribute(typeof(ProgressODoom.StyledBorderPainter), "Icons.StyledBorderPainter.ico")]
public class StyledBorderPainter : Component, IProgressBorderPainter, IDisposable {
private Border3DStyle border;
private EventHandler onPropertiesChanged;
/// <summary></summary>
public event EventHandler PropertiesChanged {
add {
if (onPropertiesChanged != null) {
foreach (Delegate d in onPropertiesChanged.GetInvocationList()) {
if (object.ReferenceEquals(d, value)) { return; }
}
}
onPropertiesChanged = (EventHandler)Delegate.Combine(onPropertiesChanged, value);
}
remove { onPropertiesChanged = (EventHandler)Delegate.Remove(onPropertiesChanged, value); }
}
private void FireChange() {
if (onPropertiesChanged != null) { onPropertiesChanged(this, EventArgs.Empty); }
}
/// <summary></summary>
public StyledBorderPainter() {
border = Border3DStyle.Raised;
}
/// <summary></summary>
[Category("Appearance"), Description("Gets or sets the border style"), Browsable(true)]
public Border3DStyle Border3D {
get { return border; }
set { border = value; FireChange(); }
}
/// <summary></summary>
[Browsable(false)]
public int BorderWidth {
get { return 2; }
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
public void PaintBorder(Rectangle box, Graphics g) {
Rectangle brd = new Rectangle(box.X, box.Y, box.Width, box.Height + 1);
ControlPaint.DrawBorder3D(g, brd, border);
}
/// <summary></summary>
public void Resize(Rectangle box) {
}
/// <summary></summary>
protected override void Dispose(bool disposing) {
base.Dispose(disposing);
}
}
}

View File

@@ -0,0 +1,112 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Collections.Generic;
namespace ProgressODoom {
[ToolboxBitmapAttribute(typeof(ProgressODoom.WaveProgressPainter), "Icons.WaveProgressPainter.ico")]
public class WaveProgressPainter : AbstractProgressPainter, IProgressPainter, IAnimatedProgressPainter, IDisposable {
private Color color1 = Color.FromArgb(110, 195, 248);
private Color color2 = Color.FromArgb(056, 150, 230);
private int marqueeSpeed = 10;
private int marqueeX = 0;
private int animateX = 0;
private bool isAnimated = false;
/// <summary></summary>
public Color BaseColor {
get { return color1; }
set {
color1 = value;
FireChange();
}
}
/// <summary></summary>
public Color WaveColor {
get { return color2; }
set {
color2 = value;
FireChange();
}
}
/// <summary></summary>
public int AnimationSpeed {
get { return marqueeSpeed; }
set { marqueeSpeed = value; FireChange(); }
}
/// <summary></summary>
public bool Animating {
get { return isAnimated; }
set { isAnimated = value; }
}
private void AnimateFrame(Rectangle box, Graphics g, ref int marqueeX) {
if (box == null || g == null || box.Width <= 1) { return; }
g.SmoothingMode = SmoothingMode.AntiAlias;
//g.Clip = new Region(box);
g.FillRectangle(new SolidBrush(color1), box);
int h = box.Height;
int hm = (int)((float)h / 2f);
using (GraphicsPath gp = new GraphicsPath()) {
Point MidLeft = new Point(0, hm);
Point MidRight = new Point(h * 2, hm);
int currentX = box.Right + animateX; // Increment currentX to animate
int left = currentX - (h * 2);
if (left < box.Left) { left = box.Left; }
while (currentX > box.Left) {
left = currentX - (h * 2);
MidLeft = new Point(left, hm);
MidRight = new Point(currentX, hm);
int crestX = currentX - h;
gp.AddBezier(MidRight, new Point(crestX, 0), new Point(crestX, h), MidLeft);
currentX -= h * 2;
}
gp.AddLine(MidLeft, new Point(box.Left, box.Bottom)); // left side
gp.AddLine(new Point(box.Left, box.Bottom), new Point(box.Right, box.Bottom)); // bottom
gp.AddLine(new Point(box.Right, box.Bottom), new Point(box.Right, hm)); // right side
g.FillPath(new SolidBrush(color2), gp);
}
g.SmoothingMode = SmoothingMode.Default;
if (isAnimated && ++animateX > (box.Height * 2)) {
animateX = 1;
}
}
/// <summary></summary>
/// <param name="box"></param>
/// <param name="g"></param>
protected override void PaintThisProgress(Rectangle box, Graphics g) {
if (box.Width <= 1) {
return;
}
if (isAnimated) {
AnimateFrame(box, g, ref marqueeX);
} else {
int x = 0;
AnimateFrame(box, g, ref x);
}
if (gloss != null) {
gloss.PaintGloss(box, g);
}
}
/// <summary></summary>
protected override void DisposeThis(bool disposing) {
}
}
}