Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
10,091 additions
and
41 deletions.
There are no files selected for viewing
169 changes: 169 additions & 0 deletions
169
Scratch/FileDialogs/FileDialogs/FileDialogs/ACListISF.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace FileDialogs | ||
{ | ||
/// <summary> | ||
/// Custom implementation of the ACListISF. | ||
/// Adds a / to each folder. | ||
/// </summary> | ||
internal class ACListISF : NativeMethods.IEnumString, NativeMethods.IACList | ||
{ | ||
#region Member Fields | ||
|
||
private int m_size; | ||
private int m_current; | ||
private string m_currentPath; | ||
private string m_currentWorkingDirectory; | ||
private bool m_excludeFiles; | ||
|
||
private List<string> m_strings; | ||
|
||
#endregion | ||
|
||
#region IEnumString Members | ||
|
||
int NativeMethods.IEnumString.Next(int celt, string[] rgelt, IntPtr pceltFetched) | ||
{ | ||
int index = 0; | ||
while ((m_current < m_size) && (celt > 0)) | ||
{ | ||
rgelt[index] = m_strings[m_current]; | ||
m_current++; | ||
index++; | ||
celt--; | ||
} | ||
|
||
if (pceltFetched != IntPtr.Zero) | ||
Marshal.WriteInt32(pceltFetched, index); | ||
|
||
if (celt != 0) | ||
return NativeMethods.S_FALSE; | ||
|
||
return NativeMethods.S_OK; | ||
} | ||
|
||
int NativeMethods.IEnumString.Skip(int celt) | ||
{ | ||
m_current += celt; | ||
if (m_current >= m_size) | ||
return NativeMethods.S_FALSE; | ||
|
||
return NativeMethods.S_OK; | ||
} | ||
|
||
void NativeMethods.IEnumString.Reset() | ||
{ | ||
m_current = 0; | ||
|
||
if (m_strings == null) | ||
m_strings = new List<string>(); | ||
|
||
m_strings.Clear(); | ||
m_size = 0; | ||
|
||
if (!string.IsNullOrEmpty(m_currentWorkingDirectory) && | ||
m_currentWorkingDirectory.IndexOfAny(Path.GetInvalidPathChars()) < 0 && | ||
string.IsNullOrEmpty(m_currentPath)) | ||
{ | ||
string[] dirs = Directory.GetDirectories(m_currentWorkingDirectory); | ||
string[] files = Directory.GetFiles(m_currentWorkingDirectory); | ||
|
||
m_size = dirs.Length + files.Length; | ||
for (int i = 0; i < m_size; i++) | ||
{ | ||
if (i < dirs.Length) | ||
m_strings.Add(GetRelativePath(dirs[i]) + @"\"); | ||
else | ||
m_strings.Add(GetRelativePath(files[i - dirs.Length])); | ||
} | ||
} | ||
|
||
m_currentPath = string.Empty; | ||
} | ||
|
||
private string GetRelativePath(string path) | ||
{ | ||
if (!m_currentWorkingDirectory.EndsWith(@"\")) | ||
return path.Replace(m_currentWorkingDirectory + @"\", ""); | ||
|
||
return path.Replace(m_currentWorkingDirectory, ""); | ||
} | ||
|
||
void NativeMethods.IEnumString.Clone(out NativeMethods.IEnumString ppenum) | ||
{ | ||
ACListISF acl = new ACListISF(); | ||
acl.m_current = m_current; | ||
acl.m_currentPath = m_currentPath; | ||
acl.m_currentWorkingDirectory = m_currentWorkingDirectory; | ||
acl.m_excludeFiles = m_excludeFiles; | ||
|
||
ppenum = acl; | ||
} | ||
|
||
#endregion | ||
|
||
#region IACList Members | ||
|
||
int NativeMethods.IACList.Expand(string pszExpand) | ||
{ | ||
m_currentPath = pszExpand; | ||
|
||
bool pathIsRooted = Path.IsPathRooted(m_currentPath); | ||
if (!pathIsRooted) | ||
m_currentPath = Path.Combine(m_currentWorkingDirectory, m_currentPath); | ||
|
||
// TODO: Add support for ..\ in GetRealPath | ||
//if (m_currentPath.Contains("..")) | ||
// m_currentPath = Path.GetFullPath(m_currentPath); | ||
|
||
m_strings.Clear(); | ||
|
||
|
||
string[] dirs = Directory.GetDirectories(m_currentPath); | ||
string[] files = Directory.GetFiles(m_currentPath); | ||
|
||
m_size = dirs.Length + files.Length; | ||
for (int i = 0; i < m_size; i++) | ||
{ | ||
if (i < dirs.Length) | ||
{ | ||
string path = dirs[i]; | ||
if (!pathIsRooted) path = GetRelativePath(path); | ||
m_strings.Add(path + @"\"); | ||
} | ||
else | ||
{ | ||
string path = files[i - dirs.Length]; | ||
if (!pathIsRooted) path = GetRelativePath(path); | ||
m_strings.Add(path); | ||
} | ||
|
||
if (m_excludeFiles && i == dirs.Length - 1) | ||
break; | ||
} | ||
|
||
return NativeMethods.S_OK; | ||
} | ||
|
||
#endregion | ||
|
||
#region Properties | ||
|
||
public string CurrentWorkingDirectory | ||
{ | ||
get { return m_currentWorkingDirectory; } | ||
set { m_currentWorkingDirectory = value; } | ||
} | ||
|
||
public bool ExcludeFiles | ||
{ | ||
get { return m_excludeFiles; } | ||
set { m_excludeFiles = value; } | ||
} | ||
|
||
#endregion | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
Scratch/FileDialogs/FileDialogs/FileDialogs/Design/FileDialogFilterEditorForm.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
Scratch/FileDialogs/FileDialogs/FileDialogs/Design/FileDialogFilterEditorForm.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Data; | ||
using System.Drawing; | ||
using System.Text; | ||
using System.Windows.Forms; | ||
|
||
namespace FileDialogs.Design | ||
{ | ||
public partial class FileDialogFilterEditorForm : Form | ||
{ | ||
public FileDialogFilterEditorForm() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void listView1_SelectedIndexChanged(object sender, EventArgs e) | ||
{ | ||
|
||
} | ||
} | ||
} |
120 changes: 120 additions & 0 deletions
120
Scratch/FileDialogs/FileDialogs/FileDialogs/Design/FileDialogFilterEditorForm.resx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?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> | ||
</root> |
Oops, something went wrong.