コード例 #1
0
        /// <summary>
        /// 添加。
        /// 如BindingSource不为空,则设置数据源
        /// </summary>
        /// <param name="item"></param>
        public override void Add(IBindingControl item)
        {
            if (m_bindingSource != null)
            {
                item.SetDataBinding(m_bindingSource, "");
            }

            base.Add(item);
        }
        /// <summary>
        /// ��ӡ�
        /// ��BindingSource��Ϊ�գ�����������Դ
        /// </summary>
        /// <param name="item"></param>
        public override void Add(IBindingControl item)
        {
            if (m_bindingSource != null)
            {
                item.SetDataBinding(m_bindingSource, "");
            }

            base.Add(item);
        }
コード例 #3
0
        public static void Refresh <TSourceValue, TTargetValue>(
            BindingMode bindingMode,
            IBindingControl <TSourceValue, TTargetValue> bindingControl)
        {
            switch (bindingMode)
            {
#if WPF
            case BindingMode.OneWayToSource:
                break;
#endif
            default:
                bindingControl.UpdateTargetValue();
                break;
            }
        }
コード例 #4
0
        private bool TryPeek(out IBindingControl bindingControl)
        {
#if WINDOWS_UWP
            return(this.bindingControlQueue.TryPeek(out bindingControl));
#else
            if (this.bindingControlQueue.Count > 0)
            {
                bindingControl = this.bindingControlQueue.Peek();
                return(true);
            }

            bindingControl = null;
            return(false);
#endif
        }
コード例 #5
0
        /// <summary>
        /// Enqueues the specified binding control.
        /// </summary>
        /// <param name="bindingControl">The binding control.</param>
        /// <returns>A dequeuer.</returns>
        public bool TryEnqueue(IBindingControl bindingControl)
        {
            /*if (this.bindingControlSet.Contains(bindingControl))
             * {
             *  return false;
             * }
             *
             * this.bindingControlSet.Add(bindingControl);*/

            if (this.bindingControlQueue.Contains(bindingControl))
            {
                return(false);
            }

            this.bindingControlQueue.Enqueue(bindingControl);
            return(true);
        }
コード例 #6
0
        /// <summary>
        /// 在列表末尾添加新的实体类。
        /// 如当前状态为StateType.Add或StateType.Edit,则直接返回,不添加新记录
        /// 状态设置为<see cref="StateType.Add"/>,
        /// 当前位置设置为新添加的实体类位置,
        /// 焦点转移到第一个可添加数据的的数据控件
        /// </summary>
        protected override object DoAddNew()
        {
            if (State == StateType.Add || State == StateType.Edit)
            {
                return(null);
            }

            // before load, m_item is null
            if (this.DisplayManager.Items == null)
            {
                IList newList = NewList();

                // not to set BindingControls
                if (this.DisplayManager.BindingControls.Count > 0)
                {
                    IBindingControl[] bcs = new IBindingControl[this.DisplayManager.BindingControls.Count];
                    this.DisplayManager.BindingControls.CopyTo(bcs, 0);
                    this.DisplayManager.BindingControls.Clear();

                    this.DisplayManager.SetDataBinding(newList, string.Empty);

                    this.DisplayManager.BindingControls.AddRange(bcs);
                }
                else
                {
                    this.DisplayManager.SetDataBinding(newList, string.Empty);
                }
            }

            object entity = AddNewItem();

            m_beforeAddPos = this.DisplayManager.Position;
            this.DisplayManager.Position = this.DisplayManager.Items.Count - 1;

            State = StateType.Add;

            return(entity);
            //this.DisplayManager.DataControls.FocusFirstInsertableControl();
        }
コード例 #7
0
        /// <summary>Updates the specified data binding state.</summary>
        /// <param name="bindingControl">The binding control.</param>
        public void Update(IBindingControl bindingControl)
        {
            if (this.bindingDispatcher.HasAccess)
            {
                bindingControl.UpdateTargetValue();
                return;
            }

            if (bindingControl.IsUpdatePending)
            {
                return;
            }

            bindingControl.IsUpdatePending = true;
            var shouldDispatch = this.updateQueue.IsEmpty;

            this.updateQueue.Enqueue(bindingControl);
            if (shouldDispatch)
            {
                this.bindingDispatcher.InvokeAsync(this.PerformUpdate);
            }
        }
