diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2017-01-29 23:26:46 +0100 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2017-01-29 23:26:46 +0100 |
| commit | dc603ff31253879bb8effb6d529f266ff78e9f3e (patch) | |
| tree | e48f38ac22040da95371f661be482389b21e473e | |
| parent | 1a4fe8bd37ed4a3e3324a134df4f90c14b315918 (diff) | |
| parent | 2ec4eeed1d0353c455719aa612a12646ae2d176e (diff) | |
Merge improvements and debug from 'CrowIDE' branch
39 files changed, 662 insertions, 222 deletions
diff --git a/Crow.csproj b/Crow.csproj index 709c7c41..4e5b52ff 100644 --- a/Crow.csproj +++ b/Crow.csproj @@ -153,6 +153,7 @@ <Compile Include="src\IML\EventBinding.cs" /> <Compile Include="src\PerformanceMeasure.cs" /> <Compile Include="src\IML\BindingMember.cs" /> + <Compile Include="src\CrowThread.cs" /> </ItemGroup> <ItemGroup> <Reference Include="System" /> @@ -184,6 +185,7 @@ <Folder Include="src\Input\" /> <Folder Include="src\rsvg\" /> <Folder Include="src\IML\" /> + <Folder Include="Icons\" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="Images\Icons\updown.svg" /> @@ -287,6 +289,18 @@ <EmbeddedResource Include="Templates\ColorPicker.template"> <LogicalName>Crow.ColorPicker.template</LogicalName> </EmbeddedResource> + <EmbeddedResource Include="Templates\ToolWindow.template"> + <LogicalName>Crow.ToolWindow.template</LogicalName> + </EmbeddedResource> + <EmbeddedResource Include="Images\Icons\maximize.svg" /> + <EmbeddedResource Include="Images\Icons\minimize.svg" /> + <EmbeddedResource Include="Images\Icons\normalize.svg" /> + <EmbeddedResource Include="Icons\open-file.svg" /> + <EmbeddedResource Include="Icons\scissors.svg" /> + <EmbeddedResource Include="Icons\copy-file.svg" /> + <EmbeddedResource Include="Icons\exit-symbol.svg" /> + <EmbeddedResource Include="Icons\paste-on-document.svg" /> + <EmbeddedResource Include="Icons\question.svg" /> </ItemGroup> <ItemGroup> <None Include="README.md" /> diff --git a/Default.style b/Default.style index af54c62a..62618b17 100644 --- a/Default.style +++ b/Default.style @@ -22,12 +22,11 @@ Menu { VerticalAlignment = Top; } MenuItem { - Height = Fit; - Width = Fit; + Width = Stretched; Background = Transparent; Foreground = LightGray; - Open = {Background = Mantis;Foreground=Jet;} - Close = {Foreground=LightGray;Background=Transparent;} + MouseEnter = {Background = vgradient|0:UnitedNationsBlue|1:Onyx;Foreground=White;} + MouseLeave = {Foreground=LightGray;Background=Transparent;} } MessageBox { Width=200; @@ -62,6 +61,13 @@ TextBox { } Window { Focusable = true; + MinimumSize=5,5; + Width = 150; + Height = 150; +} +ToolWindow { + Template = #Crow.ToolWindow.template; + Focusable = true; MinimumSize=50,50; Width = 150; Height = 150; diff --git a/Icons/copy-file.svg b/Icons/copy-file.svg new file mode 100644 index 00000000..63c2dd37 --- /dev/null +++ b/Icons/copy-file.svg @@ -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="M13 3h-3l-3-3h-7v13h6v3h10v-10l-3-3zM7 1l2 2h-2v-2zM1 12v-11h5v3h3v8h-8zM15 15h-8v-2h3v-9h2v3h3v8zM13 6v-2l2 2h-2z"></path> +</svg> diff --git a/Icons/exit-symbol.svg b/Icons/exit-symbol.svg new file mode 100644 index 00000000..3fbaa0d2 --- /dev/null +++ b/Icons/exit-symbol.svg @@ -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="M14 6h-1.7c-0.2 0-0.4-0.1-0.6-0.2l-1.3-1.3c-0.2-0.3-0.6-0.5-1.1-0.5h-0.3c1.1 0 2-0.9 2-2s-0.9-2-2-2-2 0.9-2 2c0 0.7 0.4 1.4 1 1.7l-0.2 0.3h-2c-1.1 0-2.3 0.5-3 1.5l-0.6 0.8c-0.4 0.4-0.2 1 0.2 1.3 0.4 0.2 0.9 0.1 1.2-0.3l0.5-0.7c0.3-0.4 0.7-0.6 1.2-0.6h0.8l-0.7 1.6c-0.3 0.6-0.4 1.2-0.4 1.9v2c0 0.3-0.2 0.5-0.5 0.5h-2.5c-0.6 0-1 0.4-1 1s0.4 1 1 1h3.5c0.8 0 1.5-0.7 1.5-1.5v-2.5l3.8 4.5c0.6 0.9 1.7 1.5 2.8 1.5h0.9l-5.4-6.7c-0.3-0.4-0.2-0.8 0-1.3l0.6-1.5 0.7 0.8c0.4 0.4 1 0.7 1.6 0.7h2c0.6 0 1-0.4 1-1s-0.4-1-1-1z"></path> +</svg> diff --git a/Icons/open-file.svg b/Icons/open-file.svg new file mode 100644 index 00000000..d5c6a84d --- /dev/null +++ b/Icons/open-file.svg @@ -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="M 4.0527344 0.24023438 L 4.0527344 2.1777344 L 1.9316406 2.1777344 L 0.93164062 4.1777344 L -0.068359375 4.1777344 L -0.068359375 15.177734 L 13.931641 15.177734 L 15.931641 6.1777344 L 13.759766 6.1777344 L 13.759766 3.4746094 L 10.525391 0.24023438 L 4.0527344 0.24023438 z M 4.8613281 1.0488281 L 9.7148438 1.0488281 L 9.7148438 4.2851562 L 12.951172 4.2851562 L 12.951172 6.1777344 L 4.8613281 6.1777344 L 4.8613281 1.0488281 z M 10.525391 1.0488281 L 12.951172 3.4746094 L 10.525391 3.4746094 L 10.525391 1.0488281 z M 2.53125 3.1777344 L 4.0527344 3.1777344 L 4.0527344 6.1777344 L 2.9316406 6.1777344 L 0.93164062 12.078125 L 0.93164062 5.1777344 L 1.53125 5.1777344 L 2.53125 3.1777344 z M 3.6328125 7.1777344 L 14.832031 7.1777344 L 13.232422 14.177734 L 1.3320312 14.078125 L 3.6328125 7.1777344 z "/> +</svg> diff --git a/Icons/paste-on-document.svg b/Icons/paste-on-document.svg new file mode 100644 index 00000000..b0a705ee --- /dev/null +++ b/Icons/paste-on-document.svg @@ -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="M13 4h-3v-4h-10v14h6v2h10v-9l-3-3zM3 1h4v1h-4v-1zM15 15h-8v-10h5v3h3v7zM13 7v-2l2 2h-2z"></path> +</svg> diff --git a/Icons/question.svg b/Icons/question.svg new file mode 100644 index 00000000..fb8e3d3f --- /dev/null +++ b/Icons/question.svg @@ -0,0 +1,7 @@ +<?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 11h-3c0-3 1.6-4 2.7-4.6 0.4-0.2 0.7-0.4 0.9-0.6 0.5-0.5 0.3-1.2 0.2-1.4-0.3-0.7-1-1.4-2.3-1.4-2.1 0-2.5 1.9-2.5 2.3l-3-0.4c0.2-1.7 1.7-4.9 5.5-4.9 2.3 0 4.3 1.3 5.1 3.2 0.7 1.7 0.4 3.5-0.8 4.7-0.5 0.5-1.1 0.8-1.6 1.1-0.9 0.5-1.2 1-1.2 2z"></path> +<path fill="#FFFFFF" d="M9.5 14c0 1.105-0.895 2-2 2s-2-0.895-2-2c0-1.105 0.895-2 2-2s2 0.895 2 2z"></path> +</svg> diff --git a/Icons/scissors.svg b/Icons/scissors.svg new file mode 100644 index 00000000..4b5a2255 --- /dev/null +++ b/Icons/scissors.svg @@ -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="M16 3.1c0 0-2.1-1.1-3.5-1-0.3 0-0.5 0.1-0.7 0.2l-4.3 3.4-1.8-1.5c0.1-0.3 0.2-0.6 0.3-1 0.1-1.8-1.4-3.4-3.3-3.2-1.2 0.1-2.3 1-2.6 2.2-0.3 1.3 0.2 2.5 1.2 3.2l3.3 2.6-3.3 2.6c-1 0.7-1.5 1.9-1.2 3.2 0.3 1.2 1.4 2 2.6 2.2 1.9 0.2 3.4-1.4 3.2-3.2 0-0.3-0.1-0.7-0.3-1l1.8-1.5 4.3 3.4c0.2 0.1 0.4 0.2 0.7 0.2 1.4 0.1 3.5-1 3.5-1l-5.7-4.9 5.8-4.9zM2.8 4.6c-0.9-0.1-1.6-0.9-1.5-1.8s0.9-1.6 1.8-1.5c0.9 0.1 1.6 0.9 1.5 1.8 0 0.9-0.9 1.6-1.8 1.5zM3.1 14.7c-0.9 0.1-1.7-0.6-1.8-1.5s0.6-1.7 1.5-1.8c0.9-0.1 1.7 0.6 1.8 1.5s-0.6 1.7-1.5 1.8zM12.4 3.2c0 0 0.1 0 0.2 0 0.4 0 0.9 0.1 1.4 0.2l-6.8 5.7-0.9-1.1 6.1-4.8zM14 12.6c-0.5 0.2-1 0.3-1.4 0.2-0.1 0-0.2 0-0.2 0l-4-3.2 1-0.9 4.6 3.9z"></path> +</svg> diff --git a/Images/Icons/exit.svg b/Images/Icons/exit.svg index 3d688cc7..cb8d1c27 100644 --- a/Images/Icons/exit.svg +++ b/Images/Icons/exit.svg @@ -1,62 +1,10 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> - <svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="64" height="64" - viewBox="0 0 64 64.000002" - id="svg2" - version="1.1" - inkscape:version="0.91 r13725" - sodipodi:docname="exit.svg"> - <defs - id="defs4" /> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="2.6992188" - inkscape:cx="-13.949137" - inkscape:cy="63.946457" - inkscape:document-units="px" - inkscape:current-layer="svg2" - showgrid="false" - units="px" - inkscape:window-width="1280" - inkscape:window-height="984" - inkscape:window-x="0" - inkscape:window-y="16" - inkscape:window-maximized="1" /> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - <dc:title></dc:title> - </cc:Work> - </rdf:RDF> - </metadata> - <rect - style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:8.89073467;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1" - id="rect4136" - width="55.122551" - height="55.122551" - x="4.4468598" - y="4.3914709" - ry="8.8907347" /> + viewBox="0 0 64 64"> <path style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#ff0000;stroke-width:9;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 13.884262,15.143117 c 24.231966,13.49131 34.18672,34.186719 34.18672,34.186719" diff --git a/Images/Icons/maximize.svg b/Images/Icons/maximize.svg new file mode 100644 index 00000000..b70604a6 --- /dev/null +++ b/Images/Icons/maximize.svg @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + width="14" + height="14" + viewBox="0 0 14 14"> + <path + style="fill:none;stroke:#ffffff;stroke-width:2" + d="m 2,2 10,0 0,10 -10,0 z"/> +</svg> diff --git a/Images/Icons/minimize.svg b/Images/Icons/minimize.svg new file mode 100644 index 00000000..dc3dcd2e --- /dev/null +++ b/Images/Icons/minimize.svg @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + width="64" + height="64" + viewBox="0 0 14 14"> + <path + style="fill:#ffffff;stroke:none" + d="m 1,6 12,0 0,4 -12,0 z"/> +</svg> diff --git a/Images/Icons/normalize.svg b/Images/Icons/normalize.svg new file mode 100644 index 00000000..b8b44bd5 --- /dev/null +++ b/Images/Icons/normalize.svg @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + width="14" + height="14" + viewBox="0 0 14 14"> +<!-- <rect y="7" x="7" height="40" width="40" + style="opacity:1;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:3;stroke-opacity:1" /> + <rect y="7" x="7" height="10" width="40" + style="opacity:1;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:3;stroke-opacity:1" /> + <rect y="17" x="17" height="40" width="40" + style="opacity:1;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:3;stroke-opacity:1" /> + <rect y="17" x="17" height="10" width="40" + style="opacity:1;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:3;stroke-opacity:1" />--> + <path + style="fill:none;stroke:#ffffff;stroke-width:1" + d="m 1,1 8,0 0,8 -8,0 z"/> + <path + style="fill:none;stroke:#ffffff;stroke-width:1" + d="m 4,4 8,0 0,8 -8,0 z"/> +</svg> diff --git a/Microsoft.Build.cs b/Microsoft.Build.cs new file mode 100644 index 00000000..eadbfe1e --- /dev/null +++ b/Microsoft.Build.cs @@ -0,0 +1,16 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +// +//This source code was auto-generated by MonoXSD +// +namespace Schemas { + +} diff --git a/Templates/ColorPicker.template b/Templates/ColorPicker.template index f8dec90b..cefff59b 100755 --- a/Templates/ColorPicker.template +++ b/Templates/ColorPicker.template @@ -43,4 +43,4 @@ </HorizontalStack> </VerticalStack> </HorizontalStack> -</Border>
\ No newline at end of file +</Border> diff --git a/Templates/DirectoryView.template b/Templates/DirectoryView.template index 55d652a9..f7c74a9d 100755 --- a/Templates/DirectoryView.template +++ b/Templates/DirectoryView.template @@ -6,7 +6,7 @@ <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}" + MouseEnter="{Background=vgradient|0:White|0.05:UnitedNationsBlue|1:Jet}" MouseLeave="{Background=Transparent}"/> </HorizontalStack> </ItemTemplate> @@ -15,7 +15,7 @@ <Template> <VerticalStack> <HorizontalStack Spacing="1" Height="Fit" MouseDoubleClick="./onClickForExpand" - MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}" + MouseEnter="{Background=vgradient|0:White|0.05:UnitedNationsBlue|1:Jet}" MouseLeave="{Background=Transparent}"> <Container Margin="1" Width="10" Height="10" Focusable="true" MouseClick="./onClickForExpand" MouseEnter="{Background=LightGray}" diff --git a/Templates/MenuItem.template b/Templates/MenuItem.template index 2f4400ec..0f93b20c 100644 --- a/Templates/MenuItem.template +++ b/Templates/MenuItem.template @@ -1,7 +1,7 @@ <?xml version="1.0"?> <Popper Font="{./Font}" Caption="{./Caption}" Background="{./Background}" PopDirection="{./PopDirection}" Foreground = "{./Foreground}" CanPop="{./HasChildren}" MouseClick="./onMI_Click" - IsPopped="{²./IsOpened}"> + IsPopped="{²./IsOpened}" PopWidth="{./PopWidth}" PopHeight="{./PopHeight}"> <Template> <Border Name="border1" MouseEnter="{Foreground=vgradient|0:White|0.2:Gray|0.9:Gray|1:Black}" @@ -11,13 +11,13 @@ MinimumSize = "60,0" Foreground="Transparent" Background="{./Background}"> - <Label Text="{./Caption}" - Foreground="{./Foreground}" - Margin="1" HorizontalAlignment="Left" - Font="{./Font}" /> + <Label Text="{./Caption}" + Foreground="{./Foreground}" + Margin="1" HorizontalAlignment="Left" + Font="{./Font}" /> </Border> </Template> - <Border Foreground="DimGray" Fit="true"> - <VerticalStack Name="ItemsContainer" Margin="2" Fit="true" Background="Onyx"/> + <Border Foreground="DimGray" Width="{../PopWidth}" Height="{../PopHeight}" Background="Onyx"> + <VerticalStack Name="ItemsContainer"/> </Border> </Popper> diff --git a/Templates/ToolWindow.template b/Templates/ToolWindow.template new file mode 100755 index 00000000..7325193c --- /dev/null +++ b/Templates/ToolWindow.template @@ -0,0 +1,24 @@ +<?xml version="1.0"?> +<Border BorderWidth="1" Foreground="White" CornerRadius="{./CornerRadius}" + Background="{./Background}" + MouseEnter="./onBorderMouseEnter" + MouseLeave="./onBorderMouseLeave"> + <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" + 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="{./Title}" /> + <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> +<!-- </Border>--> + <Container Name="Content" MinimumSize="50,50" Background="0.5,0.5,0.5,0.5"/> + </VerticalStack> +</Border> diff --git a/Templates/Window.template b/Templates/Window.template index 7325193c..d729021c 100755 --- a/Templates/Window.template +++ b/Templates/Window.template @@ -10,15 +10,30 @@ 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="{./Title}" /> - <Border CornerRadius="6" BorderWidth="1" Foreground="Transparent" Height="12" Width="12" + <Label Width="Stretched" Foreground="White" Margin="2" TextAlignment="Center" Text="{./Title}" /> + <Border Visible="{./ShowMinimize}" 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 Focusable="true" Path="#Crow.Images.Icons.minimize.svg" + MouseClick="./onMinimized"/> + </Border> + <Border Visible="{./ShowNormal}" BorderWidth="1" Foreground="Transparent" Height="12" Width="12" + MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}"> + <Image Focusable="true" Path="#Crow.Images.Icons.normalize.svg" + MouseClick="./onUnmaximized"/> + </Border> + <Border Visible="{./ShowMaximize}" BorderWidth="1" Foreground="Transparent" Height="12" Width="12" + MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}"> + <Image Focusable="true" Path="#Crow.Images.Icons.maximize.svg" + MouseClick="./onMaximized"/> + </Border> + <Border BorderWidth="1" Foreground="Transparent" Height="14" Width="14" + MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}"> + <Image Focusable="true" Path="#Crow.Images.Icons.exit2.svg" MouseClick="./butQuitPress"/> </Border> <GraphicObject Width="5"/> </HorizontalStack> <!-- </Border>--> - <Container Name="Content" MinimumSize="50,50" Background="0.5,0.5,0.5,0.5"/> + <Container Name="Content" MinimumSize="0,0" Background="0.5,0.5,0.5,0.5"/> </VerticalStack> </Border> diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index cbfb960e..9c1e2ba3 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -46,6 +46,7 @@ <Reference Include="glib-sharp"/> <Reference Include="OpenTK"> <HintPath>$(SolutionDir)packages\OpenTK.2.0.0\lib\net20\OpenTK.dll</HintPath> + <Package>opentk</Package> </Reference> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> diff --git a/src/Command.cs b/src/Command.cs index 35a7facc..f7a12465 100644 --- a/src/Command.cs +++ b/src/Command.cs @@ -35,16 +35,20 @@ namespace Crow #endregion #region CTOR - public Command () + public Command (Action _executeAction) { + execute = _executeAction; } #endregion + Action execute; + string caption; + Picture icon; bool isEnabled; - - [XmlAttributeAttribute()][DefaultValue(true)] + #region Public properties + [XmlAttributeAttribute][DefaultValue(true)] public virtual bool IsEnabled { get { return isEnabled; } set { @@ -54,7 +58,7 @@ namespace Crow NotifyValueChanged ("IsEnabled", isEnabled); } } - [XmlAttributeAttribute()][DefaultValue("Unamed Command")] + [XmlAttributeAttribute][DefaultValue("Unamed Command")] public virtual string Caption { get { return caption; } set { @@ -65,5 +69,27 @@ namespace Crow } } + [XmlAttributeAttribute] + public Picture Icon { + get { return icon; } + set { + if (icon == value) + return; + icon = value; + NotifyValueChanged ("Icon", icon); + } + } + #endregion + + public void Execute(){ + if (execute != null) + execute (); + } + internal void raiseAllValuesChanged(){ + NotifyValueChanged ("IsEnabled", isEnabled); + NotifyValueChanged ("Icon", icon); + NotifyValueChanged ("Caption", caption); + } + } } diff --git a/src/CrowThread.cs b/src/CrowThread.cs new file mode 100644 index 00000000..dfdeda00 --- /dev/null +++ b/src/CrowThread.cs @@ -0,0 +1,58 @@ +// +// CrowThread.cs +// +// Author: +// Jean-Philippe Bruyère <jp.bruyere@hotmail.com> +// +// Copyright (c) 2017 jp +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +using System; +using System.Threading; + +namespace Crow +{ + /// <summary> + /// Thread monitored by current interface with Finished event when state==Stopped + /// </summary> + public class CrowThread { + Thread thread; + public event EventHandler Finished; + public GraphicObject Host; + public CrowThread (GraphicObject host, ThreadStart start){ + thread = new Thread (start); + thread.IsBackground = true; + Host = host; + lock (Host.CurrentInterface.CrowThreads) + Host.CurrentInterface.CrowThreads.Add (this); + } + public void CheckState(){ + if (thread.ThreadState != ThreadState.Stopped) + return; + Finished.Raise (Host, null); + lock (Host.CurrentInterface.CrowThreads) + Host.CurrentInterface.CrowThreads.Remove (this); + } + public void Start() { thread.Start();} + public void Cancel(){ + if (thread.IsAlive){ + //cancelLoading = true; + thread.Join (); + //cancelLoading = false; + } + Host.CurrentInterface.CrowThreads.Remove (this); + } + } +} + diff --git a/src/GraphicObjects/Button.cs b/src/GraphicObjects/Button.cs index 1cfbe85c..c73062f0 100644 --- a/src/GraphicObjects/Button.cs +++ b/src/GraphicObjects/Button.cs @@ -26,7 +26,6 @@ namespace Crow public event EventHandler Pressed; public event EventHandler Released; - public event EventHandler Clicked; #region TemplatedContainer overrides public override GraphicObject Content { @@ -34,7 +33,7 @@ namespace Crow return _contentContainer == null ? null : _contentContainer.Child; } set { - if (_contentContainer != null) + if (_contentContainer != null) _contentContainer.SetChild(value); } } @@ -69,24 +68,24 @@ namespace Crow [XmlAttributeAttribute][DefaultValue("Button")] public string Caption { - get { return caption; } + get { return caption; } set { if (caption == value) return; - caption = value; + caption = value; NotifyValueChanged ("Caption", caption); } - } + } [XmlAttributeAttribute][DefaultValue("#Crow.Images.button.svg")] public string Image { - get { return image; } + get { return image; } set { if (image == value) return; - image = value; + image = value; NotifyValueChanged ("Image", image); } - } + } [XmlAttributeAttribute][DefaultValue(false)] public bool IsPressed { diff --git a/src/GraphicObjects/Container.cs b/src/GraphicObjects/Container.cs index 0b6045bb..be6774b5 100644 --- a/src/GraphicObjects/Container.cs +++ b/src/GraphicObjects/Container.cs @@ -50,8 +50,10 @@ namespace Crow if (t == null) { Assembly a = Assembly.GetEntryAssembly (); foreach (Type expT in a.GetExportedTypes ()) { - if (expT.Name == subTree.Name) + if (expT.Name == subTree.Name) { t = expT; + break; + } } } GraphicObject go = (GraphicObject)Activator.CreateInstance(t); diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs index a2d78d88..0636c14e 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -29,6 +29,7 @@ namespace Crow return; _spacing = value; NotifyValueChanged ("Spacing", Spacing); + RegisterForLayouting (LayoutingType.Sizing|LayoutingType.ArrangeChildren); } } [XmlAttributeAttribute()][DefaultValue(Orientation.Horizontal)] diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index e0e6affc..574870f8 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -270,7 +270,6 @@ namespace Crow set { if (horizontalAlignment == value) return; - horizontalAlignment = value; NotifyValueChanged("HorizontalAlignment", horizontalAlignment); RegisterForLayouting (LayoutingType.X); @@ -282,7 +281,6 @@ namespace Crow set { if (left == value) return; - left = value; NotifyValueChanged ("Left", left); this.RegisterForLayouting (LayoutingType.X); @@ -294,7 +292,6 @@ namespace Crow set { if (top == value) return; - top = value; NotifyValueChanged ("Top", top); this.RegisterForLayouting (LayoutingType.Y); @@ -509,10 +506,6 @@ namespace Crow isVisible = value; - //ensure main win doesn't keep hidden childrens ref - if (!isVisible && this.Contains (CurrentInterface.HoverWidget)) - CurrentInterface.HoverWidget = null; - if (isVisible) RegisterForLayouting (LayoutingType.Sizing); else { @@ -524,6 +517,8 @@ namespace Crow LastSlots.Width = LastSlots.Height = 0; } + //trigger a mouse to handle possible hover changes + CurrentInterface.ProcessMouseMove (CurrentInterface.Mouse.X, CurrentInterface.Mouse.Y); NotifyValueChanged ("Visible", isVisible); } @@ -893,6 +888,7 @@ namespace Crow #if DEBUG_LAYOUTING CurrentInterface.currentLQI.Slot = LastSlots; CurrentInterface.currentLQI.NewSlot = Slot; + Debug.WriteLine ("\t\t{0} => {1}",LastSlots,Slot); #endif switch (layoutType) { @@ -1193,7 +1189,7 @@ namespace Crow if (p != null) p.onMouseMove(sender,e); - MouseMove.Raise (sender, e); + MouseMove.Raise (this, e); } public virtual void onMouseDown(object sender, MouseButtonEventArgs e){ if (CurrentInterface.eligibleForDoubleClick == this && CurrentInterface.clickTimer.ElapsedMilliseconds < Interface.DoubleClick) @@ -1202,8 +1198,8 @@ namespace Crow currentInterface.clickTimer.Restart(); CurrentInterface.eligibleForDoubleClick = null; - if (CurrentInterface.activeWidget == null) - CurrentInterface.activeWidget = this; + if (CurrentInterface.ActiveWidget == null) + CurrentInterface.ActiveWidget = this; if (this.Focusable && !Interface.FocusOnHover) { BubblingMouseButtonEventArg be = e as BubblingMouseButtonEventArg; if (be.Focused == null) { diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index a285e282..3c509185 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -337,8 +337,10 @@ namespace Crow if (t == null) { Assembly a = Assembly.GetEntryAssembly (); foreach (Type expT in a.GetExportedTypes ()) { - if (expT.Name == subTree.Name) + if (expT.Name == subTree.Name) { t = expT; + break; + } } } if (t == null) diff --git a/src/GraphicObjects/Image.cs b/src/GraphicObjects/Image.cs index fa036b97..281011ad 100644 --- a/src/GraphicObjects/Image.cs +++ b/src/GraphicObjects/Image.cs @@ -11,66 +11,81 @@ namespace Crow { Picture _pic; string _svgSub; - bool scaled; - [XmlAttributeAttribute()][DefaultValue(true)] + bool scaled, keepProps; + + #region Public properties + [XmlAttributeAttribute][DefaultValue(true)] public virtual bool Scaled { get { return scaled; } set { if (scaled == value) return; - scaled = value; + scaled = value; NotifyValueChanged ("Scaled", scaled); if (_pic == null) return; _pic.Scaled = scaled; RegisterForGraphicUpdate (); } - } - bool keepProps; - [XmlAttributeAttribute()][DefaultValue(true)] + } + [XmlAttributeAttribute][DefaultValue(true)] public virtual bool KeepProportions { get { return keepProps; } set { if (keepProps == value) return; - keepProps = value; + keepProps = value; NotifyValueChanged ("KeepProportions", keepProps); if (_pic == null) return; _pic.KeepProportions = keepProps; RegisterForGraphicUpdate (); } - } - [XmlAttributeAttribute("Path")] + } + [XmlAttributeAttribute] public string Path { - get { return _pic == null ? null : _pic.Path; } - set { + get { return _pic == null ? "" : _pic.Path; } + set { + if (value == Path) + return; try { - if (string.IsNullOrEmpty(value)){ - _pic = null; - return; - } - lock(CurrentInterface.LayoutMutex){ - LoadImage (value); - _pic.Scaled = scaled; - _pic.KeepProportions = keepProps; + if (string.IsNullOrEmpty(value)) + Picture = null; + else { + lock(CurrentInterface.LayoutMutex){ + LoadImage (value); + } } } catch (Exception ex) { Debug.WriteLine (ex.Message); _pic = null; } + NotifyValueChanged ("Path", Path); } } - - [XmlAttributeAttribute()][DefaultValue(null)] + [XmlAttributeAttribute] public string SvgSub { get { return _svgSub; } set { + if (_svgSub == value) + return; _svgSub = value; RegisterForGraphicUpdate (); } } - + [XmlAttributeAttribute] + public Picture Picture { + get { return _pic; } + set { + if (_pic == value) + return; + _pic = value; + NotifyValueChanged ("Picture", _pic); + RegisterForGraphicUpdate (); + } + } + #endregion + #region CTOR public Image () : base() { @@ -80,14 +95,17 @@ namespace Crow #region Image Loading public void LoadImage (string path) { + Picture pic; + if (path.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture)) + pic = new SvgPicture (); + else + pic = new BmpPicture (); - if (path.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture)) - _pic = new SvgPicture (); - else - _pic = new BmpPicture (); + pic.LoadImage (path); + pic.Scaled = scaled; + pic.KeepProportions = keepProps; - _pic.LoadImage (path); - RegisterForGraphicUpdate (); + Picture = pic; } #endregion @@ -95,12 +113,13 @@ namespace Crow protected override int measureRawSize (LayoutingType lt) { if (_pic == null) - _pic = "#Crow.Images.Icons.IconAlerte.svg"; + return 2 * Margin; + //_pic = "#Crow.Images.Icons.IconAlerte.svg"; //TODO:take scalling in account if (lt == LayoutingType.Width) return _pic.Dimensions.Width + 2 * Margin; else - return _pic.Dimensions.Height + 2 * Margin; + return _pic.Dimensions.Height + 2 * Margin; } protected override void onDraw (Context gr) { diff --git a/src/GraphicObjects/Menu.cs b/src/GraphicObjects/Menu.cs index 1a7a3f95..66d23194 100644 --- a/src/GraphicObjects/Menu.cs +++ b/src/GraphicObjects/Menu.cs @@ -31,8 +31,10 @@ namespace Crow #endregion Orientation orientation; + bool autoOpen = false; - [XmlAttributeAttribute()][DefaultValue(Orientation.Horizontal)] + #region Public properties + [XmlAttributeAttribute][DefaultValue(Orientation.Horizontal)] public Orientation Orientation { get { return orientation; } set { @@ -42,12 +44,12 @@ namespace Crow NotifyValueChanged ("Orientation", orientation); } } - bool autoOpen = false; [XmlIgnore]public bool AutomaticOpenning { get { return autoOpen; } set { autoOpen = value; } } + #endregion public override void AddItem (GraphicObject g) { diff --git a/src/GraphicObjects/MenuItem.cs b/src/GraphicObjects/MenuItem.cs index 80b5759d..adec326f 100644 --- a/src/GraphicObjects/MenuItem.cs +++ b/src/GraphicObjects/MenuItem.cs @@ -32,12 +32,14 @@ namespace Crow public event EventHandler Open; public event EventHandler Close; - public event EventHandler Execute; string caption; - Command command;//TODO + Command command; + Picture icon; bool isOpened; + Measure popWidth, popHeight; + #region Public properties [XmlAttributeAttribute][DefaultValue(false)] public bool IsOpened { get { return isOpened; } @@ -54,38 +56,87 @@ namespace Crow onClose (this, null); } } - [XmlAttributeAttribute][DefaultValue(null)] public virtual Command Command { get { return command; } set { if (command == value) return; + + if (command != null) { + command.raiseAllValuesChanged (); + command.ValueChanged -= Command_ValueChanged; + } + command = value; + + if (command != null) { + command.ValueChanged += Command_ValueChanged; + command.raiseAllValuesChanged (); + } + NotifyValueChanged ("Command", command); } } - [XmlAttributeAttribute][DefaultValue("MenuItem")] public string Caption { - get { return caption; } + get { return Command == null ? caption : Command.Caption; } set { if (caption == value) return; caption = value; - NotifyValueChanged ("Caption", caption); + + if (command == null)//raise value changed only if not bound to a command + NotifyValueChanged ("Caption", caption); + } + } + [XmlAttributeAttribute] + public Picture Icon { + get { return Command == null ? icon : Command.Icon;; } + set { + if (icon == value) + return; + icon = value; + if (command == null) + NotifyValueChanged ("Icon", icon); } } - + [XmlAttributeAttribute()][DefaultValue("Fit")] + public virtual Measure PopWidth { + get { return popWidth; } + set { + if (popWidth == value) + return; + popWidth = value; + NotifyValueChanged ("PopWidth", popWidth); + } + } + [XmlAttributeAttribute()][DefaultValue("Fit")] + public virtual Measure PopHeight { + get { return popHeight; } + set { + if (popHeight == value) + return; + popHeight = value; + NotifyValueChanged ("PopHeight", popHeight); + } + } + #endregion + public override void AddItem (GraphicObject g) { base.AddItem (g); g.NotifyValueChanged ("PopDirection", Alignment.Right); } + void Command_ValueChanged (object sender, ValueChangeEventArgs e) + { + NotifyValueChanged (e.MemberName, e.NewValue); + } void onMI_Click (object sender, MouseButtonEventArgs e) { - Execute.Raise (this, null); + if (command != null) + command.Execute (); if(!IsOpened) (LogicalParent as Menu).AutomaticOpenning = false; } diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs index 38621337..8c79ce24 100644 --- a/src/GraphicObjects/Popper.cs +++ b/src/GraphicObjects/Popper.cs @@ -38,6 +38,7 @@ namespace Crow string caption; Alignment popDirection; GraphicObject _content; + Measure popWidth, popHeight; public event EventHandler Pop; public event EventHandler Unpop; @@ -53,6 +54,26 @@ namespace Crow NotifyValueChanged ("Caption", caption); } } + [XmlAttributeAttribute()][DefaultValue("Fit")] + public virtual Measure PopWidth { + get { return popWidth; } + set { + if (popWidth == value) + return; + popWidth = value; + NotifyValueChanged ("PopWidth", popWidth); + } + } + [XmlAttributeAttribute()][DefaultValue("Fit")] + public virtual Measure PopHeight { + get { return popHeight; } + set { + if (popHeight == value) + return; + popHeight = value; + NotifyValueChanged ("PopHeight", popHeight); + } + } [XmlAttributeAttribute()][DefaultValue(false)] public bool IsPopped { @@ -164,18 +185,6 @@ namespace Crow } #region GraphicObject overrides - public override void OnLayoutChanges (LayoutingType layoutType) - { - base.OnLayoutChanges (layoutType); - - if (_content == null) - return; - - if (layoutType == LayoutingType.Width) - _content.MinimumSize = new Size (this.Slot.Width, _content.MinimumSize.Height); - } - - public override void onMouseClick (object sender, MouseButtonEventArgs e) { if (_canPop) @@ -219,16 +228,17 @@ namespace Crow if (Content != null) { Content.Visible = true; if (Content.Parent == null) - CurrentInterface.AddWidget (Content); - CurrentInterface.PutOnTop (Content); + CurrentInterface.AddWidget (Content, true); + CurrentInterface.PutOnTop (Content, true); _content_LayoutChanged (this, new LayoutingEventArgs (LayoutingType.Sizing)); } Pop.Raise (this, e); } public virtual void onUnpop(object sender, EventArgs e) { - if (Content != null) + if (Content != null) { Content.Visible = false; + } Unpop.Raise (this, e); } } diff --git a/src/GraphicObjects/TemplatedContainer.cs b/src/GraphicObjects/TemplatedContainer.cs index 44c2ad08..f4243588 100644 --- a/src/GraphicObjects/TemplatedContainer.cs +++ b/src/GraphicObjects/TemplatedContainer.cs @@ -84,8 +84,10 @@ namespace Crow if (t == null) { Assembly a = Assembly.GetEntryAssembly (); foreach (Type expT in a.GetExportedTypes ()) { - if (expT.Name == xr.Name) + if (expT.Name == xr.Name) { t = expT; + break; + } } } if (t == null) diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs index ba49f44f..4a3a2507 100644 --- a/src/GraphicObjects/TemplatedControl.cs +++ b/src/GraphicObjects/TemplatedControl.cs @@ -154,8 +154,10 @@ namespace Crow if (t == null) { Assembly a = Assembly.GetEntryAssembly (); foreach (Type expT in a.GetExportedTypes ()) { - if (expT.Name == xr.Name) + if (expT.Name == xr.Name) { t = expT; + break; + } } } GraphicObject go = (GraphicObject)Activator.CreateInstance (t); diff --git a/src/GraphicObjects/TemplatedGroup.cs b/src/GraphicObjects/TemplatedGroup.cs index 772b89cf..4c35197f 100644 --- a/src/GraphicObjects/TemplatedGroup.cs +++ b/src/GraphicObjects/TemplatedGroup.cs @@ -40,6 +40,7 @@ namespace Crow #region events public event EventHandler<SelectionChangeEventArgs> SelectedItemChanged; + public event EventHandler Loaded; #endregion IList data; @@ -47,7 +48,7 @@ namespace Crow Color selBackground, selForeground; int itemPerPage = 50; - Thread loadingThread = null; + CrowThread loadingThread = null; volatile bool cancelLoading = false; #region Templating @@ -106,11 +107,11 @@ namespace Crow public virtual List<GraphicObject> Items{ get { return items.Children; }} [XmlAttributeAttribute][DefaultValue(-1)]public int SelectedIndex{ get { return _selectedIndex; } - set { + set { if (value == _selectedIndex) return; - _selectedIndex = value; + _selectedIndex = value; NotifyValueChanged ("SelectedIndex", _selectedIndex); NotifyValueChanged ("SelectedItem", SelectedItem); @@ -135,14 +136,14 @@ namespace Crow NotifyValueChanged ("Data", data); - lock (CurrentInterface.UpdateMutex) + //lock (CurrentInterface.UpdateMutex) ClearItems (); if (data == null) return; - loadingThread = new Thread (loading); - loadingThread.IsBackground = true; + loadingThread = new CrowThread (this, loading); + loadingThread.Finished += (object sender, EventArgs e) => (sender as TemplatedGroup).Loaded.Raise (sender, e); loadingThread.Start (); //loadPage(1); @@ -179,7 +180,7 @@ namespace Crow protected void raiseSelectedItemChanged(){ SelectedItemChanged.Raise (this, new SelectionChangeEventArgs (SelectedItem)); } - + public virtual void AddItem(GraphicObject g){ items.AddChild (g); @@ -271,8 +272,10 @@ namespace Crow if (t == null) { Assembly a = Assembly.GetEntryAssembly (); foreach (Type expT in a.GetExportedTypes ()) { - if (expT.Name == xr.Name) + if (expT.Name == xr.Name) { t = expT; + break; + } } } if (t == null) @@ -310,13 +313,8 @@ namespace Crow } } void cancelLoadingThread(){ - if (loadingThread == null) - return; - if (!loadingThread.IsAlive) - return; - cancelLoading = true; - loadingThread.Join (); - cancelLoading = false; + if (loadingThread != null) + loadingThread.Cancel (); } void loadPage(int pageNum) { @@ -341,7 +339,7 @@ namespace Crow page = gs; }else - page = Activator.CreateInstance (items.GetType ()) as Group; + page = Activator.CreateInstance (items.GetType ()) as Group; page.Name = "page" + pageNum; @@ -374,6 +372,8 @@ namespace Crow } } protected void loadItem(int i, Group page){ + if (data [i] == null)//TODO:surely a threading sync problem + return; GraphicObject g = null; ItemTemplate iTemp = null; Type dataType = data [i].GetType (); @@ -383,9 +383,29 @@ namespace Crow itempKey = getItempKey (dataType, data [i]); if (ItemTemplates.ContainsKey (itempKey)) - iTemp = ItemTemplates [itempKey]; - else - iTemp = ItemTemplates ["default"]; + iTemp = ItemTemplates [itempKey]; + else { + foreach (string it in ItemTemplates.Keys) { + Type t = Type.GetType (it); + if (t == null) { + Assembly a = Assembly.GetEntryAssembly (); + foreach (Type expT in a.GetExportedTypes ()) { + if (expT.Name == it) { + t = expT; + break; + } + } + } + if (t == null) + continue; + if (t.IsAssignableFrom (dataType)) {//TODO:types could be cached + iTemp = ItemTemplates [it]; + break; + } + } + if (iTemp == null) + iTemp = ItemTemplates ["default"]; + } lock (CurrentInterface.LayoutMutex) { g = iTemp.CreateInstance(CurrentInterface); diff --git a/src/GraphicObjects/TreeView.cs b/src/GraphicObjects/TreeView.cs index 4fa881b4..d4354b65 100644 --- a/src/GraphicObjects/TreeView.cs +++ b/src/GraphicObjects/TreeView.cs @@ -48,7 +48,6 @@ namespace Crow NotifyValueChanged ("IsRoot", isRoot); } } - [XmlIgnore]public override object SelectedItem { get { return selectedItemContainer == null ? @@ -84,6 +83,32 @@ namespace Crow NotifyValueChanged ("SelectedItem", SelectedItem); raiseSelectedItemChanged (); } + + void onExpandAll_MouseClick (object sender, MouseButtonEventArgs e) + { + ExpandAll (); + } + + public void ExpandAll(){ + foreach (Group grp in items.Children) { + foreach (GraphicObject go in grp.Children) { + Expandable exp = go as Expandable; + if (exp == null) + continue; + TreeView subTV = exp.FindByName ("List") as TreeView; + if (subTV == null) + continue; + EventHandler handler = null; + handler = delegate(object sender, EventArgs e) { + TreeView tv = sender as TreeView; + tv.Loaded -= handler; + tv.ExpandAll (); + }; + subTV.Loaded += handler; + exp.IsExpanded = true; + } + } + } } } diff --git a/src/GraphicObjects/Window.cs b/src/GraphicObjects/Window.cs index 86f05d86..9c1a0124 100644 --- a/src/GraphicObjects/Window.cs +++ b/src/GraphicObjects/Window.cs @@ -46,15 +46,20 @@ namespace Crow bool _resizable; bool _movable; bool hoverBorder = false; - bool isMaximized = false; - Measure savedH, savedW; + bool alwaysOnTop = false; + + Rectangle savedBounds; + bool _minimized = false; Container _contentContainer; Direction currentDirection = Direction.None; + #region Events public event EventHandler Closing; public event EventHandler Maximized; public event EventHandler Unmaximized; + public event EventHandler Minimize; + #endregion #region CTOR public Window () : base() { @@ -64,73 +69,115 @@ namespace Crow #region TemplatedContainer overrides public override GraphicObject Content { - get { - return _contentContainer == null ? null : _contentContainer.Child; - } - set { - _contentContainer.SetChild(value); - } + get { return _contentContainer == null ? null : _contentContainer.Child; } + set { _contentContainer.SetChild(value); } } protected override void loadTemplate(GraphicObject template = null) { base.loadTemplate (template); _contentContainer = this.child.FindByName ("Content") as Container; + + NotifyValueChanged ("ShowNormal", false); + NotifyValueChanged ("ShowMinimize", true); + NotifyValueChanged ("ShowMaximize", true); } #endregion #region public properties - [XmlAttributeAttribute()][DefaultValue("Window")] + [XmlAttributeAttribute][DefaultValue("Window")] public string Title { get { return _title; } set { + if (_title == value) + return; _title = value; NotifyValueChanged ("Title", _title); } } - [XmlAttributeAttribute()][DefaultValue("#Crow.Images.Icons.crow.png")] + [XmlAttributeAttribute][DefaultValue("#Crow.Images.Icons.crow.png")] public string Icon { get { return _icon; } set { + if (_icon == value) + return; _icon = value; NotifyValueChanged ("Icon", _icon); } } - [XmlAttributeAttribute()][DefaultValue(true)] + [XmlAttributeAttribute][DefaultValue(true)] public bool Resizable { get { return _resizable; } set { + if (_resizable == value) + return; _resizable = value; NotifyValueChanged ("Resizable", _resizable); } } - [XmlAttributeAttribute()][DefaultValue(true)] + [XmlAttributeAttribute][DefaultValue(true)] public bool Movable { get { return _movable; } set { + if (_movable == value) + return; _movable = value; NotifyValueChanged ("Movable", _movable); } } - [XmlAttributeAttribute()][DefaultValue(false)] - public bool IsMaximized { - get { return isMaximized; } + [XmlAttributeAttribute][DefaultValue(false)] + public bool IsMinimized { + get { return _minimized; } set{ - if (value == isMaximized) + if (value == IsMinimized) return; - isMaximized = value; - if (isMaximized) - onMaximized (this, null); - else - onUnmaximized (this, null); + _minimized = value; + _contentContainer.Visible = !_minimized; - NotifyValueChanged ("IsMaximized", isMaximized); + NotifyValueChanged ("IsMinimized", _minimized); + } + } + [XmlIgnore]public bool IsMaximized { + get { return Width == Measure.Stretched & Height == Measure.Stretched & !_minimized; } + } + [XmlIgnore]public bool IsNormal { + get { return !(IsMaximized|_minimized); } + } + [XmlAttributeAttribute][DefaultValue(false)] + public bool AlwaysOnTop { + get { + return alwaysOnTop; + } + set { + if (alwaysOnTop == value) + return; + alwaysOnTop = value; + if (alwaysOnTop) { + CurrentInterface.PutOnTop (this); + CurrentInterface.TopWindows++; + }else + CurrentInterface.TopWindows--; + NotifyValueChanged ("AlwaysOnTop", alwaysOnTop); } } +// [XmlAttributeAttribute()][DefaultValue(WindowState.Normal)] +// public virtual WindowState State { +// get { return _state; } +// set { +// if (_state == value) +// return; +// _state = value; +// NotifyValueChanged ("State", _state); +// NotifyValueChanged ("IsNormal", IsNormal); +// NotifyValueChanged ("IsMaximized", IsMaximized); +// NotifyValueChanged ("IsMinimized", IsMinimized); +// NotifyValueChanged ("IsNotMinimized", IsNotMinimized); +// } +// } #endregion #region GraphicObject Overrides @@ -219,14 +266,6 @@ namespace Crow return; } } -// GraphicObject firstFocusableAncestor = otkgw.hoverWidget; -// while (firstFocusableAncestor != this) { -// if (firstFocusableAncestor == null) -// return; -// if (firstFocusableAncestor.Focusable) -// return; -// firstFocusableAncestor = firstFocusableAncestor.Parent as GraphicObject; -// } if (Resizable) { Direction lastDir = currentDirection; @@ -289,21 +328,56 @@ namespace Crow base.onMouseDown (sender, e); } #endregion + protected void onMaximized (object sender, EventArgs e){ - savedW = this.Width; - savedH = this.Height; - this.Width = Measure.Stretched; - this.Height = Measure.Stretched; + lock (CurrentInterface.LayoutMutex) { + if (!IsMinimized) + savedBounds = this.LastPaintedSlot; + this.Left = this.Top = 0; + this.RegisterForLayouting (LayoutingType.Positioning); + this.Width = this.Height = Measure.Stretched; + IsMinimized = false; + Resizable = false; + NotifyValueChanged ("ShowNormal", true); + NotifyValueChanged ("ShowMinimize", true); + NotifyValueChanged ("ShowMaximize", false); + } Maximized.Raise (sender, e); + + + } protected void onUnmaximized (object sender, EventArgs e){ - this.Width = savedW; - this.Height = savedH; + lock (CurrentInterface.LayoutMutex) { + this.Left = savedBounds.Left; + this.Top = savedBounds.Top; + this.Width = savedBounds.Width; + this.Height = savedBounds.Height; + IsMinimized = false; + Resizable = true; + NotifyValueChanged ("ShowNormal", false); + NotifyValueChanged ("ShowMinimize", true); + NotifyValueChanged ("ShowMaximize", true); + } Unmaximized.Raise (sender, e); } + protected void onMinimized (object sender, EventArgs e){ + lock (CurrentInterface.LayoutMutex) { + if (IsNormal) + savedBounds = this.LastPaintedSlot; + Width = 200; + Height = 20; + Resizable = false; + IsMinimized = true; + NotifyValueChanged ("ShowNormal", true); + NotifyValueChanged ("ShowMinimize", false); + NotifyValueChanged ("ShowMaximize", true); + } + Minimize.Raise (sender, e); + } protected void onBorderMouseLeave (object sender, MouseMoveEventArgs e) { hoverBorder = false; @@ -316,9 +390,6 @@ namespace Crow } - protected void butMaximizePress (object sender, MouseButtonEventArgs e){ - IsMaximized = !IsMaximized; - } protected void butQuitPress (object sender, MouseButtonEventArgs e) { CurrentInterface.MouseCursor = XCursor.Default; diff --git a/src/Instantiator.cs b/src/Instantiator.cs index 6e94ae17..e738a741 100644 --- a/src/Instantiator.cs +++ b/src/Instantiator.cs @@ -139,10 +139,14 @@ namespace Crow if (t == null) { Assembly a = Assembly.GetEntryAssembly (); foreach (Type expT in a.GetExportedTypes ()) { - if (expT.Name == root) + if (expT.Name == root) { t = expT; + break; + } } } + if (t == null) + throw new Exception ("IML parsing error: undefined root type (" + root + ")"); return t; } void emitLoader (XmlTextReader reader, Context ctx) @@ -324,8 +328,10 @@ namespace Crow if (t == null) { Assembly a = Assembly.GetEntryAssembly (); foreach (Type expT in a.GetExportedTypes ()) { - if (expT.Name == reader.Name) + if (expT.Name == reader.Name) { t = expT; + break; + } } } if (t == null) diff --git a/src/Interface.cs b/src/Interface.cs index 89ee1b7e..565e6ab4 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -140,6 +140,9 @@ namespace Crow /// on the first instance creation of a IML item. /// </summary> public static Dictionary<String, Instantiator> Instantiators = new Dictionary<string, Instantiator>(); + public bool DesignMode = false; + public int TopWindows = 0;//window always on top count + public List<CrowThread> CrowThreads = new List<CrowThread>();//used to monitor thread finished #endregion #region Private Fields @@ -300,7 +303,7 @@ namespace Crow /// <summary>Widget is focused and button is down or another perif action is occuring /// , it can not lose focus while Active</summary> - public GraphicObject activeWidget + public GraphicObject ActiveWidget { get { return _activeWidget; } set @@ -392,6 +395,13 @@ namespace Crow _focusedWidget.onKeyDown (this, lastKeyDownEvt); } } + CrowThread[] tmpThreads; + lock (CrowThreads) { + tmpThreads = new CrowThread[CrowThreads.Count]; + Array.Copy (CrowThreads.ToArray (), tmpThreads, CrowThreads.Count); + } + for (int i = 0; i < tmpThreads.Length; i++) + tmpThreads [i].CheckState (); if (!Monitor.TryEnter (UpdateMutex)) return; @@ -533,10 +543,16 @@ namespace Crow #region GraphicTree handling /// <summary>Add widget to the Graphic tree of this interface and register it for layouting</summary> - public void AddWidget(GraphicObject g) + public void AddWidget(GraphicObject g, bool topMost = false) { g.Parent = this; - GraphicTree.Insert (0, g); + int ptr = TopWindows; + if (g is Window) { + if ((g as Window).AlwaysOnTop) + ptr = 0; + } else if (topMost) + ptr = 0; + GraphicTree.Insert (ptr, g); g.RegisteredLayoutings = LayoutingType.None; g.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren); } @@ -547,12 +563,18 @@ namespace Crow GraphicTree.Remove (g); } /// <summary> Put widget on top of other root widgets</summary> - public void PutOnTop(GraphicObject g) + public void PutOnTop(GraphicObject g, bool topMost = false) { - if (GraphicTree.IndexOf(g) > 0) + int ptr = TopWindows; + if (g is Window) { + if ((g as Window).AlwaysOnTop) + ptr = 0; + } else if (topMost) + ptr = 0; + if (GraphicTree.IndexOf(g) > ptr) { GraphicTree.Remove(g); - GraphicTree.Insert(0, g); + GraphicTree.Insert(ptr, g); EnqueueForRepaint (g); } } @@ -627,10 +649,10 @@ namespace Crow MouseMoveEventArgs e = new MouseMoveEventArgs (x, y, deltaX, deltaY); e.Mouse = Mouse; - if (_activeWidget != null) { + if (ActiveWidget != null) { //TODO, ensure object is still in the graphic tree //send move evt even if mouse move outside bounds - _activeWidget.onMouseMove (this, e); + ActiveWidget.onMouseMove (this, e); return true; } @@ -710,7 +732,7 @@ namespace Crow } _activeWidget.onMouseUp (_activeWidget, e); - activeWidget = null; + ActiveWidget = null; return true; } public bool ProcessMouseButtonDown(int button) diff --git a/src/ItemTemplate.cs b/src/ItemTemplate.cs index 1f03f7f8..34085d2b 100644 --- a/src/ItemTemplate.cs +++ b/src/ItemTemplate.cs @@ -56,6 +56,19 @@ namespace Crow public void CreateExpandDelegate (TemplatedGroup host){ Type dataType = Type.GetType(strDataType); + if (dataType == null) { + Assembly a = Assembly.GetEntryAssembly (); + foreach (Type expT in a.GetExportedTypes ()) { + if (expT.Name == strDataType) { + dataType = expT; + break; + } + } + } + if (dataType == null) { + Debug.WriteLine ("ItemTemplate error: DataType not found: {0}.", strDataType); + return; + } Type tmpGrpType = typeof(TemplatedGroup); Type evtType = typeof(EventHandler); diff --git a/src/LayoutingQueueItem.cs b/src/LayoutingQueueItem.cs index 95bc6bb7..c7ae3024 100644 --- a/src/LayoutingQueueItem.cs +++ b/src/LayoutingQueueItem.cs @@ -83,6 +83,7 @@ namespace Crow LQITime = new Stopwatch(); Slot = Rectangle.Empty; NewSlot = Rectangle.Empty; + Debug.WriteLine ("\tRegister => " + this.ToString ()); #endif } #endregion @@ -100,13 +101,20 @@ namespace Crow } #if DEBUG_LAYOUTING LQITime.Start(); + Debug.WriteLine ("=> " + this.ToString ()); #endif LayoutingTries++; if (!Layoutable.UpdateLayout (LayoutType)) { + #if DEBUG_LAYOUTING + Debug.WriteLine ("\t\tRequeued"); + #endif if (LayoutingTries < Interface.MaxLayoutingTries) { Layoutable.RegisteredLayoutings |= LayoutType; (Layoutable as GraphicObject).CurrentInterface.LayoutingQueue.Enqueue (this); } else if (DiscardCount < Interface.MaxDiscardCount) { + #if DEBUG_LAYOUTING + Debug.WriteLine ("\t\tDiscarded"); + #endif LayoutingTries = 0; DiscardCount++; Layoutable.RegisteredLayoutings |= LayoutType; |