Exemplo n.º 1
0
        public void RegisterAction(DynamicFormAction a)
        {
#if DEBUG_TRACE_LOG_ON
            _logger.Debug(string.Format("Dynamic action registered {0} - {1} [{2}]", a.ActionType, a.FieldName, a.Param));
#endif
            _actions[a.ActionType].Add(a);
        }
Exemplo n.º 2
0
        // handle specific action if trigger was called
        private void FireAction(DynamicFormActionTrigger trigger, DynamicFormAction action, object sender, ModelPropertyChangedEventArgs e)
        {
#if DEBUG_TRACE_LOG_ON
            _logger.Debug(string.Format("Form support Trigger: {0} for {1} with value {2} exec -> {3}", trigger.ActionType, trigger.FieldName, e.Value?.ToString(), action.FieldName));
#endif

            // handle execution of actions
            switch (trigger.ActionType)
            {
            case DynamicFormActionType.MaskedEnable:
            {
                MaskedEnable_FireAction(trigger, action, sender, e);
                break;
            }

            case DynamicFormActionType.MaskedVisible:
            {
                MaskedVisible_FireAction(trigger, action, sender, e);
                break;
            }

            default:

                // skip unknown action
#if DEBUG_TRACE_LOG_ON
                _logger.Error(string.Format("Form support unknown action! {1}", trigger.ActionType));
#endif
                break;
            }
        }
Exemplo n.º 3
0
        private void MaskedEnable_FireAction(DynamicFormActionTrigger trigger, DynamicFormAction action, object sender, ModelPropertyChangedEventArgs e)
        {
            // find all controls and set enabled / disabled state using proper mask
            Type enumType = trigger.Param as Type;

            if (enumType == null)
            {
                // wrong settings
                _logger.Error(string.Format("MaskedEnable_FireAction: Wrong mask enum type!"));
                return;
            }

            int mask = 0;

            try
            {
                mask = ExtendedEnum.ToInt(enumType, e.Value); //e.Value != null && e.Value.ToString() != "" ? (int)System.Enum.Parse(enumType, e.Value.ToString(), true) : 0;
            }
            catch (Exception)
            {
                //_logger.Error(string.Format("MaskedEnable_FireAction: Wrong mask enum value [{0}]!", e.Value.ToString()));
            }


            // get control
            if (ReferenceEquals(null, action.Control))
            {
                action.Control = FindControlByPropertyName(action.FieldName);
            }

            if (!ReferenceEquals(null, action.Control))
            {
                // reset data using binding source of this action
                FilterObjectbase fo = action.BindingSource?.Current as FilterObjectbase;
                if (!ReferenceEquals(fo, null))
                {
                    action.Control.DataBindings[0].DataSourceUpdateMode = DataSourceUpdateMode.Never;
                    // reset field
                    fo.ResetFieldByName(action.FieldName);
                    // turn back DS update mode
                    action.Control.DataBindings[0].DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged;
                }
                // confront field bits with enable mask arrived from trigger
                // control remain enable only if all mask (trigger) bits are present allow bitset of field (action target)
                if ((((int)(object)action.Param & (int)(object)mask) > 0))
                {
                    action.Control.Enabled = true;
                }
                else
                {
                    action.Control.Enabled = false;
                }
                // set back default style
                if (action.Control is TextEdit)
                {
                    (action.Control as TextEdit).StyleController = DefaultStyles.ContainsKey((action.Control as TextEdit)) ? DefaultStyles[(action.Control as TextEdit)] : null;
                }
            }
        }
Exemplo n.º 4
0
 private void MaskedVisible_FireAction(DynamicFormActionTrigger trigger, DynamicFormAction action, object sender, ModelPropertyChangedEventArgs e)
 {
     throw new NotImplementedException();
 }