Ejemplo n.º 1
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;
                }
            }
        }
Ejemplo n.º 2
0
        protected override void resetSlavesOfModifiedProperty(ResetSlavesAttribute att)
        {
            //should be overridden
            //we need reset slaves chain
            FilterObjectbase fo = Current as FilterObjectbase;

            att.Slaves.ToList().ForEach(
                s =>
            {
                fo.GetFilterFieldByPath(s)?.Reset();
            }
                );
        }
Ejemplo n.º 3
0
        private void repItemKeyDownHandler(object sender, KeyEventArgs ke)
        {
            if ((ke.Control && ke.KeyCode == Keys.Delete) || ((ke.KeyCode == Keys.Delete || ke.KeyCode == Keys.Back) && (sender as TextEdit)?.Text?.Length == 0))
            {
                // reset field
                FilterObjectbase fo = Current as FilterObjectbase;
                if (fo != null)
                {
                    // get field using binding
                    if ((sender as Control).DataBindings.Count > 0)
                    {
                        string FieldName = (sender as Control).DataBindings[0].BindingMemberInfo.BindingMember;

                        // avoid value kick back due to binder will react on PropertyChanged event and will pull
                        // control data back from UI to model
                        // UI is not cleared
                        (sender as Control).DataBindings[0].DataSourceUpdateMode = DataSourceUpdateMode.Never;
                        // reset field
                        fo.ResetFieldByName(FieldName);
                        // turn back DS update mode
                        (sender as Control).DataBindings[0].DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged;
                        // eventual null prompt
                        TextEdit te = sender as TextEdit;
                        if (te != null)
                        {
                            te.Properties.NullValuePrompt = "";

                            te.StyleController = EditorsHost.FormSupport.DefaultStyles.ContainsKey(te) ? EditorsHost.FormSupport.DefaultStyles[te] : null;
                        }
                        ke.Handled = true;
                    }
                }
            }

            /*
             * else
             * {
             *  TextEdit te = sender as TextEdit;
             *  if (te != null)
             *  {
             *      te.StyleController = _ModifiedStyle;
             *                  }
             * }
             */
        }
Ejemplo n.º 4
0
        protected override void GetFieldDisplayText(object sender, xwcs.core.db.binding.CustomColumnDisplayTextEventArgs e)
        {
            try {
                FilterObjectbase fo = this[e.ListSourceRowIndex] as FilterObjectbase;
                if (fo != null)
                {
                    ICriteriaTreeNode cn = fo.GetFilterFieldByPath(e.Column.FieldName);
                    if (cn.HasCriteria())
                    {
                        string cond = cn.GetCondition().LegacyToString();
                        e.DisplayText = cond;
                    }
                }
            }
#if DEBUG_TRACE_LOG_ON
            catch (Exception ex) {
                SLogManager.getInstance().getClassLogger(GetType()).Debug(ex.ToString());
#else
            catch (Exception) {
#endif
            } //just silently skip problems
        }
Ejemplo n.º 5
0
        private void setupRle(IDataBindingSource src, RepositoryItem ri, string fn)
        {
            //first detach eventual old
            if (Ri != null)
            {
                Ri.KeyPress -= repItemKeyPressHandler;
            }
            Src       = src;
            Ri        = ri;
            FieldName = fn;
            //get field
            RepositoryItemTextEdit rte = Ri as RepositoryItemTextEdit;

            if (rte != null)
            {
                FilterObjectbase fo = src.Current as FilterObjectbase;
                if (fo != null)
                {
                    ICriteriaTreeNode cn = fo.GetFilterFieldByPath(FieldName);
                    if (cn.HasCriteria())
                    {
                        string cond = cn.GetCondition().LegacyToString();
                        rte.NullValuePrompt = cond;
                    }
                }
            }

            ri.KeyPress += repItemKeyPressHandler;

            //in case of button edit set it editable by hand
            RepositoryItemButtonEdit ribe = (ri as RepositoryItemButtonEdit);

            if (ribe != null)
            {
                ribe.TextEditStyle = TextEditStyles.Standard;
            }
        }