Exemplo n.º 1
0
        public static FilterModel FromProperty(IFrozenContext frozenCtx, IEnumerable <Property> props)
        {
            var last  = props.Last();
            var label = string.Join(", ", props.Select(i => i.GetLabel()).ToArray());

            if (last is DateTimeProperty)
            {
                return(RangeFilterModel.Create(frozenCtx, label, FilterValueSource.FromProperty(props), typeof(DateTime), null, null));
            }
            else if (last is IntProperty)
            {
                return(RangeFilterModel.Create(frozenCtx, label, FilterValueSource.FromProperty(props), typeof(int), null, null));
            }
            else if (last is DecimalProperty)
            {
                return(RangeFilterModel.Create(frozenCtx, label, FilterValueSource.FromProperty(props), typeof(decimal), null, null));
            }
            else if (last is DoubleProperty)
            {
                return(RangeFilterModel.Create(frozenCtx, label, FilterValueSource.FromProperty(props), typeof(double), null, null));
            }
            else
            {
                return(SingleValueFilterModel.Create(frozenCtx, label, props));
            }
        }
Exemplo n.º 2
0
        public static SingleValueFilterModel Create(IFrozenContext frozenCtx, string label, IFilterValueSource predicate, ObjectClass referencedClass, ControlKind requestedKind, ControlKind requestedArgumentKind)
        {
            if (frozenCtx == null)
            {
                throw new ArgumentNullException("frozenCtx");
            }

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

            fmdl.FilterArguments.Add(new FilterArgumentConfig(
                                         new ObjectReferenceValueModel(label, "", true, false, requestedArgumentKind, referencedClass),
                                         ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_ObjectReferenceViewModel.Find(frozenCtx)));
            return(fmdl);
        }
Exemplo n.º 3
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);
        }