private void SourceDataListChanged(object sender, System.ComponentModel.ListChangedEventArgs e) { if (e.ListChangedType == ListChangedType.ItemChanged) { IBindingItem item = this.SourceData[e.NewIndex]; switch (item.Name) { case nameof(SourceController.LENGTH): int i = (int)item.Value; if (i > 0) { this.playbackLength = 1d / (int)item.Value; } else { this.playbackLength = 1d; } this.TaskbarItemInfo.ProgressValue = 0; break; case nameof(SourceController.CURRENTPOSITION): this.playbackPosition = (int)item.Value; this.TaskbarItemInfo.ProgressValue = this.playbackPosition * this.playbackLength; break; } } }
private async Task execIfCan(IBindingItem bi) { if (bi.CanCallCommand()) { await bi.Exec(); } }
#pragma warning disable CA1062 // Validate arguments of public methods protected override void DataSourceListChanged(object sender, ListChangedEventArgs e) { if (e.ListChangedType == ListChangedType.ItemChanged) { IBindingItem item = this.DataSource[e.NewIndex]; switch (item.Name) { case "PosterPath": if (string.IsNullOrEmpty((string)item.Value)) { this.imgPoster.Source = EMPTY_IMAGE; this.imgLogo.Visibility = Visibility.Hidden; } else { BeginSetFeaturePoster((string)item.Value); } break; case "Description": this.txtOverview.Text = (string)item.Value; break; } } }
#pragma warning disable CA1062 // Validate arguments of public methods protected override void DataSourceListChanged(object sender, ListChangedEventArgs e) { if (e.ListChangedType == ListChangedType.ItemChanged) { IBindingItem item = this.DataSource[e.NewIndex]; switch (item.Name) { case SourceController.CURRENTFILE: this.txtNowPlaying.Text = (string)item.Value; break; case SourceController.FILESIZE: this.txtFileSize.Text = (string)item.Value; break; case SourceController.POSITION: this.txtPostion.Text = (string)item.Value; break; case SourceController.DURATION: this.txtDuration.Text = (string)item.Value; break; case SourceController.CURRENTPOSITION: this.fileProgress.Value = (int)item.Value; break; case SourceController.LENGTH: this.fileProgress.Maximum = (int)item.Value; break; } } }
public IResult Bind(IBindingItem bindingItem) { if (null == bindingItem) { throw new ArgumentNullException("bindingItem"); } return(bindingItem.Bind()); }
private UnoCoreAnimation InitializeCompositeCoreAnimation(IBindingItem animatedItem) { var transform = animatedItem.DataContext as CompositeTransform; UIView view = transform.View; switch (animatedItem.PropertyName) { case CompositeTransformCenterX: case CompositeTransformCenterXWithNamespace: case "CenterX": //This animation is a Lie. transform.position.x doesn't exist, the real animator is the CPU bound one return(CreateCoreAnimation(view, "transform.position.x", value => new NSNumber(value))); case CompositeTransformCenterY: case CompositeTransformCenterYWithNamespace: case "CenterY": //This animation is a Lie. transform.position.x doesn't exist, the real animator is the CPU bound one return(CreateCoreAnimation(view, "transform.position.y", value => new NSNumber(value))); case CompositeTransformTranslateX: case CompositeTransformTranslateXWithNamespace: case "TranslateX": return(CreateCoreAnimation(view, "transform.translation.x", value => new NSNumber(value))); case CompositeTransformTranslateY: case CompositeTransformTranslateYWithNamespace: case "TranslateY": return(CreateCoreAnimation(view, "transform.translation.y", value => new NSNumber(value))); case CompositeTransformRotation: case CompositeTransformRotationWithNamespace: case "Rotation": return(CreateCoreAnimation(view, "transform.rotation", value => new NSNumber(Transform.ToRadians(value)))); case CompositeTransformScaleX: case CompositeTransformScaleXWithNamespace: case "ScaleX": return(CreateCoreAnimation(view, "transform.scale.x", value => new NSNumber(value))); case CompositeTransformScaleY: case CompositeTransformScaleYWithNamespace: case "ScaleY": return(CreateCoreAnimation(view, "transform.scale.y", value => new NSNumber(value))); //Again, we need to review how we handle SkewTransforms case CompositeTransformSkewX: case CompositeTransformSkewXWithNamespace: case "SkewX": return(CreateCoreAnimation(view, "transform", value => ToCASkewTransform(value, 0))); case CompositeTransformSkewY: case CompositeTransformSkewYWithNamespace: case "SkewY": return(CreateCoreAnimation(view, "transform", value => ToCASkewTransform(0, value))); default: throw new NotSupportedException(__notSupportedProperty); } }
private SqlCommand BuildCommand(IConfigurationElement commandElement, IBinder binder, WebPartManager manager) { SqlCommand command = new SqlCommand(); foreach (IConfigurationElementAttribute attribute in commandElement.Attributes.Values) { ReflectionServices.SetValue(command, attribute.ConfigKey, attribute.Value); } IBindingItemsCollection bindingParams = binder.NewBindingItemCollectionInstance(); binder.BindingSet.Add(commandElement.ConfigKey, bindingParams); foreach (IConfigurationElement parameterElement in commandElement.Elements.Values) { SqlParameter parameter = new SqlParameter(); foreach (IConfigurationElementAttribute parameterAttribute in parameterElement.Attributes.Values) { if ("bind" == parameterAttribute.ConfigKey) { string bindstring = parameterAttribute.Value.ToString(); bool isOutput = parameterElement.Attributes.ContainsKey("Direction") && ("Output" == parameterElement.GetAttributeReference("Direction").Value.ToString() || "InputOutput" == parameterElement.GetAttributeReference("Direction").Value.ToString()); if (bindstring.Contains(".")) { string sourcestring = bindstring.Substring(0, bindstring.IndexOf(".")); IBindingItem bindingItem = binder.NewBindingItemInstance(); if (!isOutput) { bindingItem.Source = manager.FindControl(sourcestring); bindingItem.SourceProperty = bindstring.Substring(sourcestring.Length + 1); bindingItem.Target = parameter; bindingItem.TargetProperty = "Value"; } else { bindingItem.Target = manager.FindControl(sourcestring); bindingItem.TargetProperty = bindstring.Substring(sourcestring.Length + 1); bindingItem.Source = parameter; bindingItem.SourceProperty = "Value"; } bindingParams.Add(bindingItem); } } else { ReflectionServices.SetValue(parameter, parameterAttribute.ConfigKey, parameterAttribute.Value); } } if (null == parameter.Value) { parameter.Value = DBNull.Value; } command.Parameters.Add(parameter); } return(command); }
private void add(MouseButtons button, IBindingItem cmd, IDictionary <MouseButtons, SortedList <ModifierKeys, IBindingItem> > ac, ModifierKeys keys) { SortedList <ModifierKeys, IBindingItem> list; if (!ac.TryGetValue(button, out list)) { list = new SortedList <ModifierKeys, IBindingItem>(new ModifierComparer()); ac.Add(button, list); } list.Add(keys, cmd); }
private UnoCoreAnimation InitializeRotateCoreAnimation(IBindingItem animatedItem) { var transform = animatedItem.DataContext as RotateTransform; if (animatedItem.PropertyName.Equals("Angle") || animatedItem.PropertyName.Equals(RotateTransformAngle) || animatedItem.PropertyName.Equals(RotateTransformAngleWithNamespace)) { return(CreateCoreAnimation(transform, "transform.rotation", value => new NSNumber(MathEx.ToRadians(value)))); } else { throw new NotSupportedException(__notSupportedProperty); } }
private UnoCoreAnimation InitializeScaleCoreAnimation(IBindingItem animatedItem) { var transform = animatedItem.DataContext as ScaleTransform; if (animatedItem.PropertyName.Equals("ScaleX") || animatedItem.PropertyName.Equals(ScaleTransformX) || animatedItem.PropertyName.Equals(ScaleTransformXWithNamespace)) { return(CreateCoreAnimation(transform, "transform.scale.x", value => new NSNumber(value))); } else if (animatedItem.PropertyName.Equals("ScaleY") || animatedItem.PropertyName.Equals(ScaleTransformY) || animatedItem.PropertyName.Equals(ScaleTransformYWithNamespace)) { return(CreateCoreAnimation(transform, "transform.scale.y", value => new NSNumber(value))); } else { throw new NotSupportedException(__notSupportedProperty); } }
private UnoCoreAnimation InitializeTranslateCoreAnimation(IBindingItem animatedItem) { var transform = animatedItem.DataContext as TranslateTransform; UIView view = transform.View; if (animatedItem.PropertyName.Equals("X") || animatedItem.PropertyName.Equals(TranslateTransformX) || animatedItem.PropertyName.Equals(TranslateTransformXWithNamespace)) { return(CreateCoreAnimation(view, "transform.translation.x", value => new NSNumber(value))); } else if (animatedItem.PropertyName.Equals("Y") || animatedItem.PropertyName.Equals(TranslateTransformY) || animatedItem.PropertyName.Equals(TranslateTransformYWithNamespace)) { return(CreateCoreAnimation(view, "transform.translation.y", value => new NSNumber(value))); } else { throw new NotSupportedException(__notSupportedProperty); } }
private UnoCoreAnimation InitializeSkewCoreAnimation(IBindingItem animatedItem) { // We need to review this. This won't play along if other transforms are happening at the same time since we are animating the whole transform var transform = animatedItem.DataContext as SkewTransform; UIView view = transform.View; if (animatedItem.PropertyName.Equals("AngleX") || animatedItem.PropertyName.Equals(SkewTransformAngleX) || animatedItem.PropertyName.Equals(SkewTransformAngleXWithNamespace)) { return(CreateCoreAnimation(view, "transform", value => ToCASkewTransform(value, 0))); } else if (animatedItem.PropertyName.Equals("AngleY") || animatedItem.PropertyName.Equals(SkewTransformAngleY) || animatedItem.PropertyName.Equals(SkewTransformAngleYWithNamespace)) { return(CreateCoreAnimation(view, "transform", value => ToCASkewTransform(0, value))); } else { throw new NotSupportedException(__notSupportedProperty); } }
public IResult Bind(IBindingItem bindingItem) { if (null == bindingItem) { throw new ArgumentNullException("bindingItem"); } return bindingItem.Bind(); }
public void AddOnClickAction(MouseButtons button, IBindingItem cmd, ModifierKeys key) { add(button, cmd, _clickActions, key); }
public void Add(IBindingItem item) { bindings.Add(new BindingItemWithLastValue(item, item.CanCallCommand())); }
public BindingItemWithLastValue(IBindingItem item, bool value) { this.BingingItem = item; LastCanCallResult = value; }
public BindingItemWithLastValue(IBindingItem item) { this.BingingItem = item; }
public Control CreateControl(IConfigurationElement controlElement, string index, IBinder binder, ITemplatingItem item, WebControl container, TableItemStyle invalidStyle, Dictionary <string, Control> registry, WebPartManager manager) { if (null == this._monitor) { throw new ApplicationException("Monitor not set"); } Control result; if (!controlElement.Attributes.ContainsKey("proxy") && !controlElement.Attributes.ContainsKey("type")) { result = null; } else { Control cellControl = null; string cellControlName = null; if (controlElement.Attributes.ContainsKey("proxy")) { object proxyIDValue = controlElement.GetAttributeReference("proxy").Value; string proxyID = null; if (null != proxyIDValue) { proxyID = proxyIDValue.ToString(); } if (string.IsNullOrEmpty(proxyID)) { result = null; return(result); } Control proxy = ReflectionServices.FindControlEx(proxyID, manager); if (null == proxy) { this._monitor.Register(this, this._monitor.NewEventInstance("create proxy error", null, new ApplicationException("can't find proxy " + proxyID), EVENT_TYPE.Error)); } string proxyMember = null; if (!controlElement.Attributes.ContainsKey("proxyMember")) { this._monitor.Register(this, this._monitor.NewEventInstance("create proxy error", null, new ApplicationException("proxyMember not found for proxy " + proxyID), EVENT_TYPE.Error)); } else { proxyMember = controlElement.GetAttributeReference("proxyMember").Value.ToString(); } try { cellControl = (ReflectionServices.ExtractValue(proxy, proxyMember) as Control); cellControlName = proxy + "." + proxyMember; } catch (Exception ex) { this._monitor.Register(this, this._monitor.NewEventInstance("create proxy error", null, ex, EVENT_TYPE.Error)); } if (cellControl == null && null != proxy) { this._monitor.Register(this, this._monitor.NewEventInstance("create proxy error", null, new ApplicationException(string.Format("member {0} of proxy type {1} is not a Control", proxyMember, proxy.GetType().FullName)), EVENT_TYPE.Error)); } } else { Control scope = container; if (container is TableCell) { scope = container.Parent.Parent; } try { cellControl = this.CreateControl(controlElement.GetAttributeReference("type").Value.ToString(), new bool?(item == null || item.IsReadOnly), scope); cellControlName = controlElement.GetAttributeReference("type").Value.ToString(); } catch (Exception ex) { this._monitor.Register(this, this._monitor.NewEventInstance("create control error", null, ex, EVENT_TYPE.Error)); } } if (null == cellControl) { result = null; } else { string type = null; if (controlElement.Attributes.ContainsKey("type")) { type = controlElement.GetAttributeReference("type").Value.ToString(); if (cellControl is IButtonControl) { IButtonControl btn = cellControl as IButtonControl; if (("Commander" == type || "LinkCommander" == type) && !controlElement.Attributes.ContainsKey("command")) { this._monitor.Register(this, this._monitor.NewEventInstance(string.Format("create {0} error", type), null, new ApplicationException("command not found"), EVENT_TYPE.Error)); } else { if (controlElement.Attributes.ContainsKey("command")) { btn.CommandName = controlElement.GetAttributeReference("command").Value.ToString(); } } btn.CommandArgument = index; } if (cellControl is StatelessDropDownList) { ((StatelessDropDownList)cellControl).CommandArgument = index; } } if (null != registry) { registry.Add(controlElement.ConfigKey, cellControl); } var properties = controlElement.Elements.Values; foreach (IConfigurationElement controlPropertyElement in properties) { if (!controlPropertyElement.Attributes.ContainsKey("for") || !("cell" == controlPropertyElement.GetAttributeReference("for").Value.ToString())) { string propertyName = null; if (!controlPropertyElement.Attributes.ContainsKey("member")) { this._monitor.Register(this, this._monitor.NewEventInstance(string.Format("'{0}' property set error", cellControlName), null, new ApplicationException(string.Format("member not found for '{0}'", controlPropertyElement.ConfigKey)), EVENT_TYPE.Error)); } else { propertyName = controlPropertyElement.GetAttributeReference("member").Value.ToString(); } IExpression expression = null; LWAS.Extensible.Interfaces.IResult expressionResult = null; if (controlPropertyElement.Elements.ContainsKey("expression")) { IConfigurationElement expressionElement = controlPropertyElement.GetElementReference("expression"); Manager sysmanager = manager as Manager; if (null != sysmanager && null != sysmanager.ExpressionsManager && expressionElement.Attributes.ContainsKey("type")) { expression = sysmanager.ExpressionsManager.Token(expressionElement.GetAttributeReference("type").Value.ToString()) as IExpression; if (null != expression) { try { expression.Make(expressionElement, sysmanager.ExpressionsManager); expressionResult = expression.Evaluate(); } catch (ArgumentException ax) { } } } } object defaultValue = null; if (!string.IsNullOrEmpty(propertyName) && controlPropertyElement.Attributes.ContainsKey("value")) { defaultValue = controlPropertyElement.GetAttributeReference("value").Value; if (null == expression || null == binder) { try { if (string.IsNullOrEmpty(cellControlName) || propertyName != this.KnownTypes[cellControlName].ReadOnlyProperty || (propertyName == this.KnownTypes[cellControlName].ReadOnlyProperty && defaultValue != null && !string.IsNullOrEmpty(defaultValue.ToString()))) { if (propertyName == "Watermark") { if (null != defaultValue && !String.IsNullOrEmpty(defaultValue.ToString())) { ReflectionServices.SetValue(cellControl, propertyName, defaultValue); } } else { ReflectionServices.SetValue(cellControl, propertyName, defaultValue); } } } catch (Exception ex) { this._monitor.Register(this, this._monitor.NewEventInstance(string.Format("'{0}'.'{1}'='{2}' error", cellControlName, propertyName, controlPropertyElement.GetAttributeReference("value").Value), null, ex, EVENT_TYPE.Error)); } } else { IBindingItem bindingItem = binder.NewBindingItemInstance(); bindingItem.Source = new Dictionary <string, object>() { { "0", defaultValue } }; bindingItem.SourceProperty = "0"; bindingItem.Target = cellControl; bindingItem.TargetProperty = propertyName; bindingItem.Expression = expression; bindingItem.ExpressionEvaluationResult = expressionResult; binder.BindingItems.Add(bindingItem); } } if (controlPropertyElement.Attributes.ContainsKey("isList") && (bool)controlPropertyElement.GetAttributeReference("isList").Value) { object list = null; try { list = ReflectionServices.ExtractValue(cellControl, propertyName); if (null == list) { throw new InvalidOperationException(string.Format("Member '{0}' is empty", propertyName)); } if (!(list is ListItemCollection) && !(list is IDictionary <string, object>)) { throw new InvalidOperationException(String.Format("Unsupported list type '{0}'", list.GetType().Name)); } } catch (Exception ex) { this._monitor.Register(this, this._monitor.NewEventInstance("failed to retrive the list", null, ex, EVENT_TYPE.Error)); } if (null != list) { if (controlPropertyElement.Attributes.ContainsKey("hasEmpty") && (bool)controlPropertyElement.GetAttributeReference("hasEmpty").Value) { if (list is ListItemCollection) { ((ListItemCollection)list).Add(""); } else if (list is Dictionary <string, object> ) { ((Dictionary <string, object>)list).Add("", ""); } } foreach (IConfigurationElement listItemElement in controlPropertyElement.Elements.Values) { string value = null; string text = null; string pull = null; if (listItemElement.Attributes.ContainsKey("value") && null != listItemElement.GetAttributeReference("value").Value) { value = listItemElement.GetAttributeReference("value").Value.ToString(); } if (listItemElement.Attributes.ContainsKey("text") && null != listItemElement.GetAttributeReference("text").Value) { text = listItemElement.GetAttributeReference("text").Value.ToString(); } if (listItemElement.Attributes.ContainsKey("pull") && null != listItemElement.GetAttributeReference("pull").Value) { pull = listItemElement.GetAttributeReference("pull").Value.ToString(); } if (list is ListItemCollection) { ListItem li = new ListItem(text, value); ((ListItemCollection)list).Add(li); if (null != binder && !String.IsNullOrEmpty(pull)) { IBindingItem bindingItem = binder.NewBindingItemInstance(); bindingItem.Source = item.Data; bindingItem.SourceProperty = pull; bindingItem.Target = li; bindingItem.TargetProperty = "Text"; bindingItem.Expression = expression; binder.BindingItems.Add(bindingItem); } } else if (list is Dictionary <string, object> ) { ((Dictionary <string, object>)list).Add(value, text); if (null != binder && !String.IsNullOrEmpty(pull)) { IBindingItem bindingItem = binder.NewBindingItemInstance(); bindingItem.Source = item.Data; bindingItem.SourceProperty = pull; bindingItem.Target = list; bindingItem.TargetProperty = value; bindingItem.Expression = expression; binder.BindingItems.Add(bindingItem); } } } } } if (controlPropertyElement.Attributes.ContainsKey("property")) { if (container.Page != null && null != binder) { IBindingItem bindingItem = binder.NewBindingItemInstance(); bindingItem.Source = WebPartManager.GetCurrentWebPartManager(container.Page); bindingItem.SourceProperty = "WebParts." + controlPropertyElement.GetAttributeReference("property").Value.ToString(); bindingItem.Target = cellControl; bindingItem.TargetProperty = propertyName; if (string.IsNullOrEmpty(cellControlName) || propertyName != this.KnownTypes[cellControlName].ReadOnlyProperty) { bindingItem.DefaultValue = defaultValue; } bindingItem.Expression = expression; binder.BindingItems.Add(bindingItem); } } if (controlPropertyElement.Attributes.ContainsKey("pull")) { string pull = controlPropertyElement.GetAttributeReference("pull").Value.ToString(); if (binder != null && null != item) { IBindingItem bindingItem = binder.NewBindingItemInstance(); bindingItem.Source = item.Data; bindingItem.SourceProperty = pull; bindingItem.Target = cellControl; bindingItem.TargetProperty = propertyName; if (string.IsNullOrEmpty(cellControlName) || propertyName != this.KnownTypes[cellControlName].ReadOnlyProperty) { bindingItem.DefaultValue = defaultValue; } bindingItem.Expression = expression; binder.BindingItems.Add(bindingItem); if (item.InvalidMember == bindingItem.SourceProperty) { container.ApplyStyle(invalidStyle); } } if (this.IsDesignEnabled && propertyName == this.KnownTypes[cellControlName].WatermarkProperty) { // StyleTextBox has its own Watermark feature if (typeof(StyledTextBox).IsInstanceOfType(cellControl)) { ReflectionServices.SetValue(cellControl, "Watermark", pull); } else { container.Attributes.Add("watermark", pull); } } } } } result = cellControl; } } return(result); }
private Table BuildItemTemplate(IConfigurationSection section, IBinder binder, FormViewMode mode) { Table table = new Table(); table.ID = "table"; foreach (IConfigurationElement rowElement in section.Elements.Values) { string[] span = null; if (rowElement.Attributes.ContainsKey("span")) { span = rowElement.GetAttributeReference("span").Value.ToString().Split(new char[] { ',' }); } string[] rowspan = null; if (rowElement.Attributes.ContainsKey("rowspan")) { rowspan = rowElement.GetAttributeReference("rowspan").Value.ToString().Split(new char[] { ',' }); } TableRow tr = new TableRow(); tr.ID = "tr" + table.Rows.Count.ToString(); int count = 0; foreach (IConfigurationElement controlElement in rowElement.Elements.Values) { TableCell tc = new TableCell(); tc.ID = tr.ID + "tc" + tr.Cells.Count; if (span != null && span.Length > count) { int columnSpan = 1; int.TryParse(span[count], out columnSpan); tc.ColumnSpan = columnSpan; if (rowspan != null && rowspan.Length > count) { int rowSpan = 1; int.TryParse(rowspan[count], out rowSpan); tc.RowSpan = rowSpan; } count++; } string type = null; if (controlElement.Attributes.ContainsKey("type")) { type = controlElement.GetAttributeReference("type").Value.ToString(); } if (!String.IsNullOrEmpty(type)) { Control cellControl = this.CreateControl(type, mode); cellControl.ID = tc.ID + controlElement.ConfigKey; foreach (IConfigurationElement controlPropertyElement in controlElement.Elements.Values) { string propertyName = controlPropertyElement.GetAttributeReference("member").Value.ToString(); if (controlPropertyElement.Attributes.ContainsKey("value")) { ReflectionServices.SetValue(cellControl, propertyName, controlPropertyElement.GetAttributeReference("value").Value); } if (controlPropertyElement.Attributes.ContainsKey("isList") && (bool)controlPropertyElement.GetAttributeReference("isList").Value) { ListItemCollection list = ReflectionServices.ExtractValue(cellControl, propertyName) as ListItemCollection; if (null == list) { throw new InvalidOperationException(string.Format("Member '{0}' is not a ListItemCollection", propertyName)); } if (controlPropertyElement.Attributes.ContainsKey("hasEmpty") && (bool)controlPropertyElement.GetAttributeReference("hasEmpty").Value) { if (list is ListItemCollection) { ((ListItemCollection)list).Add(""); } } foreach (IConfigurationElement listItemElement in controlPropertyElement.Elements.Values) { list.Add(new ListItem(listItemElement.GetAttributeReference("text").Value.ToString(), listItemElement.GetAttributeReference("value").Value.ToString())); } } if (controlPropertyElement.Attributes.ContainsKey("pull")) { string pull = controlPropertyElement.GetAttributeReference("pull").Value.ToString(); IBindingItem bindingItem = binder.NewBindingItemInstance(); bindingItem.Source = null; bindingItem.SourceProperty = pull; bindingItem.Target = cellControl; bindingItem.TargetProperty = propertyName; binder.BindingItems.Add(bindingItem); if (cellControl is BaseDataBoundControl) { this._boundControls.Add(pull, cellControl); if (!this._dataSources.ContainsKey(pull)) { this._dataSources.Add(pull, null); } } } } tc.Controls.Add(cellControl); } tr.Cells.Add(tc); } table.Rows.Add(tr); } return(table); }