]> O.S.I.I.S - jp/crow.git/commitdiff
TextBox, Label, simpler SVG icon for file sys viewers (improve speed a lot), divers...
authorjpbruyere <jp.bruyere@hotmail.com>
Fri, 10 Feb 2017 14:54:50 +0000 (15:54 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Fri, 10 Feb 2017 14:54:50 +0000 (15:54 +0100)
17 files changed:
Crow.csproj
Default.style
Icons/file.svg [new file with mode: 0644]
Icons/folder.svg [new file with mode: 0644]
Icons/level-up.svg [new file with mode: 0644]
Templates/Button.template
Templates/DirectoryView.template
Templates/FileDialog.template
Templates/FileDialog2.template [new file with mode: 0644]
src/Command.cs
src/GraphicObjects/FileDialog.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/Label.cs
src/GraphicObjects/MenuItem.cs
src/GraphicObjects/TemplatedGroup.cs
src/GraphicObjects/TextBox.cs

index 98790caee9db16edadff7f227a3008baca5f72ff..f5d90aa42e6ee45b570db3a7743f68c051e965df 100644 (file)
@@ -24,6 +24,8 @@
     <OutputPath>$(SolutionDir)build\$(Configuration)</OutputPath>
     <IntermediateOutputPath>$(SolutionDir)build\obj\$(Configuration)</IntermediateOutputPath>
     <AssemblyOriginatorKeyFile>crow.key</AssemblyOriginatorKeyFile>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
     <EmbeddedResource Include="Icons\exit-symbol.svg" />
     <EmbeddedResource Include="Icons\paste-on-document.svg" />
     <EmbeddedResource Include="Icons\question.svg" />
+    <EmbeddedResource Include="Templates\FileDialog2.template">
+      <LogicalName>Crow.FileDialog2.template</LogicalName>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Icons\folder.svg" />
+    <EmbeddedResource Include="Icons\file.svg" />
+    <EmbeddedResource Include="Icons\level-up.svg" />
   </ItemGroup>
   <ItemGroup>
     <None Include="README.md" />
index 0f4d81e185d064cf5ecbbac45b081d91dca3e6bd..a09c363db2887beabb1608a2b7a00c37da64687f 100644 (file)
@@ -87,6 +87,7 @@ ToolWindow {
        Height = 150;
 }
 FileDialog {
+       Template = #Crow.FileDialog.template;
        Focusable = true;
        MinimumSize=50,50;
        Width = 500;
diff --git a/Icons/file.svg b/Icons/file.svg
new file mode 100644 (file)
index 0000000..b156b0a
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+        width="64px" height="64px" viewBox="0 0 64 64" enable-background="new 0 0 64 64" xml:space="preserve">
+<g>
+       <polygon fill="#ffffff" stroke="#000000" stroke-width="2" stroke-miterlimit="10" points="23,1 55,1 55,63 9,63 9,15      "/>
+       <polyline fill="#ffffff" stroke="#000000" stroke-width="2" stroke-miterlimit="10" points="9,15 23,15 23,1       "/>
+</g>
+</svg>
diff --git a/Icons/folder.svg b/Icons/folder.svg
new file mode 100644 (file)
index 0000000..84caa4f
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
+       <defs>
+               <linearGradient id="0" x1="59.31" y1="-10.513" x2="59.15" y2="-37.783" gradientUnits="userSpaceOnUse" gradientTransform="matrix(4.17478 0 0 4.16765-1066.12 447.73)">
+                       <stop stop-color="#e4c754"/>
+                       <stop offset="1" stop-color="#ffe684"/>
+               </linearGradient>
+               <linearGradient gradientUnits="userSpaceOnUse" y2="354.29" x2="-704.05" y1="647.77" x1="-701.19" id="1">
+                       <stop stop-color="#ffdd5a"/>
+                       <stop offset="1" stop-color="#f4eca5"/>
+               </linearGradient>
+       </defs>
+       <path d="m-880.52 294.78c-4.626 0-8.349 3.718-8.349 8.335v161.41l88.94.193 372.09.807v-121.2c0-4.618-3.724-8.335-8.35-8.335h-265.48c-8.51.751-9.607-.377-13.812-5.981-5.964-7.968-14.969-21.443-20.84-29.21-4.712-6.805-5.477-6.02-13.292-6.02z" transform="matrix(.12614 0 0 .12614 115.04-27.788)" fill="url(#0)" color="#000"/>
+       <rect transform="matrix(.12614 0 0 .12614 115.04-27.788)" y="356.85" x="-890.28" height="295.13" width="463.85" fill="url(#1)" stroke="url(#1)" stroke-width="2.378" rx="9.63"/>
+</svg>
diff --git a/Icons/level-up.svg b/Icons/level-up.svg
new file mode 100644 (file)
index 0000000..86d7c78
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generated by IcoMoon.io -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16">
+<path fill="#FFFFFF" d="M9 0l4 7h-3v9h-7l2-3h2v-6h-3z"></path>
+</svg>
index b1926443a34e74f1d5bac85d4d526dbf3584dbb1..92ddb39cf07c729b61ff496459836b9c3dcb8764 100755 (executable)
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<Border Background="{./Background}" MinimumSize="50,20"
+<Border Background="{./Background}" MinimumSize="50,20" Name="Content"
        Foreground="Transparent" CornerRadius="{../CornerRadius}" BorderWidth="1"
        MouseEnter="{Foreground=vgradient|0:White|0.2:Gray|0.9:Gray|1:Black;caption.Foreground=White}"
        MouseLeave="{Foreground=Transparent;caption.Foreground=LightGray}"
index f7c74a9d5922aba6efb6fbe1bbf056c78483d956..12c8915c83e5b3ba4bc1202f097396fa7231e536 100755 (executable)
@@ -4,7 +4,7 @@
        <ItemTemplate DataType="System.IO.FileInfo">
                <HorizontalStack Focusable="true"  Height="Fit" Width="Stretched" >
                        <Image Margin="2" Width="14" Height="14"
-                               Path="#Crow.Images.Icons.file.svg"/>
+                               Path="#Crow.Icons.file.svg"/>
                        <Label Text="{Name}" Width="Stretched"
                                MouseEnter="{Background=vgradient|0:White|0.05:UnitedNationsBlue|1:Jet}"
                                MouseLeave="{Background=Transparent}"/>
@@ -26,7 +26,7 @@
                                                                SvgSub="{./IsExpanded}"/>
                                                </Container>
                                                <Image Margin="2" Width="14" Height="14"
-                                                       Path="#Crow.Images.Icons.folder.svg"/>
+                                                       Path="#Crow.Icons.folder.svg"/>
                                                <Label Text="{./Caption}"/>
                                        </HorizontalStack>
                                        <Container Name="Content" Visible="false"/>
index 7972b58304b3cc02eae4c8216ec4ebb8f960dfcd..8305dfc93bccae8ca91d9653f55e4f0ec1de8429 100644 (file)
@@ -9,7 +9,7 @@
                        <GraphicObject Width="5"/>
                        <Image Margin="1" Width="12" Height="12" Path="{./Icon}"/>
                        <Label Width="Stretched" Foreground="White" Margin="1" TextAlignment="Center" Text="{./Caption}" />
-                       <Border CornerRadius="6" BorderWidth="1" Foreground="Transparent"  Height="12" Width="12"
+                       <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"
                                         MouseClick="./butQuitPress"/>
                </HorizontalStack>
                <Container Name="Content" MinimumSize="50,50" Background="Onyx">
                        <VerticalStack Margin="1">
-                               <TextBox Text="{²./CurrentDirectory}"/>
-                               <HorizontalStack Spacing="1">
-                                       <DirectoryView ShowFiles="false" Name="dv" CurrentDirectory="{²./CurrentDirectory}"    Width="50%" Margin="0">
-                                               <Template>
-                                                       <TreeView IsRoot="true" Name="treeView" Data="{./FileSystemEntries}"
-                                                                       SelectedItemChanged="./onSelectedItemChanged">
-                                                               <ItemTemplate DataType="System.IO.FileInfo">
-                                                                       <HorizontalStack Focusable="true"  Height="Fit" Width="Stretched" Background="{../Background}" >
-                                                                               <Image Margin="2" Width="14" Height="14"
-                                                                                       Path="#Crow.Images.Icons.file.svg"/>
-                                                                               <Label Text="{Name}" Width="Stretched"
-                                                                                       MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
-                                                                                       MouseLeave="{Background=Transparent}"/>
-                                                                       </HorizontalStack>
-                                                               </ItemTemplate>
-                                                               <ItemTemplate DataType="System.IO.DirectoryInfo" Data="GetDirectories">
-                                                                       <Expandable Caption="{Name}" >
-                                                                               <Template>
-                                                                                       <VerticalStack>
-                                                                                               <HorizontalStack Spacing="1" Height="Fit" MouseDoubleClick="./onClickForExpand"
-                                                                                                               MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
-                                                                                                               MouseLeave="{Background=Transparent}">
-                                                                                                       <Container Margin="1" Width="10" Height="10" Focusable="true" MouseClick="./onClickForExpand"
-                                                                                                               MouseEnter="{Background=LightGray}"
-                                                                                                               MouseLeave="{Background=Transparent}">
-                                                                                                               <Image
-                                                                                                                       Path="{./Image}"
-                                                                                                                       Visible="{./IsExpandable}"
-                                                                                                                       SvgSub="{./IsExpanded}"/>
-                                                                                                       </Container>
-                                                                                                       <Image Margin="2" Width="14" Height="14"
-                                                                                                               Path="#Crow.Images.Icons.folder.svg"/>
-                                                                                                       <Label Text="{./Caption}"/>
-                                                                                               </HorizontalStack>
-                                                                                               <Container Name="Content" Visible="false"/>
-                                                                                       </VerticalStack>
-                                                                               </Template>
-                                                                               <HorizontalStack Height="Fit">
-                                                                                       <GraphicObject Width="12" Height="10"/>
-                                                                                       <TreeView Name="List" Height="Fit"
-                                                                                               Template="#Crow.Templates.treeList.crow" />
-                                                                               </HorizontalStack>
-                                                                       </Expandable>
-                                                               </ItemTemplate>
-                                                       </TreeView>
-                                               </Template>
-                                       </DirectoryView>
-                                       <Splitter/>
-                                       <DirectoryView ShowFiles="true" Name="fv" CurrentDirectory="{../dv.SelectedItem}" SelectedItemChanged="./onSelectedItemChanged" 
-                                               Width="100%" Margin="0">
+                               <HorizontalStack Height="Fit">
+                                       <Button Fit="true" Caption="Up" MouseClick="./goUpDirClick">
+                                               <Image Margin="2" Width="14" Height="14"
+                                                       Path="#Crow.Icons.level-up.svg"/>
+                                       </Button>
+                                       <TextBox Text="{²./CurrentDirectory}"/>
+                               </HorizontalStack>
+                               <DirectoryView ShowFiles="true" Name="fv" CurrentDirectory="{./CurrentDirectory}" SelectedItemChanged="./onFVSelectedItemChanged"
+                                               Width="100%" Margin="0" MouseDoubleClick="./onFileSelect">
                                                <Template>
                                                        <ListBox Name="fileView" Data="{./FileSystemEntries}" SelectedItemChanged="./onSelectedItemChanged">
                                                                <Template>
-                                                                       <Border BorderWidth="1" Margin="0" MinimumSize="10,10">
-                                                                               <VerticalStack>
-                                                                                       <Scroller ScrollX="{../scrollbar1.Value}"  Name="scroller1"
-                                                                                               VerticalScrolling="False" HorizontalScrolling="true">
-                                                                                               <Wrapper Orientation="Horizontal" Width="Fit" HorizontalAlignment="Left"
-                                                                                                       Name="ItemsContainer" Margin="0" Spacing="1"/>
-                                                                                       </Scroller>
-                                                                                       <ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollX}" 
-                                                                                               Maximum="{../scroller1.MaximumScroll}" Orientation="Horizontal" 
-                                                                                               Height="14" />
-                                                                               </VerticalStack>
-                                                                       </Border>
+                                                                       <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>
                                                                <ItemTemplate DataType="System.IO.FileInfo">
-                                                                       <HorizontalStack Focusable="true"  Height="Fit"   >
-                                                                               <Image Margin="2" Width="14" Height="14"
-                                                                                       Path="#Crow.Images.Icons.file.svg"/>
-                                                                               <Label Text="{Name}"
-                                                                                       MouseEnter="{Background=BlueCrayola}"
-                                                                                       MouseLeave="{Background=Transparent}"/>
+                                                                       <HorizontalStack Focusable="true"  Height="Fit">
+                                                                               <Image Margin="2" Width="16" Height="16"
+                                                                                       Path="#Crow.Icons.file.svg"/>
+                                                                                       <Label Text="{Name}" Width="Stretched"
+                                                                                               MouseEnter="{Background=BlueCrayola}"
+                                                                                               MouseLeave="{Background=Transparent}"/>
                                                                        </HorizontalStack>
                                                                </ItemTemplate>
                                                                <ItemTemplate DataType="System.IO.DirectoryInfo">
-                                                                       <HorizontalStack Focusable="true"  Height="Fit" >
-                                                                               <Image Margin="2" Width="14" Height="14"
-                                                                                       Path="#Crow.Images.Icons.folder.svg"/>
-                                                                               <Label Text="{Name}"
-                                                                                       MouseEnter="{Background=BlueCrayola}"
-                                                                                       MouseLeave="{Background=Transparent}"/>
-                                                                       </HorizontalStack>
+                                                                       <Border Foreground="Transparent" Focusable="true" Height="Fit">
+                                                                               <HorizontalStack
+                                                                                               MouseEnter="{Background=BlueCrayola}"
+                                                                                               MouseLeave="{Background=Transparent}">
+                                                                                       <Image Margin="2" Width="16" Height="16"
+                                                                                               Path="#Crow.Icons.folder.svg"/>
+                                                                                       <Label Text="{Name}" Width="Stretched"/>
+                                                                                       <Label Text="{LastAccessTime}" />
+                                                                               </HorizontalStack>
+                                                                       </Border>
                                                                </ItemTemplate>
                                                        </ListBox>
                                                </Template>
                                        </DirectoryView>
-                               </HorizontalStack>
-                               <TextBox Text="{./SelectedFile}"/>
+                               <TextBox Text="{./SelectedDirectory}"/>
+                               <TextBox Text="{²./SelectedFile}"/>
                                <HorizontalStack Fit="true" HorizontalAlignment="Right">
                                        <Button Caption="Ok" MouseClick="./onFileSelect"/>
                                        <Button Caption="Cancel" MouseClick="./onCancel"/>
diff --git a/Templates/FileDialog2.template b/Templates/FileDialog2.template
new file mode 100644 (file)
index 0000000..389e11f
--- /dev/null
@@ -0,0 +1,120 @@
+<?xml version="1.0"?>
+<Border BorderWidth="1" Foreground="White" CornerRadius="{./CornerRadius}"
+                               Background="{./Background}"
+                               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"
+                               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}" />
+                       <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"
+                                        MouseClick="./butQuitPress"/>
+                       </Border>
+                       <GraphicObject Width="5"/>
+               </HorizontalStack>
+               <Container Name="Content" MinimumSize="50,50" Background="Onyx">
+                       <VerticalStack Margin="1">
+                               <HorizontalStack Height="Fit">
+                                       <Button Caption="Up" MouseClick="./goUpDirClick"/>
+                                       <TextBox Text="{²./CurrentDirectory}"/>
+                               </HorizontalStack>
+                               <HorizontalStack Spacing="1">
+                                       <DirectoryView ShowFiles="false" Name="dv" CurrentDirectory="{²./CurrentDirectory}"    Width="50%" Margin="0"
+                                               SelectedItemChanged="./onFVSelectedItemChanged">
+                                               <Template>
+                                                       <TreeView IsRoot="true" Name="treeView" Data="{./FileSystemEntries}"
+                                                                       SelectedItemChanged="./onSelectedItemChanged">
+                                                               <ItemTemplate DataType="System.IO.FileInfo">
+                                                                       <HorizontalStack Focusable="true"  Height="Fit" Width="Stretched" Background="{../Background}" >
+                                                                               <Image Margin="2" Width="14" Height="14"
+                                                                                       Path="#Crow.Icons.file.svg"/>
+                                                                               <Label Text="{Name}" Width="Stretched"
+                                                                                       MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
+                                                                                       MouseLeave="{Background=Transparent}"/>
+                                                                       </HorizontalStack>
+                                                               </ItemTemplate>
+                                                               <ItemTemplate DataType="System.IO.DirectoryInfo" Data="GetDirectories">
+                                                                       <Expandable Caption="{Name}" >
+                                                                               <Template>
+                                                                                       <VerticalStack>
+                                                                                               <HorizontalStack Spacing="1" Height="Fit" MouseDoubleClick="./onClickForExpand"
+                                                                                                               MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
+                                                                                                               MouseLeave="{Background=Transparent}">
+                                                                                                       <Container Margin="1" Width="10" Height="10" Focusable="true" MouseClick="./onClickForExpand"
+                                                                                                               MouseEnter="{Background=LightGray}"
+                                                                                                               MouseLeave="{Background=Transparent}">
+                                                                                                               <Image
+                                                                                                                       Path="{./Image}"
+                                                                                                                       Visible="{./IsExpandable}"
+                                                                                                                       SvgSub="{./IsExpanded}"/>
+                                                                                                       </Container>
+                                                                                                       <Image Margin="2" Width="14" Height="14"
+                                                                                                               Path="#Crow.Icons.folder.svg"/>
+                                                                                                       <Label Text="{./Caption}"/>
+                                                                                               </HorizontalStack>
+                                                                                               <Container Name="Content" Visible="false"/>
+                                                                                       </VerticalStack>
+                                                                               </Template>
+                                                                               <HorizontalStack Height="Fit">
+                                                                                       <GraphicObject Width="12" Height="10"/>
+                                                                                       <TreeView Name="List" Height="Fit"
+                                                                                               Template="#Crow.Templates.treeList.crow" />
+                                                                               </HorizontalStack>
+                                                                       </Expandable>
+                                                               </ItemTemplate>
+                                                       </TreeView>
+                                               </Template>
+                                       </DirectoryView>
+                                       <Splitter/>
+                                       <DirectoryView ShowFiles="true" Name="fv" CurrentDirectory="{./SelectedDirectory}" SelectedItemChanged="./onFVSelectedItemChanged"
+                                               Width="100%" Margin="0" MouseDoubleClick="./onFileSelect">
+                                               <Template>
+                                                       <ListBox Name="fileView" Data="{./FileSystemEntries}" SelectedItemChanged="./onSelectedItemChanged">
+                                                               <Template>
+                                                                       <VerticalStack>
+                                                                               <Scroller ScrollX="{../scrollbar1.Value}"  Name="scroller1"
+                                                                                       VerticalScrolling="False" HorizontalScrolling="true">
+                                                                                       <Wrapper Orientation="Horizontal" Width="Fit" HorizontalAlignment="Left"
+                                                                                               Name="ItemsContainer" Margin="0" Spacing="1"/>
+                                                                               </Scroller>
+                                                                               <ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollX}"
+                                                                                       Maximum="{../scroller1.MaximumScroll}" Orientation="Horizontal"
+                                                                                       Height="14" />
+                                                                       </VerticalStack>
+                                                               </Template>
+                                                               <ItemTemplate DataType="System.IO.FileInfo">
+                                                                       <HorizontalStack Focusable="true"  Height="Fit"   >
+                                                                               <Image Margin="2" Width="14" Height="14"
+                                                                                       Path="#Crow.Icons.file.svg"/>
+                                                                               <Label Text="{Name}"
+                                                                                       MouseEnter="{Background=BlueCrayola}"
+                                                                                       MouseLeave="{Background=Transparent}"/>
+                                                                       </HorizontalStack>
+                                                               </ItemTemplate>
+                                                               <ItemTemplate DataType="System.IO.DirectoryInfo">
+                                                                       <HorizontalStack Focusable="true"  Height="Fit" >
+                                                                               <Image Margin="2" Width="14" Height="14"
+                                                                                       Path="#Crow.Icons.folder.svg"/>
+                                                                               <Label Text="{Name}"
+                                                                                       MouseEnter="{Background=BlueCrayola}"
+                                                                                       MouseLeave="{Background=Transparent}"/>
+                                                                       </HorizontalStack>
+                                                               </ItemTemplate>
+                                                       </ListBox>
+                                               </Template>
+                                       </DirectoryView>
+                               </HorizontalStack>
+                               <TextBox Text="{./SelectedDirectory}"/>
+                               <TextBox Text="{²./SelectedFile}"/>
+                               <HorizontalStack Fit="true" HorizontalAlignment="Right">
+                                       <Button Caption="Ok" MouseClick="./onFileSelect"/>
+                                       <Button Caption="Cancel" MouseClick="./onCancel"/>
+                               </HorizontalStack>
+                       </VerticalStack>
+               </Container>
+       </VerticalStack>
+</Border>
index f7a12465f623bc90664b0bce3d68b93d8f2d1a00..1f744f84e32a3f3b86277e20b1c482e49616792a 100644 (file)
@@ -45,17 +45,17 @@ namespace Crow
 
                string caption;
                Picture icon;
