namespace CrowIDE
{
- public class PropertyContainer : IBindable
+ public class PropertyContainer : IBindable, IValueChange
{
+ #region IBindable implementation
public object DataSource {
- get {
- throw new NotImplementedException ();
- }
+ get { return null; }
set {
throw new NotImplementedException ();
}
}
-
- #region IBindable implementation
List<Binding> bindings = new List<Binding> ();
public List<Binding> Bindings {
get { return bindings; }
}
#endregion
+ #region IValueChange implementation
+ public event EventHandler<ValueChangeEventArgs> ValueChanged;
+ public virtual void NotifyValueChanged(string MemberName, object _value)
+ {
+ ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value));
+ }
+ #endregion
+
PropertyInfo pi;
object instance;
get { return pi.GetValue(instance); }
set {
try {
- if (pi.PropertyType != value.GetType() && pi.PropertyType != typeof(string)){
+ if (!pi.PropertyType.IsAssignableFrom(value.GetType()) && pi.PropertyType != typeof(string)){
if (pi.PropertyType.IsEnum) {
pi.SetValue (instance, value);
} else {
} catch (Exception ex) {
System.Diagnostics.Debug.WriteLine ("Error setting property:"+ ex.ToString());
}
-
+ NotifyValueChanged ("Value", value);
}
}
public string Type { get { return pi.PropertyType.IsEnum ?
}
public class MembersView : ListBox
- {
+ {
object instance;
[XmlAttributeAttribute][DefaultValue(null)]
MouseEnter="{Background=UnitedNationsBlue}"
MouseLeave="{Background=Transparent}" >
<Label Margin="1" Text="{Name}" Height="Fit" Width="50%"/>
- <Popper Foreground="{²Value}" Background="White" Margin="1" Caption="{²Value}">
+ <Popper Background="White" Margin="1" Caption="{Value}">
<Template>
<HorizontalStack Spacing="3" Height="Fit" Background="{./Background}">
<Border Foreground="Black" Width="16" Height="10" CornerRadius="3"
- Background="{./Foreground}">
+ Background="{Value}">
</Border>
<Label Text="{./Caption}" Foreground="Black"/>
</HorizontalStack>
</VerticalStack>
</HorizontalStack>
<HorizontalStack Height="Fit">
- <Label Text="Red:" Width="50"/>
- <Spinner Style="ColorSpinner" Value="{²./R}" Width="50" />
+ <Label Text="Red:" Width="40"/>
+ <Spinner Style="ColorSpinner" Value="{²./R}" Width="60" />
</HorizontalStack>
<HorizontalStack Height="Fit">
- <Label Text="Green:" Width="50"/>
- <Spinner Style="ColorSpinner" Value="{²./G}" Width="50" />
+ <Label Text="Green:" Width="40"/>
+ <Spinner Style="ColorSpinner" Value="{²./G}" Width="60" />
</HorizontalStack>
<HorizontalStack Height="Fit">
- <Label Text="Blue:" Width="50"/>
- <Spinner Style="ColorSpinner" Value="{²./B}" Width="50" />
+ <Label Text="Blue:" Width="40"/>
+ <Spinner Style="ColorSpinner" Value="{²./B}" Width="60" />
</HorizontalStack>
<HorizontalStack Height="Fit">
- <Label Text="Alpha:" Width="50"/>
- <Spinner Style="ColorSpinner" Value="{²./A}" Width="50" />
+ <Label Text="Alpha:" Width="40"/>
+ <Spinner Style="ColorSpinner" Value="{²./A}" Width="60" />
</HorizontalStack>
<HorizontalStack Height="Fit">
- <Label Text="Hue:" Width="50"/>
- <Spinner Style="HSVSpinner" Value="{²../../../hueSelector.Hue}" Width="150" />
+ <Label Text="Hue:" Width="40"/>
+ <Spinner Style="HSVSpinner" Value="{²../../../hueSelector.Hue}" Width="60" />
</HorizontalStack>
<HorizontalStack Height="Fit">
- <Label Text="Sat:" Width="50"/>
- <Spinner Style="HSVSpinner" Value="{²../../../colorSelector.S}" Width="150" />
+ <Label Text="Sat:" Width="40"/>
+ <Spinner Style="HSVSpinner" Value="{²../../../colorSelector.S}" Width="60" />
</HorizontalStack>
<HorizontalStack Height="Fit">
- <Label Text="Val:" Width="50"/>
- <Spinner Style="HSVSpinner" Value="{²../../../colorSelector.V}" Width="150" />
+ <Label Text="Val:" Width="40"/>
+ <Spinner Style="HSVSpinner" Value="{²../../../colorSelector.V}" Width="60" />
</HorizontalStack>
</VerticalStack>
</HorizontalStack>
namespace Tests
{
- class BasicTests : OpenTKGameWindow
+ class BasicTests : OpenTKGameWindow, IBindable
{
+ #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")
{
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/Divers/welcome.crow" };
+ //testFiles = new string [] { @"Interfaces/Divers/colorPicker.crow" };
+ testFiles = new string [] { @"Interfaces/Divers/test2WayBinding.crow" };
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 ();
this.Title = testFiles [idx] + ". Press <F3> to switch example.";
CrowInterface.LoadInterface(testFiles[idx]).DataSource = this;
+ CompilerServices.ResolveBindings (this.Bindings);
}
void KeyboardKeyDown1 (object sender, OpenTK.Input.KeyboardKeyEventArgs e)
{
<?xml version="1.0"?>
<VerticalStack>
- <ColorPicker SelectedColor="DarkBlue" Name="colorPicker" Background="Onyx" Margin="5" Fit="True" />
- <GraphicObject Width="100" Height="60" Background="{../colorPicker.SelectedColor}"/>
+ <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
<None Include="Interfaces\Divers\colorPicker.crow">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
+ <None Include="Interfaces\Divers\test2WayBinding.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<ItemGroup>
<Folder Include="Interfaces\" />
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 ());
+ }
}
}
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
CairoHelpers.CairoRectangle (ctx, r, 2);
ctx.SetSourceColor (Color.White);
- ctx.LineWidth = 1.0;
+ ctx.LineWidth = 2.0;
ctx.Stroke();
ctx.Restore ();
}
Rectangle rGrad = r;
rGrad.Inflate (-1);
- Foreground.SetAsSource (gr, r);
- CairoHelpers.CairoRectangle (gr, r, CornerRadius);
- gr.Fill();
+ 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)));