]> O.S.I.I.S - jp/crow.git/commitdiff
* Crow.csproj:
authorjpbruyere <jp.bruyere@hotmail.com>
Sat, 6 Aug 2016 15:48:03 +0000 (17:48 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Sat, 6 Aug 2016 15:48:03 +0000 (17:48 +0200)
* 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

20 files changed:
Crow.csproj
Templates/TreeView.crow
Tests/BasicTests.cs
Tests/Interfaces/Divers/2.crow
Tests/Interfaces/Divers/test5.crow
Tests/Interfaces/Expandable/2.crow [deleted file]
Tests/Interfaces/Unsorted/0.crow
Tests/Interfaces/Unsorted/testTreeView.crow
Tests/Tests.csproj
src/CompilerServices/Bindings.cs
src/CompilerServices/CompilerServices.cs
src/CompilerServices/MemberReference.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Label.cs
src/GraphicObjects/ListBox.cs
src/GraphicObjects/PrivateContainer.cs
src/GraphicObjects/Scroller.cs
src/GraphicObjects/TemplatedControl.cs
src/IMLStream.cs
src/Interface.cs

index 3f6f6b2d2c9e71d50ea70b0fa8c74a76738dd333..7dde305f39ac8c40491ac2f50c48c55c634d17a8 100644 (file)
     <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" />
     <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" />
index db6533e374a21246fe3bf1217f2a3c74c7c5c04b..fe083072e547a14db106c304058d13f59e784fed 100644 (file)
@@ -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>
index 0c515aa6f0961092045c653dcdbcc55e31cb28e6..2a82bd238a31bc7b38defafaff3db37cc814bf87 100644 (file)
@@ -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);
+               }
        }
 }
index 5b4d9c757222ee9ad3899ac25019de7490f5b2d0..b4a06b687a7a32a2e048f113a5d89bd55de53820 100755 (executable)
                <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
index 6a75fe78f9a92a244e2e47486d5e8924d686a362..1d2d06897e509ce55292931f9f172de9c0dd3e79 100755 (executable)
@@ -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">
                                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 (executable)
index d243e67..0000000
+++ /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>
index 4e9fb7f417ea7981df34c4821e2aca8633c4d82b..d25557db53eb49b8c02121dc56ff25b351198802 100755 (executable)
@@ -1,4 +1,2 @@
 <?xml version="1.0"?>
-<Container>
-<Button Caption="m"  />
-</Container>
\ No newline at end of file
+<Spinner/>
index 5873e619e699f275d5578c1d8064f4dd694ccc6e..3ec7ce6a2732df243a466b9bbd8b9cc54e3b548c 100755 (executable)
@@ -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>
index e60faad5ee390af35a63661a76479ad5f2b34e20..944b293252d080e8dde41e07ab6cbf283b988c01 100644 (file)
     <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>
     <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\" />
index 40ade60db01f606cbdb68f74255aa85d44a7184d..8ece856c51ddc2d86515cab093c28f184cc0c71a 100644 (file)
@@ -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 ()
                {
index 4a85c442aae109dca193ec5eb64e45b7cc0aeaf0..0b69f970779c73c1539702818994551f787e09e2 100644 (file)
@@ -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
index 1dc3a3e4ab2ae3f85c2c8ea469d9e627596a1fe1..97f470fc0979b07bd1e0926f8164c5dbf18f52e4 100644 (file)
@@ -68,6 +68,10 @@ namespace Crow
 
                        return Member != null;
                }
+               public override string ToString ()
+               {
+                       return string.Format ("{0}.{1}", Instance, Member);
+               }
        }
 }
 
index 395569762928f7b09480c8f79c7d09e50942b9b6..36be650df0732e8bb0916662af5b1a8a567bb0d3 100644 (file)
@@ -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);
                }
index d09542b5279efdb65e6e520f0b96eb23505c51ed..95892314b36cf579062d639af4810ea8490c4c06 100644 (file)
@@ -72,7 +72,7 @@ namespace Crow
                protected TextExtents te;
                #endregion
 
-               [XmlAttributeAttribute][DefaultValue("SteelBlue")]
+               [XmlAttributeAttribute][DefaultValue("BlueGray")]
                public virtual Color SelectionBackground {
                        get { return selBackground; }
                        set {
index 6cef4fd9e3468bf961a1305980cf2b06f6b10ec1..b92fe39fe16e50b76c78c31f4727b7246342d8ec 100644 (file)
@@ -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];
                                }
index 93bae7faf7172b83738994696d6445b0301b8a4b..8793ba4533e052b7c10542ef379106bdb881493e 100644 (file)
@@ -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;
index 0d57cdb38cfcc81770f0a207af6354d3ca0ae327..3eaff5f4f324d2a3d1273cc12922eff55014983a 100644 (file)
@@ -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; }
index f1c719f6c73d0fbf362f140ea64e64a903d06186..9040ddeb18238e0171dc592e7218adc7e3ce390b 100644 (file)
@@ -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)
index ccc09f45b543241d0bb25f941eb9efb46bc1002f..d4dc6496084c0c91e915a68a3bf702986bf7ed63 100644 (file)
@@ -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;
index 99ea974b7167abaab6a81034d8bd75ab2470caf9..df59527566b1c6587bed04dc9d2bcac50b322ac4 100644 (file)
@@ -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){