This commit is contained in:
chudov
2009-06-26 08:03:22 +00:00
parent e55a3e7e4e
commit eaff4dbc3a
7 changed files with 551 additions and 0 deletions

342
CUEControls/IIconManager.cs Normal file
View File

@@ -0,0 +1,342 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
namespace CUEControls
{
public interface IIconManager
{
#region public properties
/// <summary>
/// Return the image list that contains the icons found to date.
/// </summary>
ImageList ImageList { get; }
#endregion
#region public methods
int GetIconIndex(FileSystemInfo filename, bool open);
/// <summary>
/// Get the icon index associated with a given filename
/// </summary>
/// <param name="filename">the filename of interest</param>
/// <param name="open">if true, the file is "open", most useful for folders</param>
/// <returns>the index into the image list for the icon associated with this file</returns>
int GetIconIndex(ExtraSpecialFolder folder, bool open);
void SetExtensionIcon(string extension, Image icon);
void SetExtensionIcon(string extension, Icon icon);
string GetFolderPath(ExtraSpecialFolder folder);
void SetFolderPath(ExtraSpecialFolder folder, string path);
string GetDisplayName(FileSystemInfo filename);
string GetDisplayName(ExtraSpecialFolder folder);
#endregion
}
// see ShlObj.h
public enum ExtraSpecialFolder
{
// Summary:
// The logical Desktop rather than the physical file system location.
Desktop = 0,
//
// Summary:
// The directory that contains the user's program groups.
Programs = 2,
//
// Summary:
// The "My Documents" folder.
//
// Version 6.0. The virtual folder representing the My Documents
// desktop item. This is equivalent to CSIDL_MYDOCUMENTS.
// Previous to Version 6.0. The file system directory used to
// physically store a user's common repository of documents.
// A typical path is C:\Documents and Settings\username\My Documents.
// This should be distinguished from the virtual My Documents folder
// in the namespace. To access that virtual folder,
// use SHGetFolderLocation, which returns the ITEMIDLIST for the
// virtual location, or refer to the technique described in
// Managing the File System.
MyDocuments = 5,
//
// Summary:
// The directory that serves as a common repository for the user's favorite
// items.
Favorites = 6,
//
// Summary:
// The directory that corresponds to the user's Startup program group.
Startup = 7,
//
// Summary:
// The directory that contains the user's most recently used documents.
Recent = 8,
//
// Summary:
// The directory that contains the Send To menu items.
SendTo = 9,
//
// Summary:
// The directory that contains the Start menu items.
StartMenu = 11,
//
// Summary:
// The "My Music" folder.
MyMusic = 13,
//
// Summary:
// The directory used to physically store file objects on the desktop.
DesktopDirectory = 16,
//
// Summary:
// The "My Computer" folder.
MyComputer = 17,
//
// Summary:
// The directory that serves as a common repository for document templates.
Templates = 21,
//
// Summary:
// The directory that serves as a common repository for application-specific
// data for the current roaming user.
//
// Version 4.71. The file system directory that serves as
// a common repository for application-specific data.
// A typical path is C:\Documents and Settings\username\Application Data.
// This CSIDL is supported by the redistributable Shfolder.dll
// for systems that do not have the Microsoft Internet Explorer 4.0
// integrated Shell installed
ApplicationData = 26,
//
// Summary:
// The directory that serves as a common repository for application-specific
// data that is used by the current, non-roaming user.
//
// Version 5.0. The file system directory that serves as a data
// repository for local (nonroaming) applications. A typical path
// is C:\Documents and Settings\username\Local Settings\Application Data.
LocalApplicationData = 28,
//
// Summary:
// The directory that serves as a common repository for temporary Internet files.
//
// Version 4.72. The file system directory that serves as
// a common repository for temporary Internet files. A typical
// path is C:\Documents and Settings\username\Local Settings\Temporary Internet Files.
InternetCache = 32,
//
// Summary:
// The directory that serves as a common repository for Internet cookies.
//
// The file system directory that serves as a common repository
// for Internet cookies. A typical path is
// C:\Documents and Settings\username\Cookies.
Cookies = 33,
//
// Summary:
// The directory that serves as a common repository for Internet history items.
History = 34,
//
// Summary:
// The directory that serves as a common repository for application-specific
// data that is used by all users.
//
// Version 5.0. The file system directory containing
// application data for all users. A typical path is
// C:\Documents and Settings\All Users\Application Data.
CommonApplicationData = 35,
// Summary:
// The Windows directory.
//
// Version 5.0. The Windows directory or SYSROOT.
// This corresponds to the %windir% or %SYSTEMROOT% environment
// variables. A typical path is C:\Windows.
Windows = 0x0024,
//
// Summary:
// The System directory.
//
// Version 5.0. The Windows System folder. A typical
// path is C:\Windows\System32.
System = 37,
//
// Summary:
// The program files directory.
//
// Version 5.0. The Program Files folder. A typical
// path is C:\Program Files.
ProgramFiles = 38,
//
// Summary:
// The "My Pictures" folder.
//
// Version 5.0. The file system directory that serves as
// a common repository for image files. A typical path is
// C:\Documents and Settings\username\My Documents\My Pictures.
MyPictures = 39,
// User Profile
Profile = 0x0028,
//
// Summary:
// The directory for components that are shared across applications.
//
// Version 5.0. A folder for components that are shared across
// applications. A typical path is C:\Program Files\Common.
// Valid only for Windows NT, Windows 2000, and Windows XP systems.
// Not valid for Windows Millennium Edition (Windows Me).
CommonProgramFiles = 43,
// The file system directory that contains documents
// that are common to all users. A typical paths is
// C:\Documents and Settings\All Users\Documents.
// Valid for Windows NT systems and Microsoft Windows 95 and
// Windows 98 systems with Shfolder.dll installed.
CommonDocuments = 0x002e,
// Version 5.0. The file system directory containing
// administrative tools for all users of the computer.
CommonAdministrativeTools = 0x002f,
// Version 5.0. The file system directory that is used
// to store administrative tools for an individual user.
// The Microsoft Management Console (MMC) will save customized
// consoles to this directory, and it will roam with the user.
AdministrativeTools = 0x0030,
// Music common to all users
CommonMusic = 0x0035
// Version 5.0. Combine this CSIDL with any of the following CSIDLs
// to force the creation of the associated folder.
// CreateFlag = 0x8000
}
public unsafe class MonoIconMgr : IIconManager
{
#region private variables
private ImageList m_image_list;
private IDictionary<int, int> m_index_map;
private IDictionary<string, int> m_extension_map;
#endregion
#region constructor
/// <summary>
/// This creates a new shell icon manager.
/// </summary>
public MonoIconMgr()
{
m_image_list = new ImageList();
m_index_map = new Dictionary<int, int>();
m_extension_map = new Dictionary<string, int>();
m_image_list.ImageSize = new Size(16, 16);
m_image_list.ColorDepth = ColorDepth.Depth32Bit;
m_image_list.Images.Add(Properties.Resources.folder);
}
#endregion
#region public properties
/// <summary>
/// Return the image list that contains the icons found to date.
/// </summary>
public ImageList ImageList
{
get
{
return m_image_list;
}
}
#endregion
#region public methods
/// <summary>
/// Get the icon index associated with a given filename
/// </summary>
/// <param name="filename">the filename of interest</param>
/// <param name="open">if true, the file is "open", most useful for folders</param>
/// <returns>the index into the image list for the icon associated with this file</returns>
public int GetIconIndex(FileSystemInfo filename, bool open)
{
int iIcon;
if (filename is FileInfo && m_extension_map.TryGetValue(filename.Extension.ToLower(), out iIcon))
return iIcon;
//iIcon = MapIcon(System.Drawing.SystemIcons.Application, info.iIcon);
//DestroyIcon(info.hIcon);
return 0;
}
/// <summary>
/// Get the icon index associated with a given filename
/// </summary>
/// <param name="filename">the filename of interest</param>
/// <param name="open">if true, the file is "open", most useful for folders</param>
/// <returns>the index into the image list for the icon associated with this file</returns>
public int GetIconIndex(ExtraSpecialFolder folder, bool open)
{
return 0;
}
#endregion
#region private methods
//private int MapIcon(IntPtr hIcon, int iIcon)
//{
// int index = 0;
// if (!m_index_map.TryGetValue(iIcon, out index))
// {
// m_image_list.Images.Add(Icon.FromHandle(hIcon));
// index = m_image_list.Images.Count - 1;
// m_index_map.Add(iIcon, index);
// }
// return index;
//}
public void SetExtensionIcon(string extension, Image icon)
{
m_image_list.Images.Add(extension, icon);
m_extension_map.Add(extension, m_image_list.Images.Count - 1);
}
public void SetExtensionIcon(string extension, Icon icon)
{
m_image_list.Images.Add(extension, icon);
m_extension_map.Add(extension, m_image_list.Images.Count - 1);
}
public string GetFolderPath(ExtraSpecialFolder folder)
{
switch (folder)
{
case ExtraSpecialFolder.MyComputer:
return "/";
}
return Environment.GetFolderPath((Environment.SpecialFolder)folder);
}
public void SetFolderPath(ExtraSpecialFolder folder, string path)
{
throw new Exception("SetFolderPath not supported");
}
public string GetDisplayName(FileSystemInfo filename)
{
return filename.Name;
}
public string GetDisplayName(ExtraSpecialFolder folder)
{
switch (folder)
{
case ExtraSpecialFolder.MyComputer:
return "/";
}
return Path.GetFileName(Environment.GetFolderPath((Environment.SpecialFolder) folder));
}
#endregion
}
}

View File

@@ -0,0 +1,70 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.1434
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace CUEControls.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CUEControls.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
internal static System.Drawing.Icon folder {
get {
object obj = ResourceManager.GetObject("folder", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
}
}

View File

@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="folder" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\folder.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B

15
CUERipper/app.config Normal file
View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="CUERipper.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<CUERipper.Properties.Settings>
<setting name="MAIN_FREEDB_SITEADDRESS" serializeAs="String">
<value>freedb.org</value>
</setting>
</CUERipper.Properties.Settings>
</userSettings>
</configuration>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB