aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects/FileDialog.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/GraphicObjects/FileDialog.cs')
-rw-r--r--src/GraphicObjects/FileDialog.cs175
1 files changed, 83 insertions, 92 deletions
diff --git a/src/GraphicObjects/FileDialog.cs b/src/GraphicObjects/FileDialog.cs
index 16a60a4f..543b27cc 100644
--- a/src/GraphicObjects/FileDialog.cs
+++ b/src/GraphicObjects/FileDialog.cs
@@ -29,112 +29,103 @@ using System.Text.RegularExpressions;
namespace Crow
{
- public class FileDialog: IValueChange
+ public class FileDialog: Window
{
- #region IValueChange implementation
- public event EventHandler<ValueChangeEventArgs> ValueChanged;
- public virtual void NotifyValueChanged(string MemberName, object _value)
- {
- ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value));
- }
- #endregion
-
- Window window;
- DirectoryInfo currentDir;
- FileInfo selectedFile;
- string searchPattern = "*";
+ string searchPattern, curDirectory;
#region CTOR
- public FileDialog ()
+ public FileDialog () : base()
{
- currentDir = new DirectoryInfo (Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
- //window = Interface..Load("#Crow.Templates.FileDialog.goml") as Window;
- window.DataSource = this;
}
#endregion
-
- public string CurrentPath {
- get { return currentDir.FullName; }
+ //[DefaultValue(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))]
+ [XmlAttributeAttribute][DefaultValue("/home")]
+ public virtual string CurrentDirectory {
+ get { return curDirectory; }
set {
- currentDir = new DirectoryInfo (value);
- NotifyValueChanged ("CurrentPath", CurrentPath);
+ if (curDirectory == value)
+ return;
+ curDirectory = value;
+ NotifyValueChanged ("CurrentDirectory", curDirectory);
+
}
- }
- public string SearchPattern {
+ }
+
+ [XmlAttributeAttribute()][DefaultValue("*")]
+ public virtual string SearchPattern {
get { return searchPattern; }
set {
- searchPattern = value;
- NotifyValueChanged ("Files", Files);
- }
- }
+ if (searchPattern == value)
+ return;
+ searchPattern = value;
+ NotifyValueChanged ("SearchPattern", searchPattern);
- public DirectoryInfo[] Directories
- {
- get {
- //currentDir.GetDirectories
- List<DirectoryInfo> tmp = currentDir.GetDirectories ().Where(fi => !fi.Attributes.HasFlag(FileAttributes.Hidden)).ToList();
- if (currentDir.Parent != null)
- tmp.Insert (0, currentDir.Parent);
- return tmp.ToArray ();
}
- }
- public FileInfo[] Files
- {
- get {
- string[] exts = searchPattern.Replace("*","").Split ('|');
- //return currentDir.GetFiles (searchPattern).Where(fi => !fi.Attributes.HasFlag(FileAttributes.Hidden)).ToArray();
- return currentDir.GetFiles().Where(f => exts.Any
- (x => f.Name.EndsWith (x, StringComparison.InvariantCultureIgnoreCase))).ToArray();
- }
- }
-
- public void Show(){
- //.AddWidget(window);
- }
-
- void OnSelectedItemChanged (object sender, SelectionChangeEventArgs e)
- {
- currentDir = e.NewValue as DirectoryInfo;
- NotifyValueChanged ("CurrentPath", CurrentPath);
- NotifyValueChanged ("Directories", Directories);
- NotifyValueChanged ("Files", Files);
-
- }
- void onFileListItemChanged (object sender, SelectionChangeEventArgs e)
- {
- selectedFile = e.NewValue as FileInfo;
- }
- void onFileSelect(object sender, MouseButtonEventArgs e){
- //OpenTKGameWindow.currentWindow.DeleteWidget(window);
- }
- }
- public class DirContainer: IValueChange
- {
- #region IValueChange implementation
- public event EventHandler<ValueChangeEventArgs> ValueChanged;
- public void NotifyValueChanged(string name, object value)
- {
- ValueChanged.Raise (this, new ValueChangeEventArgs (name, value));
- }
- #endregion
+ }
- public DirectoryInfo CurDir;
- public DirContainer(DirectoryInfo _dir){
- CurDir = _dir;
- }
- public string Name {
- get { return CurDir.Name; }
- }
-
- void onDirUp(object sender, MouseButtonEventArgs e)
- {
-
- }
- public void onMouseDown(object sender, MouseButtonEventArgs e)
- {
- Debug.WriteLine (sender.ToString ());
- }
+// public DirectoryInfo[] Directories
+// {
+// get {
+// //currentDir.GetDirectories
+// List<DirectoryInfo> tmp = currentDir.GetDirectories ().Where(fi => !fi.Attributes.HasFlag(FileAttributes.Hidden)).ToList();
+// if (currentDir.Parent != null)
+// tmp.Insert (0, currentDir.Parent);
+// return tmp.ToArray ();
+// }
+// }
+// public FileInfo[] Files
+// {
+// get {
+// string[] exts = searchPattern.Replace("*","").Split ('|');
+// //return currentDir.GetFiles (searchPattern).Where(fi => !fi.Attributes.HasFlag(FileAttributes.Hidden)).ToArray();
+// return currentDir.GetFiles().Where(f => exts.Any
+// (x => f.Name.EndsWith (x, StringComparison.InvariantCultureIgnoreCase))).ToArray();
+// }
+// }
+// void OnSelectedItemChanged (object sender, SelectionChangeEventArgs e)
+// {
+// currentDir = e.NewValue as DirectoryInfo;
+// NotifyValueChanged ("CurrentPath", CurrentPath);
+// NotifyValueChanged ("Directories", Directories);
+// NotifyValueChanged ("Files", Files);
+//
+// }
+// void onFileListItemChanged (object sender, SelectionChangeEventArgs e)
+// {
+// selectedFile = e.NewValue as FileInfo;
+// }
+// void onFileSelect(object sender, MouseButtonEventArgs e){
+// //OpenTKGameWindow.currentWindow.DeleteWidget(window);
+// }
}
+// public class DirContainer: IValueChange
+// {
+// #region IValueChange implementation
+// public event EventHandler<ValueChangeEventArgs> ValueChanged;
+// public void NotifyValueChanged(string name, object value)
+// {
+// ValueChanged.Raise (this, new ValueChangeEventArgs (name, value));
+// }
+// #endregion
+//
+// public DirectoryInfo CurDir;
+// public DirContainer(DirectoryInfo _dir){
+// CurDir = _dir;
+// }
+// public string Name {
+// get { return CurDir.Name; }
+// }
+//
+// void onDirUp(object sender, MouseButtonEventArgs e)
+// {
+//
+// }
+// public void onMouseDown(object sender, MouseButtonEventArgs e)
+// {
+// Debug.WriteLine (sender.ToString ());
+// }
+//
+// }
}