]> O.S.I.I.S - jp/crow.git/commitdiff
file dialog improvments, window title colors property in window class
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 7 Feb 2018 15:09:04 +0000 (16:09 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 7 Feb 2018 15:18:20 +0000 (16:18 +0100)
13 files changed:
Crow.csproj
Default.style
Templates/CheckBox2.template [new file with mode: 0644]
Templates/FileDialog.template
Templates/MessageBox.template
Templates/ToolWindow.template
Templates/Window.template
Tests/Interfaces/Divers/0.crow
Tests/Interfaces/Unsorted/testFileDialog.crow
src/GraphicObjects/DirectoryView.cs
src/GraphicObjects/FileDialog.cs
src/GraphicObjects/Window.cs
src/StyleReader.cs

index 13cab16df4eda742ff79b83c811e646f8448b105..c45642b5022f6d5e0a1af17834793c13707847be 100644 (file)
     <EmbeddedResource Include="Templates\imgItem.template" />
     <EmbeddedResource Include="Templates\ArrowBut.template" />
     <EmbeddedResource Include="Templates\treeList.template" />
+    <EmbeddedResource Include="Templates\CheckBox2.template" />
   </ItemGroup>
   <ItemGroup>
     <None Include="Crow.dll.config">
index 07689b506bb6e5df88af52147a563f7b3ec3138f..98c10255584089ec4a68d7d1b369ff4afe4cfd3a 100644 (file)
@@ -136,4 +136,14 @@ HSVSpinner {
        Minimum = 0;
        Maximum = 1;
        SmallIncrement = 0.01;
+}
+TxtInFileDialog {
+       Margine = 1;
+       Font = droid, 12;
+}
+CheckBoxAlt {
+       Template= #Crow.Templates.CheckBox2.template;
+       Background = Transparent;
+       Checked={Background=DarkSlateGray;Foreground=LightGray;};
+       Unchecked = {Background=Transparent;Foreground=DimGray;};
 }
\ No newline at end of file
diff --git a/Templates/CheckBox2.template b/Templates/CheckBox2.template
new file mode 100644 (file)
index 0000000..db61dd1
--- /dev/null
@@ -0,0 +1,7 @@
+<Border Foreground="Transparent" MouseEnter="{Foreground=Gray}" MouseLeave="{Foreground=Transparent}">
+       <Label Font="{./Font}" Text="{./Caption}"
+               Margin="1"
+               Background="{./Background}"
+               Foreground="{./Foreground}"
+               TextAlignment="Center"/>
+</Border>
\ No newline at end of file
index 7eba68281edfb80e91ae3af16dd3f08dffca2f0c..62a7dc6d6e228467a7921a4d24f7c9b5df6ef85a 100644 (file)
@@ -4,11 +4,11 @@
                                MouseEnter="./onBorderMouseEnter"
                                MouseLeave="./onBorderMouseLeave">
        <VerticalStack Spacing="0">
-               <HorizontalStack Background="vgradient|0:0.4,0.6,0.0,0.5|1:0.0,0.8,0.8,0.9"
+               <HorizontalStack Background="{./TitleBarBackground}"
                                Name="hs" Margin="2" Spacing="0" Height="Fit">
                        <GraphicObject Width="5"/>
                        <Image Margin="1" Width="12" Height="12" Path="{./Icon}"/>
-                       <Label Width="Stretched" Foreground="White" Margin="1" TextAlignment="Center" Text="{./Caption}" />
+                       <Label Width="Stretched" Foreground="{./TitleBarForeground}" Margin="1" TextAlignment="Center" Text="{./Caption}" />
                        <Border CornerRadius="0" BorderWidth="1" Foreground="Transparent"  Height="12" Width="12"
                                MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}">
                                <Image Focusable="true" Name="Image" Margin="0" Width="Stretched" Height="Stretched" Path="#Crow.Images.Icons.exit2.svg"
                                                <Image Margin="2" Width="14" Height="14"
                                                        Path="#Crow.Icons.level-up.svg"/>
                                        </Button>
-                                       <TextBox Text="{²./CurrentDirectory}"/>
+                                       <TextBox Style="TxtInFileDialog" Text="{²./CurrentDirectory}"/>
                                </HorizontalStack>
-                               <DirectoryView ShowFiles="true" Name="fv" CurrentDirectory="{./CurrentDirectory}" SelectedItemChanged="./onFVSelectedItemChanged"
+                               <DirectoryView ShowHidden="{²../cbShowHidden.IsChecked}" FileMask="{²../txtFileMask.Text}" ShowFiles="{²../cbShowFiles.IsChecked}" Name="fv" CurrentDirectory="{./CurrentDirectory}" SelectedItemChanged="./onFVSelectedItemChanged"
                                                Width="100%" Margin="0" MouseDoubleClick="./onFileSelect">
