diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2016-08-06 17:48:03 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2016-08-06 17:48:03 +0200 |
| commit | c45ce80e0e4298afcbeee9215ee2d1d30c4c3be8 (patch) | |
| tree | ec659a28153b9df8406736d9f8df6ee255b8cb7e | |
| parent | f42cabddc008529eddc0a43cad3be2b39b6790ee (diff) | |
* Crow.csproj:
* Label.cs: update
* GraphicObject.cs: key up
* ListBox.cs: IMLStream instanciing
* PrivateContainer.cs: Clear child Changes
* Scroller.cs: scroller have VerticalSrcrolling by default
* TemplatedControl.cs: remove unused hostClass attribute
* IMLStream.cs: IMLStream instance and source properties
* Interface.cs: removed unused hostClass
Only putOnTop Window widget when focused
KeyboardState key up and down
* TreeView.crow: no border in default template
* BasicTests.cs: IMLEditor
PropLessBinding test
* Tests.csproj:
* 2.crow:
* 0.crow:
* test5.crow:
* 2.crow:
* testTreeView.crow: update tests
* Bindings.cs:
* MemberReference.cs:
* CompilerServices.cs: property less bindings debug
| -rw-r--r-- | Crow.csproj | 2 | ||||
| -rw-r--r-- | Templates/TreeView.crow | 17 | ||||
| -rw-r--r-- | Tests/BasicTests.cs | 35 | ||||
| -rwxr-xr-x | Tests/Interfaces/Divers/2.crow | 22 | ||||
| -rwxr-xr-x | Tests/Interfaces/Divers/test5.crow | 27 | ||||
| -rwxr-xr-x | Tests/Interfaces/Expandable/2.crow | 13 | ||||
| -rwxr-xr-x | Tests/Interfaces/Unsorted/0.crow | 4 | ||||
| -rwxr-xr-x | Tests/Interfaces/Unsorted/testTreeView.crow | 80 | ||||
| -rw-r--r-- | Tests/Tests.csproj | 12 | ||||
| -rw-r--r-- | src/CompilerServices/Bindings.cs | 63 | ||||
| -rw-r--r-- | src/CompilerServices/CompilerServices.cs | 4 | ||||
| -rw-r--r-- | src/CompilerServices/MemberReference.cs | 4 | ||||
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 3 | ||||
| -rw-r--r-- | src/GraphicObjects/Label.cs | 2 | ||||
| -rw-r--r-- | src/GraphicObjects/ListBox.cs | 2 | ||||
| -rw-r--r-- | src/GraphicObjects/PrivateContainer.cs | 3 | ||||
| -rw-r--r-- | src/GraphicObjects/Scroller.cs | 2 | ||||
| -rw-r--r-- | src/GraphicObjects/TemplatedControl.cs | 6 | ||||
| -rw-r--r-- | src/IMLStream.cs | 19 | ||||
| -rw-r--r-- | src/Interface.cs | 23 |
20 files changed, 172 insertions, 171 deletions
diff --git a/Crow.csproj b/Crow.csproj index 3f6f6b2d..7dde305f 100644 --- a/Crow.csproj +++ b/Crow.csproj @@ -135,6 +135,7 @@ <Compile Include="src\CompilerServices\Bindings.cs" /> <Compile Include="src\StyleReader.cs" /> <Compile Include="src\IMLStream.cs" /> + <Compile Include="src\GraphicObjects\DirectoryView.cs" /> </ItemGroup> <ItemGroup> <Reference Include="System" /> @@ -227,6 +228,7 @@ <EmbeddedResource Include="Default.style" /> <EmbeddedResource Include="Images\Icons\folder.svg" /> <EmbeddedResource Include="Images\Icons\file.svg" /> + <EmbeddedResource Include="Templates\DirectoryView.crow" /> </ItemGroup> <ItemGroup> <None Include="README.md" /> diff --git a/Templates/TreeView.crow b/Templates/TreeView.crow index db6533e3..fe083072 100644 --- a/Templates/TreeView.crow +++ b/Templates/TreeView.crow @@ -1,10 +1,7 @@ -<Border BorderWidth="1" Margin="1" MinimumSize="10,10" - Background="{./Background}" 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="List" Margin="0" VerticalAlignment="Top"/> - </Scroller> -</Border> - +<Scroller Name="scroller1" Margin="1" VerticalScrolling="true" + Background="{./Background}" + Height="{./HeightPolicy}" Width="{./WidthPolicy}" + ValueChanged="./_scroller_ValueChanged"> + <VerticalStack LayoutChanged="./_list_LayoutChanged" + Height="Fit" Width="{./WidthPolicy}" Name="List" Margin="0" VerticalAlignment="Top"/> +</Scroller> diff --git a/Tests/BasicTests.cs b/Tests/BasicTests.cs index 0c515aa6..2a82bd23 100644 --- a/Tests/BasicTests.cs +++ b/Tests/BasicTests.cs @@ -70,6 +70,16 @@ namespace Tests } get { return testList; } } + string curSources = ""; + public string CurSources { + get { return curSources; } + set { + if (value == curSources) + return; + curSources = value; + NotifyValueChanged ("CurSources", curSources); + } + } #endregion void OnClear (object sender, MouseButtonEventArgs e) => TestList = null; @@ -113,6 +123,10 @@ namespace Tests GraphicObject w = CrowInterface.LoadInterface ("Interfaces/Divers/testWindow2.goml"); w.DataSource = this; return; + }else if (e.Key == OpenTK.Input.Key.F6) { + GraphicObject w = CrowInterface.LoadInterface ("Interfaces/Divers/imlEditor.crow"); + w.DataSource = this; + return; } else if (e.Key == OpenTK.Input.Key.F2) idx--; else if (e.Key == OpenTK.Input.Key.F3) @@ -131,7 +145,20 @@ namespace Tests GraphicObject obj = CrowInterface.LoadInterface(testFiles[idx]); obj.DataSource = this; } - + void Tv_SelectedItemChanged (object sender, SelectionChangeEventArgs e) + { + FileInfo fi = e.NewValue as FileInfo; + if (fi == null) + return; + if (fi.Extension == ".crow" || fi.Extension == ".goml") { + IMLStream imls = new IMLStream (fi.FullName); + lock (CrowInterface.UpdateMutex) { + (CrowInterface.FindByName ("crowContainer") as Container).SetChild + (imls.Instance); + CurSources = imls.Source; + } + } + } void onButClick(object send, MouseButtonEventArgs e) { Console.WriteLine ("button clicked:" + send.ToString()); @@ -150,5 +177,11 @@ namespace Tests BasicTests win = new BasicTests (); win.Run (30); } + protected override void OnUpdateFrame (OpenTK.FrameEventArgs e) + { + base.OnUpdateFrame (e); + string test = e.Time.ToString (); + NotifyValueChanged ("PropertyLessBinding", test); + } } } diff --git a/Tests/Interfaces/Divers/2.crow b/Tests/Interfaces/Divers/2.crow index 5b4d9c75..b4a06b68 100755 --- a/Tests/Interfaces/Divers/2.crow +++ b/Tests/Interfaces/Divers/2.crow @@ -10,26 +10,4 @@ <Label Text="bottom center" Width="80" Height="30" Background="DarkBlue" TextAlignment="Bottom"/> <Label Text="bottom right" Width="80" Height="30" Background="DarkBlue" TextAlignment="BottomRight"/> </HorizontalStack> -<!-- <HorizontalStack Fit="true"> - <Label Text="label1" Foreground="LightBlue" Margin="5" Background="DarkRed"/> - <TextRun Text="textrun1" Width="Stretched"/> - <Button Text="Click Me"/> - <CheckBox/> - <GroupBox Caption="choice"> - <VerticalStack> - <RadioButton Caption="Choice 1" IsChecked="true"/> - <RadioButton Caption="Choice 2"/> - <RadioButton Caption="Choice 3"/> - </VerticalStack> - </GroupBox> - <Expandable Caption="expand me"> - <Label Text="this is a test"/> - </Expandable> - <Popper Caption="pop me"> - <Label Background="Red"/> - </Popper> - <ComboBox/> - </HorizontalStack> - <MessageBox></MessageBox> - <Window><Label/></Window>--> </VerticalStack>
\ No newline at end of file diff --git a/Tests/Interfaces/Divers/test5.crow b/Tests/Interfaces/Divers/test5.crow index 6a75fe78..1d2d0689 100755 --- a/Tests/Interfaces/Divers/test5.crow +++ b/Tests/Interfaces/Divers/test5.crow @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<Container Name="container0" Foreground="White" BorderWidth="2" Margin="100" +<Container Name="container0" Foreground="White" BorderWidth="2" Margin="1" CornerRadius="50"> <Group Name="group0" Background="Green" Margin="20"> <HorizontalStack Name="hs0" Background="Blue" Margin="20"> @@ -18,29 +18,4 @@ MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/> </HorizontalStack> </Group> -<!-- <Scroller Height="100" Width="300" Background="Green" VerticalScrolling="true" Margin="5"> - <Group Name="MainGrp" Background="Red" VerticalAlignment="Top" - Foreground="White" BorderWidth="2" Margin="10" Focusable="True" - Width="400" Height="200"> - <HorizontalStack> - <Button Width="Fit" Height="Fit" Margin="5" BorderWidth="2" Background="Gray"> - <Label Text="button"/> - </Button> - <Button Width="Fit" Height="Fit" Margin="5" BorderWidth="2"> - <Label Text="button"/> - </Button> - <Button Width="Fit" Height="Fit" Margin="5" BorderWidth="2"> - <Label Text="button"/> - </Button> - <Button Width="Fit" Height="Fit" Margin="5" BorderWidth="2"> - <Label Text="button"/> - </Button> - <Button Width="Fit" Height="200" Margin="5" BorderWidth="2" > - <Label Text="button"/> - </Button> - </HorizontalStack> - </Group> - <Container Width="100" Height="200" Margin="5" BorderWidth="2" VerticalAlignment="Top"/> - </Scroller>--> - </Container>
\ No newline at end of file diff --git a/Tests/Interfaces/Expandable/2.crow b/Tests/Interfaces/Expandable/2.crow deleted file mode 100755 index d243e67e..00000000 --- a/Tests/Interfaces/Expandable/2.crow +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0"?> -<Expandable Fit="true" Caption="Test expandable" Background="DimGray"> - <VerticalStack Margin="5" Background="Green" Fit="true"> - <CheckBox Name="chk1" Background="Red" Fit="true"/> - <CheckBox Name="chk2" IsChecked="true" Fit="true"/> - <CheckBox Name="chk3" Fit="true"/> - <CheckBox Name="chk4" Fit="true"/> - <HorizontalStack Fit="true" Margin="2" Background="Blue"> - <Label Name="captionFps" Text="Fps:" Width="30" TextAlignment="Right"/> - <Label Name="valueFps" Text="{fps}" Font="droid , 12" Width="Fit" TextAlignment="Center" Background="AoEnglish"/> - </HorizontalStack> - </VerticalStack> -</Expandable> diff --git a/Tests/Interfaces/Unsorted/0.crow b/Tests/Interfaces/Unsorted/0.crow index 4e9fb7f4..d25557db 100755 --- a/Tests/Interfaces/Unsorted/0.crow +++ b/Tests/Interfaces/Unsorted/0.crow @@ -1,4 +1,2 @@ <?xml version="1.0"?> -<Container> -<Button Caption="m" /> -</Container>
\ No newline at end of file +<Spinner/> diff --git a/Tests/Interfaces/Unsorted/testTreeView.crow b/Tests/Interfaces/Unsorted/testTreeView.crow index 5873e619..3ec7ce6a 100755 --- a/Tests/Interfaces/Unsorted/testTreeView.crow +++ b/Tests/Interfaces/Unsorted/testTreeView.crow @@ -1,43 +1,41 @@ <?xml version="1.0"?> -<HorizontalStack> - <TreeView IsRoot="true" Name="treeView" Height="100%" Width="40%" Data="{CurDirectory}" Background="DimGray"> - <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}"/> +<TreeView IsRoot="true" Name="treeView" Data="{CurDirectory}" Background="DimGray"> + <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="GetFileSystemInfos"> + <Expandable Caption="{Name}" > + <Template> + <VerticalStack Height="{./HeightPolicy}" Width="{./WidthPolicy}"> + <HorizontalStack Spacing="1" Height="Fit" Width="{./WidthPolicy}" + MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}" + MouseLeave="{Background=Transparent}"> + <Image Margin="2" Width="12" Height="12" + Visible="{./HasContent}" + Path="{./Image}" + SvgSub="{./IsExpanded}"/> + <Image Margin="2" Width="14" Height="14" + Path="#Crow.Images.Icons.folder.svg"/> + <Label Text="{./Caption}" Width="{./WidthPolicy}"/> + </HorizontalStack> + <Container Name="Content" Visible="false" + Height="{./HeightPolicy}" Width="{./WidthPolicy}"/> + </VerticalStack> + </Template> + <HorizontalStack Height="Fit" Width="{./WidthPolicy}"> + <GraphicObject Width="12" Height="10"/> + <TreeView Name="List" Height="Fit" Width="{./WidthPolicy}"> + <Template> + <VerticalStack Height="Fit" Width="{../WidthPolicy}" Name="List"/> + </Template> + </TreeView> </HorizontalStack> - </ItemTemplate> - <ItemTemplate DataType="System.IO.DirectoryInfo" Data="GetFileSystemInfos"> - <Expandable Caption="{Name}" > - <Template> - <VerticalStack Height="{./HeightPolicy}" Width="{./WidthPolicy}"> - <HorizontalStack Spacing="1" Height="Fit" Width="{./WidthPolicy}" - MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}" - MouseLeave="{Background=Transparent}"> - <Image Margin="2" Width="12" Height="12" - Visible="{./HasContent}" - Path="{./Image}" - SvgSub="{./IsExpanded}"/> - <Image Margin="2" Width="14" Height="14" - Path="#Crow.Images.Icons.folder.svg"/> - <Label Text="{./Caption}" Width="{./WidthPolicy}"/> - </HorizontalStack> - <Container Name="Content" Visible="false" - Height="{./HeightPolicy}" Width="{./WidthPolicy}"/> - </VerticalStack> - </Template> - <HorizontalStack Height="Fit" Width="{./WidthPolicy}"> - <GraphicObject Width="12" Height="10"/> - <TreeView Name="List" Height="Fit" Width="{./WidthPolicy}" - Template="#Tests.Interfaces.treeList.crow" /> - </HorizontalStack> - </Expandable> - </ItemTemplate> - </TreeView> - <Border Width="60%"> - <Label Text="{../../treeView.SelectedItem}"/> - </Border> -</HorizontalStack>
\ No newline at end of file + </Expandable> + </ItemTemplate> +</TreeView> diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index e60faad5..944b2932 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -291,9 +291,6 @@ <None Include="Interfaces\Expandable\7.crow"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> - <None Include="Interfaces\Expandable\2.crow"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </None> <None Include="Interfaces\Splitter\1.crow"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> @@ -341,6 +338,15 @@ <None Include="Interfaces\Unsorted\testItemTemplateTag.crow"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Include="Interfaces\Divers\testDirViewer2.crow"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="Interfaces\Divers\testPropLess.crow"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="Interfaces\Divers\imlEditor.crow"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> </ItemGroup> <ItemGroup> <Folder Include="Interfaces\" /> diff --git a/src/CompilerServices/Bindings.cs b/src/CompilerServices/Bindings.cs index 40ade60d..8ece856c 100644 --- a/src/CompilerServices/Bindings.cs +++ b/src/CompilerServices/Bindings.cs @@ -93,12 +93,12 @@ namespace Crow /// resolve target expression /// </summary> /// <returns><c>true</c>, if target was found, <c>false</c> otherwise.</returns> - public bool FindTarget () + public bool TryFindTarget () { if (Target != null) return true; - string member = null; + string memberName = null; //if binding exp = '{}' => binding is done on datasource if (string.IsNullOrEmpty (Expression)) { @@ -118,85 +118,86 @@ namespace Crow string [] bindingExp = expression.Split ('/'); + if (bindingExp.Length == 1) { //datasource binding - Target = new MemberReference ((Source.Instance as GraphicObject).DataSource); - member = bindingExp [0]; + object dataSource = (Source.Instance as GraphicObject).DataSource; + if (dataSource == null) { + Debug.WriteLine ("\tDataSource is null => " + this.ToString()); + return false; + } + + Target = new MemberReference (dataSource); + memberName = bindingExp [0]; } else { int ptr = 0; - ILayoutable tmp = Source.Instance as ILayoutable; + ILayoutable tmpTarget = Source.Instance as ILayoutable; //if exp start with '/' => Graphic tree parsing start at source if (string.IsNullOrEmpty (bindingExp [0])) ptr++; else if (bindingExp[0] == "."){ //search template root do { - tmp = tmp.Parent; - if (tmp == null) + tmpTarget = tmpTarget.Parent; + if (tmpTarget == null) return false; - if (tmp is Interface) + if (tmpTarget is Interface) throw new Exception ("Not in Templated Control"); - } while (!(tmp is TemplatedControl)); + } while (!(tmpTarget is TemplatedControl)); ptr++; } while (ptr < bindingExp.Length - 1) { - if (tmp == null) { + if (tmpTarget == null) { #if DEBUG_BINDING Debug.WriteLine ("\tERROR: target not found => " + this.ToString()); #endif return false; } if (bindingExp [ptr] == "..") - tmp = tmp.LogicalParent; + tmpTarget = tmpTarget.LogicalParent; else if (bindingExp [ptr] == ".") { if (ptr > 0) throw new Exception ("Syntax error in binding, './' may only appear in first position"); - tmp = Source.Instance as ILayoutable; + tmpTarget = Source.Instance as ILayoutable; } else - tmp = (tmp as GraphicObject).FindByName (bindingExp [ptr]); + tmpTarget = (tmpTarget as GraphicObject).FindByName (bindingExp [ptr]); ptr++; } - if (tmp == null) { + if (tmpTarget == null) { #if DEBUG_BINDING - Debug.WriteLine ("\tERROR: target not found => " + this.ToString()); + Debug.WriteLine ("\tERROR: Binding Target not found => " + this.ToString()); #endif return false; } + Target = new MemberReference (tmpTarget); + string [] bindTrg = bindingExp [ptr].Split ('.'); if (bindTrg.Length == 1) - member = bindTrg [0]; + memberName = bindTrg [0]; else if (bindTrg.Length == 2) { - tmp = (tmp as GraphicObject).FindByName (bindTrg [0]); - member = bindTrg [1]; + tmpTarget = (tmpTarget as GraphicObject).FindByName (bindTrg [0]); + memberName = bindTrg [1]; } else throw new Exception ("Syntax error in binding, expected 'go dot member'"); - Target = new MemberReference (tmp); - } - if (Target == null) { - #if DEBUG_BINDING - Debug.WriteLine ("Binding Source is null: " + Expression); - #endif - return false; } - if (Target.TryFindMember (member)) { + if (Target.TryFindMember (memberName)) { if (TwoWayBinding) { IBindable source = Target.Instance as IBindable; if (source == null) throw new Exception (Source.Instance + " does not implement IBindable for 2 way bindings"); source.Bindings.Add (new Binding (Target, Source)); } - return true; } - #if DEBUG_BINDING - Debug.WriteLine ("Binding member not found: " + member); + else + Debug.WriteLine ("Property less binding: " + Target + expression); #endif - Target = null; - return false; + + return true; } public void Reset () { diff --git a/src/CompilerServices/CompilerServices.cs b/src/CompilerServices/CompilerServices.cs index 4a85c442..0b69f970 100644 --- a/src/CompilerServices/CompilerServices.cs +++ b/src/CompilerServices/CompilerServices.cs @@ -31,7 +31,7 @@ namespace Crow CompilerServices.CompileEventSource (b); continue; } - if (!b.FindTarget ()) + if (!b.TryFindTarget ()) continue; //register handler for event if (b.Target.Method == null) { @@ -53,7 +53,7 @@ namespace Crow continue; } - if (!b.FindTarget ()) + if (!b.TryFindTarget ()) continue; //group Bindings by target instanceq diff --git a/src/CompilerServices/MemberReference.cs b/src/CompilerServices/MemberReference.cs index 1dc3a3e4..97f470fc 100644 --- a/src/CompilerServices/MemberReference.cs +++ b/src/CompilerServices/MemberReference.cs @@ -68,6 +68,10 @@ namespace Crow return Member != null; } + public override string ToString () + { + return string.Format ("{0}.{1}", Instance, Member); + } } } diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 39556976..36be650d 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -1072,6 +1072,9 @@ namespace Crow public virtual void onKeyDown(object sender, KeyboardKeyEventArgs e){ KeyDown.Raise (sender, e); } + public virtual void onKeyUp(object sender, KeyboardKeyEventArgs e){ + KeyUp.Raise (sender, e); + } public virtual void onKeyPress(object sender, KeyPressEventArgs e){ KeyPress.Raise (sender, e); } diff --git a/src/GraphicObjects/Label.cs b/src/GraphicObjects/Label.cs index d09542b5..95892314 100644 --- a/src/GraphicObjects/Label.cs +++ b/src/GraphicObjects/Label.cs @@ -72,7 +72,7 @@ namespace Crow protected TextExtents te; #endregion - [XmlAttributeAttribute][DefaultValue("SteelBlue")] + [XmlAttributeAttribute][DefaultValue("BlueGray")] public virtual Color SelectionBackground { get { return selBackground; } set { diff --git a/src/GraphicObjects/ListBox.cs b/src/GraphicObjects/ListBox.cs index 6cef4fd9..b92fe39f 100644 --- a/src/GraphicObjects/ListBox.cs +++ b/src/GraphicObjects/ListBox.cs @@ -172,7 +172,7 @@ namespace Crow itemStream = ItemTemplates ["default"]; lock (Interface.CurrentInterface.LayoutMutex) { - g = Interface.Load (itemStream); + g = itemStream.Instance; page.AddChild (g); g.DataSource = data [i]; } diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs index 93bae7fa..8793ba45 100644 --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@ -51,10 +51,11 @@ namespace Crow { if (child != null) { + child.ClearBinding (); contentSize = new Size (0, 0); child.LayoutChanged -= OnChildLayoutChanges; - this.RegisterForLayouting (LayoutingType.Sizing); child.Parent = null; + this.RegisterForGraphicUpdate (); } child = _child as GraphicObject; diff --git a/src/GraphicObjects/Scroller.cs b/src/GraphicObjects/Scroller.cs index 0d57cdb3..3eaff5f4 100644 --- a/src/GraphicObjects/Scroller.cs +++ b/src/GraphicObjects/Scroller.cs @@ -39,7 +39,7 @@ namespace Crow public event EventHandler<ScrollingEventArgs> Scrolled; #region public properties - [XmlAttributeAttribute][DefaultValue(false)] + [XmlAttributeAttribute][DefaultValue(true)] public bool VerticalScrolling { get { return _verticalScrolling; } set { _verticalScrolling = value; } diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs index f1c719f6..9040ddeb 100644 --- a/src/GraphicObjects/TemplatedControl.cs +++ b/src/GraphicObjects/TemplatedControl.cs @@ -77,7 +77,7 @@ namespace Crow if (string.IsNullOrEmpty(_template)) loadTemplate (); else - loadTemplate (Interface.Load (_template, this)); + loadTemplate (Interface.Load (_template)); } } [XmlAttributeAttribute][DefaultValue("#Crow.Templates.ItemTemplate.goml")] @@ -116,7 +116,7 @@ namespace Crow { if (template == null) { DefaultTemplate dt = (DefaultTemplate)this.GetType ().GetCustomAttributes (typeof(DefaultTemplate), true).FirstOrDefault(); - this.SetChild (Interface.Load (dt.Path, this)); + this.SetChild (Interface.Load (dt.Path)); }else this.SetChild (template); @@ -184,7 +184,7 @@ namespace Crow } } } else - loadTemplate (Interface.Load (template, this)); + loadTemplate (Interface.Load (template)); //if no template found, load default one if (this.child == null) diff --git a/src/IMLStream.cs b/src/IMLStream.cs index ccc09f45..d4dc6496 100644 --- a/src/IMLStream.cs +++ b/src/IMLStream.cs @@ -37,6 +37,25 @@ namespace Crow public IMLStream(Byte[] b) : base (b){ RootType = Interface.GetTopContainerOfXMLStream (this); } + /// <summary> + /// Create a graphicObject instance from the this XML stream. + /// </summary> + public GraphicObject Instance { + get { + Seek (0, SeekOrigin.Begin); + return Interface.Load (this, this.RootType); + } + } + /// <summary> + /// Gets the xml source code as a string + /// </summary> + public string Source { + get { + Seek (0, SeekOrigin.Begin); + using (StreamReader sr = new StreamReader(this)) + return sr.ReadToEnd(); + } + } } public class ItemTemplate : IMLStream { public EventHandler Expand; diff --git a/src/Interface.cs b/src/Interface.cs index 99ea974b..df595275 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -218,7 +218,7 @@ namespace Crow xs.Serialize (s, graphicObject, xn); } } - public static GraphicObject Load (string path, object hostClass = null) + public static GraphicObject Load (string path) { System.Globalization.CultureInfo savedCulture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; @@ -226,7 +226,7 @@ namespace Crow GraphicObject tmp = null; try { using (Stream stream = GetStreamFromPath (path)) { - tmp = Load(stream, GetTopContainerOfXMLStream(stream), hostClass); + tmp = Load(stream, GetTopContainerOfXMLStream(stream)); } } catch (Exception ex) { throw new Exception ("Error loading <" + path + ">:", ex); @@ -236,11 +236,7 @@ namespace Crow return tmp; } - internal static GraphicObject Load (IMLStream stream, object hostClass = null){ - stream.Seek (0, SeekOrigin.Begin); - return Load(stream, stream.RootType, hostClass); - } - internal static GraphicObject Load (Stream stream, Type type, object hostClass = null) + internal static GraphicObject Load (Stream stream, Type type) { #if DEBUG_LOAD Stopwatch loadingTime = new Stopwatch (); @@ -257,7 +253,6 @@ namespace Crow XmlSerializer xs = new XmlSerializer (type); result = (GraphicObject)xs.Deserialize (stream); - //result.DataSource = hostClass; CurrentInterface.XmlLoading = false; #if DEBUG_LOAD @@ -277,7 +272,7 @@ namespace Crow public GraphicObject LoadInterface (string path) { lock (UpdateMutex) { - GraphicObject tmp = Interface.Load (path, this); + GraphicObject tmp = Interface.Load (path); AddWidget (tmp); return tmp; @@ -644,7 +639,8 @@ namespace Crow GraphicObject g = GraphicTree[i]; if (g.MouseIsIn (e.Position)) { g.checkHoverWidget (e); - PutOnTop (g); + if (g is Window) + PutOnTop (g); return true; } } @@ -716,6 +712,7 @@ namespace Crow #region Keyboard public bool ProcessKeyDown(int Key){ + Keyboard.SetKeyState((Crow.Key)Key,true); if (_focusedWidget == null) return false; KeyboardKeyEventArgs e = new KeyboardKeyEventArgs((Crow.Key)Key, false, Keyboard); @@ -723,9 +720,11 @@ namespace Crow return true; } public bool ProcessKeyUp(int Key){ - if (_activeWidget == null) + Keyboard.SetKeyState((Crow.Key)Key,false); + if (_focusedWidget == null) return false; - //KeyboardKeyEventArgs e = new KeyboardKeyEventArgs((Crow.Key)Key, false, Keyboard); + KeyboardKeyEventArgs e = new KeyboardKeyEventArgs((Crow.Key)Key, false, Keyboard); + _focusedWidget.onKeyUp (this, e); return true; } public bool ProcessKeyPress(char Key){ |