-               bool isEnabled;
+               bool canExecute = true;
 
                #region Public properties
                [XmlAttributeAttribute][DefaultValue(true)]
-               public virtual bool IsEnabled {
-                       get { return isEnabled; }
+               public virtual bool CanExecute {
+                       get { return canExecute; }
                        set {
-                               if (isEnabled == value)
+                               if (canExecute == value)
                                        return;
-                               isEnabled = value;
-                               NotifyValueChanged ("IsEnabled", isEnabled);
+                               canExecute = value;
+                               NotifyValueChanged ("CanExecute", canExecute);
                        }
                }
                [XmlAttributeAttribute][DefaultValue("Unamed Command")]
@@ -82,11 +82,11 @@ namespace Crow
                #endregion
 
                public void Execute(){
-                       if (execute != null)
+                       if (execute != null && CanExecute)
                                execute ();
                }
                internal void raiseAllValuesChanged(){
-                       NotifyValueChanged ("IsEnabled", isEnabled);
+                       NotifyValueChanged ("CanExecute", canExecute);
                        NotifyValueChanged ("Icon", icon);
                        NotifyValueChanged ("Caption", caption);
                }
index 0ee78e130d31318ff10a7d33f8edc5012e9229a7..f1e4b71dc6be36de163ca16f0e330e834acd2da4 100644 (file)
@@ -31,7 +31,7 @@ namespace Crow
 {
        public class FileDialog: Window
        {
-               string searchPattern, curDirectory;
+               string searchPattern, curDir, _selectedFile, _selectedDir;
 
                #region events
                public event EventHandler OkClicked;
@@ -45,17 +45,17 @@ namespace Crow
 
                [XmlAttributeAttribute][DefaultValue("/home")]
                public virtual string CurrentDirectory {
-                       get { return curDirectory; }
+                       get { return curDir; }
                        set {
-                               if (curDirectory == value)
+                               if (curDir == value)
                                        return;
-                               curDirectory = value;
-                               NotifyValueChanged ("CurrentDirectory", curDirectory);
-
+                               curDir = value;
+                               NotifyValueChanged ("CurrentDirectory", curDir);
+                               SelectedDirectory = curDir;
                        }
                }
 
-               [XmlAttributeAttribute()][DefaultValue("*")]
+               [XmlAttributeAttribute][DefaultValue("*")]
                public virtual string SearchPattern {
                        get { return searchPattern; }
                        set {
@@ -66,11 +66,8 @@ namespace Crow
 
                        }
                }
-               string _selectedFile;
-               [XmlIgnore]public string SelectedFile {
-                       get {
-                               return _selectedFile;
-                       }
+               [XmlAttributeAttribute]public string SelectedFile {
+                       get { return _selectedFile; }
                        set {
                                if (value == _selectedFile)
                                        return;
@@ -78,19 +75,44 @@ namespace Crow
                                NotifyValueChanged ("SelectedFile", _selectedFile);
                        }
                }
-               public void onSelectedItemChanged (object sender, SelectionChangeEventArgs e){
+               [XmlAttributeAttribute]public string SelectedDirectory {
+                       get { return _selectedDir; }
+                       set {
+                               if (value == _selectedDir)
+                                       return;
+                               _selectedDir = value;
+                               NotifyValueChanged ("SelectedDirectory", _selectedDir);
+                       }
+               }
 
-                       string tmp = "";
+               public void onFVSelectedItemChanged (object sender, SelectionChangeEventArgs e){
+                       if (e.NewValue != null) {
+                               if (File.GetAttributes (e.NewValue.ToString ()).HasFlag (FileAttributes.Directory)) {
+                                       SelectedDirectory = e.NewValue.ToString ();
+                                       SelectedFile = "";
+                               } else {
+                                       SelectedDirectory = Path.GetDirectoryName (e.NewValue.ToString ());
+                                       SelectedFile = Path.GetFileName (e.NewValue.ToString ());
+                               }
+                       }
+               }
+               public void onDVSelectedItemChanged (object sender, SelectionChangeEventArgs e){
                        if (e.NewValue != null)
-                               tmp = e.NewValue.ToString();
-                       if (tmp == SelectedFile)
+                               SelectedDirectory = e.NewValue.ToString();
+               }
+               public void goUpDirClick (object sender, MouseButtonEventArgs e){
+                       string root = Directory.GetDirectoryRoot(CurrentDirectory);
+                       if (CurrentDirectory == root)
                                return;
-                       SelectedFile = tmp;
-                       //SelectedItemChanged.Raise (this, e);
+                       CurrentDirectory = Directory.GetParent(CurrentDirectory).FullName;
                }
                void onFileSelect(object sender, MouseButtonEventArgs e){
-                       OkClicked.Raise (this, null);
-                       unloadDialog ((sender as GraphicObject).CurrentInterface);
+                       if (string.IsNullOrEmpty (SelectedFile))
+                               CurrentDirectory = SelectedDirectory;
+                       else {
+                               OkClicked.Raise (this, null);
+                               unloadDialog ((sender as GraphicObject).CurrentInterface);
+                       }
                }
                void onCancel(object sender, MouseButtonEventArgs e){
                        unloadDialog ((sender as GraphicObject).CurrentInterface);
index e468cce923e012fcc41186481c4f6696c33a9e8d..7aac41d7eadd1ecfc44ae923f7e513519817c21e 100644 (file)
@@ -1169,16 +1169,20 @@ namespace Crow
                #region Mouse handling
                public virtual bool MouseIsIn(Point m)
                {
-                       if (!(Visible & isEnabled))
-                               return false;
-                       if (ScreenCoordinates (Slot).ContainsOrIsEqual (m)) {
-                               Scroller scr = Parent as Scroller;
-                               if (scr == null) {
-                                       if (Parent is GraphicObject)
-                                               return (Parent as GraphicObject).MouseIsIn (m);
-                                       else return true;
+                       try {
+                               if (!(Visible & isEnabled))
+                                       return false;
+                               if (ScreenCoordinates (Slot).ContainsOrIsEqual (m)) {
+                                       Scroller scr = Parent as Scroller;
+                                       if (scr == null) {
+                                               if (Parent is GraphicObject)
+                                                       return (Parent as GraphicObject).MouseIsIn (m);
+                                               else return true;
+                                       }
+                                       return scr.MouseIsIn (scr.savedMousePos);
                                }
-                               return scr.MouseIsIn (scr.savedMousePos);
+                       } catch (Exception ex) {
+                               return false;
                        }
                        return false;
                }
index 0defeabd174ed4b90acdbb03d9c960967026dd4f..6e470b9538310f31a7fa67883594e9a6aecfb4ee 100644 (file)
@@ -38,8 +38,8 @@ namespace Crow
         }
                public virtual void AddChild(GraphicObject g){
                        lock (children) {
-                               Children.Add (g);
                                g.Parent = this;
+                               Children.Add (g);
                        }
                        g.RegisteredLayoutings = LayoutingType.None;
                        g.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
index 071dc79f1f6d9b70b02ba0d15fa13638b32f9d6b..7a355f2d1d2e3ed09ba660163b451d153ecae7ca 100644 (file)
@@ -44,6 +44,13 @@ namespace Crow
                }
                #endregion
 
+               public event EventHandler<TextChangeEventArgs> TextChanged;
+
+               public virtual void OnTextChanged(Object sender, TextChangeEventArgs e)
+               {
+                       NotifyValueChanged ("Text", Text);
+                       TextChanged.Raise (this, e);
+               }
         //TODO:change protected to private
 
                #region private and protected fields
@@ -147,7 +154,7 @@ namespace Crow
 
                                lines = getLines;
 
-                               NotifyValueChanged ("Text", _text);
+                               OnTextChanged (this, new TextChangeEventArgs (Text));
                                RegisterForGraphicUpdate ();
             }
         }
@@ -363,7 +370,8 @@ namespace Crow
                                        CurrentColumn = lines [CurrentLine].Length;
                                        lines [CurrentLine] += lines [CurrentLine + 1];
                                        lines.RemoveAt (CurrentLine + 1);
-                                       NotifyValueChanged ("Text", Text);
+
+                                       OnTextChanged (this, new TextChangeEventArgs (Text));
                                        return;
                                }
                                CurrentColumn--;
@@ -386,7 +394,7 @@ namespace Crow
                                SelBegin = -1;
                                SelRelease = -1;
                        }
-                       NotifyValueChanged ("Text", Text);
+                       OnTextChanged (this, new TextChangeEventArgs (Text));
                }
                /// <summary>
                /// Insert new string at caret position, should be sure no line break is inside.
@@ -409,7 +417,7 @@ namespace Crow
                                lines [CurrentLine] = lines [CurrentLine].Insert (CurrentColumn, str);
                                CurrentColumn += str.Length;
                        }
-                       NotifyValueChanged ("Text", Text);
+                       OnTextChanged (this, new TextChangeEventArgs (Text));
                }
                /// <summary>
                /// Insert a line break.
