Esempio n. 1
0
 private void DataField_LostFocus(object sender, RoutedEventArgs e)
 {
     if ((TextField.Text.Length > 0) && (_textContentChanged))
     {
         DataFieldEventArgs ev = new DataFieldEventArgs(DataFieldChangedEvent)
         {
             FieldData = TextField.Text
         };
         IDictionary <string, object> valueDictionary = new Dictionary <string, object>
         {
             [TABLENAME]     = TableName,
             [FIELD]         = DataSourcePath,
             [DATATABLE]     = ItemSource,
             [CHANGED_VALUE] = TextField.Text
         };
         _filler.FillDataObject(TextField.Text, DataSourcePath, ref _dataObject);
         DataObject = _dataObject;
         valueDictionary[DATAOBJECT] = DataObject;
         ev.ChangedValuesObjects     = valueDictionary;
         if (this.ItemChangedCommand != null)
         {
             if (ItemChangedCommand.CanExecute(valueDictionary))
             {
                 ItemChangedCommand.Execute(valueDictionary);
             }
         }
         else
         {
             RaiseEvent(ev);
         }
         _textContentChanged = false;
     }
 }
Esempio n. 2
0
        // fill the data object if the data source path is ready
        private void FillDo(string value, ref object dataObject)
        {
            var source = DataSourcePath;

            if (string.IsNullOrEmpty(source))
            {
                return;
            }
            if (!string.IsNullOrEmpty(value))
            {
                _filler.FillDataObject(value, DataSourcePath, ref dataObject);
            }
        }
Esempio n. 3
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);
                            }
                        }
                    }
                }
            }
        }