Some refactoring in CUETools

This commit is contained in:
karamanolev
2011-10-24 14:11:42 +00:00
parent e0f784a88a
commit ce79dd8641
19 changed files with 2883 additions and 3493 deletions

View File

@@ -82,6 +82,12 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="TreeNodes\FileSystemTreeNodeLocalDBCollision.cs" />
<Compile Include="TreeNodes\FileSystemTreeNodeLocalDB.cs" />
<Compile Include="TreeNodes\FileSystemTreeNodeLocalDBCategory.cs" />
<Compile Include="TreeNodes\FileSystemTreeNodeLocalDBEntry.cs" />
<Compile Include="TreeNodes\FileSystemTreeNodeLocalDBFolder.cs" />
<Compile Include="TreeNodes\FileSystemTreeNodeLocalDBGroup.cs" />
<Compile Include="frmSubmit.cs">
<SubType>Form</SubType>
</Compile>

View File

@@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using CUETools.Processor;
namespace JDP
{
public class FileSystemTreeNodeLocalDB : FileSystemTreeNodeLocalDBFolder
{
public override string Path
{
get
{
return null;
}
}
public override string DisplayName
{
get
{
return "Local DB";
}
}
public override int DisplayIcon
{
get
{
return icon_mgr.GetIconIndex(".#puzzle");
}
}
public FileSystemTreeNodeLocalDB(CUEControls.IIconManager icon_mgr, List<CUEToolsLocalDBEntry> group)
: base(icon_mgr)
{
this.Group = group;
this.SelectedImageIndex = this.ImageIndex = this.DisplayIcon;
this.Text = this.DisplayName;
}
public override void DoExpand()
{
this.Nodes.Add(new FileSystemTreeNodeLocalDBCategory(
icon_mgr, this.Group, true, true, icon_mgr.GetIconIndex(".#puzzle"), "By Uniqueness",
i => ((int)FileSystemTreeNodeLocalDBCollision.GetGroupType(this.Group.FindAll(j => j.DiscID == i.DiscID))).ToString(),
i => FileSystemTreeNodeLocalDBCollision.GroupTypeToDescription(FileSystemTreeNodeLocalDBCollision.GetGroupType(this.Group.FindAll(j => j.DiscID == i.DiscID))),
i => icon_mgr.GetIconIndex(FileSystemTreeNodeLocalDBCollision.GroupTypeToIconTag(FileSystemTreeNodeLocalDBCollision.GetGroupType(this.Group.FindAll(j => j.DiscID == i.DiscID)))))); //converter_icon
this.Nodes.Add(new FileSystemTreeNodeLocalDBCategory(
icon_mgr, this.Group, true, true, icon_mgr.GetIconIndex(".flac"), "By Format",
i => i.AudioPaths == null || i.AudioPaths.Count == 0 ? null : System.IO.Path.GetExtension(i.AudioPaths[0]).ToLower(),
null,
i => icon_mgr.GetIconIndex(i.AudioPaths[0])));
this.Nodes.Add(new FileSystemTreeNodeLocalDBCategory(
icon_mgr, this.Group, false, true, icon_mgr.GetIconIndex(".#users"), "By Artist",
i => i.Metadata.Artist, null, null));
this.Nodes.Add(new FileSystemTreeNodeLocalDBCategory(
icon_mgr, this.Group, true, false, icon_mgr.GetIconIndex(".#calendar"), "By Release Date",
i => i.Metadata.Year, null, null));
this.Nodes.Add(new FileSystemTreeNodeLocalDBCategory(
icon_mgr, this.Group, true, true, icon_mgr.GetIconIndex(".#alarm_clock"), "By Verification Date",
i =>
i.VerificationDate == DateTime.MinValue ? "0" :
i.VerificationDate.AddHours(1) > DateTime.Now ? "1" :
i.VerificationDate.AddDays(1) > DateTime.Now ? "2" :
i.VerificationDate.AddDays(7) > DateTime.Now ? "3" :
i.VerificationDate.AddDays(31) > DateTime.Now ? "4" :
i.VerificationDate.AddDays(365) > DateTime.Now ? "5" :
"6",
i =>
i.VerificationDate == DateTime.MinValue ? "never" :
i.VerificationDate.AddHours(1) > DateTime.Now ? "this hour" :
i.VerificationDate.AddDays(1) > DateTime.Now ? "this day" :
i.VerificationDate.AddDays(7) > DateTime.Now ? "this week" :
i.VerificationDate.AddDays(31) > DateTime.Now ? "this month" :
i.VerificationDate.AddDays(365) > DateTime.Now ? "this year" :
"more than a year ago",
null));
this.Nodes.Add(new FileSystemTreeNodeLocalDBCategory(
icon_mgr, this.Group, true, true, icon_mgr.GetIconIndex(".#ar"), "By AccurateRip Confidence",
i =>
i.VerificationDate == DateTime.MinValue ? "00" :
i.ARConfidence == 0 ? "01" :
i.ARConfidence == 1 ? "02" :
i.ARConfidence == 2 ? "03" :
i.ARConfidence == 3 ? "04" :
i.ARConfidence < 5 ? "05" :
i.ARConfidence < 10 ? "06" :
i.ARConfidence < 20 ? "07" :
i.ARConfidence < 50 ? "08" :
i.ARConfidence < 100 ? "09" :
"10",
i =>
i.VerificationDate == DateTime.MinValue ? "?" :
i.ARConfidence == 0 ? "0" :
i.ARConfidence == 1 ? "1" :
i.ARConfidence == 2 ? "2" :
i.ARConfidence == 3 ? "3" :
i.ARConfidence < 5 ? "< 5" :
i.ARConfidence < 10 ? "< 10" :
i.ARConfidence < 20 ? "< 20" :
i.ARConfidence < 50 ? "< 50" :
i.ARConfidence < 100 ? "< 100" :
">=100",
null));
}
}
}

