Exemple #1
0
        private void CreateItemAndActivate(ObjectClass targetClass)
        {
            var targetType = targetClass.GetDescribedInterfaceType();
            var item       = this.DataContext.Create(targetType);
            var result     = DataObjectViewModel.Fetch(ViewModelFactory, DataContext, ViewModelFactory.GetWorkspace(DataContext), item);

            AddItem(result);
            ActivateItem(result, true);
        }
Exemple #2
0
        public IQueryable GetUntypedQuery(ObjectClass cls)
        {
            var mi = this.GetType().FindGenericMethod(true, "GetUntypedQueryHack", new[] { cls.GetDescribedInterfaceType().Type }, new Type[0]);

            return((IQueryable)mi.Invoke(this, new object[0]));
        }
Exemple #3
0
        private static Property ShowCreatePropertyDialog(IZetboxContext ctx, ObjectClass propCls, Module targetModule, out bool show)
        {
            var ifType = propCls.GetDescribedInterfaceType();

            var dlg = _vmf.CreateDialog(ctx, string.Format(Zetbox.App.Projekte.Client.ZetboxBase.Strings.CreatePropertyDlg_Title, ifType.Type.Name))
                .AddString("name", NamedObjects.Base.Classes.Zetbox.App.Base.Property_Properties.Name.Find(_frozenCtx).GetLabel())
                .AddString("label", NamedObjects.Base.Classes.Zetbox.App.Base.Property_Properties.Label.Find(_frozenCtx).GetLabel(), allowNullInput: true)
                .AddString("description", NamedObjects.Base.Classes.Zetbox.App.Base.Property_Properties.Description.Find(_frozenCtx).GetLabel(), allowNullInput: true)
                .AddString("categorytags", NamedObjects.Base.Classes.Zetbox.App.Base.Property_Properties.CategoryTags.Find(_frozenCtx).GetLabel(), allowNullInput: true, vmdesc: NamedObjects.Gui.ViewModelDescriptors.Zetbox_Client_Presentables_ZetboxBase_TagPropertyEditorViewModel.Find(_frozenCtx))
                .AddObjectReference("module", NamedObjects.Base.Classes.Zetbox.App.Base.Property_Properties.Module.Find(_frozenCtx).GetLabel(), typeof(Module).GetObjectClass(_frozenCtx), value: targetModule)
                .AddBool("isNullable", Zetbox.App.Projekte.Client.ZetboxBase.Strings.IsNullable, value: true);

            if (typeof(StringProperty).IsAssignableFrom(ifType.Type))
            {
                var p = NamedObjects.Base.Classes.Zetbox.App.Base.StringRangeConstraint_Properties.MaxLength.Find(_frozenCtx);
                dlg.AddInt("str_maxlengt", p.GetLabel(), allowNullInput: true, description: p.GetDescription());
            }
            if (typeof(DateTimeProperty).IsAssignableFrom(ifType.Type))
            {
                var p = NamedObjects.Base.Classes.Zetbox.App.Base.DateTimeProperty_Properties.DateTimeStyle.Find(_frozenCtx);
                dlg.AddEnumeration("dt_style", p.GetLabel(), _frozenCtx.FindPersistenceObject<Enumeration>(new Guid("1385e46d-3e5b-4d91-bf9a-94a740f08ba1")), description: p.GetDescription(), value: (int)DateTimeStyles.Date);
            }
            if (typeof(DecimalProperty).IsAssignableFrom(ifType.Type))
            {
                var p = NamedObjects.Base.Classes.Zetbox.App.Base.DecimalProperty_Properties.Precision.Find(_frozenCtx);
                var s = NamedObjects.Base.Classes.Zetbox.App.Base.DecimalProperty_Properties.Scale.Find(_frozenCtx);
                dlg.AddInt("decimal_precision", p.GetLabel(), description: p.GetDescription(), value: 10);
                dlg.AddInt("decimal_scale", s.GetLabel(), description: s.GetDescription(), value: 2);
            }
            if (typeof(EnumerationProperty).IsAssignableFrom(ifType.Type))
            {
                var p = NamedObjects.Base.Classes.Zetbox.App.Base.EnumerationProperty_Properties.Enumeration.Find(_frozenCtx);
                dlg.AddObjectReference("enum", p.GetLabel(), typeof(Enumeration).GetObjectClass(_frozenCtx), description: p.GetDescription());
            }
            if (typeof(CompoundObjectProperty).IsAssignableFrom(ifType.Type))
            {
                var p = NamedObjects.Base.Classes.Zetbox.App.Base.CompoundObjectProperty_Properties.CompoundObjectDefinition.Find(_frozenCtx);
                dlg.AddObjectReference("cp_def", p.GetLabel(), typeof(CompoundObject).GetObjectClass(_frozenCtx), description: p.GetDescription());
            }
            if (typeof(IntProperty).IsAssignableFrom(ifType.Type))
            {
                var min = NamedObjects.Base.Classes.Zetbox.App.Base.IntegerRangeConstraint_Properties.Min.Find(_frozenCtx);
                var max = NamedObjects.Base.Classes.Zetbox.App.Base.IntegerRangeConstraint_Properties.Max.Find(_frozenCtx);
                dlg.AddInt("int_min", min.GetLabel(), description: min.GetDescription(), allowNullInput: true);
                dlg.AddInt("int_max", max.GetLabel(), description: max.GetDescription(), allowNullInput: true);
            }

            dlg.AddBool("show", Zetbox.App.Projekte.Client.ZetboxBase.Strings.ShowPropertyWhenFinished, value: false, description: Zetbox.App.Projekte.Client.ZetboxBase.Strings.ShowPropertyWhenFinishedDescription);

            Property newProp = null;
            bool localShow = false;
            dlg.Show(((values) =>
            {
                newProp = (Property)ctx.Create(ifType);
                newProp.Name = (string)values["name"];
                newProp.Label = (string)values["label"];
                newProp.Description = (string)values["description"];
                newProp.CategoryTags = (string)values["categorytags"];
                newProp.Module = (Module)values["module"];
                if (!(bool)values["isNullable"])
                {
                    newProp.Constraints.Add(ctx.Create<NotNullableConstraint>());
                }

                if (values.ContainsKey("str_maxlengt"))
                {
                    var c = ctx.Create<StringRangeConstraint>();
                    c.MinLength = 0;
                    c.MaxLength = (int?)values["str_maxlengt"];
                    newProp.Constraints.Add(c);
                }
                if (values.ContainsKey("int_min") && values.ContainsKey("int_max") && values["int_min"] != null && values["int_max"] != null)
                {
                    var c = ctx.Create<IntegerRangeConstraint>();
                    c.Min = (int)values["int_min"];
                    c.Max = (int)values["int_max"];
                    newProp.Constraints.Add(c);
                }
                if (values.ContainsKey("dt_style"))
                {
                    ((DateTimeProperty)newProp).DateTimeStyle = (DateTimeStyles)values["dt_style"];
                }
                if (values.ContainsKey("decimal_precision"))
                {
                    ((DecimalProperty)newProp).Precision = (int)values["decimal_precision"];
                }
                if (values.ContainsKey("decimal_scale"))
                {
                    ((DecimalProperty)newProp).Scale = (int)values["decimal_scale"];
                }
                if (values.ContainsKey("enum"))
                {
                    ((EnumerationProperty)newProp).Enumeration = (Enumeration)values["enum"];
                }
                if (values.ContainsKey("cp_def"))
                {
                    ((CompoundObjectProperty)newProp).CompoundObjectDefinition = (CompoundObject)values["cp_def"];
                }

                if (newProp is CompoundObjectProperty)
                {
                    ((CompoundObjectProperty)newProp).IsList = false;
                    ((CompoundObjectProperty)newProp).HasPersistentOrder = false;
                }

                localShow = (bool)values["show"];
            }));

            show = localShow;
            return newProp;
        }