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> </Reference>
</ItemGroup> </ItemGroup>
<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"> <Compile Include="frmSubmit.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </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; using System.Windows.Forms;
namespace JDP namespace JDP

File diff suppressed because it is too large Load Diff

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

@@ -28,84 +28,91 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.buttonNo = new System.Windows.Forms.Button(); this.buttonNo = new System.Windows.Forms.Button();
this.buttonYes = new System.Windows.Forms.Button(); this.buttonYes = new System.Windows.Forms.Button();
this.checkBoxRemember = new System.Windows.Forms.CheckBox(); this.checkBoxRemember = new System.Windows.Forms.CheckBox();
this.labelAlreadyExist = new System.Windows.Forms.Label(); this.labelAlreadyExist = new System.Windows.Forms.Label();
this.textFiles = new System.Windows.Forms.TextBox(); this.textFiles = new System.Windows.Forms.TextBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// buttonNo // buttonNo
// //
this.buttonNo.DialogResult = System.Windows.Forms.DialogResult.No; this.buttonNo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonNo.Location = new System.Drawing.Point(587, 278); this.buttonNo.DialogResult = System.Windows.Forms.DialogResult.No;
this.buttonNo.Name = "buttonNo"; this.buttonNo.Location = new System.Drawing.Point(590, 266);
this.buttonNo.Size = new System.Drawing.Size(75, 23); this.buttonNo.Name = "buttonNo";
this.buttonNo.TabIndex = 0; this.buttonNo.Size = new System.Drawing.Size(75, 23);
this.buttonNo.Text = "No"; this.buttonNo.TabIndex = 0;
this.buttonNo.UseVisualStyleBackColor = true; this.buttonNo.Text = "No";
// this.buttonNo.UseVisualStyleBackColor = true;
// buttonYes //
// // buttonYes
this.buttonYes.DialogResult = System.Windows.Forms.DialogResult.Yes; //
this.buttonYes.Location = new System.Drawing.Point(506, 278); this.buttonYes.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonYes.Name = "buttonYes"; this.buttonYes.DialogResult = System.Windows.Forms.DialogResult.Yes;
this.buttonYes.Size = new System.Drawing.Size(75, 23); this.buttonYes.Location = new System.Drawing.Point(509, 266);
this.buttonYes.TabIndex = 1; this.buttonYes.Name = "buttonYes";
this.buttonYes.Text = "Yes"; this.buttonYes.Size = new System.Drawing.Size(75, 23);
this.buttonYes.UseVisualStyleBackColor = true; this.buttonYes.TabIndex = 1;
// this.buttonYes.Text = "Yes";
// checkBoxRemember this.buttonYes.UseVisualStyleBackColor = true;
// //
this.checkBoxRemember.AutoSize = true; // checkBoxRemember
this.checkBoxRemember.Location = new System.Drawing.Point(12, 282); //
this.checkBoxRemember.Name = "checkBoxRemember"; this.checkBoxRemember.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.checkBoxRemember.Size = new System.Drawing.Size(128, 17); this.checkBoxRemember.AutoSize = true;
this.checkBoxRemember.TabIndex = 3; this.checkBoxRemember.Location = new System.Drawing.Point(9, 270);
this.checkBoxRemember.Text = "Remember my choice"; this.checkBoxRemember.Name = "checkBoxRemember";
this.checkBoxRemember.UseVisualStyleBackColor = true; this.checkBoxRemember.Size = new System.Drawing.Size(128, 17);
// this.checkBoxRemember.TabIndex = 3;
// labelAlreadyExist this.checkBoxRemember.Text = "Remember my choice";
// this.checkBoxRemember.UseVisualStyleBackColor = true;
this.labelAlreadyExist.AutoSize = true; //
this.labelAlreadyExist.Location = new System.Drawing.Point(201, 283); // labelAlreadyExist
this.labelAlreadyExist.Name = "labelAlreadyExist"; //
this.labelAlreadyExist.Size = new System.Drawing.Size(203, 13); this.labelAlreadyExist.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.labelAlreadyExist.TabIndex = 2; this.labelAlreadyExist.AutoSize = true;
this.labelAlreadyExist.Text = "Some of the files already exist. Overwrite?"; this.labelAlreadyExist.Location = new System.Drawing.Point(213, 271);
// this.labelAlreadyExist.Name = "labelAlreadyExist";
// textFiles this.labelAlreadyExist.Size = new System.Drawing.Size(203, 13);
// this.labelAlreadyExist.TabIndex = 2;
this.textFiles.Font = new System.Drawing.Font("Courier New", 8.25F); this.labelAlreadyExist.Text = "Some of the files already exist. Overwrite?";
this.textFiles.Location = new System.Drawing.Point(9, 9); //
this.textFiles.Margin = new System.Windows.Forms.Padding(0); // textFiles
this.textFiles.Multiline = true; //
this.textFiles.Name = "textFiles"; this.textFiles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
this.textFiles.ReadOnly = true; | System.Windows.Forms.AnchorStyles.Left)
this.textFiles.ScrollBars = System.Windows.Forms.ScrollBars.Both; | System.Windows.Forms.AnchorStyles.Right)));
this.textFiles.Size = new System.Drawing.Size(656, 254); this.textFiles.Font = new System.Drawing.Font("Courier New", 8.25F);
this.textFiles.TabIndex = 4; this.textFiles.Location = new System.Drawing.Point(9, 9);
this.textFiles.TabStop = false; this.textFiles.Margin = new System.Windows.Forms.Padding(0);
this.textFiles.WordWrap = false; this.textFiles.Multiline = true;
// this.textFiles.Name = "textFiles";
// frmOverwrite this.textFiles.ReadOnly = true;
// this.textFiles.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.textFiles.Size = new System.Drawing.Size(656, 254);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.textFiles.TabIndex = 4;
this.ClientSize = new System.Drawing.Size(674, 313); this.textFiles.TabStop = false;
this.Controls.Add(this.textFiles); this.textFiles.WordWrap = false;
this.Controls.Add(this.labelAlreadyExist); //
this.Controls.Add(this.checkBoxRemember); // frmOverwrite
this.Controls.Add(this.buttonYes); //
this.Controls.Add(this.buttonNo); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.MaximizeBox = false; this.ClientSize = new System.Drawing.Size(674, 301);
this.MinimizeBox = false; this.Controls.Add(this.textFiles);
this.Name = "frmOverwrite"; this.Controls.Add(this.labelAlreadyExist);
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Controls.Add(this.checkBoxRemember);
this.Text = "Overwrite?"; this.Controls.Add(this.buttonYes);
this.ResumeLayout(false); this.Controls.Add(this.buttonNo);
this.PerformLayout(); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "frmOverwrite";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Overwrite?";
this.ResumeLayout(false);
this.PerformLayout();
} }

