<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" />
-<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>
}
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;
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)
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());
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);
+ }
}
}
<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
<?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
+++ /dev/null
-<?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>
<?xml version="1.0"?>
-<Container>
-<Button Caption="m" />
-</Container>
\ No newline at end of file
+<Spinner/>
<?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>
<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\" />
/// 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)) {
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 ()
{
CompilerServices.CompileEventSource (b);
continue;
}
- if (!b.FindTarget ())
+ if (!b.TryFindTarget ())
continue;
//register handler for event
if (b.Target.Method == null) {
continue;
}
- if (!b.FindTarget ())
+ if (!b.TryFindTarget ())
continue;
//group Bindings by target instanceq
return Member != null;
}
+ public override string ToString ()
+ {
+ return string.Format ("{0}.{1}", Instance, Member);
+ }
}
}
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);
}
protected TextExtents te;
#endregion
- [XmlAttributeAttribute][DefaultValue("SteelBlue")]
+ [XmlAttributeAttribute][DefaultValue("BlueGray")]
public virtual Color SelectionBackground {
get { return selBackground; }
set {
itemStream = ItemTemplates ["default"];
lock (Interface.CurrentInterface.LayoutMutex) {
- g = Interface.Load (itemStream);
+ g = itemStream.Instance;
page.AddChild (g);
g.DataSource = data [i];
}
{
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;
public event EventHandler<ScrollingEventArgs> Scrolled;
#region public properties
- [XmlAttributeAttribute][DefaultValue(false)]
+ [XmlAttributeAttribute][DefaultValue(true)]
public bool VerticalScrolling {
get { return _verticalScrolling; }
set { _verticalScrolling = value; }
if (string.IsNullOrEmpty(_template))
loadTemplate ();
else
- loadTemplate (Interface.Load (_template, this));
+ loadTemplate (Interface.Load (_template));
}
}
[XmlAttributeAttribute][DefaultValue("#Crow.Templates.ItemTemplate.goml")]
{
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);
}
}
} else
- loadTemplate (Interface.Load (template, this));
+ loadTemplate (Interface.Load (template));
//if no template found, load default one
if (this.child == null)
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;
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;
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);
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 ();
XmlSerializer xs = new XmlSerializer (type);
result = (GraphicObject)xs.Deserialize (stream);
- //result.DataSource = hostClass;
CurrentInterface.XmlLoading = false;
#if DEBUG_LOAD
public GraphicObject LoadInterface (string path)
{
lock (UpdateMutex) {
- GraphicObject tmp = Interface.Load (path, this);
+ GraphicObject tmp = Interface.Load (path);
AddWidget (tmp);
return tmp;
GraphicObject g = GraphicTree[i];
if (g.MouseIsIn (e.Position)) {
g.checkHoverWidget (e);
- PutOnTop (g);
+ if (g is Window)
+ PutOnTop (g);
return true;
}
}
#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);
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){