View File

@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using CUETools.Processor;
namespace JDP
{
public class FileSystemTreeNodeLocalDBCategory : FileSystemTreeNodeLocalDBFolder
{
private Converter<CUEToolsLocalDBEntry, string> m_converter_key;
private Converter<CUEToolsLocalDBEntry, string> m_converter_name;
private Converter<CUEToolsLocalDBEntry, int> m_converter_icon;
private int m_icon;
private string m_name;
public bool ShowArtist { get; set; }
public bool ShowYear { get; set; }
public override string Path
{
get { return null; }
}
public override string DisplayName
{
get { return m_name; }
}
public override int DisplayIcon
{
get { return m_icon; }
}
public FileSystemTreeNodeLocalDBCategory(CUEControls.IIconManager icon_mgr, List<CUEToolsLocalDBEntry> group, bool showArtist, bool showYear, int icon, string name, Converter<CUEToolsLocalDBEntry, string> converter_key, Converter<CUEToolsLocalDBEntry, string> converter_name, Converter<CUEToolsLocalDBEntry, int> converter_icon)
: base(icon_mgr)
{
this.Group = group;
this.m_converter_key = converter_key;
this.m_converter_name = converter_name ?? converter_key;
this.m_converter_icon = converter_icon ?? (i => m_icon);
this.m_icon = icon;
this.m_name = name;
this.ShowArtist = showArtist;
this.ShowYear = showYear;
this.SelectedImageIndex = this.ImageIndex = this.DisplayIcon;
this.Text = this.DisplayName;
}
public override void DoExpand()
{
foreach (var group in CUEToolsLocalDB.Group(Group, m_converter_key, null))
this.Nodes.Add(new FileSystemTreeNodeLocalDBGroup(icon_mgr, group, ShowArtist, ShowYear, m_converter_icon(group[0]), m_converter_name(group[0])));
}
}
}

View File

@@ -0,0 +1,98 @@
using System.Collections.Generic;
using CUETools.Processor;
namespace JDP
{
public class FileSystemTreeNodeLocalDBCollision : FileSystemTreeNodeLocalDBFolder
{
public enum GroupType
{
Unverified = 0,
Different = 1,
Offsetted = 2,
Equal = 3,
Single = 4
}
public bool ShowArtist { get; set; }
public bool ShowYear { get; set; }
public override string Path
{
get
{
return null;
}
}
public override string DisplayName
{
get
{
var artistItem = Group.Find(i => !string.IsNullOrEmpty(i.Metadata.Artist) && ShowArtist);
var titleItem = Group.Find(i => !string.IsNullOrEmpty(i.Metadata.Title));
var yearItem = Group.Find(i => !string.IsNullOrEmpty(i.Metadata.Year) && ShowYear);
var discItem = Group.Find(i => !string.IsNullOrEmpty(i.Metadata.DiscNumberAndTotal));
return
(artistItem == null ? "" : artistItem.Metadata.Artist + " - ")
+ (titleItem == null ? "" : titleItem.Metadata.Title)
+ (yearItem == null ? "" : " (" + yearItem.Metadata.Year + ")")
+ (discItem == null ? "" : " [" + discItem.Metadata.DiscNumberAndTotal + "]");
}
}
public override int DisplayIcon
{
get
{
return icon_mgr.GetIconIndex(GroupTypeToIconTag(GetGroupType(Group)));
}
}
public FileSystemTreeNodeLocalDBCollision(CUEControls.IIconManager icon_mgr, List<CUEToolsLocalDBEntry> group, bool showArtist, bool showYear)
: base(icon_mgr)
{
this.Group = group;
this.ShowArtist = showArtist;
this.ShowYear = showYear;
this.SelectedImageIndex = this.ImageIndex = this.DisplayIcon;
this.Text = this.DisplayName;
}
internal static string GroupTypeToIconTag(GroupType type)
{
return type == GroupType.Equal ? ".#picture"
: type == GroupType.Offsetted ? ".#pictures"
: type == GroupType.Different ? ".#images"
: type == GroupType.Unverified ? ".#images_question"
: ".#puzzle";
}
internal static string GroupTypeToDescription(GroupType type)
{
return type == GroupType.Equal ? "Identical clones"
: type == GroupType.Offsetted ? "Offsetted clones"
: type == GroupType.Different ? "Mismatching clones"
: type == GroupType.Unverified ? "Not yet verified clones"
: "Unique";
}
internal static GroupType GetGroupType(List<CUEToolsLocalDBEntry> group)
{
if (group.Count < 2)
return GroupType.Single;
if (!group.TrueForAll(i => i.OffsetSafeCRC != null))
return GroupType.Unverified;
if (!group.TrueForAll(i => i.OffsetSafeCRC.DifferByOffset(group[0].OffsetSafeCRC)))
return GroupType.Different;
if (!group.TrueForAll(i => i.OffsetSafeCRC == group[0].OffsetSafeCRC))
return GroupType.Offsetted;
return GroupType.Equal;
}
public override void DoExpand()
{
foreach (var item in Group)
this.Nodes.Add(new FileSystemTreeNodeLocalDBEntry(icon_mgr, item, ShowArtist, ShowYear, null));
}
}
}