View File

@@ -1,10 +1,4 @@
using System; using System.Windows.Forms;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace JDP 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; using System.Windows.Forms;
namespace JDP namespace JDP

View File

@@ -28,40 +28,40 @@ namespace JDP
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmReport)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmReport));
this.btnClose = new System.Windows.Forms.Button(); this.btnClose = new System.Windows.Forms.Button();
this.txtReport = new System.Windows.Forms.TextBox(); this.txtReport = new System.Windows.Forms.TextBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// btnClose // btnClose
// //
resources.ApplyResources(this.btnClose, "btnClose"); resources.ApplyResources(this.btnClose, "btnClose");
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnClose.Name = "btnClose"; this.btnClose.Name = "btnClose";
this.btnClose.UseVisualStyleBackColor = true; this.btnClose.UseVisualStyleBackColor = true;
// //
// txtReport // txtReport
// //
resources.ApplyResources(this.txtReport, "txtReport"); resources.ApplyResources(this.txtReport, "txtReport");
this.txtReport.BackColor = System.Drawing.SystemColors.Control; this.txtReport.BackColor = System.Drawing.SystemColors.Control;
this.txtReport.BorderStyle = System.Windows.Forms.BorderStyle.None; this.txtReport.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.txtReport.Name = "txtReport"; this.txtReport.Name = "txtReport";
this.txtReport.ReadOnly = true; this.txtReport.ReadOnly = true;
// //
// frmReport // frmReport
// //
resources.ApplyResources(this, "$this"); resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnClose; this.CancelButton = this.btnClose;
this.Controls.Add(this.txtReport); this.Controls.Add(this.txtReport);
this.Controls.Add(this.btnClose); this.Controls.Add(this.btnClose);
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
this.Name = "frmReport"; this.Name = "frmReport";
this.ShowInTaskbar = false; this.ShowInTaskbar = false;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
} }

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; using System.Windows.Forms;
namespace JDP namespace JDP
{ {
public partial class frmReport : Form public partial class frmReport : Form
{ {
public string Message
{
get { return txtReport.Text; }
set { txtReport.Text = value; }
}
public frmReport() public frmReport()
{ {
InitializeComponent(); InitializeComponent();
txtReport.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
}
public string Message {
get { return txtReport.Text; }
set { txtReport.Text = value; }
} }
} }
} }

View File

@@ -148,7 +148,7 @@
<value>1</value> <value>1</value>
</data> </data>
<data name="txtReport.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms"> <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>
<data name="txtReport.Font" type="System.Drawing.Font, System.Drawing"> <data name="txtReport.Font" type="System.Drawing.Font, System.Drawing">
<value>Courier New, 8.25pt</value> <value>Courier New, 8.25pt</value>

View File

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

View File

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