Пример #1
0
        private void InitializeBehaviour()
        {
            var entityTitle = NameConventions.MakeTitle(entity.Title, "Formulário");
            var actionTitle = NameConventions.MakeTitle(action.Title, action.Name);

            Icon = Resources.FormEdit.ToIcon();
            Text = $"{entityTitle} - {actionTitle}";

            foreach (Field field in action.Fields)
            {
                var title = NameConventions.MakeTitle(field.Title, field.Name);
                var value = field.Value;

                var widget = WidgetFactory.CreateWidget(field.Type);

                widget._CopyFrom(field);

                widget.Title         = title;
                widget.Control.Tag   = field;
                widget.Control.Width = 200;

                if (widget is SubmitWidget button)
                {
                    button.Click += async(o, e) =>
                    {
                        pnContent.Enabled = false;
                        try
                        {
                            await SubmitAsync();
                        }
                        finally
                        {
                            pnContent.Enabled = true;
                        }
                    };
                }
                if (field.ReadOnly == true)
                {
                    widget.Control.TabStop = false;
                }

                pnContent.Controls.Add(widget.Control);
            }
        }
Пример #2
0
        private void InitializeBehaviour()
        {
            Icon = Resources.FormData.ToIcon();
            Text = NameConventions.MakeTitle(entity.Title, "Formulário");

            var properties =
                from property in entity.Properties
                where !property.Name.StartsWith("_") &&
                !(property.Value is PropertyCollection)
                select property;

            foreach (Property property in properties)
            {
                var header      = entity.FindHeader(property.Name, Rel.Data);
                var headerTitle = header.Properties["title"]?.Value?.ToString();

                IWidget widget = new InfoWidget();
                widget.Title         = headerTitle ?? property.Name.ChangeCase(TextCase.ProperCase);
                widget.Value         = property.Value;
                widget.Control.Width = 200;
                pnContent.Controls.Add(widget.Control);
            }
        }