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 }
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; } }
public void HandleFilterFiledKeyEvent(FilterFieldEventData ffe) { //handle popup opening TextEdit be = ffe.Field as TextEdit; //get field PropertyDescriptor pd = ReflectionHelper.GetPropertyDescriptorFromPath(_ds.Current.GetType(), ffe.FieldName); if (be != null) { // handle changed style be.StyleController = _eh.FormSupport.ModifiedStyle; _destEdit = be; DataTable fo = new DataTable(); Type ut = pd.PropertyType; //handle nullable try { ut = Nullable.GetUnderlyingType(pd.PropertyType) ?? pd.PropertyType; } catch (Exception) { ut = pd.PropertyType; } if (ffe.FieldName == "v_xwbo_iter.extra" || ffe.FieldName == "v_xwbo_note.extra") { fo.Columns.Add(new DataColumn("i.Text", typeof(string))); fo.Columns.Add(new DataColumn("i.OTA", typeof(string))); fo.Columns.Add(new DataColumn("n.Note", typeof(string))); } else { fo.Columns.Add(new DataColumn(ffe.FieldName, ut)); } // be sere fc is created make_fc(); //connect property to filter popup _fc.CurrentFieldName = ffe.FieldName; //set initial criteria _fc.filterEditorControl.FilterCriteria = CriteriaOperator.Parse(""); _fc.filterEditorControl.SourceControl = fo; //we can take old value if present ICriteriaTreeNode field = (_ds.Current as FilterObjectbase)?.GetFilterFieldByPath(ffe.FieldName); if (_fc.CurrentFieldName == "v_xwbo_iter.extra" || _fc.CurrentFieldName == "v_xwbo_note.extra") { try { _fc.filterEditorControl.FilterCriteria = CriteriaOperator.Parse(field.ToString()); } catch (Exception e) { _logger.Error(e.ToString()); _fc.filterEditorControl.FilterCriteria = null; } } else { if (field != null && field.HasCriteria()) { _fc.filterEditorControl.FilterCriteria = field.GetCondition(); } else { switch (ffe.ActionChar) { case '<': _fc.filterEditorControl.FilterString = string.Format("[{0}] < ?", ffe.FieldName); break; case ':': _fc.filterEditorControl.FilterString = string.Format("[{0}] between (?, ?)", ffe.FieldName); break; case '>': _fc.filterEditorControl.FilterString = string.Format("[{0}] > ?", ffe.FieldName); break; case '*': _fc.filterEditorControl.FilterString = string.Format("contains([{0}], ?)", ffe.FieldName); break; case '=': _fc.filterEditorControl.FilterString = string.Format("[{0}] = ?", ffe.FieldName); break; } } } /* * _fc.filterEditorControl.FilterControl.BeforeCreateValueEditor += (object ss, CreateValueEditorEventArgs ee) => * { * //ee.CustomRepositoryItem = new RepositoryItemDateEdit(); * //ee.RepositoryItem = * }; */ /* * _fc.filterEditorControl.FilterControl.PopupMenuShowing += (spm, spe) => * { * spe.Menu.BeforePopup += (ms, me) => * { * }; * }; */ _fc.filterEditorControl.FilterControl.ShowOperandTypeIcon = true; _popup.Size = new Size(Math.Max(be.Width, 400), 200); _popup.ShowCloseButton = false; _popup.ShowSizeGrip = true; be.EditValue = null; // null current value be.Properties.NullValuePromptShowForEmptyValue = true; be.Properties.NullValuePrompt = _fc.filterEditorControl.FilterString; be.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; be.Properties.ShowNullValuePromptWhenFocused = true; Point pt = be.PointToScreen(new Point(0, be.Height)); _popup.ShowPopup(_barManager, pt); _fc.filterEditorControl.FilterControl.Focus(); //wait eventual shift pressed DateTime twoSec = DateTime.Now.AddSeconds(2); while (DateTime.Now < twoSec && (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))) { //Console.WriteLine(string.Format("Waiting! {0}, {1}, L({2}) R({3}) ", DateTime.Now, twoSec, Keyboard.GetKeyStates(Key.LeftShift), Keyboard.GetKeyStates(Key.LeftShift))); SendKeys.Flush(); Thread.Sleep(100); } if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)) { MessageBox.Show("Ma lo molli sto shift?"); } else { SendKeys.Flush(); SendKeys.Send("{RIGHT}"); SendKeys.Send("{RIGHT}"); SendKeys.Send("{RIGHT}"); SendKeys.Send("{ENTER}"); } // set future closing motive // so user must confirm with ok click _popupCloseKind = PopupCloseKind.Cancel; } }