예제 #1
0
        public static OptionalPredicateFilterModel Create(IFrozenContext frozenCtx, string label, string predicate, ControlKind requestedKind, ControlKind requestedArgumentKind)
        {
            if (frozenCtx == null)
            {
                throw new ArgumentNullException("frozenCtx");
            }

            var fmdl = new OptionalPredicateFilterModel()
            {
                Label         = label,
                ValueSource   = FilterValueSource.FromExpression(predicate),
                ViewModelType = ViewModelDescriptors.Zetbox_Client_Presentables_FilterViewModels_OptionalPredicateFilterViewModel.Find(frozenCtx),
                RequestedKind = requestedKind,
            };
            var valueMdl = new BoolValueModel(label, "", false, false, requestedArgumentKind);

            valueMdl.Value = false;
            fmdl.FilterArguments.Add(new FilterArgumentConfig(valueMdl,
                                                              ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_NullableBoolPropertyViewModel.Find(frozenCtx)));
            return(fmdl);
        }
예제 #2
0
        public static SingleValueFilterModel Create(IFrozenContext frozenCtx, string label, IFilterValueSource predicate, Type propType, ControlKind requestedKind, ControlKind requestedArgumentKind)
        {
            if (frozenCtx == null)
            {
                throw new ArgumentNullException("frozenCtx");
            }
            if (propType == null)
            {
                throw new ArgumentNullException("propType");
            }

            var fmdl = new SingleValueFilterModel()
            {
                Label                  = label,
                ValueSource            = predicate,
                Operator               = FilterOperators.Equals,
                ViewModelType          = ViewModelDescriptors.Zetbox_Client_Presentables_FilterViewModels_SingleValueFilterViewModel.Find(frozenCtx),
                RequestedKind          = requestedKind,
                RefreshOnFilterChanged = false,
            };

            ViewModelDescriptor vDesc = null;
            BaseValueModel      mdl   = null;

            if (propType == typeof(decimal))
            {
                vDesc = ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_NullableDecimalPropertyViewModel.Find(frozenCtx);
                mdl   = new DecimalValueModel(label, "", true, false, requestedArgumentKind);
            }
            else if (propType == typeof(int))
            {
                vDesc = ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_NullableStructValueViewModel_1_System_Int32_.Find(frozenCtx);
                mdl   = new NullableStructValueModel <int>(label, "", true, false, requestedArgumentKind);
            }
            else if (propType == typeof(double))
            {
                vDesc = ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_NullableStructValueViewModel_1_System_Double_.Find(frozenCtx);
                mdl   = new NullableStructValueModel <double>(label, "", true, false, requestedArgumentKind);
            }
            else if (propType == typeof(bool))
            {
                vDesc = ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_NullableBoolPropertyViewModel.Find(frozenCtx);
                fmdl.RefreshOnFilterChanged = true;
                if (requestedArgumentKind == null)
                {
                    requestedArgumentKind = NamedObjects.Gui.ControlKinds.Zetbox_App_GUI_DropdownBoolKind.Find(frozenCtx);
                }
                mdl = new BoolValueModel(label, "", true, false, requestedArgumentKind);
            }
            else if (propType == typeof(string))
            {
                vDesc         = ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_ClassValueViewModel_1_System_String_.Find(frozenCtx);
                mdl           = new ClassValueModel <string>(label, "", true, false, requestedArgumentKind);
                fmdl.Operator = FilterOperators.Contains;
            }
            else
            {
                throw new NotSupportedException(string.Format("Singlevalue filters of Type {0} are not supported yet", propType.Name));
            }

            fmdl.FilterArguments.Add(new FilterArgumentConfig(mdl, vDesc));
            return(fmdl);
        }