internal static void BindDate(Calendar element, XmlNode node, Control root) { XmlAttribute dateAttribute = node.Attribute("Date"); if (dateAttribute != null) { if (dateAttribute.IsBinding()) { Action <EventHandler> subscribe = func => { element._calendar.DaySelected += func; element._calendar.DaySelectedDoubleClick += func; }; root.BindingContext.BindProperty( subscribe, () => element._calendar.Date, value => element._calendar.Date = SetDateFromDynamic(value), "Date", dateAttribute.Value); } else { element._calendar.Date = SetDateFromDynamic(dateAttribute.Value); } } }
public static void BindExpand(this VisualTreeElement element, XmlNode node, Control root) { XmlAttribute hexpand = node.Attribute("HorizontalExpansion"); if (hexpand != null) { if (hexpand.IsBinding()) { throw new NotImplementedException(); } else { element.Widget.Hexpand = bool.Parse(hexpand.Value); } } XmlAttribute vexpand = node.Attribute("VerticalExpansion"); if (vexpand != null) { if (vexpand.IsBinding()) { throw new NotImplementedException(); } else { element.Widget.Vexpand = bool.Parse(vexpand.Value); } } }
public static void BindSize(this VisualTreeElement element, XmlNode node, Control root) { XmlAttribute height = node.Attribute("Height"); if (height != null) { if (height.IsBinding()) { throw new NotImplementedException(); } else { element.Widget.HeightRequest = int.Parse(height.Value); } } XmlAttribute width = node.Attribute("Widght"); if (width != null) { if (width.IsBinding()) { throw new NotImplementedException(); } else { element.Widget.WidthRequest = int.Parse(width.Value); } } }
public static void BindAlignment(this VisualTreeElement element, XmlNode node, Control root) { XmlAttribute halign = node.Attribute("HorizontalAlignment"); if (halign != null) { if (halign.IsBinding()) { throw new NotImplementedException(); } else { element.Widget.Halign = (Align)Enum.Parse(typeof(Align), halign.Value); } } XmlAttribute valign = node.Attribute("VerticalAlignment"); if (valign != null) { if (valign.IsBinding()) { throw new NotImplementedException(); } else { element.Widget.Valign = (Align)Enum.Parse(typeof(Align), valign.Value); } } }
private static void BindClick(Button element, XmlNode node, Control root) { XmlAttribute attribute = node.Attribute("Click"); if (attribute.IsBinding()) { Action <EventHandler> subscribe = func => element.button.Clicked += func; root.BindingContext.BindCommand(subscribe, "Click", attribute.Value); } }
private static void BindText(Textbox element, XmlNode node, Control root) { XmlAttribute attribute = node.Attribute("Text"); if (attribute.IsBinding()) { Action <EventHandler> subscribe = func => ((IEditable)element.Widget).Changed += func; root.BindingContext.BindProperty(subscribe, () => element.Text, text => element.Text = text, "Text", attribute.Value); } else { element.Text = attribute?.Value; } }
public static BindingExpression BindingExpression(this XmlAttribute attribute) { if (attribute.IsBinding()) { string[] segments = attribute.Value.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string target = segments[1]; if (target.EndsWith("}")) { target = target.Substring(0, target.Length - 1); } return(new BindingExpression(attribute.Value, target, true)); } return(new BindingExpression(attribute.Value, string.Empty, false)); }
internal static void BindText(Label element, XmlNode node, Control root) { XmlAttribute attribute = node.Attribute("Text"); if (attribute.IsBinding()) { Action <EventHandler> subscribe = func => { }; root.BindingContext.BindProperty(subscribe, () => element.Text, text => element.Text = text, "Text", attribute.Value); } else { element.Text = attribute?.Value; } }
public static void BindMargin(this VisualTreeElement element, XmlNode node, Control root) { XmlAttribute attribute = node.Attribute("Margin"); if (attribute != null) { if (attribute.IsBinding()) { Action <EventHandler> subscribe = func => { }; root.BindingContext.BindProperty( subscribe, () => element.Widget.MarginString(), value => element.Widget.SetMargin((string)value), "Margin", attribute.Value); } else { element.Widget.SetMargin(attribute.Value); } } }
internal void BindValue(XmlNode node) { XmlAttribute valueAttribute = node.Attribute("Value"); if (valueAttribute != null) { if (valueAttribute.IsBinding()) { Gtk.Range range = (Gtk.Range)Widget; Action <EventHandler> subscribe = func => range.ValueChanged += func; BindingContext.BindProperty( subscribe, () => range.Value, value => range.Value = value, "Value", valueAttribute.Value); } else { throw new NotImplementedException("What possible reason could you have for doing this?"); } } }