<package >
<metadata>
<id>Crow.OpenTK</id>
- <version>0.4.8</version>
+ <version>0.4.10</version>
<title>C# Rapid Open Widget Toolkit</title>
<authors>JP Bruyere</authors>
<owners>Grand Tetras Software</owners>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWin32Manifest>False</NoWin32Manifest>
- <SignAssembly>false</SignAssembly>
+ <SignAssembly>true</SignAssembly>
<DelaySign>False</DelaySign>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<Description>C# Rapid Open Widget</Description>
<BaseAddress>4194304</BaseAddress>
- <ReleaseVersion>0.4</ReleaseVersion>
+ <ReleaseVersion>0.5</ReleaseVersion>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<OutputPath>$(SolutionDir)build\$(Configuration)</OutputPath>
<IntermediateOutputPath>$(SolutionDir)build\obj\$(Configuration)</IntermediateOutputPath>
+ <AssemblyOriginatorKeyFile>crow.key</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <Optimize>True</Optimize>
- <DebugType>None</DebugType>
- <DefineConstants>__linux__;MEASURE_TIME</DefineConstants>
+ <Optimize>true</Optimize>
+ <DefineConstants>__linux__</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Compile Include="src\Colors.cs" />
<Compile Include="src\IML\MemberAddress.cs" />
<Compile Include="src\IML\NodeStack.cs" />
<Compile Include="src\IML\BindingDefinition.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="src\GraphicObjects\ColorPicker.cs" />
+ <Compile Include="src\GraphicObjects\ColorSelector.cs" />
+ <Compile Include="src\GraphicObjects\HueSelector.cs" />
+ <Compile Include="src\GraphicObjects\SaturationValueSelector.cs" />
+ <Compile Include="src\IML\EventBinding.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<EmbeddedResource Include="Templates\Menu.template">
<LogicalName>Crow.Menu.template</LogicalName>
</EmbeddedResource>
+ <EmbeddedResource Include="Templates\ColorPicker.template">
+ <LogicalName>Crow.ColorPicker.template</LogicalName>
+ </EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="README.md" />
$6.Wrap = False
$5.inheritsSet = Mono
description = @C.R.O.W. c# Rapid Open Widgets\n\nCrow is a pure c# widget toolkit with XML definition of interface, bindings, styling...\n
- version = 0.4
+ version = 0.5
EndGlobalSection
EndGlobal
Foreground = Black;
Selectable = True;
Text = TextBox;
+ Margin = 1;
}
Window {
Focusable = true;
Width = 150;
Height = 150;
}
+FileDialog {
+ Focusable = true;
+ MinimumSize=50,50;
+ Width = 500;
+ Height = 300;
+}
Border {
Foreground = Gray;
}
Control {
Margin=0;
Spacing=3;
+}
+ColorSpinner {
+ Minimum = 0;
+ Maximum = 255;
+ SmallIncrement = 1;
+}
+HSVSpinner {
+ Minimum = 0;
+ Maximum = 1;
+ SmallIncrement = 0.01;
}
\ No newline at end of file
-using System.Reflection;
+//
+// AssemblyInfo.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2016 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.Reflection;
using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("golib")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("golib")]
-[assembly: AssemblyCopyright("Copyright © 2014")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
+[assembly: AssemblyTitle ("Crow")]
+[assembly: AssemblyDescription ("C# Rapid Open Widgets")]
+[assembly: AssemblyConfiguration ("")]
+[assembly: AssemblyCompany ("Grand Tetra Software")]
+[assembly: AssemblyProduct ("Crow")]
+[assembly: AssemblyCopyright ("Copyright (c) 2016 - Jean-Philippe Bruyère <jp_bruyere@hotmail.com>")]
+[assembly: AssemblyTrademark ("")]
+[assembly: AssemblyCulture ("en-US")]
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("150376dc-e648-46a2-b692-6429d0a62362")]
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion ("0.5.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("crow.key")]
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.1")]
-[assembly: AssemblyFileVersion("1.0.0.1")]
<?xml version="1.0"?>
<Border Name="Content"
Background="vgradient|0:White|0.1:LightGray|0.9:LightGray|1:Black" Foreground="DarkGray"
- Height="{./HeightPolicy}" Width="{./WidthPolicy}"
MouseEnter="{Foreground=White}"
MouseLeave="{Foreground=DarkGray}"
MouseDown="{Background=vgradient|0:Black|0.1:LightGray|0.9:LightGray|1:White}"
MouseUp="{Background=vgradient|0:White|0.1:LightGray|0.9:LightGray|1:Black}"
>
-</Border>
\ No newline at end of file
+</Border>
<?xml version="1.0"?>
-<Border Background="{./Background}" MinimumSize="50,20" Height="{./HeightPolicy}" Width="{./WidthPolicy}"
- Foreground="Transparent" CornerRadius="{./CornerRadius}" BorderWidth="1"
+<Border Background="{./Background}" MinimumSize="50,20"
+ 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}"
MouseDown="{Foreground=vgradient|0:Black|0.05:Gray|0.85:Gray|1:White}"
MouseUp="{Foreground=vgradient|0:White|0.2:Gray|0.9:Gray|1:Black}"
>
<Label Font="{./Font}" Name="caption" Margin="3" Foreground="LightGray" Text="{./Caption}"/>
-</Border>
\ No newline at end of file
+</Border>
<?xml version="1.0"?>
-<HorizontalStack Style="Control" Background="{./Background}" Height="{./HeightPolicy}" Width="{./WidthPolicy}">
+<HorizontalStack Style="Control" Background="{./Background}">
<Image Style="Icon" Path="#Crow.Images.Icons.checkbox.svg"
SvgSub="{./IsChecked}"/>
- <Label Font="{./Font}" Text="{./Caption}" Height="{./HeightPolicy}" Width="{./WidthPolicy}"/>
+ <Label Font="{./Font}" Text="{./Caption}"/>
</HorizontalStack>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<Border Background="{./Background}" Foreground="{./Foreground}"
+ CornerRadius="{./CornerRadius}" BorderWidth="1">
+ <HorizontalStack Spacing="0">
+ <VerticalStack Margin="10">
+ <SaturationValueSelector S="{²./S}" V="{²./V}" Focusable="true" Name="colorSelector" Margin="0"
+ Foreground="{../hueSelector.HueColor}"
+ Width="140" Height="140" Background="DimGray"/>
+ <HueSelector Hue="{²./H}" Focusable="true" Name="hueSelector" Margin="0" Width="140" Height="20" Background="DimGray"/>
+ </VerticalStack>
+ <VerticalStack Margin="5" Height="Stretched">
+ <HorizontalStack Height="Fit" Width="Stretched">
+ <GraphicObject Width="40" Height="30" Background="{./SelectedColor}"/>
+ <VerticalStack Margin="2">
+ <Label Focusable="true" Selectable="true" Width="Stretched" Text="{./SelectedColor}" />
+ <Label Focusable="true" Selectable="true" Width="Stretched" Text="{./HexColor}" />
+ </VerticalStack>
+ </HorizontalStack>
+ <HorizontalStack Height="Fit">
+ <Label Text="Red:" Width="40"/>
+ <Spinner Style="ColorSpinner" Value="{²./R}" Width="60" />
+ </HorizontalStack>
+ <HorizontalStack Height="Fit">
+ <Label Text="Green:" Width="40"/>
+ <Spinner Style="ColorSpinner" Value="{²./G}" Width="60" />
+ </HorizontalStack>
+ <HorizontalStack Height="Fit">
+ <Label Text="Blue:" Width="40"/>
+ <Spinner Style="ColorSpinner" Value="{²./B}" Width="60" />
+ </HorizontalStack>
+ <HorizontalStack Height="Fit">
+ <Label Text="Alpha:" Width="40"/>
+ <Spinner Style="ColorSpinner" Value="{²./A}" Width="60" />
+ </HorizontalStack>
+ <HorizontalStack Height="Fit">
+ <Label Text="Hue:" Width="40"/>
+ <Spinner Style="HSVSpinner" Value="{²./H}" Width="60" />
+ </HorizontalStack>
+ <HorizontalStack Height="Fit">
+ <Label Text="Sat:" Width="40"/>
+ <Spinner Style="HSVSpinner" Value="{²./S}" Width="60" />
+ </HorizontalStack>
+ <HorizontalStack Height="Fit">
+ <Label Text="Val:" Width="40"/>
+ <Spinner Style="HSVSpinner" Value="{²./V}" Width="60" />
+ </HorizontalStack>
+ </VerticalStack>
+ </HorizontalStack>
+</Border>
\ No newline at end of file
<?xml version="1.0"?>
-<Popper Name="popper" PopDirection="Bottom" Height="{../HeightPolicy}" Width="{../WidthPolicy}">
+<Popper Name="popper" PopDirection="Bottom">
<Template>
- <Border CornerRadius="0" Foreground="LightGray" Height="{../../HeightPolicy}" Width="{../../WidthPolicy}">
- <HorizontalStack Margin="0
- " Spacing="1" Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}">
+ <Border CornerRadius="0" Foreground="LightGray">
+ <HorizontalStack Margin="0" Spacing="1">
<TextBox MinimumSize="80,10" Margin="1" Foreground="Black" Background="White"
- Text="{../../../../SelectedItem}"
- Height="{../../../../HeightPolicy}" Width="{../../../../WidthPolicy}"/>
+ Text="{../../../../SelectedItem}"/>
<Button Width="14" Height="14" Focusable="false"
Template="#Crow.Templates.ArrowButTemplate.crow">
<Image Margin="0" Path="#Crow.Images.Icons.updown.svg" SvgSub="down"/>
MinimumSize="{../../MinimumPopupSize}" Fit="true">
<Scroller Name="scroller1" Margin="2" VerticalScrolling="true"
MaximumSize="0,200"
- Height="{../HeightPolicy}" Width="{../WidthPolicy}"
- HorizontalAlignment="Left"
- ValueChanged="../../../_scroller_ValueChanged">
- <VerticalStack LayoutChanged="../../../../_list_LayoutChanged"
- Height="Fit" Width="{../../WidthPolicy}" Name="ItemsContainer" Margin="0"
+ HorizontalAlignment="Left">
+ <VerticalStack
+ Height="Fit" Name="ItemsContainer" Margin="0"
HorizontalAlignment="Left"
VerticalAlignment="Top"/>
</Scroller>
<?xml version="1.0"?>
-<TreeView IsRoot="true" Name="treeView" Data="{./FileSystemEntries}"
+<TreeView IsRoot="true" Name="treeView" Data="{./FileSystemEntries}" Background="{./Background}"
SelectedItemChanged="./onSelectedItemChanged">
<ItemTemplate DataType="System.IO.FileInfo">
- <HorizontalStack Focusable="true" Height="Fit" Width="Stretched" Background="{../Background}" >
+ <HorizontalStack Focusable="true" Height="Fit" Width="Stretched" >
<Image Margin="2" Width="14" Height="14"
Path="#Crow.Images.Icons.file.svg"/>
<Label Text="{Name}" Width="Stretched"
<ItemTemplate DataType="System.IO.DirectoryInfo" Data="GetFileSystemInfos">
<Expandable Caption="{Name}" >
<Template>
- <VerticalStack Height="{./HeightPolicy}" Width="{./WidthPolicy}">
- <HorizontalStack Spacing="1" Height="Fit" Width="{./WidthPolicy}"
+ <VerticalStack>
+ <HorizontalStack Spacing="1" Height="Fit" MouseDoubleClick="./onClickForExpand"
MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
MouseLeave="{Background=Transparent}">
- <Image Margin="2" Width="12" Height="12"
- Path="{./Image}"
- SvgSub="{./IsExpanded}"/>
+ <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}" Width="{./WidthPolicy}"/>
+ <Label Text="{./Caption}"/>
</HorizontalStack>
- <Container Name="Content" Visible="false"
- Height="{./HeightPolicy}" Width="{./WidthPolicy}"/>
+ <Container Name="Content" Visible="false"/>
</VerticalStack>
</Template>
- <HorizontalStack Height="Fit" Width="{./WidthPolicy}">
+ <HorizontalStack Height="Fit">
<GraphicObject Width="12" Height="10"/>
- <TreeView Name="List" Height="Fit" Width="{./WidthPolicy}"
+ <TreeView Name="List" Height="Fit"
Template="#Crow.Templates.treeList.crow" />
</HorizontalStack>
</Expandable>
<?xml version="1.0"?>
-<Border BorderWidth="1" Foreground="{./Foreground}" Background="{./Background}"
- Height="{./HeightPolicy}" Width="{./WidthPolicy}">
- <VerticalStack Height="{./HeightPolicy}" Width="{./WidthPolicy}">
- <HorizontalStack Spacing="1" Height="Fit" Width="{./WidthPolicy}">
- <Image Style="Icon" Margin="2"
- Visible="{./HasContent}"
- Path="{./Image}"
- SvgSub="{./IsExpanded}"/>
- <Label Text="{./Caption}" Width="{./WidthPolicy}"/>
+<Border BorderWidth="1" Foreground="{./Foreground}" Background="{./Background}">
+ <VerticalStack>
+ <HorizontalStack Spacing="1" Height="Fit" MouseDoubleClick="./onClickForExpand">
+ <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>
+ <Label Text="{./Caption}"/>
</HorizontalStack>
- <Container Name="Content" Visible="false"
- Height="{./HeightPolicy}" Width="{./WidthPolicy}"/>
+ <Container Name="Content" Visible="false"/>
</VerticalStack>
</Border>
\ No newline at end of file
<?xml version="1.0"?>
-<Window Caption="OpenFile" Height="300" Width="500">
- <VerticalStack Margin="5">
- <TextBox Margin="1" Width="0" Height="-1" Text="{CurrentPath}"/>
- <HorizontalStack >
- <ListBox Data="{Directories}" Width="-1" Height="0"
- Background="0.5,0.5,0.5,0.5"
- SelectedItemChanged="OnSelectedItemChanged"
- Template="#Crow.Templates.ScrollingListBox.goml"
- ItemTemplate="#Crow.Templates.tmpDirItem.goml" >
- </ListBox>
- <ListBox Data="{Files}" Width="0" Height="0"
- Background="0.5,0.5,0.5,0.5"
- SelectedItemChanged="onFileListItemChanged"
- Template="#Crow.Templates.ScrollingListBox.goml"
- ItemTemplate="#Crow.Templates.imgItemTemplate.goml">
- </ListBox>
- </HorizontalStack>
- <HorizontalStack Fit="true" HorizontalAlignment="Right">
- <Button Caption="Ok" MouseClick="onFileSelect"/>
- <Button Caption="Cancel"/>
+<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="{./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>
+ <Container Name="Content" MinimumSize="50,50" Background="Onyx">
+ <VerticalStack Margin="5">
+ <TextBox Text="{²./CurrentDirectory}"/>
+ <HorizontalStack>
+ <DirectoryView ShowFiles="false" Name="dv" CurrentDirectory="{²./CurrentDirectory}" SelectedItemChanged="./Tv_SelectedItemChanged"
+ Width="50%" Margin="1">
+ <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/>
+
+ </HorizontalStack>
+ <TextBox Text="{../../dv.SelectedItem}"/>
+ <HorizontalStack Fit="true" HorizontalAlignment="Right">
+ <Button Caption="Ok" MouseClick="onFileSelect"/>
+ <Button Caption="Cancel"/>
+ </HorizontalStack>
+ </VerticalStack>
+ </Container>
</VerticalStack>
-</Window>
+</Border>
<?xml version="1.0"?>
-<Container Background="{./Background}" Height="{./HeightPolicy}" Width="{./WidthPolicy}">
- <Group Height="{./HeightPolicy}" Width="{./WidthPolicy}">
- <VerticalStack Spacing="0"
- Height="{./HeightPolicy}" Width="{./WidthPolicy}">
- <GraphicObject Height="6" Width="{./WidthPolicy}"/>
- <Border CornerRadius="5" BorderWidth="1" Margin="10" Foreground="{./Foreground}"
- Height="{./HeightPolicy}" Width="{./WidthPolicy}">
- <Container Name="Content" Margin="0" MinimumSize="70,10"
- Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}"/>
+<Container Background="{./Background}">
+ <Group>
+ <VerticalStack Spacing="0">
+ <GraphicObject Height="6"/>
+ <Border CornerRadius="5" BorderWidth="1" Margin="10" Foreground="{./Foreground}">
+ <Container Name="Content" Margin="0" MinimumSize="70,10"/>
</Border>
</VerticalStack>
<Label Text="{./Caption}" VerticalAlignment="Top" Left="8"
<?xml version="1.0"?>
-<Border BorderWidth="1" Margin="1" MinimumSize="10,10" Height="{./HeightPolicy}" Width="{./WidthPolicy}" >
- <Scroller Name="scroller1" Margin="1" VerticalScrolling="true"
- Height="{./HeightPolicy}" Width="{./WidthPolicy}"
- ValueChanged="./_scroller_ValueChanged">
- <VerticalStack LayoutChanged="./_list_LayoutChanged"
- Height="Fit" Width="{./WidthPolicy}" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
+<Border BorderWidth="1" Margin="1" MinimumSize="10,10">
+ <Scroller Name="scroller1" Margin="1" VerticalScrolling="true">
+ <VerticalStack
+ Height="Fit" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
</Scroller>
-</Border>
\ No newline at end of file
+</Border>
<?xml version="1.0"?>
-<HorizontalStack Name="ItemsContainer" Margin="0" Background="{./Background}"
- Width="{./WidthPolicy}" Height="{./HeightPolicy}"/>
+<HorizontalStack Name="ItemsContainer" Margin="0" Background="{./Background}"/>
MouseLeave="{Foreground=Transparent}"
MouseDown="{Foreground=vgradient|0:Black|0.05:Gray|0.85:Gray|1:White}"
MouseUp="{Foreground=vgradient|0:White|0.2:Gray|0.9:Gray|1:Black}"
- Height="{./HeightPolicy}" Width="{./WidthPolicy}"
MinimumSize = "60,0"
Foreground="Transparent"
Background="{./Background}">
<?xml version="1.0"?>
-<Border Height="{./HeightPolicy}" Width="{./WidthPolicy}" CornerRadius="0"
+<Border CornerRadius="0"
MouseEnter="./onBorderMouseEnter"
MouseLeave="./onBorderMouseLeave">
- <VerticalStack Height="{./HeightPolicy}" Width="{./WidthPolicy}" Background="{./Background}">
- <Border BorderWidth="0" Foreground="White" Width="{./WidthPolicy}" Height="Fit"
+ <VerticalStack Background="{./Background}">
+ <Border BorderWidth="0" Foreground="White" Height="Fit"
Background="vgradient|0:0.4,0.6,0.0,0.5|1:0.0,0.8,0.8,0.9">
- <HorizontalStack Name="hs" Margin="2" Spacing="1" Width="{./WidthPolicy}" Height="Fit" >
+ <HorizontalStack Name="hs" Margin="2" Spacing="1" Height="Fit" >
<GraphicObject Width="5" Height="5"/>
<Image Margin="1" Width="12" Height="12" Path="{./Icon}"/>
- <Label Foreground="White" Width="{./WidthPolicy}" Margin="1" TextAlignment="Center" Text="{./Title}" />
+ <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" Path="#Crow.Images.Icons.exit2.svg"
<GraphicObject Width="5" Height="5"/>
</HorizontalStack>
</Border>
- <HorizontalStack Margin="5" Height="{./HeightPolicy}" Width="{./WidthPolicy}">
+ <HorizontalStack Margin="5">
<Image Name="Image" Width="20%" Height="20" Path="#Crow.Images.Icons.iconInfo.svg" />
- <Label Margin="5" Font="serif, 10" Height="{./HeightPolicy}" Width="80%" Text="{./Message}"
+ <Label Margin="5" Font="serif, 10" Width="80%" Text="{./Message}"
TextAlignment="Left"
Multiline="true" />
</HorizontalStack>
<?xml version="1.0"?>
-<Border Background="{./Background}" BorderWidth="1" Foreground="{./Foreground}" Height="Fit" Width="{./WidthPolicy}">
- <HorizontalStack Spacing="1" Height="Fit" Width="{./WidthPolicy}">
+<Border Background="{./Background}" BorderWidth="1" Foreground="{./Foreground}" Height="Fit">
+ <HorizontalStack Spacing="1" Height="Fit">
<Image Style="Icon" Margin="2"
Path="#Crow.Images.Icons.expandable.svg" SvgSub="{./IsPopped}"/>
- <Label Text="{./Caption}" Width="{./WidthPolicy}"/>
+ <Label Text="{./Caption}" />
</HorizontalStack>
</Border>
\ No newline at end of file
<?xml version="1.0"?>
-<HorizontalStack Style="Control" Background="{./Background}" Height="{./HeightPolicy}" Width="{./WidthPolicy}">
+<HorizontalStack Style="Control" Background="{./Background}">
<Image Style="Icon" Path="#Crow.Images.Icons.radiobutton.svg"
SvgSub="{./IsChecked}"/>
- <Label Text="{./Caption}" Height="{./HeightPolicy}" Width="{./WidthPolicy}"/>
+ <Label Text="{./Caption}"/>
</HorizontalStack>
\ No newline at end of file
<?xml version="1.0"?>
-<Border BorderWidth="1" Foreground="LightGray" Width="{./WidthPolicy}" Height="{./HeightPolicy}">
- <GenericStack Orientation="{./Orientation}" Spacing="0"
- Width="{./WidthPolicy}" Height="{./HeightPolicy}">
+<Border BorderWidth="1" Foreground="LightGray">
+ <GenericStack Orientation="{./Orientation}" Spacing="0">
<Button MouseRepeat="true" Width="12" Height="12" MouseClick="./onScrollBack"
Template="#Crow.Templates.ArrowButTemplate.crow">
<Image Margin="1" Path="#Crow.Images.Icons.updown.svg" SvgSub="up"/>
Orientation="{./Orientation}"
Value="{./Value}"
Maximum="{./Maximum}"
+ Height="{./HeightPolicy}" Width="{./WidthPolicy}"
LargeIncrement="{./LargeIncrement}"
SmallIncrement="{./SmallIncrement}"
Background="hgradient|0:DimGray|0.1:Gray|0.95:Gray|1:White"
- Width="{./WidthPolicy}" Height="{./HeightPolicy}"
ValueChanged="./onSliderValueChange"/>
<Button MouseRepeat="true" Width="12" Height="12" MouseClick="./onScrollForth"
Template="#Crow.Templates.ArrowButTemplate.crow">
<?xml version="1.0"?>
-<Border BorderWidth="1" Height="{./HeightPolicy}" Width="{./WidthPolicy}" Background="{./Background}">
- <HorizontalStack Margin="1" Height="{./HeightPolicy}" Width="{./WidthPolicy}" >
- <Scroller Name="scroller1" Height="{./HeightPolicy}" Width="{./WidthPolicy}"
- Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}"
- ValueChanged="./_scroller_ValueChanged">
- <VerticalStack Width="{./WidthPolicy}" Height="-1" MinimumSize="10,10"
- Name="ItemsContainer" Margin="0" VerticalAlignment="Top"
- LayoutChanged="./_list_LayoutChanged"/>
+<Border BorderWidth="1" Background="{./Background}">
+ <HorizontalStack Margin="1">
+ <Scroller Name="scroller1"
+ Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}">
+ <VerticalStack Height="Fit" MinimumSize="10,10"
+ Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
</Scroller>
<ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollY}"
Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical"
- Width="14" Height="{./HeightPolicy}" />
+ Width="14" />
</HorizontalStack>
-</Border>
\ No newline at end of file
+</Border>
<?xml version="1.0"?>
-<HorizontalStack MinimumSize="40,10" Name="hstack" Margin="0" Spacing="0"
- Height="{./HeightPolicy}" Width="{./WidthPolicy}">
- <Border BorderWidth="1" Height="{./HeightPolicy}" Width="80%" Background="White"
+<HorizontalStack MinimumSize="40,10" Name="hstack" Margin="0" Spacing="0">
+ <Border BorderWidth="1" Width="80%" Background="White"
Foreground="DimGray" Margin="0">
- <Label Foreground="DimGray" Height="{./HeightPolicy}" Width="Stretched"
+ <Label Foreground="DimGray" Width="Stretched"
Text="{./Value}" TextAlignment="Right" Margin="0"/>
</Border>
<VerticalStack MinimumSize="8,10" Width="20%" Height="Stretched" Spacing="0" Margin="0" Background="Red">
<?xml version="1.0"?>
<GenericStack Orientation="Vertical" Spacing="0"
- Width="{./WidthPolicy}" Height="{./HeightPolicy}"
Background="Onyx"
MouseEnter="{caption.Foreground=White}"
MouseLeave="{caption.Foreground=Gray}">
<HorizontalStack Margin="2" Left="{./TabOffset}"
Name="TabTitle"
HorizontalAlignment="Left"
- Height="{../../../TabThickness}"
+ Height="{./TabThickness}"
Width="Fit">
<Label Name="caption" Text="{./Caption}" Foreground="Gray"/>
<Border CornerRadius="5" 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="../../../../butCloseTabClick"/>
+ MouseClick="./butCloseTabClick"/>
</Border>
</HorizontalStack>
- <Container
- Name="Content" Width="{./WidthPolicy}" Height="{./HeightPolicy}"/>
+ <Container Name="Content"/>
</GenericStack>
<?xml version="1.0"?>
-<HorizontalStack Height="{./HeightPolicy}" Width="{./WidthPolicy}">
+<HorizontalStack>
<Scroller Name="scroller1" Margin="1" VerticalScrolling="true"
Background="{./Background}"
- Height="{./HeightPolicy}" Width="{./WidthPolicy}"
- ScrollY="{../scrollbar1.Value}"
- ValueChanged="./_scroller_ValueChanged">
- <VerticalStack LayoutChanged="./_list_LayoutChanged"
- Height="Fit" Width="{./WidthPolicy}" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
+ ScrollY="{../scrollbar1.Value}">
+ <VerticalStack
+ Height="Fit" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
</Scroller>
<ScrollBar
Name="scrollbar1"
<?xml version="1.0"?>
<Border BorderWidth="1" Foreground="White" CornerRadius="{./CornerRadius}"
Background="{./Background}"
- Height="{./HeightPolicy}" Width="{./WidthPolicy}"
MouseEnter="./onBorderMouseEnter"
MouseLeave="./onBorderMouseLeave">
- <VerticalStack Height="{./HeightPolicy}" Width="{./WidthPolicy}" Spacing="0">
+ <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" Width="{./WidthPolicy}" Height="Fit">
+ Name="hs" Margin="2" Spacing="0" Height="Fit">
<GraphicObject Width="5"/>
<Image Margin="1" Width="12" Height="12" Path="{./Icon}"/>
- <Label Foreground="White" Width="{./WidthPolicy}" Margin="1" TextAlignment="Center" Text="{./Title}" />
+ <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"
<GraphicObject Width="5"/>
</HorizontalStack>
<!-- </Border>-->
- <Container Name="Content" MinimumSize="50,50" Height="{./HeightPolicy}" Width="{./WidthPolicy}" Background="0.5,0.5,0.5,0.5"/>
+ <Container Name="Content" MinimumSize="50,50" Background="0.5,0.5,0.5,0.5"/>
</VerticalStack>
-</Border>
\ No newline at end of file
+</Border>
<?xml version="1.0"?>
<VerticalStack
- Height="Fit" Width="{./WidthPolicy}" Name="ItemsContainer"/>
\ No newline at end of file
+ Height="Fit" Name="ItemsContainer"/>
{
class BasicTests : OpenTKGameWindow
{
+ #region IBindable implementation
+ public object DataSource {
+ get { return null; }
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+ List<Binding> bindings = new List<Binding> ();
+ public List<Binding> Bindings {
+ get { return bindings; }
+ }
+ #endregion
+
public BasicTests ()
: base(800, 600,"test: press <F3> to toogle test files")
{
string[] testFiles;
#region Test values for Binding
- public int intValue = 25;
+ public int intValue = 500;
DirectoryInfo curDir = new DirectoryInfo (Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
+ //DirectoryInfo curDir = new DirectoryInfo (@"/mnt/data/Images");
public FileSystemInfo[] CurDirectory {
get { return curDir.GetFileSystemInfos (); }
}
"string1",
"string2",
"string3",
- "string4",
- "string5",
- "string6",
- "string7",
- "string8",
- "string8",
- "string8",
- "string8",
- "string8",
- "string8",
- "string9"
+// "string4",
+// "string5",
+// "string6",
+// "string7",
+// "string8",
+// "string8",
+// "string8",
+// "string8",
+// "string8",
+// "string8",
+// "string9"
}
);
+ public IList<String> TestList2 {
+ set{
+ List2 = value;
+ NotifyValueChanged ("TestList2", testList);
+ }
+ get { return List2; }
+ }
IList<Color> testList = Color.ColorDic.ToList();
public IList<Color> TestList {
set{
NotifyValueChanged ("CurSources", curSources);
}
}
+ bool boolVal = true;
+ public bool BoolVal {
+ get { return boolVal; }
+ set {
+ if (boolVal == value)
+ return;
+ boolVal = value;
+ NotifyValueChanged ("BoolVal", boolVal);
+ }
+ }
+
#endregion
void OnClear (object sender, MouseButtonEventArgs e) => TestList = null;
this.KeyDown += KeyboardKeyDown1;
+ //testFiles = new string [] { @"Interfaces/Unsorted/testFileDialog.crow" };
+ //testFiles = new string [] { @"Interfaces/Divers/colorPicker.crow" };
testFiles = new string [] { @"Interfaces/Divers/welcome.crow" };
+ //testFiles = new string [] { @"Interfaces/Divers/test2WayBinding.crow" };
+ testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Splitter", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/GraphicObject", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Container", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Group", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Stack", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Wrapper", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Divers", "*.crow")).ToArray ();
- testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Splitter", "*.crow")).ToArray ();
- testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/TemplatedControl", "*.crow")).ToArray ();
- testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/TemplatedContainer", "*.crow")).ToArray ();
- testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/TemplatedGroup", "*.crow")).ToArray ();
- this.Title = testFiles [idx] + ". Press <F3> to switch example.";
+ object tc = Color.AirForceBlueRaf;
CrowInterface.LoadInterface(testFiles[idx]).DataSource = this;
}
void KeyboardKeyDown1 (object sender, OpenTK.Input.KeyboardKeyEventArgs e)
else
return;
- CrowInterface.ClearInterface ();
-
- if (idx == testFiles.Length)
- idx = 0;
- else if (idx < 0)
- idx = testFiles.Length - 1;
-
- this.Title = testFiles [idx] + ". Press <F3> to cycle examples.";
try {
+ CrowInterface.ClearInterface ();
+
+ if (idx == testFiles.Length)
+ idx = 0;
+ else if (idx < 0)
+ idx = testFiles.Length - 1;
+
+ this.Title = testFiles [idx] + ". Press <F3> to cycle examples.";
+
GraphicObject obj = CrowInterface.LoadInterface(testFiles[idx]);
obj.DataSource = this;
} catch (Exception ex) {
{
base.OnUpdateFrame (e);
string test = e.Time.ToString ();
+ IntValue++;
+ if (IntValue == 1000)
+ IntValue = 0;
NotifyValueChanged ("PropertyLessBinding", test);
}
void onNew(object sender, EventArgs e){
<?xml version="1.0"?>
<Container Background="Onyx" Margin="10" Width="90%" Height="90%">
- <GraphicObject Margin="10" Width="Stretched" Height="Stretched" Background="Mantis"
+ <GraphicObject Margin="10" Background="Mantis"
MinimumSize="50,50"/>
</Container>
\ No newline at end of file
<?xml version="1.0"?>
<Window Title="Showcase" Height="90%" Width="90%">
<HorizontalStack >
- <VerticalStack Width="33%" Margin="5">
+ <VerticalStack Width="30%" Margin="5">
<GroupBox Caption="Performance" Height="Fit">
<VerticalStack Width="90%" Height="Fit" Spacing="2" >
<HorizontalStack Height="Fit">
<TextBox Text="TextBox" Multiline="true" Margin="3"/>
<HorizontalStack Height="Fit" Margin="5" Background="Onyx" CornerRadius="10">
<VerticalStack Spacing="5" Width="50%">
+ <CheckBox Fit="true" Caption="test"/>
<CheckBox Fit="true"/>
<CheckBox Fit="true"/>
- <CheckBox Fit="true"/>
- <CheckBox Fit="true"/>
+ <CheckBox Fit="true" IsChecked="true"/>
</VerticalStack>
<VerticalStack Spacing="5" Width="50%">
<RadioButton Fit="true"/>
- <RadioButton Fit="true"/>
+ <RadioButton Fit="true" IsChecked="true"/>
<RadioButton Fit="true"/>
<RadioButton Fit="true"/>
</VerticalStack>
<GroupBox Caption="Templated controls" Height="Fit" Margin="5">
<HorizontalStack Height="Fit">
<VerticalStack Width="50%">
- <CheckBox Template="#Tests.Interfaces.CheckBox2.imlt" Style="CheckBox2"/>
- <CheckBox Template="#Tests.Interfaces.CheckBox2.imlt" Style="CheckBox2"/>
- <CheckBox Template="#Tests.Interfaces.CheckBox2.imlt" Style="CheckBox2"/>
- <CheckBox Template="#Tests.Interfaces.CheckBox2.imlt" Style="CheckBox2"/>
+ <CheckBox IsChecked="true" Style="CheckBox2"/>
+ <CheckBox Style="CheckBox2"/>
+ <CheckBox Style="CheckBox2"/>
+ <CheckBox Style="CheckBox2"/>
</VerticalStack>
<Splitter/>
<VerticalStack Width="50%">
- <RadioButton Template="#Tests.Interfaces.CheckBox2.imlt" Style="RadioButton2"/>
- <RadioButton Template="#Tests.Interfaces.CheckBox2.imlt" Style="RadioButton2"/>
- <RadioButton Template="#Tests.Interfaces.CheckBox2.imlt" Style="RadioButton2"/>
- <RadioButton Template="#Tests.Interfaces.CheckBox2.imlt" Style="RadioButton2"/>
+ <RadioButton Style="RadioButton2"/>
+ <RadioButton Style="RadioButton2"/>
+ <RadioButton Style="RadioButton2"/>
+ <RadioButton Style="RadioButton2"/>
</VerticalStack>
</HorizontalStack>
</GroupBox>
</HorizontalStack>
</VerticalStack>
<Splitter/>
- <VerticalStack Width="33%" Margin="5" Spacing="5">
+ <VerticalStack Width="40%" Margin="5" Spacing="5">
<Expandable Background="DimGray">
<Image Path="#Crow.Images.Icons.crow.svg"/>
</Expandable>
- <Popper Background="DimGray" PopDirection="Bottom">
+ <Popper Background="DimGray" >
<Border Fit="True" Background="DimGray" CornerRadius="0" BorderWidth="1">
<Image Path="#Crow.Images.Icons.crow.svg" Width="100" Height="100" Margin="10"
MouseEnter="{Background=LightGray}"
</Border>
</Popper>
<Slider Height="10" Width="90%"/>
- <Container Height="Fit" Background="Onyx" Margin="2" CornerRadius="5">
+ <Container Height="Fit" Width="200" Background="Onyx" Margin="2" CornerRadius="5">
<ProgressBar Background="DimGray" Height="10" Value="50"/>
</Container>
<Image Path="#Crow.Images.Icons.crow.svg" Width="60" Height="60" Background="LightGray" />
- <TabView Name="tabview1"
+<!-- <TabView Name="tabview1"
Height="120" Orientation="Horizontal" Spacing="15">
<TabItem Name="TabItem1" Caption="Tab 1" Margin="0">
<VerticalStack Fit="true">
<TextBox Height="Stretched" Margin="5" Multiline="true" TextAlignment="TopLeft"/>
</Container>
</TabItem>
- </TabView>
+ </TabView>-->
<MessageBox Movable="false"/>
+ <ColorPicker SelectedColor="{²../go.Background}" Name="colorPicker" Background="Onyx" Margin="5" Fit="True" />
+ <GraphicObject Name="go" Width="100" Height="60" Background="DarkBlue"/>
</VerticalStack>
<Splitter/>
- <VerticalStack Width="33%" Margin="5">
+ <VerticalStack Width="30%" Margin="5">
<Border Margin="5" Height="Fit">
<Label Width="Stretched" Margin="1" Text="{../../dv.SelectedItem}"/>
</Border>
- <Border Margin="5" Height="50%">
- <DirectoryView Name="dv" CurrentDirectory="./" Margin="1"/>
+ <Border Margin="5" Height="30%">
+ <DirectoryView Name="dv" CurrentDirectory="/" Margin="1"/>
</Border>
<Splitter/>
<ListBox Data="{TestList}" Margin="5"
ItemTemplate="#Tests.Interfaces.colorItem.crow"
- Template="#Crow.Templates.ScrollingListBox.goml"/>
+ Template="#Crow.Templates.ScrollingListBox.goml"
+ />
</VerticalStack>
</HorizontalStack>
</Window>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<VerticalStack>
+ <ColorPicker SelectedColor="{²../go.Background}" Name="colorPicker" Background="Onyx" Margin="5" Fit="True" />
+ <GraphicObject Name="go" Width="100" Height="60" Background="DarkBlue"/>
+ <GraphicObject Name="go" Width="100" Height="60" Background="{../colorPicker.SelectedColor}"/>
+
+</VerticalStack>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<VerticalStack Fit="true">
+ <CheckBox IsChecked="{²BoolVal}"/>
+ <CheckBox Caption="second" IsChecked="{²BoolVal}"/>
+</VerticalStack>
\ No newline at end of file
<?xml version="1.0"?>
-<GraphicObject Margin="10" Width="50%" Height="50%" Background="Mantis"
+<GraphicObject Margin="10" Width="50%" Height="50%"
+ Background="hgradient|0:Red|0.25:Blue|0.5:Green|0.75:Yellow|1:Red"
MinimumSize="50,50"/>
\ No newline at end of file
<?xml version="1.0"?>
<TreeView IsRoot="true" Name="treeView" Data="{CurDirectory}" Background="DimGray">
<ItemTemplate DataType="System.IO.FileInfo">
- <HorizontalStack Focusable="true" Height="Fit" Width="Stretched" Background="{../Background}" >
+ <HorizontalStack Focusable="true" Height="Fit" Width="Stretched" >
<Image Margin="2" Width="14" Height="14"
Path="#Crow.Images.Icons.file.svg"/>
<Label Text="{Name}" Width="Stretched"
<ItemTemplate DataType="System.IO.DirectoryInfo" Data="GetFileSystemInfos">
<Expandable Caption="{Name}" >
<Template>
- <VerticalStack Height="{./HeightPolicy}" Width="{./WidthPolicy}">
- <HorizontalStack Spacing="1" Height="Fit" Width="{./WidthPolicy}"
+ <VerticalStack>
+ <HorizontalStack Spacing="1" Height="Fit"
MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
MouseLeave="{Background=Transparent}">
<Image Margin="2" Width="12" Height="12"
SvgSub="{./IsExpanded}"/>
<Image Margin="2" Width="14" Height="14"
Path="#Crow.Images.Icons.folder.svg"/>
- <Label Text="{./Caption}" Width="{./WidthPolicy}"/>
+ <Label Text="{./Caption}"/>
</HorizontalStack>
- <Container Name="Content" Visible="false"
- Height="{./HeightPolicy}" Width="{./WidthPolicy}"/>
+ <Container Name="Content" Visible="false"/>
</VerticalStack>
</Template>
- <HorizontalStack Height="Fit" Width="{./WidthPolicy}">
+ <HorizontalStack Height="Fit">
<GraphicObject Width="12" Height="10"/>
- <TreeView Name="List" Height="Fit" Width="{./WidthPolicy}">
+ <TreeView Name="List" Height="Fit">
<Template>
- <VerticalStack Height="Fit" Width="{../WidthPolicy}" Name="ItemsContainer"/>
+ <VerticalStack Height="Fit" Name="ItemsContainer"/>
</Template>
</TreeView>
</HorizontalStack>
<Label Text="{../ColorList.SelectedItem}" Background="DarkGreen"/>
<Label Text="{Hover}" Background="DarkGreen"/>
<Button Caption="Clear" Width="Stretched" MouseClick="OnClear"/>
- <ListBox Name="ColorList" Data="{TestList}" Background="0.5,0.5,0.5,0.5"
- HorizontalAlignment="Center" Width="Fit" Height="200" Margin="0"
- ItemTemplate="#Tests.Interfaces.colorItem.crow"
- Template="#Crow.Templates.ScrollingListBox.goml">
-<!-- <Template>
- <Border BorderWidth="1" Height="{../HeightPolicy}" Width="{../WidthPolicy}">
- <HorizontalStack Margin="1" Height="{../../HeightPolicy}" Width="{../../WidthPolicy}" >
- <Scroller Name="scroller1" Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}"
- Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}"
- ValueChanged="../../../_scroller_ValueChanged">
- <VerticalStack Width="{../../../../WidthPolicy}" Height="Fit" MinimumSize="100,100"
- Name="List" Margin="0" VerticalAlignment="Top"
- LayoutChanged="../../../../_list_LayoutChanged"/>
- </Scroller>
- <ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollY}"
- Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical"
- Width="12" Height="{../../../HeightPolicy}" />
- </HorizontalStack>
- </Border>
- </Template>-->
+<!-- <ListBox Name="ColorList" Data="{TestList}" Width="200" Height="200"
+ ItemTemplate="#Tests.Interfaces.colorItem.crow">
</ListBox>
- <Button Caption="Load list" Width="Stretched" MouseClick="../../../OnLoadList"/>
+ <Button Caption="Load list" Width="Stretched" MouseClick="OnLoadList"/>-->
</VerticalStack>
</Border>
\ No newline at end of file
<ListBox Data="{TestList}" Background="0.5,0.5,0.5,0.7"
HorizontalAlignment="Center" Width="200" Height="200" Margin="5">
<Template>
- <Border BorderWidth="1" Height="{../HeightPolicy}" Width="{../WidthPolicy}">
- <HorizontalStack Margin="1" Height="{../../HeightPolicy}" Width="{../../WidthPolicy}" >
- <Scroller Name="scroller1" Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}"
- Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}"
- ValueChanged="../../../_scroller_ValueChanged">
- <VerticalStack Width="{../../../../WidthPolicy}" Height="Fit" MinimumSize="10,10"
+ <Border BorderWidth="1">
+ <HorizontalStack Margin="1">
+ <Scroller Name="scroller1"
+ Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}">
+ <VerticalStack Height="Fit" MinimumSize="10,10"
Name="ItemsContainer" Margin="0"
VerticalAlignment="Top"
- HorizontalAlignment="Left"
- LayoutChanged="../../../../_list_LayoutChanged"/>
+ HorizontalAlignment="Left"/>
</Scroller>
<ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollY}"
Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical"
- Width="14" Height="{../../../HeightPolicy}" />
+ Width="14"/>
</HorizontalStack>
</Border>
</Template>
MouseEnter="{Background=hgradient|0:DarkRed|1:Transparent}"
MouseLeave="{Background=Transparent}">
<GraphicObject Height="12" Width="20" Background="{}" Margin="0" CornerRadius="3"/>
- <Label Text="{Name}" Margin="0" Width="Stretched"/>
+ <Label Text="{}" Margin="0" Width="Stretched"/>
</HorizontalStack>
</ItemTemplate>
</ListBox>
<Button Caption="Clear" MouseClick="OnClear"/>
</HorizontalStack>
</VerticalStack>
-</Border>
\ No newline at end of file
+</Border>
--- /dev/null
+<?xml version="1.0"?>
+<Group Name="TopContainer" Width="400" Height="400"
+ Focusable="True" Background="Gray">
+ <ScrollBar Height="Stretched" Orientation="Vertical" Width="16" Maximum="100"/>
+</Group>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>
-<Group Name="TopContainer" Width="400" Height="400"
- Focusable="True" Background="Gray">
- <ScrollBar Height="Stretched" Orientation="Vertical" Width="16" Maximum="100"/>
-</Group>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<VerticalStack Name="TopContainer" Width="400" Height="Fit"
+ Margin="20" Background="DarkGray">
+
+ <HorizontalStack Fit="true" Margin="5" Background="SkyBlue">
+ <Spinner Value="{IntValue}" ValueChanged="onSpinnerValueChange"/>
+ <Spinner Value="5"/>
+ <Spinner Value="5"/>
+ <Button/>
+ </HorizontalStack>
+</VerticalStack>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>
-<VerticalStack Name="TopContainer" Width="400" Height="Fit"
- Margin="20" Background="DarkGray">
-
- <HorizontalStack Fit="true" Margin="5" Background="SkyBlue">
- <Spinner Value="{IntValue}" ValueChanged="onSpinnerValueChange"/>
- <Spinner Value="5"/>
- <Spinner Value="5"/>
- <Button/>
- </HorizontalStack>
-</VerticalStack>
\ No newline at end of file
<Label Text="{../../Caption}" Width="{../../WidthPolicy}"/>
<Container Name="Content" Visible="false" Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"/>
</VerticalStack>-->
-<Group BorderWidth="1" Foreground="LightGray" Height="{../HeightPolicy}" Width="{../WidthPolicy}"
+<Group BorderWidth="1" Foreground="LightGray"
MouseClick="../onMouseClick">
- <VerticalStack Height="{../../HeightPolicy}" Width="{../../WidthPolicy}">
- <Label Text="{../../../Caption}" Width="{../../../WidthPolicy}"/>
- <Container Name="Content" Visible="false" Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}"/>
+ <VerticalStack>
+ <Label Text="{../../../Caption}"/>
+ <Container Name="Content" Visible="false"/>
</VerticalStack>
</Group>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<FileDialog Title="Open File" CurrentDirectory="/"/>
+
+++ /dev/null
-<?xml version="1.0"?>
-<FileDialog Width="500" Height="300"/>
-
<?xml version="1.0"?>
-<VerticalStack
- Height="Fit" Width="{../WidthPolicy}" Name="List"/>
\ No newline at end of file
+<VerticalStack Height="Fit" Name="List"/>
\ No newline at end of file
<StartupObject>Tests.BasicTests</StartupObject>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ReleaseVersion>0.4</ReleaseVersion>
+ <ReleaseVersion>0.5</ReleaseVersion>
<OutputPath>$(SolutionDir)build/$(Configuration)</OutputPath>
<IntermediateOutputPath>$(SolutionDir)build/obj/$(Configuration)</IntermediateOutputPath>
<CustomCommands>
<Command type="Execute" command="${TargetName}" workingdir="${SolutionDir}/build/${ProjectConfigName}" />
</CustomCommands>
</CustomCommands>
- <SynchReleaseVersion>false</SynchReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
- <None Include="Interfaces\Unsorted\testFileDialog.goml">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </None>
<None Include="Interfaces\Unsorted\testTypeViewer.goml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Interfaces\TemplatedControl\testRadioButton.crow">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
- <None Include="Interfaces\TemplatedControl\testScrollbar.goml">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </None>
- <None Include="Interfaces\TemplatedControl\testSpinner.goml">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </None>
<None Include="Interfaces\TemplatedContainer\test_Listbox.crow">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Interfaces\TemplatedGroup\2.crow">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
+ <None Include="Interfaces\TemplatedControl\testScrollbar.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Interfaces\TemplatedControl\testSpinner.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Interfaces\Divers\colorPicker.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Interfaces\Divers\test2WayBinding.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Interfaces\Unsorted\testFileDialog.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<ItemGroup>
<Folder Include="Interfaces\" />
Background = Teal;
}
CheckBox2 {
+ Template= #Tests.Interfaces.CheckBox2.imlt;
Background = Onyx;
Checked={Background=Mantis;Font=droid bold, 10};
Unchecked = {Background=Onyx;Font=droid,10};
}
RadioButton2 {
+ Template=#Tests.Interfaces.CheckBox2.imlt;
Background = Onyx;
Checked = {Background=Mantis;Font=droid bold, 10};
Unchecked = {Background=Onyx;Font=droid,10};
<?xml version="1.0"?>
<Label Text="{../Caption}" Style="#Tests.ui.LabelButton.style"
- Height="Fit" Width="{../WidthPolicy}"/>
+ Height="Fit"/>
<?xml version="1.0"?>
-<Border BorderWidth="1" Foreground="White" CornerRadius="15"
- Height="{../HeightPolicy}" Width="{../WidthPolicy}"
+<Border BorderWidth="1" Foreground="White" CornerRadius="15"
MouseEnter="../onBorderMouseEnter"
MouseLeave="../onBorderMouseLeave"
Background="vgradient|0:0.6,0.6,0.6,0.9|1:0.4,0.4,0.4,0.6">
- <VerticalStack Height="{../../HeightPolicy}" Width="{../../WidthPolicy}">
- <HorizontalStack Height="Fit" Width="{../../../WidthPolicy}">
+ <VerticalStack>
+ <HorizontalStack Height="Fit">
<Label Margin="2" Font="{../../../../Font}" Text="{../../../../Title}" Width="Stretched"/>
<Border HorizontalAlignment="Right" Margin="0" VerticalAlignment="Top"
CornerRadius="6" BorderWidth="1" Foreground="Transparent"
MouseClick="../../../../../butQuitPress"/>
</Border>
</HorizontalStack>
- <Container Name="Content"
- Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}"/>
+ <Container Name="Content"/>
</VerticalStack>
</Border>
\ No newline at end of file
namespace Crow
{
+ /// <summary>
+ /// Universal Color structure
+ /// </summary>
public struct Color
{
#region CTOR
{
return (Color)s;
}
+ public static Color FromHSV(double _h, double _v = 1.0, double _s = 1.0){
+ Color c = Color.Black;
+
+ if (_s == 0) {//HSV from 0 to 1
+ c.R = _v;
+ c.G = _v;
+ c.B = _v;
+ }else{
+ double var_h = _h * 6.0;
+
+ if (var_h == 6.0)
+ var_h = 0; //H must be < 1
+ double var_i = Math.Floor( var_h ); //Or ... var_i = floor( var_h )
+ double var_1 = _v * ( 1.0 - _s );
+ double var_2 = _v * (1.0 - _s * (var_h - var_i));
+ double var_3 = _v * (1.0 - _s * (1.0 - (var_h - var_i)));
+
+ if (var_i == 0.0) {
+ c.R = _v;
+ c.G = var_3;
+ c.B = var_1;
+ }else if ( var_i == 1.0 ) { c.R = var_2 ; c.G = _v ; c.B = var_1; }
+ else if ( var_i == 2 ) { c.R = var_1 ; c.G = _v ; c.B = var_3; }
+ else if ( var_i == 3 ) { c.R = var_1 ; c.G = var_2 ; c.B = _v; }
+ else if ( var_i == 4 ) { c.R = var_3 ; c.G = var_1 ; c.B = _v; }
+ else { c.R = _v ; c.G = var_1 ; c.B = var_2; }
+ }
+ return c;
+ }
}
}
GetMethod("CreateDelegate", new Type[] { typeof(Type), typeof(object)});
internal static MethodInfo miObjToString = typeof(object).GetMethod("ToString");
-
internal static Type ehTypeDSChange = eiDSChange.EventHandlerType;
internal static FieldInfo fi_ehTypeDSChange = typeof(CompilerServices).GetField("ehTypeDSChange", BindingFlags.Static | BindingFlags.NonPublic);
if (b.Target.Member != null)
il.Emit (OpCodes.Ldstr, b.Target.Member.Name);
else
- il.Emit (OpCodes.Ldstr, b.Expression.Split ('/').LastOrDefault ());
+ il.Emit (OpCodes.Ldstr, b.Expression.Split ('/').LastOrDefault ().Split('.').LastOrDefault());
il.Emit (OpCodes.Ldc_I4_4);//StringComparison.Ordinal
il.Emit (OpCodes.Callvirt, stringEquals);
il.Emit (OpCodes.Brtrue, jumpTable [i]);
il.Emit (OpCodes.Callvirt, tostring.Method);
} else if (!sourceValueType.IsValueType)
il.Emit (OpCodes.Castclass, sourceValueType);
- else if (b.Source.Property.PropertyType != sourceValueType) {
+ else if (b.Source.Property.PropertyType != sourceValueType && b.Source.Property.PropertyType != typeof(object)) {
il.Emit (OpCodes.Callvirt, CompilerServices.GetConvertMethod (b.Source.Property.PropertyType));
} else
il.Emit (OpCodes.Unbox_Any, b.Source.Property.PropertyType);
il.Emit (OpCodes.Pop);
il.Emit (OpCodes.Ret);
- Delegate del = dm.CreateDelegate (eiValueChange.EventHandlerType, Bindings [0].Source.Instance);
- miValueChangeAdd.Invoke (grouped [0].Target.Instance, new object [] { del });
+ try {
+ Delegate del = dm.CreateDelegate (eiValueChange.EventHandlerType, Bindings [0].Source.Instance);
+ miValueChangeAdd.Invoke (grouped [0].Target.Instance, new object [] { del });
+
+ } catch (Exception ex) {
+ Debug.WriteLine ("Binding Delegate error for {0}: \n{1}", Bindings [0].Source.Instance, ex.ToString ());
+ }
}
}
}
if (tmp != null)
return tmp;
- if (dstType == typeof(string))
+ if (dstType == typeof(string) || dstType == typeof(object))//TODO:object should be allowed to return null and not ""
return "";
if (dstType.IsValueType)
return Activator.CreateInstance (dstType);
+
return null;
}
public static void emitGetInstance (ILGenerator il, NodeAddress orig, NodeAddress dest){
/// Emit conversion from orig type to dest type
/// </summary>
public static void emitConvert(ILGenerator il, Type origType, Type destType){
- if (destType == typeof(string))
+ if (destType == typeof(object))
+ return;
+ if (destType == typeof(string)) {
+ System.Reflection.Emit.Label emitNullStr = il.DefineLabel ();
+ System.Reflection.Emit.Label endConvert = il.DefineLabel ();
+ il.Emit (OpCodes.Dup);
+ il.Emit (OpCodes.Brfalse, emitNullStr);
il.Emit (OpCodes.Callvirt, CompilerServices.miObjToString);
- else if (origType.IsValueType) {
+ il.Emit (OpCodes.Br, endConvert);
+ il.MarkLabel (emitNullStr);
+ il.Emit (OpCodes.Pop);//remove null string from stack
+ il.Emit (OpCodes.Ldstr, "");//replace with empty string
+ il.MarkLabel (endConvert);
+ }else if (origType.IsValueType) {
if (destType != origType) {
il.Emit (OpCodes.Callvirt, CompilerServices.GetConvertMethod (destType));
}else
public static void RemoveEventHandlerByName(object instance, string eventName, string delegateName){
Type t = instance.GetType ();
FieldInfo fiEvt = CompilerServices.GetEventHandlerField (t, eventName);
+ if (fiEvt == null) {
+ Debug.WriteLine ("RemoveHandlerByName: Event '" + eventName + "' not found in " + instance);
+ return;
+ }
EventInfo eiEvt = t.GetEvent (eventName);
MulticastDelegate multiDel = fiEvt.GetValue (instance) as MulticastDelegate;
if (multiDel != null) {
}
}
}
-
+ internal static Delegate createDel(Type eventType, object instance, string method){
+ Type t = instance.GetType ();
+ MethodInfo mi = t.GetMethod (method);
+ if (mi == null)
+ return null;
+ return Delegate.CreateDelegate (eventType, instance, mi);
+ }
public static Delegate compileDynEventHandler(EventInfo sourceEvent, string expression, NodeAddress currentNode = null){
#if DEBUG_BINDING
Debug.WriteLine ("\tCompile Event {0}: {1}", sourceEvent.Name, expression);
throw new Exception ("Binding error: try to bind outside IML source");
ptr -= levelUp;
}
- Node[] targetNode = new Node[ptr+1];
- Array.Copy (sourceAddr.ToArray (), targetNode, ptr + 1);
- return new NodeAddress (targetNode);
+ //TODO:change Template special address identified with Nodecount = 0 to something not using array count to 0,
+ //here linq is working without limits checking in compile option
+ //but defining a 0 capacity array with limits cheking enabled, cause 'out of memory' error
+ return new NodeAddress (sourceAddr.Take(ptr+1).ToArray());//[ptr+1];
+ //Array.Copy (sourceAddr.ToArray (), targetNode, ptr + 1);
+ //return new NodeAddress (targetNode);
}
}
Vertical
}
- public enum Alignment : byte
+ public enum Alignment
{
Top = 0x01,
Left = 0x02,
--- /dev/null
+//
+// ColorPicker.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2016 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.Xml.Serialization;
+using System.ComponentModel;
+
+namespace Crow
+{
+ public class ColorPicker : TemplatedControl
+ {
+ public ColorPicker () : base ()
+ {
+ }
+
+ const double div = 255.0;
+ const double colDiv = 1.0 / div;
+
+ Color curColor;
+ double h,s,v;
+
+ [XmlAttributeAttribute()]
+ public virtual double R {
+ get { return Math.Round(curColor.R * div); }
+ set {
+ if (R == value)
+ return;
+ curColor.R = value * colDiv;
+ NotifyValueChanged ("R", R);
+ hsvFromRGB ();
+ notifyCurColorHasChanged ();
+ }
+ }
+ [XmlAttributeAttribute()]
+ public virtual double G {
+ get { return Math.Round(curColor.G * div); }
+ set {
+ if (G == value)
+ return;
+ curColor.G = value * colDiv;
+ NotifyValueChanged ("G", G);
+ notifyCurColorHasChanged ();
+ hsvFromRGB ();
+ }
+ }
+ [XmlAttributeAttribute()]
+ public virtual double B {
+ get { return Math.Round(curColor.B * div); }
+ set {
+ if (B == value)
+ return;
+ curColor.B = value * colDiv;
+ NotifyValueChanged ("B", B);
+ notifyCurColorHasChanged ();
+ hsvFromRGB ();
+ }
+ }
+ [XmlAttributeAttribute()]
+ public virtual double A {
+ get { return Math.Round(curColor.A * div); }
+ set {
+ if (A == value)
+ return;
+ curColor.A = value * colDiv;
+ NotifyValueChanged ("A", A);
+ notifyCurColorHasChanged ();
+ hsvFromRGB ();
+ }
+ }
+ [XmlAttributeAttribute()]
+ public virtual double H {
+ get { return Math.Round (h, 3); }
+ set {
+ if (H == value)
+ return;
+ h = value;
+ NotifyValueChanged ("H", H);
+ rgbFromHSV ();
+ }
+ }
+ [XmlAttributeAttribute()]
+ public virtual double S {
+ get { return Math.Round (s, 2); }
+ set {
+ if (s == value)
+ return;
+ s = value;
+ NotifyValueChanged ("S", S);
+ rgbFromHSV ();
+ }
+ }
+ [XmlAttributeAttribute()]
+ public virtual double V {
+ get { return Math.Round (v, 2); }
+ set {
+ if (v == value)
+ return;
+ v = value;
+ NotifyValueChanged ("V", V);
+ rgbFromHSV ();
+ }
+ }
+
+ [XmlAttributeAttribute]
+ public virtual Fill SelectedColor {
+ get { return new SolidColor(curColor); }
+ set {
+ Color c = (value as SolidColor).color;
+ if (curColor == c)
+ return;
+ curColor = c;
+ notifyCurColorHasChanged ();
+ notifyRGBAHasChanged ();
+ hsvFromRGB ();
+ }
+ }
+
+ void notifyCurColorHasChanged(){
+ NotifyValueChanged ("SelectedColor", SelectedColor);
+ string n = curColor.ToString ();
+ if (char.IsLetter(n[0]))
+ NotifyValueChanged ("SelectedColorName", n);
+ else
+ NotifyValueChanged ("SelectedColorName", "-");
+ NotifyValueChanged ("HexColor", ((int)R).ToString ("X2") + ((int)G).ToString ("X2") + ((int)B).ToString ("X2") + ((int)A).ToString ("X2"));
+ }
+ void notifyRGBAHasChanged(){
+ NotifyValueChanged ("R", R);
+ NotifyValueChanged ("G", G);
+ NotifyValueChanged ("B", B);
+ NotifyValueChanged ("A", A);
+ }
+ void notifyHSVHasChanged(){
+ NotifyValueChanged ("H", H);
+ NotifyValueChanged ("S", S);
+ NotifyValueChanged ("V", V);
+ }
+ void hsvFromRGB(){
+ Color c = curColor;
+ double min = Math.Min (c.R, Math.Min (c.G, c.B)); //Min. value of RGB
+ double max = Math.Max (c.R, Math.Max (c.G, c.B)); //Max. value of RGB
+ double diff = max - min; //Delta RGB value
+
+ v = max;
+
+ if ( diff == 0 )//This is a gray, no chroma...
+ {
+ h = 0;
+ s = 0;
+ }else{//Chromatic data...
+ s = diff / max;
+
+ double diffR = (((max - c.R) / 6.0) + (diff / 2.0)) / diff;
+ double diffG = (((max - c.G) / 6.0) + (diff / 2.0)) / diff;
+ double diffB = (((max - c.B) / 6.0) + (diff / 2.0)) / diff;
+
+ if (c.R == max)
+ h = diffB - diffG;
+ else if (c.G == max)
+ h = (1.0 / 3.0) + diffR - diffB;
+ else if (c.B == max)
+ h = (2.0 / 3.0) + diffG - diffR;
+
+ if (h < 0)
+ h += 1;
+ if (h > 1)
+ h -= 1;
+
+ }
+ notifyHSVHasChanged ();
+ }
+ void rgbFromHSV(){
+ Color c = Color.Black;
+
+ if (s == 0) {//HSV from 0 to 1
+ c.R = v;
+ c.G = v;
+ c.B = v;
+ }else{
+ double var_h = h * 6.0;
+
+ if (var_h == 6.0)
+ var_h = 0; //H must be < 1
+ double var_i = Math.Floor( var_h ); //Or ... var_i = floor( var_h )
+ double var_1 = v * ( 1.0 - s );
+ double var_2 = v * (1.0 - s * (var_h - var_i));
+ double var_3 = v * (1.0 - s * (1.0 - (var_h - var_i)));
+
+ if (var_i == 0.0) {
+ c.R = v;
+ c.G = var_3;
+ c.B = var_1;
+ }else if ( var_i == 1.0 ) { c.R = var_2 ; c.G = v ; c.B = var_1; }
+ else if ( var_i == 2 ) { c.R = var_1 ; c.G = v ; c.B = var_3; }
+ else if ( var_i == 3 ) { c.R = var_1 ; c.G = var_2 ; c.B = v; }
+ else if ( var_i == 4 ) { c.R = var_3 ; c.G = var_1 ; c.B = v; }
+ else { c.R = v ; c.G = var_1 ; c.B = var_2; }
+ }
+
+ curColor = c;
+ notifyCurColorHasChanged ();
+ notifyRGBAHasChanged ();
+ }
+ }
+}
+
--- /dev/null
+//
+// ColorPicker.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2016 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.Xml.Serialization;
+using System.ComponentModel;
+
+namespace Crow
+{
+ public class ColorSelector : GraphicObject
+ {
+ public ColorSelector (): base()
+ {
+ }
+
+ const double div = 255.0;
+ const double colDiv = 1.0 / div;
+ protected Point mousePos;
+
+ public override void onMouseMove (object sender, MouseMoveEventArgs e)
+ {
+ base.onMouseMove (sender, e);
+ if (CurrentInterface.Mouse.LeftButton == ButtonState.Released)
+ return;
+ updateMouseLocalPos (e.Position);
+ }
+ public override void onMouseDown (object sender, MouseButtonEventArgs e)
+ {
+ base.onMouseDown (sender, e);
+ if (e.Button == MouseButton.Left)
+ updateMouseLocalPos (e.Position);
+ }
+
+ protected virtual void updateMouseLocalPos(Point mPos){
+ Rectangle r = ScreenCoordinates (Slot);
+ Rectangle cb = ClientRectangle;
+ mousePos = mPos - r.Position;
+
+ mousePos.X = Math.Max(cb.X, mousePos.X);
+ mousePos.X = Math.Min(cb.Right-1, mousePos.X);
+ mousePos.Y = Math.Max(cb.Y, mousePos.Y);
+ mousePos.Y = Math.Min(cb.Bottom-1, mousePos.Y);
+ }
+// virtual protected void updateColorFromPicking(bool redraw = true){
+// SelectedColor = new SolidColor(getPixelAt(mousePos.X, mousePos.Y));
+//
+// updateHSV ();
+//
+// NotifyValueChanged ("R", R);
+// NotifyValueChanged ("G", G);
+// NotifyValueChanged ("B", B);
+// NotifyValueChanged ("A", A);
+//
+// if (redraw)
+// RegisterForRedraw ();
+// }
+//
+// protected Color getPixelAt(int x, int y){
+// if (bmp == null)
+// return Color.Transparent;
+//
+// int ptr = y * Slot.Width * 4 + x * 4;
+//
+// return new Color(
+// (double)bmp[ptr + 2] * colDiv,
+// (double)bmp[ptr + 1] * colDiv,
+// (double)bmp[ptr] * colDiv,
+// (double)bmp[ptr + 3] * colDiv);
+// }
+ }
+}
+
OldDataSource = oldDataSource;
NewDataSource = newDataSource;
}
+ public override string ToString ()
+ {
+ return string.Format ("DSChangeEA: {0} => {1}", OldDataSource, NewDataSource);
+ }
}
}
NotifyValueChanged ("SelectedItem", _selectedItem);
}
}
- [XmlAttributeAttribute()][DefaultValue(false)]
+ [XmlAttributeAttribute()][DefaultValue(true)]
public virtual bool ShowFiles {
get { return showFiles; }
set {
}
[XmlIgnore]public FileSystemInfo[] FileSystemEntries {
get {
- return showFiles ? new DirectoryInfo (CurrentDirectory).GetFileSystemInfos ():
- new DirectoryInfo(currentDirectory).GetDirectories();
+ return string.IsNullOrEmpty(CurrentDirectory) ? null :
+ showFiles ?
+ new DirectoryInfo (CurrentDirectory).GetFileSystemInfos () :
+ new DirectoryInfo(CurrentDirectory).GetDirectories();
}
}
public void onSelectedItemChanged (object sender, SelectionChangeEventArgs e){
public event EventHandler Collapse;
#endregion
- #region GraphicObject overrides
- public override void onMouseClick (object sender, MouseButtonEventArgs e)
+ public BooleanTestOnInstance GetIsExpandable;
+
+ public void onClickForExpand (object sender, MouseButtonEventArgs e)
{
- if (this.HasFocus)
- IsExpanded = !IsExpanded;
- base.onMouseClick (sender, e);
+ IsExpanded = !IsExpanded;
}
- #endregion
public override GraphicObject Content {
get {
}
#region Public properties
- [XmlAttributeAttribute()][DefaultValue("Expandable")]
+ [XmlAttributeAttribute][DefaultValue("Expandable")]
public string Caption {
get { return caption; }
set {
NotifyValueChanged ("Caption", caption);
}
}
- [XmlAttributeAttribute()][DefaultValue("#Crow.Images.Icons.expandable.svg")]
+ [XmlAttributeAttribute][DefaultValue("#Crow.Images.Icons.expandable.svg")]
public string Image {
get { return image; }
set {
NotifyValueChanged ("Image", image);
}
}
- [XmlAttributeAttribute()][DefaultValue(false)]
+ [XmlAttributeAttribute][DefaultValue(false)]
public bool IsExpanded
{
get { return _isExpanded; }
_isExpanded = value;
- if (!HasContent)
+ bool isExp = IsExpandable;
+ NotifyValueChanged ("IsExpandable", isExp);
+ if (!(HasContent & isExp))
_isExpanded = false;
NotifyValueChanged ("IsExpanded", _isExpanded);
[XmlIgnore]public bool HasContent {
get { return _contentContainer == null ? false : _contentContainer.Child != null; }
}
-
+ [XmlIgnore]public bool IsExpandable {
+ get {
+ try {
+ return GetIsExpandable == null ? true : GetIsExpandable (this);
+ } catch (Exception ex) {
+ System.Diagnostics.Debug.WriteLine ("Not Expandable error: " + ex.ToString ());
+ return false;
+ }
+ }
+ }
#endregion
public virtual void onExpand(object sender, EventArgs e)
namespace Crow
{
- public class FileDialog: IValueChange
+ public class FileDialog: Window
{
- #region IValueChange implementation
- public event EventHandler<ValueChangeEventArgs> ValueChanged;
- public virtual void NotifyValueChanged(string MemberName, object _value)
- {
- ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value));
- }
- #endregion
-
- Window window;
- DirectoryInfo currentDir;
- FileInfo selectedFile;
- string searchPattern = "*";
+ string searchPattern, curDirectory;
#region CTOR
- public FileDialog ()
+ public FileDialog () : base()
{
- currentDir = new DirectoryInfo (Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
- //window = Interface..Load("#Crow.Templates.FileDialog.goml") as Window;
- window.DataSource = this;
}
#endregion
-
- public string CurrentPath {
- get { return currentDir.FullName; }
+ //[DefaultValue(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))]
+ [XmlAttributeAttribute][DefaultValue("/home")]
+ public virtual string CurrentDirectory {
+ get { return curDirectory; }
set {
- currentDir = new DirectoryInfo (value);
- NotifyValueChanged ("CurrentPath", CurrentPath);
+ if (curDirectory == value)
+ return;
+ curDirectory = value;
+ NotifyValueChanged ("CurrentDirectory", curDirectory);
+
}
- }
- public string SearchPattern {
+ }
+
+ [XmlAttributeAttribute()][DefaultValue("*")]
+ public virtual string SearchPattern {
get { return searchPattern; }
set {
- searchPattern = value;
- NotifyValueChanged ("Files", Files);
- }
- }
+ if (searchPattern == value)
+ return;
+ searchPattern = value;
+ NotifyValueChanged ("SearchPattern", searchPattern);
- public DirectoryInfo[] Directories
- {
- get {
- //currentDir.GetDirectories
- List<DirectoryInfo> tmp = currentDir.GetDirectories ().Where(fi => !fi.Attributes.HasFlag(FileAttributes.Hidden)).ToList();
- if (currentDir.Parent != null)
- tmp.Insert (0, currentDir.Parent);
- return tmp.ToArray ();
}
- }
- public FileInfo[] Files
- {
- get {
- string[] exts = searchPattern.Replace("*","").Split ('|');
- //return currentDir.GetFiles (searchPattern).Where(fi => !fi.Attributes.HasFlag(FileAttributes.Hidden)).ToArray();
- return currentDir.GetFiles().Where(f => exts.Any
- (x => f.Name.EndsWith (x, StringComparison.InvariantCultureIgnoreCase))).ToArray();
- }
- }
-
- public void Show(){
- //.AddWidget(window);
- }
-
- void OnSelectedItemChanged (object sender, SelectionChangeEventArgs e)
- {
- currentDir = e.NewValue as DirectoryInfo;
- NotifyValueChanged ("CurrentPath", CurrentPath);
- NotifyValueChanged ("Directories", Directories);
- NotifyValueChanged ("Files", Files);
-
- }
- void onFileListItemChanged (object sender, SelectionChangeEventArgs e)
- {
- selectedFile = e.NewValue as FileInfo;
- }
- void onFileSelect(object sender, MouseButtonEventArgs e){
- //OpenTKGameWindow.currentWindow.DeleteWidget(window);
- }
- }
- public class DirContainer: IValueChange
- {
- #region IValueChange implementation
- public event EventHandler<ValueChangeEventArgs> ValueChanged;
- public void NotifyValueChanged(string name, object value)
- {
- ValueChanged.Raise (this, new ValueChangeEventArgs (name, value));
- }
- #endregion
+ }
- public DirectoryInfo CurDir;
- public DirContainer(DirectoryInfo _dir){
- CurDir = _dir;
- }
- public string Name {
- get { return CurDir.Name; }
- }
-
- void onDirUp(object sender, MouseButtonEventArgs e)
- {
-
- }
- public void onMouseDown(object sender, MouseButtonEventArgs e)
- {
- Debug.WriteLine (sender.ToString ());
- }
+// public DirectoryInfo[] Directories
+// {
+// get {
+// //currentDir.GetDirectories
+// List<DirectoryInfo> tmp = currentDir.GetDirectories ().Where(fi => !fi.Attributes.HasFlag(FileAttributes.Hidden)).ToList();
+// if (currentDir.Parent != null)
+// tmp.Insert (0, currentDir.Parent);
+// return tmp.ToArray ();
+// }
+// }
+// public FileInfo[] Files
+// {
+// get {
+// string[] exts = searchPattern.Replace("*","").Split ('|');
+// //return currentDir.GetFiles (searchPattern).Where(fi => !fi.Attributes.HasFlag(FileAttributes.Hidden)).ToArray();
+// return currentDir.GetFiles().Where(f => exts.Any
+// (x => f.Name.EndsWith (x, StringComparison.InvariantCultureIgnoreCase))).ToArray();
+// }
+// }
+// void OnSelectedItemChanged (object sender, SelectionChangeEventArgs e)
+// {
+// currentDir = e.NewValue as DirectoryInfo;
+// NotifyValueChanged ("CurrentPath", CurrentPath);
+// NotifyValueChanged ("Directories", Directories);
+// NotifyValueChanged ("Files", Files);
+//
+// }
+// void onFileListItemChanged (object sender, SelectionChangeEventArgs e)
+// {
+// selectedFile = e.NewValue as FileInfo;
+// }
+// void onFileSelect(object sender, MouseButtonEventArgs e){
+// //OpenTKGameWindow.currentWindow.DeleteWidget(window);
+// }
}
+// public class DirContainer: IValueChange
+// {
+// #region IValueChange implementation
+// public event EventHandler<ValueChangeEventArgs> ValueChanged;
+// public void NotifyValueChanged(string name, object value)
+// {
+// ValueChanged.Raise (this, new ValueChangeEventArgs (name, value));
+// }
+// #endregion
+//
+// public DirectoryInfo CurDir;
+// public DirContainer(DirectoryInfo _dir){
+// CurDir = _dir;
+// }
+// public string Name {
+// get { return CurDir.Name; }
+// }
+//
+// void onDirUp(object sender, MouseButtonEventArgs e)
+// {
+//
+// }
+// public void onMouseDown(object sender, MouseButtonEventArgs e)
+// {
+// Debug.WriteLine (sender.ToString ());
+// }
+//
+// }
}
Interface currentInterface = null;
- public Interface CurrentInterface {
+ [XmlIgnore]public Interface CurrentInterface {
get {
if (currentInterface == null) {
currentInterface = Interface.CurrentInterface;
public event EventHandler<ValueChangeEventArgs> ValueChanged;
public virtual void NotifyValueChanged(string MemberName, object _value)
{
+ //Debug.WriteLine ("Value changed: {0}->{1} = {2}", this, MemberName, _value);
ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value));
}
#endregion
verticalAlignment = value;
NotifyValueChanged("VerticalAlignment", verticalAlignment);
+ RegisterForLayouting (LayoutingType.Y);
}
}
[XmlAttributeAttribute()][DefaultValue(HorizontalAlignment.Center)]
horizontalAlignment = value;
NotifyValueChanged("HorizontalAlignment", horizontalAlignment);
+ RegisterForLayouting (LayoutingType.X);
}
}
[XmlAttributeAttribute()][DefaultValue(0)]
Width = Height = Measure.Fit;
}
}
- [XmlAttributeAttribute()][DefaultValue("Stretched")]
+ [XmlAttributeAttribute()][DefaultValue("Inherit")]
public virtual Measure Width {
- get { return width; }
+ get {
+ return width.Units == Unit.Inherit ?
+ Parent is GraphicObject ? (Parent as GraphicObject).WidthPolicy :
+ Measure.Stretched : width;
+ }
set {
if (width == value)
return;
this.RegisterForLayouting (LayoutingType.Width);
}
}
- [XmlAttributeAttribute()][DefaultValue("Stretched")]
+ [XmlAttributeAttribute()][DefaultValue("Inherit")]
public virtual Measure Height {
- get { return height; }
+ get {
+ return height.Units == Unit.Inherit ?
+ Parent is GraphicObject ? (Parent as GraphicObject).HeightPolicy :
+ Measure.Stretched : height;
+ }
set {
if (height == value)
return;
set {
if (background == value)
return;
+ if (value == null)
+ return;
background = value;
NotifyValueChanged ("Background", background);
RegisterForRedraw ();
MouseMove.Raise (sender, e);
}
public virtual void onMouseDown(object sender, MouseButtonEventArgs e){
+ if (CurrentInterface.eligibleForDoubleClick == this && CurrentInterface.clickTimer.ElapsedMilliseconds < Interface.DoubleClick)
+ onMouseDoubleClick (this, e);
+ else
+ currentInterface.clickTimer.Restart();
+ CurrentInterface.eligibleForDoubleClick = null;
+
if (CurrentInterface.activeWidget == null)
CurrentInterface.activeWidget = this;
if (this.Focusable && !Interface.FocusOnHover) {
MouseUp.Raise (this, e);
- if (MouseIsIn (e.Position) && IsActive)
+ if (MouseIsIn (e.Position) && IsActive) {
+ if (CurrentInterface.clickTimer.ElapsedMilliseconds < Interface.DoubleClick)
+ CurrentInterface.eligibleForDoubleClick = this;
onMouseClick (this, e);
+ }
}
public virtual void onMouseClick(object sender, MouseButtonEventArgs e){
-
- if (Interface.clickTimer.ElapsedMilliseconds > 0 &&
- Interface.clickTimer.ElapsedMilliseconds < Interface.DoubleClick) {
- Interface.clickTimer.Reset ();
- onMouseDoubleClick (this, e);
- return;
- } else
- Interface.clickTimer.Restart ();
-
GraphicObject p = Parent as GraphicObject;
if (p != null)
p.onMouseClick(sender,e);
--- /dev/null
+//
+// HueSelector.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2016 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.Xml.Serialization;
+using System.ComponentModel;
+using Cairo;
+
+namespace Crow
+{
+ public class HueSelector : ColorSelector
+ {
+ public HueSelector () : base()
+ {
+ }
+
+ Orientation _orientation;
+ double hue;
+
+ [XmlAttributeAttribute][DefaultValue(Orientation.Horizontal)]
+ public virtual Orientation Orientation
+ {
+ get { return _orientation; }
+ set {
+ if (_orientation == value)
+ return;
+ _orientation = value;
+ NotifyValueChanged ("Orientation", _orientation);
+ RegisterForGraphicUpdate ();
+ }
+ }
+ [XmlAttributeAttribute()]
+ public virtual double Hue {
+ get { return hue; }
+ set {
+ if (hue == value)
+ return;
+ hue = value;
+
+ notifyHueChanged ();
+ updateMousePosFromHue ();
+ }
+ }
+ protected override void onDraw (Cairo.Context gr)
+ {
+ base.onDraw (gr);
+
+ Rectangle r = ClientRectangle;
+
+ Gradient.Type gt = Gradient.Type.Horizontal;
+ if (Orientation == Orientation.Vertical)
+ gt = Gradient.Type.Vertical;
+
+ Crow.Gradient grad = new Gradient (gt);
+
+ grad.Stops.Add (new Gradient.ColorStop (0, new Color (1, 0, 0, 1)));
+ grad.Stops.Add (new Gradient.ColorStop (0.167, new Color (1, 1, 0, 1)));
+ grad.Stops.Add (new Gradient.ColorStop (0.333, new Color (0, 1, 0, 1)));
+ grad.Stops.Add (new Gradient.ColorStop (0.5, new Color (0, 1, 1, 1)));
+ grad.Stops.Add (new Gradient.ColorStop (0.667, new Color (0, 0, 1, 1)));
+ grad.Stops.Add (new Gradient.ColorStop (0.833, new Color (1, 0, 1, 1)));
+ grad.Stops.Add (new Gradient.ColorStop (1, new Color (1, 0, 0, 1)));
+
+ grad.SetAsSource (gr, r);
+ CairoHelpers.CairoRectangle (gr, r, CornerRadius);
+ gr.Fill();
+ }
+
+ public override void Paint (ref Context ctx)
+ {
+ base.Paint (ref ctx);
+
+ Rectangle rb = Slot + Parent.ClientRectangle.Position;
+ ctx.Save ();
+
+ ctx.Translate (rb.X, rb.Y);
+
+ ctx.SetSourceColor (Color.White);
+ Rectangle r = ClientRectangle;
+ if (Orientation == Orientation.Horizontal) {
+ r.Width = 5;
+ r.X = mousePos.X;
+ } else {
+ r.Height = 5;
+ r.Y = mousePos.Y;
+ }
+
+ CairoHelpers.CairoRectangle (ctx, r, 2);
+ ctx.SetSourceColor (Color.White);
+ ctx.LineWidth = 2.0;
+ ctx.Stroke();
+ ctx.Restore ();
+ }
+ public override void OnLayoutChanges (LayoutingType layoutType)
+ {
+ base.OnLayoutChanges (layoutType);
+
+ if (Orientation == Orientation.Horizontal) {
+ if (layoutType == LayoutingType.Width)
+ updateMousePosFromHue ();
+ } else if (layoutType == LayoutingType.Height)
+ updateMousePosFromHue ();
+ }
+ protected override void updateMouseLocalPos (Point mPos)
+ {
+ base.updateMouseLocalPos (mPos);
+ if (Orientation == Orientation.Horizontal)
+ hue = (double)mousePos.X / (double)ClientRectangle.Width;
+ else
+ hue = (double)mousePos.Y / (double)ClientRectangle.Height;
+ notifyHueChanged ();
+ }
+ void updateMousePosFromHue(){
+ if (Orientation == Orientation.Horizontal)
+ mousePos.X = (int)Math.Floor(hue * (double)ClientRectangle.Width);
+ else
+ mousePos.Y = (int)Math.Floor(hue * (double)ClientRectangle.Height);
+ CurrentInterface.EnqueueForRepaint (this);
+ }
+ void notifyHueChanged(){
+ NotifyValueChanged ("Hue", hue);
+ NotifyValueChanged ("HueColor", new SolidColor (Color.FromHSV (hue)));
+ }
+ }
+}
+
public override void onMouseLeave (object sender, MouseMoveEventArgs e)
{
base.onMouseLeave (sender, e);
- IsOpened = false;
+ //IsOpened = false;
}
}
}
if (isOpened) {
onOpen (this, null);
- if (MenuRoot != null)
- MenuRoot.IsOpened = true;
+// if (MenuRoot != null)
+// MenuRoot.IsOpened = true;
}else
onClose (this, null);
}
Execute.Raise (this, null);
}
protected virtual void onOpen (object sender, EventArgs e){
- MenuRoot.IsOpened = true;
+ //MenuRoot.IsOpened = true;
Open.Raise (this, null);
}
protected virtual void onClose (object sender, EventArgs e){
protected void _content_LayoutChanged (object sender, LayoutingEventArgs e)
{
- ILayoutable tc = Content.Parent as ILayoutable;
+ ILayoutable tc = Content.Parent;
if (tc == null)
return;
Rectangle r = this.ScreenCoordinates (this.Slot);
{
if (!_isPopped || _content == null) {
base.onMouseLeave (sender, e);
- System.Diagnostics.Debug.WriteLine ("NotPopped***popper mouse leave:"+ this.ToString());
return;
}
if (!_content.MouseIsIn (e.Position)) {
base.onMouseLeave (sender, e);
- System.Diagnostics.Debug.WriteLine ("***popper mouse leave:"+ this.ToString());
IsPopped = false;
return;
}
--- /dev/null
+//
+// SaturationValueSelector.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2016 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 Cairo;
+using System.Xml.Serialization;
+
+namespace Crow
+{
+ public class SaturationValueSelector : ColorSelector
+ {
+ public SaturationValueSelector () : base()
+ {
+ }
+
+ double v, s;
+
+ [XmlAttributeAttribute()]
+ public virtual double V {
+ get { return v; }
+ set {
+ if (v == value)
+ return;
+ v = value;
+ NotifyValueChanged ("V", v);
+ mousePos.Y = (int)Math.Floor((1.0-v) * (double)ClientRectangle.Height);
+
+ CurrentInterface.EnqueueForRepaint (this);
+ }
+ }
+ [XmlAttributeAttribute()]
+ public virtual double S {
+ get { return s; }
+ set {
+ if (s == value)
+ return;
+ s = value;
+ NotifyValueChanged ("S", s);
+ mousePos.X = (int)Math.Floor(s * (double)ClientRectangle.Width);
+ CurrentInterface.EnqueueForRepaint (this);
+ }
+ }
+ protected override void onDraw (Cairo.Context gr)
+ {
+ base.onDraw (gr);
+
+ Rectangle r = ClientRectangle;
+ Rectangle rGrad = r;
+ rGrad.Inflate (-1);
+
+ if (Foreground != null) {//TODO:test if null should be removed
+ Foreground.SetAsSource (gr, r);
+ CairoHelpers.CairoRectangle (gr, r, CornerRadius);
+ gr.Fill ();
+ }
+
+ Crow.Gradient grad = new Gradient (Gradient.Type.Horizontal);
+ grad.Stops.Add (new Gradient.ColorStop (0, new Color (1, 1, 1, 1)));
+ grad.Stops.Add (new Gradient.ColorStop (1, new Color (1, 1, 1, 0)));
+ grad.SetAsSource (gr, rGrad);
+ CairoHelpers.CairoRectangle (gr, r, CornerRadius);
+ gr.Fill();
+ grad = new Gradient (Gradient.Type.Vertical);
+ grad.Stops.Add (new Gradient.ColorStop (0, new Color (0, 0, 0, 0)));
+ grad.Stops.Add (new Gradient.ColorStop (1, new Color (0, 0, 0, 1)));
+ grad.SetAsSource (gr, rGrad);
+ CairoHelpers.CairoRectangle (gr, r, CornerRadius);
+ gr.Fill();
+ }
+
+ public override void Paint (ref Context ctx)
+ {
+ base.Paint (ref ctx);
+
+ Rectangle rb = Slot + Parent.ClientRectangle.Position;
+ ctx.Save ();
+
+ ctx.Translate (rb.X, rb.Y);
+
+ ctx.SetSourceColor (Color.White);
+ ctx.Arc (mousePos.X, mousePos.Y, 3.0, 0, Math.PI * 2.0);
+ ctx.LineWidth = 1.0;
+ ctx.Stroke ();
+
+ ctx.Restore ();
+ }
+
+ protected override void updateMouseLocalPos (Point mPos)
+ {
+ base.updateMouseLocalPos (mPos);
+
+ Rectangle cb = ClientRectangle;
+ s = (double)mousePos.X / (double)cb.Width;
+ v = 1.0 - (double)mousePos.Y / (double)cb.Height;
+ NotifyValueChanged ("S", s);
+ NotifyValueChanged ("V", v);
+ }
+ public override void OnLayoutChanges (LayoutingType layoutType)
+ {
+ base.OnLayoutChanges (layoutType);
+ switch (layoutType) {
+ case LayoutingType.Width:
+ mousePos.X = (int)Math.Floor(s * (double)ClientRectangle.Width);
+ break;
+ case LayoutingType.Height:
+ mousePos.Y = (int)Math.Floor((1.0-v) * (double)ClientRectangle.Height);
+ break;
+ }
+ }
+ }
+}
+
#endregion
protected Group items;
- string _itemTemplate;
+ string _itemTemplate, _dataTest;
#region events
public event EventHandler<SelectionChangeEventArgs> SelectedItemChanged;
//but then i should test if null in msil gen
public Dictionary<string, ItemTemplate> ItemTemplates = new Dictionary<string, Crow.ItemTemplate>();
+ /// <summary>
+ /// Default item template
+ /// </summary>
[XmlAttributeAttribute][DefaultValue("#Crow.Templates.ItemTemplate.goml")]
public string ItemTemplate {
get { return _itemTemplate; }
else
NotifyValueChanged ("HasChildren", true);
}
+ /// <summary>
+ /// Use to define condition on Data item for selecting among ItemTemplates.
+ /// Default value is 'TypeOf' for selecting Template depending on Type of Data.
+ /// Other possible values are properties of Data
+ /// </summary>
+ /// <value>The data property test.</value>
+ [XmlAttributeAttribute][DefaultValue("TypeOf")]
+ public string DataTest {
+ get { return _dataTest; }
+ set {
+ if (value == _dataTest)
+ return;
+
+ _dataTest = value;
+
+ NotifyValueChanged("DataTest", _dataTest);
+ }
+ }
#endregion
public virtual List<GraphicObject> Items{ get { return items.Children; }}
[XmlIgnore]public virtual object SelectedItem{
get { return data == null ? null : _selectedIndex < 0 ? null : data[_selectedIndex]; }
}
-
+ [XmlIgnore]public bool HasItems {
+ get { return Items.Count > 0; }
+ }
[XmlAttributeAttribute]public IList Data {
get { return data; }
set {
NotifyValueChanged ("Data", data);
- lock (CurrentInterface.UpdateMutex)
+ //lock (CurrentInterface.UpdateMutex)
ClearItems ();
if (data == null)
NotifyValueChanged ("SelectedIndex", _selectedIndex);
NotifyValueChanged ("SelectedItem", SelectedItem);
SelectedItemChanged.Raise (this, new SelectionChangeEventArgs (SelectedItem));
+ NotifyValueChanged ("HasItems", HasItems);
}
}
page.Name = "page" + pageNum;
-// //reset size to fit in the dir of the stacking
-// //because items total size is forced to approx size
-// if (_gsList.Orientation == Orientation.Horizontal) {
-// page.Width = Measure.Fit;
- //page.BindMember ("Height", "../HeightPolicy");
- //page.BindMember ("Width", "../WidthPolicy");
-// } else {
-// page.Height = Measure.Fit;
-// page.BindMember ("Width", "../WidthPolicy");
-// }
-
for (int i = (pageNum - 1) * itemPerPage; i < pageNum * itemPerPage; i++) {
if (i >= data.Count)
break;
return;
loadItem (i, page);
-
- //g.LogicalParent = this;
}
lock (CurrentInterface.LayoutMutex)
loadingTime.ElapsedMilliseconds, this.ToString());
#endif
}
+ string getItempKey(Type dataType, object o){
+ try {
+ return dataType.GetProperty (_dataTest).GetGetMethod ().Invoke (o, null).ToString();
+ } catch (Exception ex) {
+ return dataType.FullName;
+ }
+ }
protected void loadItem(int i, Group page){
GraphicObject g = null;
ItemTemplate iTemp = null;
Type dataType = data [i].GetType ();
+ string itempKey = dataType.FullName;
+
+ if (_dataTest != "TypeOf")
+ itempKey = getItempKey (dataType, data [i]);
- if (ItemTemplates.ContainsKey (dataType.FullName))
- iTemp = ItemTemplates [dataType.FullName];
+ if (ItemTemplates.ContainsKey (itempKey))
+ iTemp = ItemTemplates [itempKey];
else
iTemp = ItemTemplates ["default"];
lock (CurrentInterface.LayoutMutex) {
g = iTemp.CreateInstance(CurrentInterface);
page.AddChild (g);
- g.DataSource = data [i];
+ registerItemClick (g);
}
- registerItemClick (g);
-
if (iTemp.Expand != null && g is Expandable) {
(g as Expandable).Expand += iTemp.Expand;
- }
+ (g as Expandable).GetIsExpandable = iTemp.HasSubItems;
+ }
+ //g.LogicalParent = this;
+
+
+ g.DataSource = data [i];
}
protected virtual void registerItemClick(GraphicObject g){
g.MouseClick += itemClick;
continue;
}
}
-
+
+ if (bd is EventBinding) {
+ emitHandlerMethodAddition (bd as EventBinding);
+ continue;
+ }
+
MemberInfo miSource = bd.SourceMemberAddress.member;
if (miSource == null)
throw new Exception ("Source member '" + bd.SourceMember + "' not found");
- if (miSource.MemberType == MemberTypes.Event)
- emitHandlerMethodAddition (bd, miSource as EventInfo);
- else
- StorePropertyBinding (bd);
+ StorePropertyBinding (bd);
}
}
public void ResolveName (BindingDefinition bd){
/// </summary>
/// <param name="bd">Bd.</param>
/// <param name="evt">passed as arg to prevent refetching it for the 3rd time</param>
- public void emitHandlerMethodAddition(BindingDefinition bd, EventInfo evt){
+ public void emitHandlerMethodAddition(EventBinding bd){
//fetch source instance with address for handler addition (as 1st arg of handler.add)
il.Emit (OpCodes.Ldloc_0);//push root
CompilerServices.emitGetInstance (il, bd.SourceNA);
//load handlerType of sourceEvent to create handler delegate (1st arg)
- il.Emit (OpCodes.Ldtoken, evt.EventHandlerType);
+ il.Emit (OpCodes.Ldtoken, bd.SourceEvent.EventHandlerType);
il.Emit (OpCodes.Call, CompilerServices.miGetTypeFromHandle);
//load target the where the method is defined (2nd arg)
il.Emit (OpCodes.Ldloc_0);
CompilerServices.emitGetInstance (il, bd.TargetNA);
//load methodInfo (3rd arg)
- il.Emit (OpCodes.Ldtoken, bd.TargetMemberAddress.member as MethodInfo);
- il.Emit (OpCodes.Call, CompilerServices.miGetTypeFromHandle);
-
- il.Emit (OpCodes.Callvirt, typeof(Delegate).GetMethod ("CreateDelegate",
- new Type[] { typeof(Type), typeof(object), typeof(MethodInfo) }));//create bound delegate
+ il.Emit (OpCodes.Ldstr, bd.TargetMember);
+ //il.Emit (OpCodes.Call, CompilerServices.miGetTypeFromHandle);
+
+ //il.Emit (OpCodes.Pop);
+ //il.Emit (OpCodes.Pop);
+ //il.Emit (OpCodes.Pop);
+ //il.Emit (OpCodes.Pop);
+ il.Emit (OpCodes.Callvirt, typeof(CompilerServices).GetMethod ("createDel", BindingFlags.Static | BindingFlags.NonPublic));
+ //il.Emit (OpCodes.Callvirt, typeof(Delegate).GetMethod ("CreateDelegate",
+ // new Type[] { typeof(Type), typeof(object), typeof(MethodInfo) }));//create bound delegate
- il.Emit (OpCodes.Callvirt, evt.AddMethod);//call add event
+ il.Emit (OpCodes.Callvirt, bd.SourceEvent.AddMethod);//call add event
}
+
}
}
\ No newline at end of file
--- /dev/null
+//
+// EventBinding.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2016 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.Reflection;
+
+namespace Crow.IML
+{
+ public class EventBinding : BindingDefinition
+ {
+ public EventInfo SourceEvent;
+
+ #region CTOR
+ public EventBinding (NodeAddress _sourceNA, EventInfo _sourceEvt, NodeAddress _targetNA, string _targetMember, string _targetName = "")
+ : base (_sourceNA, _sourceEvt.Name, _targetNA, _targetMember, _targetName)
+ {
+ SourceEvent = _sourceEvt;
+ }
+ #endregion
+ }
+}
+
System.Reflection.Emit.Label finish = il.DefineLabel ();
il.Emit (OpCodes.Br, finish);
il.MarkLabel (cancel);
- il.EmitWriteLine (string.Format ("Handler method '{0}' not found. {1}={2} ", bindingDef.TargetMember, sourceEvent.Name, expression));
+ il.EmitWriteLine (string.Format ("Handler method '{0}' for '{1}' not found in new dataSource ", bindingDef.TargetMember, sourceEvent.Name));
il.MarkLabel (finish);
il.Emit (OpCodes.Ret);
else //template handler binding, will be added to root parentChanged
templateCachedDelegateIndices.Add (delDSIndex);
} else {//normal in tree handler binding, store until tree is complete (end of parse)
-
+ ctx.UnresolvedTargets.Add (new EventBinding (
+ bindingDef.SourceNA, sourceEvent,
+ bindingDef.TargetNA, bindingDef.TargetMember, bindingDef.TargetName));
}
}
#endregion
il.Emit (OpCodes.Call, typeof(CompilerServices).GetMethod("getMemberInfoWithReflexion", BindingFlags.Static | BindingFlags.Public));
il.Emit (OpCodes.Stloc_1);//save memberInfo
il.Emit (OpCodes.Ldloc_1);//push mi for test if null
- il.Emit (OpCodes.Brfalse, cancelInit);
+ il.Emit (OpCodes.Brfalse, cancel);
}
il.Emit (OpCodes.Ldarg_1);//load source of dataSourceChanged which is the dest instance
if (!string.IsNullOrEmpty(bindingDef.TargetMember)){
il.MarkLabel(cancelInit);
+ //check if new dataSource implement IValueChange
+ il.Emit (OpCodes.Ldarg_2);//load new datasource
+ il.Emit (OpCodes.Ldfld, CompilerServices.fiDSCNewDS);
+ il.Emit (OpCodes.Isinst, typeof(IValueChange));
+ il.Emit (OpCodes.Brfalse, cancel);
il.Emit(OpCodes.Ldarg_0);//load ref to this instanciator onto the stack
il.Emit (OpCodes.Ldarg_1);//load datasource change source
#region Static and constants
public static int DoubleClick = 200;//ms
- internal static Stopwatch clickTimer = new Stopwatch();
+ internal Stopwatch clickTimer = new Stopwatch();
+ internal GraphicObject eligibleForDoubleClick = null;
public static int TabSize = 4;
public static string LineBreak = "\r\n";
//TODO: shold be declared in graphicObject
namespace Crow
{
+ public delegate bool BooleanTestOnInstance(object instance);
+
public class ItemTemplate : Instantiator {
public EventHandler Expand;
+ public BooleanTestOnInstance HasSubItems;
string strDataType;
string fetchMethodName;
public void CreateExpandDelegate (TemplatedGroup host){
Type dataType = Type.GetType(strDataType);
Type tmpGrpType = typeof(TemplatedGroup);
- Type hostType = tmpGrpType;//not sure is the best place to put the dyn method
Type evtType = typeof(EventHandler);
PropertyInfo piData = tmpGrpType.GetProperty ("Data");
Type handlerArgsType = evtParams [1].ParameterType;
Type [] args = { typeof (object), typeof (object), handlerArgsType };
- DynamicMethod dm = new DynamicMethod ("dyn_expand_" + fetchMethodName,
- typeof (void),
- args,
- hostType);
+ #region Expand dyn meth
+ //DM is bound to templatedGroup root (arg0)
+ //arg1 is the sender of the expand event
+ DynamicMethod dm = new DynamicMethod ("dyn_expand_" + fetchMethodName,
+ typeof (void), args, true);
- #region IL generation
System.Reflection.Emit.Label gotoEnd;
System.Reflection.Emit.Label ifDataIsNull;
il.Emit (OpCodes.Ldarg_1);//load sender of expand event
- MethodInfo miFindByName = typeof(GraphicObject).GetMethod("FindByName");
il.Emit(OpCodes.Ldstr, "List");
- il.Emit (OpCodes.Callvirt, miFindByName);
+ il.Emit (OpCodes.Callvirt, typeof(GraphicObject).GetMethod("FindByName"));
il.Emit (OpCodes.Stloc_0);
//check that 'Data' of list is not already set
il.Emit (OpCodes.Ldarg_1);//get the dataSource of the sender
il.Emit (OpCodes.Callvirt, typeof(GraphicObject).GetProperty("DataSource").GetGetMethod ());
- if (fetchMethodName != "self"){//special keyword self allows the use of recurent list<<<
- emitGetSubData(il, dataType);
- }
+ if (fetchMethodName != "self")//special keyword self allows the use of recurent list<<<
+ emitGetSubData(il, dataType);
//set 'return' from the fetch method as 'data' of the list
il.Emit (OpCodes.Callvirt, piData.GetSetMethod ());
il.MarkLabel(gotoEnd);
il.Emit (OpCodes.Ret);
+ Expand = (EventHandler)dm.CreateDelegate (evtType, host);
#endregion
- Expand = (EventHandler)dm.CreateDelegate (evtType, host);
+ #region Items counting dyn method
+ //dm is unbound, arg0 is instance of Item container to expand
+ dm = new DynamicMethod ("dyn_count_" + fetchMethodName,
+ typeof (bool), new Type[] {typeof(object)}, true);
+ il = dm.GetILGenerator (256);
+
+ //get the dataSource of the arg0
+ il.Emit (OpCodes.Ldarg_0);
+ il.Emit (OpCodes.Callvirt, typeof(GraphicObject).GetProperty("DataSource").GetGetMethod ());
+
+ if (fetchMethodName != "self")
+ emitGetSubData(il, dataType);
+
+ il.Emit (OpCodes.Callvirt, typeof(System.Collections.ICollection).GetProperty("Count").GetGetMethod());
+ il.Emit (OpCodes.Ldc_I4_0);
+ il.Emit (OpCodes.Cgt);
+ il.Emit (OpCodes.Ret);
+ HasSubItems = (BooleanTestOnInstance)dm.CreateDelegate (typeof(BooleanTestOnInstance));
+ #endregion
}
void emitGetSubData(ILGenerator il, Type dataType){
MethodInfo miGetDatas = dataType.GetMethod (fetchMethodName, new Type[] {});
if (Layoutable.Parent == null) {//TODO:improve this
//cancel layouting for object without parent, maybe some were in queue when
//removed from a listbox
+ #if DEBUG_LAYOUTING
Debug.WriteLine ("ERROR: processLayouting, no parent for: " + this.ToString ());
+ #endif
return;
}
#if DEBUG_LAYOUTING
/// <summary>
/// Measurement unit
/// </summary>
- public enum Unit { Pixel, Percent }
+ public enum Unit { Pixel, Percent, Inherit }
/// <summary>
/// Measure class allow proportional sizes as well as stretched and fit on content.
/// </summary>
/// set to 100 Percents
/// </summary>
public static Measure Stretched = new Measure(100, Unit.Percent);
-
+ public static Measure Inherit = new Measure (0, Unit.Inherit);
#region CTOR
public Measure (int _value, Unit _units = Unit.Pixel)
{
}
public override string ToString ()
{
- return Value == -1 ? "Fit" :
+ return Units == Unit.Inherit ? "Inherit" :
+ Value == -1 ? "Fit" :
Units == Unit.Percent ? Value == 100 ? "Stretched" :
Value.ToString () + "%" : Value.ToString ();
}
string st = s.Trim ();
int tmp = 0;
- if (string.Equals ("Fit", st, StringComparison.Ordinal))
+ if (string.Equals ("Inherit", st, StringComparison.Ordinal))
+ return Measure.Inherit;
+ else if (string.Equals ("Fit", st, StringComparison.Ordinal))
return Measure.Fit;
else if (string.Equals ("Stretched", s, StringComparison.Ordinal))
- return Measure.Stretched;
+ return Measure.Stretched;
else {
if (st.EndsWith ("%", StringComparison.Ordinal)) {
if (int.TryParse (s.Substring(0, st.Length - 1), out tmp))
{
public class SolidColor : Fill
{
- Color color = Color.Transparent;
+ public Color color = Color.Transparent;
#region CTOR
public SolidColor(Color c)
{