View File

@@ -0,0 +1,67 @@
using System.IO;
using CUEControls;
using CUETools.Processor;
namespace JDP
{
public class FileSystemTreeNodeLocalDBEntry : FileSystemTreeNode
{
private string m_input_path;
public bool ShowArtist { get; set; }
public bool ShowYear { get; set; }
public CUEToolsLocalDBEntry Item { get; private set; }
public override string Path
{
get
{
return m_input_path ?? Item.Path;
}
}
public override string DisplayName
{
get
{
if (m_input_path != null && File.Exists(m_input_path))
return icon_mgr.GetDisplayName(new FileInfo(m_input_path));
return
(string.IsNullOrEmpty(Item.Metadata.Artist) || !ShowArtist ? "" : Item.Metadata.Artist + " - ")
+ Item.Metadata.Title
+ (string.IsNullOrEmpty(Item.Metadata.Year) || !ShowYear ? "" : " (" + Item.Metadata.Year + ")")
+ (string.IsNullOrEmpty(Item.Metadata.DiscNumberAndTotal) ? "" : " [" + Item.Metadata.DiscNumberAndTotal + "]");
}
}
public override int DisplayIcon
{
get
{
return icon_mgr.GetIconIndex(m_input_path ?? (Item.AudioPaths == null || Item.AudioPaths.Count == 0 ? "*.wav" : Item.AudioPaths[0]));
}
}
public FileSystemTreeNodeLocalDBEntry(IIconManager icon_mgr, CUEToolsLocalDBEntry item, bool showArtist, bool showYear, string inputPath)
: base(icon_mgr, inputPath == null && item.InputPaths != null && item.InputPaths.Count > 1)
{
this.Item = item;
this.m_input_path = inputPath;
this.ShowArtist = showArtist;
this.ShowYear = showYear;
this.SelectedImageIndex = this.ImageIndex = this.DisplayIcon;
this.Text = this.DisplayName;
//// Choose state from m_state_image_list
//if (item.InputPaths.Find(path => Path.GetExtension(path).ToLower() == ".cue") != null)
// album.StateImageKey = "cue";
//else
// album.StateImageKey = "blank";
}
public override void DoExpand()
{
if (Item.InputPaths != null)
foreach (var path in Item.InputPaths)
this.Nodes.Add(new FileSystemTreeNodeLocalDBEntry(icon_mgr, Item, ShowArtist, ShowYear, path));
}
}
}

View File

@@ -0,0 +1,31 @@
using System.Collections.Generic;
using System.Windows.Forms;
using CUEControls;
using CUETools.Processor;
namespace JDP
{
public abstract class FileSystemTreeNodeLocalDBFolder : FileSystemTreeNode
{
public List<CUEToolsLocalDBEntry> Group { get; protected set; }
public FileSystemTreeNodeLocalDBFolder(IIconManager icon_mgr)
: base(icon_mgr, true)
{
}
public void Purge(List<CUEToolsLocalDBEntry> entries)
{
foreach (TreeNode child in this.Nodes)
{
if (child is FileSystemTreeNodeLocalDBFolder)
(child as FileSystemTreeNodeLocalDBFolder).Purge(entries);
if ((child is FileSystemTreeNodeLocalDBEntry && entries.Contains((child as FileSystemTreeNodeLocalDBEntry).Item))
|| (child is FileSystemTreeNodeLocalDBGroup && (child as FileSystemTreeNodeLocalDBGroup).Group.Count == 0))
child.Remove();
}
this.Group.RemoveAll(item => entries.Contains(item));
}
}
}

View File