-                                               <Template>
-                                                       <ListBox ItemTemplate="#Crow.Templates.FileItems.template" Name="fileView" Data="{./FileSystemEntries}"
-                                                               SelectedItemChanged="./onSelectedItemChanged">
-                                                               <Template>
-                                                                       <HorizontalStack>
-                                                                               <Scroller ScrollX="{../scrollbar1.Value}"  Name="scroller1"
-                                                                                       VerticalScrolling="true" HorizontalScrolling="false">
-                                                                                       <VerticalStack Height="Fit" VerticalAlignment="Top"
-                                                                                               Name="ItemsContainer" Margin="0" Spacing="1"/>
-                                                                               </Scroller>
-                                                                               <ScrollBar Name="scrollbar1" Value="{²../scroller1.ScrollY}"
-                                                                                       Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical"
-                                                                                       Width="14" />
-                                                                       </HorizontalStack>
-                                                               </Template>
-                                                       </ListBox>
-                                               </Template>
-                                       </DirectoryView>
-                               <TextBox Text="{./SelectedDirectory}"/>
-                               <TextBox Text="{²./SelectedFile}"/>
+                                       <Template>
+                                               <ListBox ItemTemplate="#Crow.Templates.FileItems.template" Name="fileView" Data="{./FileSystemEntries}"
+                                                       SelectedItemChanged="./onSelectedItemChanged">
+                                                       <Template>
+                                                               <HorizontalStack>
+                                                                       <Scroller ScrollX="{../scrollbar1.Value}"  Name="scroller1"
+                                                                               VerticalScrolling="true" HorizontalScrolling="false">
+                                                                               <VerticalStack Height="Fit" VerticalAlignment="Top"
+                                                                                       Name="ItemsContainer" Margin="0" Spacing="1"/>
+                                                                       </Scroller>
+                                                                       <ScrollBar Name="scrollbar1" Value="{²../scroller1.ScrollY}"
+                                                                               Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical"
+                                                                               Width="14" />
+                                                               </HorizontalStack>
+                                                       </Template>
+                                               </ListBox>
+                                       </Template>
+                               </DirectoryView>
+                               <HorizontalStack Height="Fit">
+                                       <TextBox Style="TxtInFileDialog" Text="{²./SelectedFile}"/>
+                                       <TextBox Style="TxtInFileDialog" Width="50" Name="txtFileMask" Text="{²./SearchPattern}"/>
+                               </HorizontalStack>
+                               <HorizontalStack Margin="5" Fit="true" HorizontalAlignment="Right">
+                                       <CheckBox Style="CheckBoxAlt" Name="cbShowFiles" Caption="Show Files" IsChecked="{²./ShowFiles}"/>
+                                       <CheckBox Style="CheckBoxAlt" Name="cbShowHidden" Caption="Show Hidden" IsChecked="{²./ShowHidden}"/>
+                               </HorizontalStack>
                                <HorizontalStack Fit="true" HorizontalAlignment="Right">
                                        <Button Caption="Ok" MouseClick="./onFileSelect"/>
                                        <Button Caption="Cancel" MouseClick="./onCancel"/>
index b601f43c047c4c9176376bda9705d2e7d92fe154..129e24ca244efcaec17af5d3aad5c63c972a8079 100644 (file)
@@ -4,11 +4,11 @@
                                MouseLeave="./onBorderMouseLeave">
        <VerticalStack Background="{./Background}">
                <Border BorderWidth="0" Foreground="White" Height="Fit" Width="Stretched" MinimumSize="200,0"
-                               Background="vgradient|0:0.4,0.6,0.0,0.5|1:0.0,0.8,0.8,0.9">
+                               Background="{./TitleBarBackground}">
                        <HorizontalStack Name="hs" Margin="2" Spacing="1" Height="Fit" >
                                <GraphicObject Width="5" Height="5"/>
                                <Image Margin="1" Width="12" Height="12" Path="{./Icon}"/>
-                               <Label Width="Stretched" Foreground="White" Margin="1" TextAlignment="Center" Text="{./Caption}" />
+                               <Label Width="Stretched" Foreground="{./TitleBarForeground}" Margin="1" TextAlignment="Center" Text="{./Caption}" />
                                <Border CornerRadius="3" BorderWidth="1" Foreground="Transparent"  Height="12" Width="12"
                                        MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}">
                                        <Image Focusable="true" Name="Image" Path="#Crow.Images.Icons.exit2.svg"
