/// <summary> /// SelectionChanged. This event get triggered when the selection change in a property /// </summary> /// <param name="sender">The sender of the call</param> /// <param name="e"> Event args</param> private static void ComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { var comboBox = sender as ComboBox; if (comboBox != null) { var command = comboBox.GetValue(ItemChangedCommandProperty) as ICommand; if (command != null) { IDictionary <string, object> objectName = new Dictionary <string, object>(); object dataObject = GetDataSource(comboBox); if (dataObject != null) { string dataPath = GetDataSourcePath(comboBox); if (string.IsNullOrEmpty(dataPath)) { int selectedIndex = comboBox.SelectedIndex; ComponentUtils.SetPropValue(dataObject, dataPath, selectedIndex); objectName["ChangedIndex"] = selectedIndex; objectName["ChangedValue"] = comboBox.SelectedValue; } objectName["DataObject"] = GetDataSource(comboBox); objectName["DataSourcePath"] = GetDataSourcePath(comboBox); } command.Execute(objectName); } } }
/// <summary> /// Fill the data object with a type /// </summary> /// <param name="textField">Field of the text.</param> /// <param name="dataObject">Data object to be filled.</param> /// <param name="dataField">Data field to be filled.</param> public void FillDataObject(object textField, string dataField, ref object dataObject) { bool isBasedDto = (dataObject is BaseViewObject); if (dataObject == null) { return; } try { if (!isBasedDto) { ComponentUtils.SetPropValue(dataObject, "Value." + dataField, textField, true); var tmpValue = ComponentUtils.GetPropValue(dataObject, "Value." + dataField); if (tmpValue.ToString() != textField.ToString()) { ComponentUtils.SetPropValue(dataObject, "Value." + dataField.ToUpper(), textField, true); } } else { ComponentUtils.SetPropValue(dataObject, dataField, textField, true); var tmpValue = ComponentUtils.GetPropValue(dataObject, dataField); if (tmpValue.ToString() != textField.ToString()) { ComponentUtils.SetPropValue(dataObject, dataField.ToUpper(), textField, true); } } } catch (Exception e) { string msg = e.Message; } }
public void Execute() { var cpValue = ComponentUtils.GetTextDo(DataObject, "CP", DataType.Any); if (!string.IsNullOrEmpty(cpValue)) { var provinceValue = cpValue.Substring(0, 2); ComponentUtils.SetPropValue(DataObject, "PROV", provinceValue); } }
private void ExecuteRules(object newValue) { var newDataObject = newValue; var box = this.RelatedObject as DualFieldSearchBox; if (newDataObject != null) { var cpValue = ComponentUtils.GetTextDo(newDataObject, "CP", DataType.Any); if (!string.IsNullOrEmpty(cpValue)) { var provinceValue = cpValue.Substring(0, 2); if (newValue is BaseViewObject) { SetValues(provinceValue, "PROV", "PROVINCIA", newDataObject); } else { SetValues(provinceValue, "Value.PROV", "Value.PROVINCIA", newDataObject); } } } ExecuteRuleOnPobla(newValue); /* * Basically this does the same as above but with the related paths. */ if (!string.IsNullOrEmpty(RelatedPath)) { var relatedValue = ComponentUtils.GetTextDo(newDataObject, Path, DataType.Any); if (!string.IsNullOrEmpty(relatedValue)) { var provinceValue = relatedValue.Substring(0, 2); string pathStr; if (newDataObject is BaseViewObject) { pathStr = RelatedPath; } else { pathStr = "Value." + RelatedPath; } ComponentUtils.SetPropValue(newDataObject, pathStr, provinceValue); } } if (box != null) { box.DataView = newDataObject; } }
private void SetValues(string provinceValue, string provField, string proveExt, object newDataObject) { var prov = ComponentUtils.GetTextDo(newDataObject, provField, DataType.Any); if (!string.IsNullOrEmpty(prov)) { ComponentUtils.SetPropValue(newDataObject, provField, provinceValue); } else { var provincia = ComponentUtils.GetTextDo(newDataObject, proveExt, DataType.Any); if (!string.IsNullOrEmpty(provincia)) { ComponentUtils.SetPropValue(newDataObject, proveExt, provinceValue); } } }
private void PhoneTextBox_LostFocus(object sender, RoutedEventArgs e) { if (textChanged) { ComponentUtils.SetPropValue(DataObject, Phone, _phoneTextBox.Text); IDictionary <string, object> valueDictionary = new Dictionary <string, object> { [DATAOBJECT] = DataObject, [CHANGED_VALUE] = _phoneTextBox.Text }; if (ItemChangedCommand != null) { if (ItemChangedCommand.CanExecute(valueDictionary)) { ItemChangedCommand.Execute(valueDictionary); } } textChanged = false; } }
private void ChangedValue(string path, string value) { if (textChanged) { ComponentUtils.SetPropValue(DataObject, path, value); IDictionary <string, object> valueDictionary = new Dictionary <string, object> { [DATAOBJECT] = DataObject, [CHANGED_VALUE] = value, ["Field"] = path }; if (ItemChangedCommand != null) { if (ItemChangedCommand.CanExecute(valueDictionary)) { ItemChangedCommand.Execute(valueDictionary); } } textChanged = false; } }
private static void DataSourcePathChange(DependencyObject d, DependencyPropertyChangedEventArgs e) { string path = e.NewValue as string; object value = GetDataSource(d); ComponentFiller filler = new ComponentFiller(); if (value != null) { if (value is DataTable) { DataTable currentTable = value as DataTable; filler.FetchDataFieldObject(currentTable, path); } else { var propValue = ComponentUtils.GetPropValue(value, path); if (propValue != null) { ComponentUtils.SetPropValue(value, path, propValue); } } } }