コード例 #8
0
 public void Initialize(IBindingControl bindingControl)
 {
     this.bindingControl = bindingControl;
 }
コード例 #9
0
        public static void UpdateTargetValue <TRoot, TSource, TSourceValue, TTarget, TTargetValue>(
            IBindingControl <TSourceValue, TTargetValue> bindingControl,
            IDataBindingState <TRoot, TSource, TSourceValue, TTarget, TTargetValue> dataBindingState)
            where TTarget : DependencyObject
        {
            if (dataBindingState.IsUpdating)
            {
                return;
            }

            TTargetValue targetValue = default;
            var          setValue    = false;

            try
            {
                var target = dataBindingState.Target;
                if (target != null)
                {
                    setValue = true;
                    if (dataBindingState.TryGetSourceValue(out var sourceValue))
                    {
                        targetValue = dataBindingState.ConversionParameters.ValueConverter != null?dataBindingState.ConversionParameters.ValueConverter.Convert(
                            sourceValue,
                            typeof(TTargetValue),
                            dataBindingState.ConversionParameters.ConverterParameter,
#if WINDOWS_UWP
                            (string)target.GetValue(FrameworkElement.LanguageProperty))
#else
                            ((XmlLanguage)target.GetValue(FrameworkElement.LanguageProperty)).GetSpecificCulture())
#endif
                                      : bindingControl.Convert(sourceValue);
                    }
                    else
                    {
                        targetValue = dataBindingState.ConversionParameters.TargetNullValue.Value;
                    }
                }
            }
            catch (Exception)
            {
                setValue    = true;
                targetValue = dataBindingState.ConversionParameters.FallbackValue.Value;
            }
            finally
            {
                /*if (!Equals(targetValue, dataBindingState.CurrentTargetValue))
                 * {*/
                if (setValue)
                {
                    dataBindingState.IsUpdating = true;
                    //// dataBindingState.CurrentTargetValue = targetValue;
#if WINDOWS_UWP
                    dataBindingState.Target.SetValue(dataBindingState.TargetProperty, targetValue);
#else
                    dataBindingState.Target.SetCurrentValue(dataBindingState.TargetProperty, targetValue);
#endif
                    dataBindingState.IsUpdating = false;
                    //// }
                }
            }
        }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Dequeuer" /> struct.
 /// </summary>
 /// <param name="updateQueue">The update queue.</param>
 /// <param name="bindingControl">The binding control.</param>
 public Dequeuer(UpdateQueue updateQueue, IBindingControl bindingControl)
 {
     this.updateQueue = updateQueue;
     this.Value       = bindingControl;
 }
コード例 #11
0
 internal void Remove(IBindingControl bindingControl)
 {
     this.bindingControlQueue.Dequeue();
     //// this.bindingControlSet.Remove(bindingControl);
 }
コード例 #12
0
        /// <summary>
        /// ���б�ĩβ����µ�ʵ���ࡣ
        /// �統ǰ״̬ΪStateType.Add��StateType.Edit����ֱ�ӷ��أ�������¼�¼
        /// ״̬����Ϊ<see cref="StateType.Add"/>��
        /// ��ǰλ������Ϊ����ӵ�ʵ����λ�ã�
        /// ����ת�Ƶ���һ����������ݵĵ����ݿؼ�
        /// </summary>
        protected override object DoAddNew()
        {
            if (State == StateType.Add || State == StateType.Edit)
            {
                return null;
            }

            // before load, m_item is null
            if (this.DisplayManager.Items == null)
            {
                IList newList = NewList();

                // not to set BindingControls
                if (this.DisplayManager.BindingControls.Count > 0)
                {
                    IBindingControl[] bcs = new IBindingControl[this.DisplayManager.BindingControls.Count];
                    this.DisplayManager.BindingControls.CopyTo(bcs, 0);
                    this.DisplayManager.BindingControls.Clear();

                    this.DisplayManager.SetDataBinding(newList, string.Empty);

                    this.DisplayManager.BindingControls.AddRange(bcs);
                }
                else
                {
                    this.DisplayManager.SetDataBinding(newList, string.Empty);
                }
            }

            object entity = AddNewItem();

            m_beforeAddPos = this.DisplayManager.Position;
            this.DisplayManager.Position = this.DisplayManager.Items.Count - 1;

            State = StateType.Add;

            return entity;
            //this.DisplayManager.DataControls.FocusFirstInsertableControl();
        }