コード例 #1
0
		public FilterAspectForBindingSource(IDataBindingSource ds, IEditorsHost eh, BarManager bm){
			_ds = ds;
			_barManager = bm;
			_popup = new PopupControlContainer();
			_fc = new FieldExpressionControl();
			_popup.Controls.Add(_fc);
			_fc.Dock = DockStyle.Fill;

			//weak event
			_fc.OnCancel += (s, e) =>
			{
				_popupCloseKind = PopupCloseKind.Cancel;
				_popup.HidePopup();
			};
			//weak event
			_fc.OnOk += (s, e) =>
			{
				_popupCloseKind = PopupCloseKind.Confirm;
				_popup.HidePopup();
			};

			_fc.filterEditorControl.FilterControl.BeforeShowValueEditor += showvalueEditor_handler;

			_popup.CloseUp += popup_CloseUp;
		}
コード例 #2
0
        // we need lazy creation
        private void make_fc()
        {
            if (_fc != null)
            {
                return;
            }

            _fc = new FieldExpressionControl();
            _popup.Controls.Add(_fc);
            _fc.Dock = DockStyle.Fill;

            //weak event
            _fc.OnCancel += (s, e) =>
            {
                _popupCloseKind = PopupCloseKind.Cancel;
                _popup.HidePopup();
            };
            //weak event
            _fc.OnOk += (s, e) =>
            {
                _popupCloseKind = PopupCloseKind.Confirm;
                _popup.HidePopup();
            };

            _fc.filterEditorControl.FilterControl.BeforeShowValueEditor += showvalueEditor_handler;
        }
コード例 #3
0
		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)
			{
				_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;
				}

				fo.Columns.Add(new DataColumn(ffe.FieldName, ut));

				//connect property to filter popup
				_fc.CurrentFieldName = ffe.FieldName;

				//set initial criteria
				_fc.filterEditorControl.SourceControl = fo;
				//we can take old value if present
				ICriteriaTreeNode field = (_ds.Current as FilterObjectbase)?.GetFilterFieldByPath(ffe.FieldName);
				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;
					}
				}						
				

				/*
				_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;
			}
		}
コード例 #4
0
        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;
            }
        }