Ejemplo n.º 1
0
        /// <summary>
        /// Creates a binding between data and UI elements. It allows for either ONE_WAY binding (the UI is updated by data) or
        /// TWO_WAY binding (the UI is still updated by the data, but the data source is updated by the UI property on close).
        /// </summary>
        protected void CreateBinding <T1, T2>(object UIObject, string UIPropName, object DataSource, string DataSourcePropName, int BindingType, bool UpdateOnTimer)
        {
            if (UIObject.GetType() != typeof(T1))
            {
                return;
            }
            FieldPointer <T1> UIPointer         = new FieldPointer <T1>(UIObject, UIPropName);
            FieldPointer <T2> DataSourcePointer = new FieldPointer <T2>(DataSource, DataSourcePropName);

            if (UpdateOnTimer)
            {
                BindingType += 2;                 // <-- Converts ONE_WAY to ONE_WAY_WITH_TIMER and same for TWO_WAY
            }
            if (BindingList == null)
            {
                BindingList = new List <DlgBind>();
            }
            BindingList.Add(new GenericDlgBind <T1, T2>(UIPointer, DataSourcePointer, BindingType));
            if (UpdateOnTimer && (updateTimer == null || !updateTimer.Enabled))
            {
                updateTimer = CREATE_TIMER(OnUpdateDialog, 250);
            }
            else
            {
                OnUpdateDialog();
            }
        }
Ejemplo n.º 2
0
        public void ValidateParameterValues(ParameterValueCollection parameters)
        {
            List <ParameterClass> ps = _event.GetParameters(this);

            if (ps.Count > 0)
            {
                if (ps[0].IsLibType && typeof(object).Equals(ps[0].BaseClassType))
                {
                    if (string.Compare("sender", ps[0].Name, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        if (parameters.Count == 0)
                        {
                            ParameterValue pv = new ParameterValue(_action);
                            pv.Name = ps[0].Name;
                            pv.SetDataType(typeof(object));
                            pv.ValueType = EnumValueType.Property;
                            pv.Property  = _event.RootPointer;
                            parameters.Add(pv);
                        }
                        if (ps.Count > 1)
                        {
                            if (ps[1].IsLibType && typeof(EventArgs).Equals(ps[1].BaseClassType))
                            {
                                if (parameters.Count < 2)
                                {
                                    ParameterValue pv = new ParameterValue(_action);
                                    pv.Name = ps[1].Name;
                                    pv.SetDataType(typeof(EventArgs));
                                    pv.ValueType = EnumValueType.Property;
                                    FieldPointer fp = new FieldPointer();
                                    fp.Owner      = new DataTypePointer(new TypePointer(typeof(EventArgs)));
                                    fp.MemberName = "Empty";
                                    pv.Property   = fp;
                                    parameters.Add(pv);
                                }
                            }
                        }
                    }
                }
            }
            ParameterValueCollection.ValidateParameterValues(parameters, ps, this);
        }