Exemplo n.º 1
0
        protected virtual void OnItemSourceChanged(DependencyPropertyChangedEventArgs e)
        {
            DataTable table = e.NewValue as DataTable;

            this._itemSource = table;
            if (!string.IsNullOrEmpty(_dataField))
            {
                if (table != null)
                {
                    var componentFiller = new ComponentFiller();
                    componentFiller.FillComboxBox(table, _dataField, ref this.KarveComboBox);
                }
            }
        }
Exemplo n.º 2
0
 private void OnDataFieldPropertyChanged(DependencyPropertyChangedEventArgs e)
 {
     _dataField = e.NewValue as string;
     if (_itemSource != null)
     {
         if (!string.IsNullOrEmpty(_dataField))
         {
             DataColumnCollection collection = _itemSource.Columns;
             if (collection.Contains(_dataField))
             {
                 ComponentFiller componentFiller = new ComponentFiller();
                 componentFiller.FillComboxBox(_itemSource, _dataField, ref KarveComboBox);
             }
         }
     }
 }
Exemplo n.º 3
0
        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);
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void EditorTextOnLostFocus(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(_previousDataArea) && (string.IsNullOrEmpty(this._currentDataArea)))
            {
                return;
            }
            if (_editorText == null)
            {
                _editorText = GetTemplateChild("PART_EditorText") as MultiLineTextEditor;
            }
            if (_editorText == null)
            {
                return;
            }

            // ok
            _dataAreaChanged = _previousDataArea != _editorText.Text;

            if (_dataAreaChanged)
            {
                _previousDataArea = _currentDataArea;
                _currentDataArea  = _editorText.Text;
                if (_editorText.Text != null)
                {
                    DataAreaFieldEventsArgs ev = new DataAreaFieldEventsArgs(DataAreaChangedEvent);
                    ev.FieldData = _editorText.Text;
                    ComponentFiller filler = new ComponentFiller();

                    var dataObject = ControlExt.GetDataSource(this);
                    if (dataObject == null)
                    {
                        dataObject = DataSource;
                    }

                    if (!string.IsNullOrEmpty(DataSourcePath))
                    {
                        var path = DataSourcePath;
                        if (string.IsNullOrEmpty(DataSourcePath))
                        {
                            path = ControlExt.GetDataSourcePath(this);
                        }
                        filler.FillDataObject(_editorText.Text, path, ref dataObject);
                        DataSource = dataObject;

                        IDictionary <string, object> valueDictionary = CreateDictionary(dataObject, _editorText.Text, _previousDataArea);

                        ev.ChangedValuesObjects = valueDictionary;

                        if (ItemChangedCommand != null)
                        {
                            ICommand ex = ItemChangedCommand;
                            if (ex.CanExecute(valueDictionary))
                            {
                                ex.Execute(valueDictionary);
                            }
                        }
                        RaiseEvent(ev);
                        _dataAreaChanged = false;
                    }
                    else
                    {
                        IDictionary <string, object> valueDictionary = CreateDictionary(dataObject, _editorText.Text, _previousDataArea);
                        if (ItemChangedCommand != null)
                        {
                            ICommand ex = ItemChangedCommand;
                            if (ex.CanExecute(valueDictionary))
                            {
                                ex.Execute(valueDictionary);
                            }
                        }
                    }
                }
            }
        }