index f021f6ee162de6fa1860adff2173d4694ff542aa..2fcb73093d4a5ea46abb3ad504b87cf755eadbd1 100755 (executable)
@@ -6,11 +6,11 @@
        <VerticalStack Spacing="0">
 <!--           <Border Name="TitleBar" BorderWidth="1" Foreground="White" Width="{./WidthPolicy}" Height="Fit"
                                Background="vgradient|0:0.4,0.6,0.0,0.5|1:0.0,0.8,0.8,0.9">-->
-                       <HorizontalStack Background="vgradient|0:0.4,0.6,0.0,0.5|1:0.0,0.8,0.8,0.9"
+                       <HorizontalStack Background="{./TitleBarBackground}"
                                        Name="hs" Margin="2" Spacing="0" Height="Fit">
                                <GraphicObject Width="5"/>
                                <Image Margin="1" Width="12" Height="12" Path="{./Icon}"/>
-                               <Label Width="Stretched" Foreground="White" Margin="1" TextAlignment="Center" Text="{./Caption}" />
+                               <Label Width="Stretched" Foreground="{./TitleBarForeground}" Margin="1" TextAlignment="Center" Text="{./Caption}" />
                                <Border CornerRadius="6" BorderWidth="1" Foreground="Transparent"  Height="12" Width="12"
                                        MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}">
                                        <Image Focusable="true" Name="Image" Margin="0" Width="Stretched" Height="Stretched" Path="#Crow.Images.Icons.exit2.svg"
index 20b231478f7cd08d3e6d91fd8c8920dac403b271..770d5c2c85df7ded5c97b974e4dc964f66e5e661 100755 (executable)
@@ -6,11 +6,11 @@
        <VerticalStack Spacing="0">
 <!--           <Border Name="TitleBar" BorderWidth="1" Foreground="White" Width="{./WidthPolicy}" Height="Fit"
                                Background="vgradient|0:0.4,0.6,0.0,0.5|1:0.0,0.8,0.8,0.9">-->
-                       <HorizontalStack Background="vgradient|0:0.4,0.6,0.0,0.5|1:0.0,0.8,0.8,0.9"
+                       <HorizontalStack Background="{./TitleBarBackground}"
                                        Name="hs" Margin="2" Spacing="0" Height="Fit">
                                <GraphicObject Width="5"/>
                                <Image Margin="1" Width="12" Height="12" Path="{./Icon}"/>
-                               <Label Width="Stretched" Foreground="White" Margin="2" TextAlignment="Center" Text="{./Caption}" />
+                               <Label Width="Stretched" Foreground="{./TitleBarForeground}" Margin="2" TextAlignment="Center" Text="{./Caption}" />
                                <Border Visible="{./ShowMinimize}" BorderWidth="1" Foreground="Transparent"  Height="12" Width="12"
                                        MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}">
                                        <Image Focusable="true" Path="#Crow.Images.Icons.minimize.svg"
index 330e3bd8e59d910f85f7fc9d51f568b24001335b..d5cf83c686576d19d2a5c369a03271c7f94df7eb 100755 (executable)
                        <Splitter/>-->
                        <ListBox Name="colorList" Data="{TestList}" Margin="5"
                                         ItemTemplate="#Tests.Interfaces.colorItem.crow"
-                                        Template="#Crow.Templates.ScrollingListBox.templat"
+                                        Template="#Crow.Templates.ScrollingListBox.template"
                                         />
                </VerticalStack>
        </HorizontalStack>
index d24b1c99d16b6a9f12e02b27eecdd7938a6f28e6..868baf633ddce042abe9774cf60fc610b32d88cb 100644 (file)
@@ -1,3 +1,3 @@
 <?xml version="1.0"?>
-<FileDialog Caption="Open File" CurrentDirectory="/"/>
+<FileDialog Caption="Open File" CurrentDirectory="/" SearchPattern="*.*"/>
 
index 0aa44267ef16395d48556683f1647eb9c96c814b..d530f0cb91660373a3c24497f3d1882a0d8c3f7c 100644 (file)
@@ -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){
index f2fb3b894031157cdb5e6c8d066d7fa177d02975..a5ba7b20a51cdb79de30f8b59f8acb00f4b2a31e 100644 (file)
@@ -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);
                }
        }
 }
index 5025b3fb22fc5460d2b449dfa3aa4e97cf764803..cb9498ff8c2779760e162968fe05ee8b8fbef1c6 100644 (file)
@@ -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 {
index db12053dc79718ad1789deb21a84e485570f3895..8a79cd4aa05094c4bc3a0992f2a7c475db112506 100644 (file)
@@ -31,6 +31,10 @@ using System.Reflection;
 
 namespace Crow
 {
+       /// <summary>
+       /// Parser for style files.
+       /// </summary>
+       //TODO: style key shared by different class may use only first encouneter class setter, which can cause bug.
        public class StyleReader : StreamReader
        {
                enum readerState { classNames, propertyName, expression }