diff --git a/CASA/gui/CASAManager.csproj b/CASA/gui/CASAManager.csproj index 6af1cf2a..6a36278e 100644 --- a/CASA/gui/CASAManager.csproj +++ b/CASA/gui/CASAManager.csproj @@ -190,6 +190,11 @@ SubType = "Code" BuildAction = "Compile" /> + + /// Summary description for FileChooser. + /// + public class FileChooser + { + private string m_currentDirectory = "c:/"; + private string m_hintFile = null; + private string m_sFileSelected = null; + private bool m_bFileChoosing = true; + + private Gtk.TreeStore tsDrives = new TreeStore(typeof(string)); + private Gtk.TreeStore ts = new TreeStore(typeof(string), typeof(string)); + + Thread tChooserThread = null; + Thread tMainThread = null; + + +#region Glade Widgets + + [Glade.Widget] + Gtk.Dialog dialogFileChooser; + + [Glade.Widget] + Gtk.TreeView treeviewFavorites, + treeviewListing; + + [Glade.Widget] + Gtk.Entry entrySelectedFile, + entryCurrentDir; + + [Glade.Widget] + Gtk.Button buttonUP; + + +#endregion + + public FileChooser() + { + // + // TODO: Add constructor logic here + // + + } + + public string GetFile(string sHintDir, string sHintFile) + { + if (sHintDir != null) + { + if (Directory.Exists(sHintDir)) + m_currentDirectory = sHintDir; + } + + if (sHintFile != null) + { + m_hintFile = sHintFile; + } + + + if (true) + { + DoWork(); + } + else + { + //start a FileChooser Thread, and suspend this one until a file is selected or user cancels + tChooserThread = new Thread(new ThreadStart(DoWork)); + tChooserThread.Start(); + + // wait for it to start + while (!tChooserThread.IsAlive); + + // allow filechooser to run + Thread.Sleep(1); + + // wait for FileChooserThread to complete + tChooserThread.Join(); + } + + return m_currentDirectory + m_sFileSelected; + + } + + private void DoWork() + { + + // display chooser + Show(); + + // wait for user + while (m_bFileChoosing) + { + // Flush pending events to keep the GUI reponsive + while (Gtk.Application.EventsPending ()) + Gtk.Application.RunIteration (); + Thread.Sleep(100); + } + } + + public void Show(string sHintDir, string sHintFile) + { + + if (sHintDir != null) + { + if (Directory.Exists(sHintDir)) + m_currentDirectory = sHintDir; + } + + if (sHintFile != null) + { + m_hintFile = sHintFile; + } + + this.Show(); + } + + public void Show() + { + // load and connect handlers + Glade.XML gxmlTemp = new Glade.XML(Common.GladeFile, "dialogFileChooser", null); + gxmlTemp.Autoconnect(this); + + // show logical drives + string[] drives = Directory.GetLogicalDrives(); + for (int i=0; i + + True + Choose File + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER_ON_PARENT + True + 500 + 525 + True + True + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + False + True + + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + False + 0 + + + + True + False + 0 + + + + True + Look in: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 4 + False + False + + + + + + 50 + True + True + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + False + False + False + True + False + False + False + + + + + 8 + True + True + + + + + 0 + True + True + + + + + + True + False + 0 + + + + True + False + 0 + + + + True + True + True + True + 0 + + True + * + False + + + 0 + True + True + + + + + + True + True + GTK_RELIEF_NORMAL + True + + + + + True + gtk-go-up + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 8 + False + False + + + + + 0 + False + False + + + + + + True + True + GTK_POLICY_NEVER + GTK_POLICY_ALWAYS + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + False + False + False + + + + + 6 + True + True + + + + + + True + False + 0 + + + + True + File name: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 5 + False + False + + + + + + True + True + True + True + 0 + + True + * + False + + + 5 + True + True + + + + + 0 + False + True + + + + + 0 + True + True + + + + + 0 + True + True + + + + + +