@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using CUETools.Processor;
namespace JDP
{
public class FileSystemTreeNodeLocalDBGroup : FileSystemTreeNodeLocalDBFolder
{
private int m_icon;
private string m_name;
public bool ShowArtist { get; set; }
public bool ShowYear { get; set; }
public override string Path
{
get { return null; }
}
public override string DisplayName
{
get { return m_name; }
}
public override int DisplayIcon
{
get { return m_icon; }
}
public FileSystemTreeNodeLocalDBGroup(CUEControls.IIconManager icon_mgr, List<CUEToolsLocalDBEntry> group, bool showArtist, bool showYear, int icon, string name)
: base(icon_mgr)
{
this.Group = group;
this.m_icon = icon;
this.m_name = name;
this.ShowArtist = showArtist;
this.ShowYear = showYear;
this.SelectedImageIndex = this.ImageIndex = this.DisplayIcon;
this.Text = this.DisplayName;
}
private static int Compare(List<CUEToolsLocalDBEntry> a, List<CUEToolsLocalDBEntry> b)
{
int diff = FileSystemTreeNodeLocalDBCollision.GetGroupType(a) - FileSystemTreeNodeLocalDBCollision.GetGroupType(b);
return diff != 0 ? diff :
String.Compare(
a[0].Metadata.Artist + " - " + a[0].Metadata.Title + " - " + a[0].Metadata.DiscNumberAndTotal,
b[0].Metadata.Artist + " - " + b[0].Metadata.Title + " - " + b[0].Metadata.DiscNumberAndTotal);
}
public override void DoExpand()
{
var byDiscId = CUEToolsLocalDB.Group(Group, i => i.DiscID, (a, b) => Compare(a, b));
foreach (var group in byDiscId)
{
if (group.Count > 1)
this.Nodes.Add(new FileSystemTreeNodeLocalDBCollision(icon_mgr, group, ShowArtist, ShowYear));
else
this.Nodes.Add(new FileSystemTreeNodeLocalDBEntry(icon_mgr, group[0], ShowArtist, ShowYear, null));
}
}
}
}

View File

@@ -1,9 +1,3 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace JDP

View File

