示例#1
0
        private void imgMd_Click(object sender, EventArgs e)
        {
            if (!_IsPostAndComments)
            {
                return;
            }

            try
            {
                //UcFilterParams wUcFilterParams = new UcFilterParams();
                //wUcFilterParams.AllTree = true;
                //wUcFilterParams.PostId = this._Comment.ElementId.Value;
                //wUcFilterParams.SCInternalCode = this._Comment.SCInternalCode;

                //UcPostAndComment wUcPostAndComment = new UcPostAndComment();
                //wUcPostAndComment.Populate(wUcFilterParams);

                PopupControlContainer popup = new PopupControlContainer();


                popup.BringToFront();
                popup.ShowPopup(barManager1, this.PointToScreen(this.imgMd.Location));
            }
            catch (Exception ex)
            {
                //Helper.ShowErrorMessage(ex);
            }
        }
        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;
            }
        }