aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2018-02-07 16:09:04 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2018-02-07 16:18:20 +0100
commiteb481b4917140e7930a3bafa2ef01852d5fd105f (patch)
tree4444c91115a4d3dd6ce0544a85193e64baa0c448 /src/GraphicObjects
parentef49ffc63e4f99d0f716b70c600315d41137e506 (diff)
file dialog improvments, window title colors property in window class
Diffstat (limited to 'src/GraphicObjects')
-rw-r--r--src/GraphicObjects/DirectoryView.cs47
-rw-r--r--src/GraphicObjects/FileDialog.cs28
-rw-r--r--src/GraphicObjects/Window.cs30
3 files changed, 94 insertions, 11 deletions
diff --git a/src/GraphicObjects/DirectoryView.cs b/src/GraphicObjects/DirectoryView.cs
index 0aa44267..d530f0cb 100644
--- a/src/GraphicObjects/DirectoryView.cs
+++ b/src/GraphicObjects/DirectoryView.cs
@@ -28,6 +28,8 @@ using System;
using System.Xml.Serialization;
using System.ComponentModel;
using System.IO;
+using System.Collections.Generic;
+using System.Linq;
namespace Crow
{
@@ -46,7 +48,8 @@ namespace Crow
#endregion
string currentDirectory = "/";
- bool showFiles;
+ bool showFiles, showHidden;
+ string fileMask = "*.*";
object _selectedItem;
[XmlIgnore]public object SelectedItem {
@@ -71,6 +74,28 @@ namespace Crow
NotifyValueChanged ("FileSystemEntries", FileSystemEntries);
}
}
+ [XmlAttributeAttribute()][DefaultValue(false)]
+ public virtual bool ShowHidden {
+ get { return showHidden; }
+ set {
+ if (showHidden == value)
+ return;
+ showHidden = value;
+ NotifyValueChanged ("ShowHidden", showHidden);
+ NotifyValueChanged ("FileSystemEntries", FileSystemEntries);
+ }
+ }
+ [XmlAttributeAttribute][DefaultValue("*.*")]
+ public virtual string FileMask {
+ get { return fileMask; }
+ set {
+ if (fileMask == value)
+ return;
+ fileMask = value;
+ NotifyValueChanged ("FileMask", fileMask);
+ NotifyValueChanged ("FileSystemEntries", FileSystemEntries);
+ }
+ }
[XmlAttributeAttribute][DefaultValue("/")]
public virtual string CurrentDirectory {
get { return currentDirectory; }
@@ -83,11 +108,21 @@ namespace Crow
}
}
[XmlIgnore]public FileSystemInfo[] FileSystemEntries {
- get {
- return string.IsNullOrEmpty(CurrentDirectory) ? null :
- showFiles ?
- new DirectoryInfo (CurrentDirectory).GetFileSystemInfos () :
- new DirectoryInfo(CurrentDirectory).GetDirectories();
+ get {
+ try {
+ if (string.IsNullOrEmpty(CurrentDirectory))
+ return null;
+ DirectoryInfo di = new DirectoryInfo(CurrentDirectory);
+ List<FileSystemInfo> fi = new List<FileSystemInfo> (di.GetDirectories());
+ if (showFiles && !string.IsNullOrEmpty(fileMask))
+ fi.AddRange(di.GetFiles(fileMask));
+ return showHidden ?
+ fi.ToArray() :
+ fi.Where(f=>!f.Attributes.HasFlag (FileAttributes.Hidden)).ToArray();
+ } catch (Exception ex) {
+ Console.WriteLine (ex.ToString ());
+ return null;
+ }
}
}
public void onSelectedItemChanged (object sender, SelectionChangeEventArgs e){
diff --git a/src/GraphicObjects/FileDialog.cs b/src/GraphicObjects/FileDialog.cs
index f2fb3b89..a5ba7b20 100644
--- a/src/GraphicObjects/FileDialog.cs
+++ b/src/GraphicObjects/FileDialog.cs
@@ -46,6 +46,7 @@ namespace Crow
#endregion
string searchPattern, curDir, _selectedFile, _selectedDir;
+ bool showHidden, showFiles;
#region events
public event EventHandler OkClicked;
@@ -74,6 +75,26 @@ namespace Crow
}
}
+ [XmlAttributeAttribute()][DefaultValue(false)]
+ public virtual bool ShowHidden {
+ get { return showHidden; }
+ set {
+ if (showHidden == value)
+ return;
+ showHidden = value;
+ NotifyValueChanged ("ShowHidden", showHidden);
+ }
+ }
+ [XmlAttributeAttribute()][DefaultValue(true)]
+ public virtual bool ShowFiles {
+ get { return showFiles; }
+ set {
+ if (showFiles == value)
+ return;
+ showFiles = value;
+ NotifyValueChanged ("ShowFiles", showFiles);
+ }
+ }
[XmlAttributeAttribute]public string SelectedFile {
get { return _selectedFile; }
set {
@@ -119,14 +140,11 @@ namespace Crow
CurrentDirectory = SelectedDirectory;
else {
OkClicked.Raise (this, null);
- unloadDialog ((sender as GraphicObject).CurrentInterface);
+ CurrentInterface.DeleteWidget (this);
}
}
void onCancel(object sender, MouseButtonEventArgs e){
- unloadDialog ((sender as GraphicObject).CurrentInterface);
- }
- void unloadDialog(Interface host){
- host.DeleteWidget (this);
+ CurrentInterface.DeleteWidget (this);
}
}
}
diff --git a/src/GraphicObjects/Window.cs b/src/GraphicObjects/Window.cs
index 5025b3fb..cb9498ff 100644
--- a/src/GraphicObjects/Window.cs
+++ b/src/GraphicObjects/Window.cs
@@ -51,6 +51,8 @@ namespace Crow
bool _movable;
protected bool hoverBorder = false;
bool alwaysOnTop = false;
+ Fill titleBarBackground = Color.UnitedNationsBlue;
+ Fill titleBarForeground = Color.White;
Rectangle savedBounds;
bool _minimized = false;
@@ -91,6 +93,34 @@ namespace Crow
NotifyValueChanged ("Icon", _icon);
}
}
+ /// <summary>
+ /// Background of the title bar if any.
+ /// </summary>
+ [XmlAttributeAttribute][DefaultValue("vgradient|0:Onyx|1:UnitedNationsBlue")]
+ public virtual Fill TitleBarBackground {
+ get { return titleBarBackground; }
+ set {
+ if (titleBarBackground == value)
+ return;
+ titleBarBackground = value;
+ NotifyValueChanged ("TitleBarBackground", titleBarBackground);
+ RegisterForRedraw ();
+ }
+ }
+ /// <summary>
+ /// Foreground of the title bar, usualy used for the window caption color.
+ /// </summary>
+ [XmlAttributeAttribute][DefaultValue("White")]
+ public virtual Fill TitleBarForeground {
+ get { return titleBarForeground; }
+ set {
+ if (titleBarForeground == value)
+ return;
+ titleBarForeground = value;
+ NotifyValueChanged ("TitleBarForeground", titleBarForeground);
+ RegisterForRedraw ();
+ }
+ }
[XmlAttributeAttribute][DefaultValue(true)]
public bool Resizable {
get {