@@ -420,7 +428,7 @@ namespace Crow
                        lines [CurrentLine] = lines [CurrentLine].Substring (0, CurrentColumn);
                        CurrentLine++;
                        CurrentColumn = 0;
-                       NotifyValueChanged ("Text", Text);
+                       OnTextChanged (this, new TextChangeEventArgs (Text));
                }
 
                #region GraphicObject overrides
index b277194e0c19cd6055931c03a0dd4d333699e7a9..e317e0cb5e1c220243a74d7700a5d70c9620813f 100644 (file)
@@ -79,6 +79,11 @@ namespace Crow
                        }
                }
                [XmlAttributeAttribute]
+               public override bool IsEnabled {
+                       get { return Command == null ? base.IsEnabled : Command.CanExecute; }
+                       set { base.IsEnabled = value; }
+               }
+               [XmlAttributeAttribute]
                public override string Caption {
                        get { return Command == null ? base.Caption : Command.Caption; }
                        set { base.Caption = value; }
@@ -124,7 +129,10 @@ namespace Crow
 
                void Command_ValueChanged (object sender, ValueChangeEventArgs e)
                {
-                       NotifyValueChanged (e.MemberName, e.NewValue);
+                       string mName = e.MemberName;
+                       if (mName == "CanExecute")
+                               mName = "IsEnabled";
+                       NotifyValueChanged (mName, e.NewValue);
                }
                void onMI_Click (object sender, MouseButtonEventArgs e)
                {
@@ -141,7 +149,7 @@ namespace Crow
                }
                public override bool MouseIsIn (Point m)
                {
-                       return base.MouseIsIn (m) || child.MouseIsIn (m);
+                       return IsEnabled ? base.MouseIsIn (m) || child.MouseIsIn (m) : false;
                }
                public override void onMouseEnter (object sender, MouseMoveEventArgs e)
                {
index 2e2eef47696a7215cb63a600a3ce0988a53e9245..5a702122340721d300859bd789311081c834037c 100644 (file)
@@ -163,7 +163,6 @@ namespace Crow
                                loadingThread = new CrowThread (this, loading);
                                loadingThread.Finished += (object sender, EventArgs e) => (sender as TemplatedGroup).Loaded.Raise (sender, e);
                                loadingThread.Start ();
-                               //loadPage(1);
 
                                NotifyValueChanged ("SelectedIndex", _selectedIndex);
                                NotifyValueChanged ("SelectedItem", SelectedItem);
index 44690342649fbbe1a7cf0754a44803986d31a550..ab84596bd826ff52d1ddef2634ec8ec00bab83b6 100644 (file)
@@ -58,13 +58,6 @@ namespace Crow
                        FontExtents fe = gr.FontExtents;
                }
                #endregion
-
-               public event EventHandler<TextChangeEventArgs> TextChanged;
-
-               public virtual void OnTextChanged(Object sender, TextChangeEventArgs e)
-               {
-                       TextChanged.Raise (this, e);
-               }
                        
         #region Keyboard handling
                public override void onKeyDown (object sender, KeyboardKeyEventArgs e)