@@ -170,7 +170,7 @@ namespace JDP {
//
// toolStripContainer1.LeftToolStripPanel
//
this.toolStripContainer1.LeftToolStripPanel.MaximumSize = new System.Drawing.Size(43, 0);
this.toolStripContainer1.LeftToolStripPanel.MaximumSize = new System.Drawing.Size(32, 0);
this.toolStripContainer1.LeftToolStripPanelVisible = false;
this.toolStripContainer1.Name = "toolStripContainer1";
this.toolStripContainer1.RightToolStripPanelVisible = false;
@@ -278,14 +278,14 @@ namespace JDP {
CUEControls.ExtraSpecialFolder.Profile,
CUEControls.ExtraSpecialFolder.MyMusic,
CUEControls.ExtraSpecialFolder.CommonMusic};
this.fileSystemTreeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.fileSystemTreeView1_AfterCheck);
this.fileSystemTreeView1.NodeExpand += new CUEControls.FileSystemTreeViewNodeExpandHandler(this.fileSystemTreeView1_NodeExpand);
this.fileSystemTreeView1.DragDrop += new System.Windows.Forms.DragEventHandler(this.fileSystemTreeView1_DragDrop);
this.fileSystemTreeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.fileSystemTreeView1_AfterSelect);
this.fileSystemTreeView1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.fileSystemTreeView1_MouseDown);
this.fileSystemTreeView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.fileSystemTreeView1_KeyDown);
this.fileSystemTreeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.fileSystemTreeView1_AfterCheck);
this.fileSystemTreeView1.AfterExpand += new System.Windows.Forms.TreeViewEventHandler(this.fileSystemTreeView1_AfterExpand);
this.fileSystemTreeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.fileSystemTreeView1_AfterSelect);
this.fileSystemTreeView1.DragDrop += new System.Windows.Forms.DragEventHandler(this.fileSystemTreeView1_DragDrop);
this.fileSystemTreeView1.DragOver += new System.Windows.Forms.DragEventHandler(this.fileSystemTreeView1_DragOver);
this.fileSystemTreeView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.fileSystemTreeView1_KeyDown);
this.fileSystemTreeView1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.fileSystemTreeView1_MouseDown);
//
// tableLayoutPanel2
//
@@ -355,7 +355,7 @@ namespace JDP {
//
resources.ApplyResources(this.checkBoxUseAccurateRip, "checkBoxUseAccurateRip");
this.checkBoxUseAccurateRip.Image = global::JDP.Properties.Resources.AR;
this.checkBoxUseAccurateRip.MinimumSize = new System.Drawing.Size(0, 21);
this.checkBoxUseAccurateRip.MinimumSize = new System.Drawing.Size(0, 16);
this.checkBoxUseAccurateRip.Name = "checkBoxUseAccurateRip";
this.toolTip1.SetToolTip(this.checkBoxUseAccurateRip, resources.GetString("checkBoxUseAccurateRip.ToolTip"));
this.checkBoxUseAccurateRip.UseVisualStyleBackColor = true;
@@ -365,7 +365,7 @@ namespace JDP {
//
resources.ApplyResources(this.checkBoxUseFreeDb, "checkBoxUseFreeDb");
this.checkBoxUseFreeDb.Image = global::JDP.Properties.Resources.freedb16;
this.checkBoxUseFreeDb.MinimumSize = new System.Drawing.Size(0, 21);
this.checkBoxUseFreeDb.MinimumSize = new System.Drawing.Size(0, 16);
this.checkBoxUseFreeDb.Name = "checkBoxUseFreeDb";
this.toolTip1.SetToolTip(this.checkBoxUseFreeDb, resources.GetString("checkBoxUseFreeDb.ToolTip"));
this.checkBoxUseFreeDb.UseVisualStyleBackColor = true;
@@ -403,7 +403,7 @@ namespace JDP {
//
resources.ApplyResources(this.checkBoxUseMusicBrainz, "checkBoxUseMusicBrainz");
this.checkBoxUseMusicBrainz.Image = global::JDP.Properties.Resources.musicbrainz;
this.checkBoxUseMusicBrainz.MinimumSize = new System.Drawing.Size(0, 21);
this.checkBoxUseMusicBrainz.MinimumSize = new System.Drawing.Size(0, 16);
this.checkBoxUseMusicBrainz.Name = "checkBoxUseMusicBrainz";
this.toolTip1.SetToolTip(this.checkBoxUseMusicBrainz, resources.GetString("checkBoxUseMusicBrainz.ToolTip"));
this.checkBoxUseMusicBrainz.UseVisualStyleBackColor = true;
@@ -547,7 +547,7 @@ namespace JDP {
// labelFormat
//
resources.ApplyResources(this.labelFormat, "labelFormat");
this.labelFormat.MinimumSize = new System.Drawing.Size(21, 21);
this.labelFormat.MinimumSize = new System.Drawing.Size(16, 16);
this.labelFormat.Name = "labelFormat";
//
// comboBoxAudioFormat
@@ -1052,8 +1052,8 @@ namespace JDP {
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.toolStripContainer1);
this.Name = "frmCUETools";
this.Load += new System.EventHandler(this.frmCUETools_Load);
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.frmCUETools_FormClosed);
this.Load += new System.EventHandler(this.frmCUETools_Load);
this.toolStripContainer1.BottomToolStripPanel.ResumeLayout(false);
this.toolStripContainer1.BottomToolStripPanel.PerformLayout();
this.toolStripContainer1.ContentPanel.ResumeLayout(false);

View File

@@ -2630,407 +2630,4 @@ namespace JDP
}
}
}
public class FileSystemTreeNodeLocalDBEntry : CUEControls.FileSystemTreeNode
{
private string m_input_path;
public bool ShowArtist { get; set; }
public bool ShowYear { get; set; }
public CUEToolsLocalDBEntry Item { get; private set; }
public override string Path
{
get
{
return m_input_path ?? Item.Path;
}
}
public override string DisplayName
{
get
{
if (m_input_path != null && File.Exists(m_input_path))
return icon_mgr.GetDisplayName(new FileInfo(m_input_path));
return
(string.IsNullOrEmpty(Item.Metadata.Artist) || !ShowArtist ? "" : Item.Metadata.Artist + " - ")
+ Item.Metadata.Title
+ (string.IsNullOrEmpty(Item.Metadata.Year) || !ShowYear ? "" : " (" + Item.Metadata.Year + ")")
+ (string.IsNullOrEmpty(Item.Metadata.DiscNumberAndTotal) ? "" : " [" + Item.Metadata.DiscNumberAndTotal + "]");
}
}
public override int DisplayIcon
{
get
{
return icon_mgr.GetIconIndex(m_input_path ?? (Item.AudioPaths == null || Item.AudioPaths.Count == 0 ? "*.wav" : Item.AudioPaths[0]));
}
}
public FileSystemTreeNodeLocalDBEntry(CUEControls.IIconManager icon_mgr, CUEToolsLocalDBEntry item, bool showArtist, bool showYear, string inputPath)
: base(icon_mgr, inputPath == null && item.InputPaths != null && item.InputPaths.Count > 1)
{
this.Item = item;
this.m_input_path = inputPath;
this.ShowArtist = showArtist;
this.ShowYear = showYear;
this.SelectedImageIndex = this.ImageIndex = this.DisplayIcon;
this.Text = this.DisplayName;
//// Choose state from m_state_image_list
//if (item.InputPaths.Find(path => Path.GetExtension(path).ToLower() == ".cue") != null)
// album.StateImageKey = "cue";
//else
// album.StateImageKey = "blank";
}
public override void DoExpand()
{
if (Item.InputPaths != null)
foreach (var path in Item.InputPaths)
this.Nodes.Add(new FileSystemTreeNodeLocalDBEntry(icon_mgr, Item, ShowArtist, ShowYear, path));
}
}
public abstract class FileSystemTreeNodeLocalDBFolder : CUEControls.FileSystemTreeNode
{
public List<CUEToolsLocalDBEntry> Group { get; protected set; }
public FileSystemTreeNodeLocalDBFolder(CUEControls.IIconManager icon_mgr)
: base(icon_mgr, true)
{
}
public void Purge(List<CUEToolsLocalDBEntry> entries)
{
foreach (TreeNode child in this.Nodes)
{
if (child is FileSystemTreeNodeLocalDBFolder)
(child as FileSystemTreeNodeLocalDBFolder).Purge(entries);
if ((child is FileSystemTreeNodeLocalDBEntry && entries.Contains((child as FileSystemTreeNodeLocalDBEntry).Item))
|| (child is FileSystemTreeNodeLocalDBGroup && (child as FileSystemTreeNodeLocalDBGroup).Group.Count == 0))
child.Remove();
}
this.Group.RemoveAll(item => entries.Contains(item));
}
}
public class FileSystemTreeNodeLocalDBCollision : FileSystemTreeNodeLocalDBFolder
{
public enum GroupType
{
Unverified = 0,
Different = 1,
Offsetted = 2,
Equal = 3,
Single = 4
}
public bool ShowArtist { get; set; }
public bool ShowYear { get; set; }
public override string Path
{
get
{
return null;
}
}
public override string DisplayName
{
get
{
var artistItem = Group.Find(i => !string.IsNullOrEmpty(i.Metadata.Artist) && ShowArtist);
var titleItem = Group.Find(i => !string.IsNullOrEmpty(i.Metadata.Title));
var yearItem = Group.Find(i => !string.IsNullOrEmpty(i.Metadata.Year) && ShowYear);
var discItem = Group.Find(i => !string.IsNullOrEmpty(i.Metadata.DiscNumberAndTotal));
return
(artistItem == null ? "" : artistItem.Metadata.Artist + " - ")
+ (titleItem == null ? "" : titleItem.Metadata.Title)
+ (yearItem == null ? "" : " (" + yearItem.Metadata.Year + ")")
+ (discItem == null ? "" : " [" + discItem.Metadata.DiscNumberAndTotal + "]");
}
}
public override int DisplayIcon
{
get
{
return icon_mgr.GetIconIndex(GroupTypeToIconTag(GetGroupType(Group)));
}
}
public FileSystemTreeNodeLocalDBCollision(CUEControls.IIconManager icon_mgr, List<CUEToolsLocalDBEntry> group, bool showArtist, bool showYear)
: base(icon_mgr)
{
this.Group = group;
this.ShowArtist = showArtist;
this.ShowYear = showYear;
this.SelectedImageIndex = this.ImageIndex = this.DisplayIcon;
this.Text = this.DisplayName;
}
internal static string GroupTypeToIconTag(GroupType type)
{
return type == GroupType.Equal ? ".#picture"
: type == GroupType.Offsetted ? ".#pictures"
: type == GroupType.Different ? ".#images"
: type == GroupType.Unverified ? ".#images_question"
: ".#puzzle";
}
internal static string GroupTypeToDescription(GroupType type)
{
return type == GroupType.Equal ? "Identical clones"
: type == GroupType.Offsetted ? "Offsetted clones"
: type == GroupType.Different ? "Mismatching clones"
: type == GroupType.Unverified ? "Not yet verified clones"
: "Unique";
}
internal static GroupType GetGroupType(List<CUEToolsLocalDBEntry> group)
{
if (group.Count < 2)
return GroupType.Single;
if (!group.TrueForAll(i => i.OffsetSafeCRC != null))
return GroupType.Unverified;
if (!group.TrueForAll(i => i.OffsetSafeCRC.DifferByOffset(group[0].OffsetSafeCRC)))
return GroupType.Different;
if (!group.TrueForAll(i => i.OffsetSafeCRC == group[0].OffsetSafeCRC))
return GroupType.Offsetted;
return GroupType.Equal;
}
public override void DoExpand()
{
foreach (var item in Group)
this.Nodes.Add(new FileSystemTreeNodeLocalDBEntry(icon_mgr, item, ShowArtist, ShowYear, null));
}
}
public class FileSystemTreeNodeLocalDBGroup : FileSystemTreeNodeLocalDBFolder
{
private int m_icon;
private string m_name;
public bool ShowArtist { get; set; }
public bool ShowYear { get; set; }
public override string Path
{
get
{
return null;
}
}
public override string DisplayName
{
get
{
return m_name;
}
}
public override int DisplayIcon
{
get
{
return m_icon;
}
}
public FileSystemTreeNodeLocalDBGroup(CUEControls.IIconManager icon_mgr, List<CUEToolsLocalDBEntry> group, bool showArtist, bool showYear, int icon, string name)
: base(icon_mgr)
{
this.Group = group;
this.m_icon = icon;
this.m_name = name;
this.ShowArtist = showArtist;
this.ShowYear = showYear;
this.SelectedImageIndex = this.ImageIndex = this.DisplayIcon;
this.Text = this.DisplayName;
}
private static int Compare(List<CUEToolsLocalDBEntry> a, List<CUEToolsLocalDBEntry> b)
{
int diff = FileSystemTreeNodeLocalDBCollision.GetGroupType(a) - FileSystemTreeNodeLocalDBCollision.GetGroupType(b);
return diff != 0 ? diff :
String.Compare(
a[0].Metadata.Artist + " - " + a[0].Metadata.Title + " - " + a[0].Metadata.DiscNumberAndTotal,
b[0].Metadata.Artist + " - " + b[0].Metadata.Title + " - " + b[0].Metadata.DiscNumberAndTotal);
}
public override void DoExpand()
{
var byDiscId = CUEToolsLocalDB.Group(Group, i => i.DiscID, (a, b) => Compare(a,b));
foreach (var group in byDiscId)
{
if (group.Count > 1)
this.Nodes.Add(new FileSystemTreeNodeLocalDBCollision(icon_mgr, group, ShowArtist, ShowYear));
else
this.Nodes.Add(new FileSystemTreeNodeLocalDBEntry(icon_mgr, group[0], ShowArtist, ShowYear, null));
}
}
}
public class FileSystemTreeNodeLocalDBCategory : FileSystemTreeNodeLocalDBFolder
{
private Converter<CUEToolsLocalDBEntry, string> m_converter_key;
private Converter<CUEToolsLocalDBEntry, string> m_converter_name;
private Converter<CUEToolsLocalDBEntry, int> m_converter_icon;
private int m_icon;
private string m_name;
public bool ShowArtist { get; set; }
public bool ShowYear { get; set; }
public override string Path
{
get
{
return null;
}
}
public override string DisplayName
{
get
{
return m_name;
}
}
public override int DisplayIcon
{
get
{
return m_icon;
}
}
public FileSystemTreeNodeLocalDBCategory(CUEControls.IIconManager icon_mgr, List<CUEToolsLocalDBEntry> group, bool showArtist, bool showYear, int icon, string name, Converter<CUEToolsLocalDBEntry, string> converter_key, Converter<CUEToolsLocalDBEntry, string> converter_name, Converter<CUEToolsLocalDBEntry, int> converter_icon)
: base(icon_mgr)
{
this.Group = group;
this.m_converter_key = converter_key;
this.m_converter_name = converter_name ?? converter_key;
this.m_converter_icon = converter_icon ?? (i => m_icon);
this.m_icon = icon;
this.m_name = name;
this.ShowArtist = showArtist;
this.ShowYear = showYear;
this.SelectedImageIndex = this.ImageIndex = this.DisplayIcon;
this.Text = this.DisplayName;
}
public override void DoExpand()
{
foreach (var group in CUEToolsLocalDB.Group(Group, m_converter_key, null))
this.Nodes.Add(new FileSystemTreeNodeLocalDBGroup(icon_mgr, group, ShowArtist, ShowYear, m_converter_icon(group[0]), m_converter_name(group[0])));
}
}
public class FileSystemTreeNodeLocalDB : FileSystemTreeNodeLocalDBFolder
{
public override string Path
{
get
{
return null;
}
}
public override string DisplayName
{
get
{
return "Local DB";
}
}
public override int DisplayIcon
{
get
{
return icon_mgr.GetIconIndex(".#puzzle");
}
}
public FileSystemTreeNodeLocalDB(CUEControls.IIconManager icon_mgr, List<CUEToolsLocalDBEntry> group)
: base(icon_mgr)
{
this.Group = group;
this.SelectedImageIndex = this.ImageIndex = this.DisplayIcon;
this.Text = this.DisplayName;
}
public override void DoExpand()
{
this.Nodes.Add(new FileSystemTreeNodeLocalDBCategory(
icon_mgr, this.Group, true, true, icon_mgr.GetIconIndex(".#puzzle"), "By Uniqueness",
i => ((int)FileSystemTreeNodeLocalDBCollision.GetGroupType(this.Group.FindAll(j => j.DiscID == i.DiscID))).ToString(),
i => FileSystemTreeNodeLocalDBCollision.GroupTypeToDescription(FileSystemTreeNodeLocalDBCollision.GetGroupType(this.Group.FindAll(j => j.DiscID == i.DiscID))),
i => icon_mgr.GetIconIndex(FileSystemTreeNodeLocalDBCollision.GroupTypeToIconTag(FileSystemTreeNodeLocalDBCollision.GetGroupType(this.Group.FindAll(j => j.DiscID == i.DiscID)))))); //converter_icon
this.Nodes.Add(new FileSystemTreeNodeLocalDBCategory(
icon_mgr, this.Group, true, true, icon_mgr.GetIconIndex(".flac"), "By Format",
i => i.AudioPaths == null || i.AudioPaths.Count == 0 ? null : System.IO.Path.GetExtension(i.AudioPaths[0]).ToLower(),
null,
i => icon_mgr.GetIconIndex(i.AudioPaths[0])));
this.Nodes.Add(new FileSystemTreeNodeLocalDBCategory(
icon_mgr, this.Group, false, true, icon_mgr.GetIconIndex(".#users"), "By Artist",
i => i.Metadata.Artist, null, null));
this.Nodes.Add(new FileSystemTreeNodeLocalDBCategory(
icon_mgr, this.Group, true, false, icon_mgr.GetIconIndex(".#calendar"), "By Release Date",
i => i.Metadata.Year, null, null));
this.Nodes.Add(new FileSystemTreeNodeLocalDBCategory(
icon_mgr, this.Group, true, true, icon_mgr.GetIconIndex(".#alarm_clock"), "By Verification Date",
i =>
i.VerificationDate == DateTime.MinValue ? "0" :
i.VerificationDate.AddHours(1) > DateTime.Now ? "1" :
i.VerificationDate.AddDays(1) > DateTime.Now ? "2" :
i.VerificationDate.AddDays(7) > DateTime.Now ? "3" :
i.VerificationDate.AddDays(31) > DateTime.Now ? "4" :
i.VerificationDate.AddDays(365) > DateTime.Now ? "5" :
"6",
i =>
i.VerificationDate == DateTime.MinValue ? "never" :
i.VerificationDate.AddHours(1) > DateTime.Now ? "this hour" :
i.VerificationDate.AddDays(1) > DateTime.Now ? "this day" :
i.VerificationDate.AddDays(7) > DateTime.Now ? "this week" :
i.VerificationDate.AddDays(31) > DateTime.Now ? "this month" :
i.VerificationDate.AddDays(365) > DateTime.Now ? "this year" :
"more than a year ago",
null));
this.Nodes.Add(new FileSystemTreeNodeLocalDBCategory(
icon_mgr, this.Group, true, true, icon_mgr.GetIconIndex(".#ar"), "By AccurateRip Confidence",
i =>
i.VerificationDate == DateTime.MinValue ? "00" :
i.ARConfidence == 0 ? "01" :
i.ARConfidence == 1 ? "02" :
i.ARConfidence == 2 ? "03" :
i.ARConfidence == 3 ? "04" :
i.ARConfidence < 5 ? "05" :
i.ARConfidence < 10 ? "06" :
i.ARConfidence < 20 ? "07" :
i.ARConfidence < 50 ? "08" :
i.ARConfidence < 100 ? "09" :
"10",
i =>
i.VerificationDate == DateTime.MinValue ? "?" :
i.ARConfidence == 0 ? "0" :
i.ARConfidence == 1 ? "1" :
i.ARConfidence == 2 ? "2" :
i.ARConfidence == 3 ? "3" :
i.ARConfidence < 5 ? "< 5" :
i.ARConfidence < 10 ? "< 10" :
i.ARConfidence < 20 ? "< 20" :
i.ARConfidence < 50 ? "< 50" :
i.ARConfidence < 100 ? "< 100" :
">=100",
null));
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -37,8 +37,9 @@
//
// buttonNo
//
this.buttonNo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonNo.DialogResult = System.Windows.Forms.DialogResult.No;
this.buttonNo.Location = new System.Drawing.Point(587, 278);
this.buttonNo.Location = new System.Drawing.Point(590, 266);
this.buttonNo.Name = "buttonNo";
this.buttonNo.Size = new System.Drawing.Size(75, 23);
this.buttonNo.TabIndex = 0;
@@ -47,8 +48,9 @@
//
// buttonYes
//
this.buttonYes.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonYes.DialogResult = System.Windows.Forms.DialogResult.Yes;
this.buttonYes.Location = new System.Drawing.Point(506, 278);
this.buttonYes.Location = new System.Drawing.Point(509, 266);
this.buttonYes.Name = "buttonYes";
this.buttonYes.Size = new System.Drawing.Size(75, 23);
this.buttonYes.TabIndex = 1;
@@ -57,8 +59,9 @@
//
// checkBoxRemember
//
this.checkBoxRemember.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.checkBoxRemember.AutoSize = true;
this.checkBoxRemember.Location = new System.Drawing.Point(12, 282);
this.checkBoxRemember.Location = new System.Drawing.Point(9, 270);
this.checkBoxRemember.Name = "checkBoxRemember";
this.checkBoxRemember.Size = new System.Drawing.Size(128, 17);
this.checkBoxRemember.TabIndex = 3;
@@ -67,8 +70,9 @@
//
// labelAlreadyExist
//
this.labelAlreadyExist.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.labelAlreadyExist.AutoSize = true;
this.labelAlreadyExist.Location = new System.Drawing.Point(201, 283);
this.labelAlreadyExist.Location = new System.Drawing.Point(213, 271);
this.labelAlreadyExist.Name = "labelAlreadyExist";
this.labelAlreadyExist.Size = new System.Drawing.Size(203, 13);
this.labelAlreadyExist.TabIndex = 2;
@@ -76,6 +80,9 @@
//
// textFiles
//
this.textFiles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textFiles.Font = new System.Drawing.Font("Courier New", 8.25F);
this.textFiles.Location = new System.Drawing.Point(9, 9);
this.textFiles.Margin = new System.Windows.Forms.Padding(0);
@@ -92,7 +99,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(674, 313);
this.ClientSize = new System.Drawing.Size(674, 301);
this.Controls.Add(this.textFiles);
this.Controls.Add(this.labelAlreadyExist);
this.Controls.Add(this.checkBoxRemember);

View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms;
namespace JDP
{

View File

@@ -1,9 +1,3 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace JDP

View File

@@ -1,23 +1,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace JDP
{
public partial class frmReport : Form
{
public frmReport()
public string Message
{
InitializeComponent();
txtReport.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
}
public string Message {
get { return txtReport.Text; }
set { txtReport.Text = value; }
}
public frmReport()
{
InitializeComponent();
}
}
}

View File

@@ -148,7 +148,7 @@
<value>1</value>
</data>
<data name="txtReport.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Left, Right</value>
<value>Top, Bottom, Left, Right</value>
</data>
<data name="txtReport.Font" type="System.Drawing.Font, System.Drawing">
<value>Courier New, 8.25pt</value>

View File

@@ -2,15 +2,14 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.IO;
using System.Threading;
using CUETools.Processor;
using System.Windows.Forms;
using CUEControls;
using CUETools.Processor;
namespace JDP {
namespace JDP
{
public partial class frmSettings : Form {
bool _reducePriority;
CUEConfig _config;

View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms;
namespace JDP
{