コード例 #1
0
        /// <inheritDocs />
        public override IMetaField GetMetaField(IFormFieldControl formFieldControl)
        {
            var metaField = base.GetMetaField(formFieldControl);

            metaField.Title = Res.Get <EnhancedFormsResources>().Country;

            return(metaField);
        }
コード例 #2
0
        /// <summary>
        /// Raises the form field validating event.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <returns>Whether validation succeeded.</returns>
        protected virtual bool RaiseFormFieldValidatingEvent(IFormFieldControl control)
        {
            var formEvent = new FormFieldValidatingEvent()
            {
                FormFieldControl = control
            };

            return(!this.ValidationEventFailed(formEvent));
        }
コード例 #3
0
        /// <inheritDocs />
        public override IMetaField GetMetaField(IFormFieldControl formFieldControl)
        {
            var metaField = base.GetMetaField(formFieldControl);

            if (string.IsNullOrEmpty(metaField.Title))
            {
                metaField.Title = Res.Get <FieldResources>().Untitled;
            }

            return(metaField);
        }
コード例 #4
0
        /// <inheritDocs />
        public override IMetaField GetMetaField(IFormFieldControl formFieldControl)
        {
            var metaField = base.GetMetaField(formFieldControl);

            if (string.IsNullOrEmpty(metaField.Title))
            {
                metaField.Title = Res.Get<FieldResources>().Untitled;
            }

            return metaField;
        }
コード例 #5
0
        public static string GetFieldName(FieldControl fieldControl)
        {
            IFormFieldControl formFieldControl = (IFormFieldControl)fieldControl;

            if (string.IsNullOrEmpty(formFieldControl.MetaField.FieldName))
            {
                return(string.Concat(fieldControl.GetType().Name, "_", ((Control)fieldControl).ID.ToString()));
            }
            else
            {
                return(formFieldControl.MetaField.FieldName);
            }
        }
コード例 #6
0
        /// <inheritDocs />
        public override IMetaField GetMetaField(IFormFieldControl formFieldControl)
        {
            var metaField = base.GetMetaField(formFieldControl);

            if (string.IsNullOrEmpty(metaField.Title))
            {
                metaField.Title = Res.Get <FieldResources>().SelectChoice;
            }

            if (string.IsNullOrEmpty(metaField.DefaultValue))
            {
                var choices = this.DeserializeChoices();
                if (choices.Any())
                {
                    metaField.DefaultValue = choices.FirstOrDefault();
                }
            }

            return(metaField);
        }
コード例 #7
0
        /// <summary>
        /// Gets the default metafield based on the field control.
        /// </summary>
        /// <param name="formFieldControl">The field control.</param>
        /// <returns>The meta field.</returns>
        public virtual IMetaField GetMetaField(IFormFieldControl formFieldControl)
        {
            var metaField = formFieldControl.LoadDefaultMetaField();

            return(metaField);
        }
コード例 #8
0
        /// <summary>
        /// Gets the default metafield based on the field control.
        /// </summary>
        /// <param name="formFieldControl">The field control.</param>
        /// <returns>The meta field.</returns>
        public virtual IMetaField GetMetaField(IFormFieldControl formFieldControl)
        {
            var metaField = formFieldControl.LoadDefaultMetaField();

            return metaField;
        }
コード例 #9
0
        public static void DrawBorder(Graphics graphics, IFormFieldControl formFieldChild, Size clientSize, bool focus)
        {
            if (formFieldChild == null || !formFieldChild.IsFieldVisible)
            {
                return;
            }

            Rectangle borderRect = new Rectangle(0, 0, clientSize.Width, clientSize.Height);

            Rectangle innerRect = new Rectangle(
                formFieldChild.BorderThickness,
                formFieldChild.BorderThickness,
                clientSize.Width - (formFieldChild.BorderThickness * 2),
                clientSize.Height - (formFieldChild.BorderThickness * 2)
                );

            ButtonBorderStyle mainBoderStyle = ButtonBorderStyle.Solid;

            ButtonBorderStyle innerBoderTopLeftStyle     = ButtonBorderStyle.Solid;
            ButtonBorderStyle innerBoderBottomRightStyle = ButtonBorderStyle.Solid;

            Color innerBoderTopLeftColor     = Color.DarkGray;
            Color innerBoderBottomRightColor = Color.LightGray;

            switch (formFieldChild.FieldBorderStyle)
            {
            case FieldBorderStyle.Solid:
                mainBoderStyle             = ButtonBorderStyle.Solid;
                innerBoderTopLeftStyle     = ButtonBorderStyle.None;
                innerBoderBottomRightStyle = ButtonBorderStyle.None;
                break;

            case FieldBorderStyle.Dashed:
                mainBoderStyle             = ButtonBorderStyle.Dotted;
                innerBoderTopLeftStyle     = ButtonBorderStyle.None;
                innerBoderBottomRightStyle = ButtonBorderStyle.None;
                break;

            case FieldBorderStyle.Beveled:
                mainBoderStyle             = ButtonBorderStyle.Solid;
                innerBoderTopLeftStyle     = ButtonBorderStyle.Solid;
                innerBoderBottomRightStyle = ButtonBorderStyle.Solid;

                innerBoderTopLeftColor     = Color.White;
                innerBoderBottomRightColor = Color.FromArgb(
                    formFieldChild.BackgroundColor.A,
                    (int)(formFieldChild.BackgroundColor.R * 0.9),
                    (int)(formFieldChild.BackgroundColor.G * 0.9),
                    (int)(formFieldChild.BackgroundColor.B * 0.9)
                    );
                break;

            case FieldBorderStyle.Inset:
                mainBoderStyle             = ButtonBorderStyle.Solid;
                innerBoderTopLeftStyle     = ButtonBorderStyle.Solid;
                innerBoderBottomRightStyle = ButtonBorderStyle.Inset;
                break;

            case FieldBorderStyle.Underlined:
                mainBoderStyle             = ButtonBorderStyle.Solid;
                innerBoderTopLeftStyle     = ButtonBorderStyle.None;
                innerBoderBottomRightStyle = ButtonBorderStyle.None;
                break;
            }

            ControlPaint.DrawBorder(graphics, borderRect,
                                    focus ? formFieldChild.FocusedBorderColor : formFieldChild.BorderColor, formFieldChild.BorderThickness, mainBoderStyle,       //Left
                                    focus ? formFieldChild.FocusedBorderColor : formFieldChild.BorderColor, formFieldChild.BorderThickness, mainBoderStyle,       //Top
                                    focus ? formFieldChild.FocusedBorderColor : formFieldChild.BorderColor, formFieldChild.BorderThickness, mainBoderStyle,       //Right
                                    focus ? formFieldChild.FocusedBorderColor : formFieldChild.BorderColor, formFieldChild.BorderThickness, mainBoderStyle        //Bottom
                                    );

            ControlPaint.DrawBorder(graphics, innerRect,
                                    innerBoderTopLeftColor, formFieldChild.BorderThickness, innerBoderTopLeftStyle,                                               //Left
                                    innerBoderTopLeftColor, formFieldChild.BorderThickness, innerBoderTopLeftStyle,                                               //Top
                                    innerBoderBottomRightColor, formFieldChild.BorderThickness, innerBoderBottomRightStyle,                                       //Right
                                    innerBoderBottomRightColor, formFieldChild.BorderThickness, innerBoderBottomRightStyle                                        //Bottom
                                    );
        }
コード例 #10
0
        protected override void InitializeControls(GenericContainer container)
        {
            IFormFieldControl thisControl     = base.ParentDesigner.PropertyEditor.Control as IFormFieldControl;
            FormDraftControl  thisControlData = base.ParentDesigner.PropertyEditor.ControlData as FormDraftControl;

            FormDescription form = FManager.GetFormByName(thisControlData.Form.Name);

            IControlsContainer cc = GetControlsContainer(form.Id);

            List <ControlData> formControls = (List <ControlData>) typeof(PageHelper)
                                              .GetMethod("SortControls", BindingFlags.Static | BindingFlags.NonPublic)
                                              .Invoke(null, new object[] { new[] { cc }, 1 });

            formControls.RemoveAll(fc => fc.ObjectType == "Telerik.Sitefinity.Modules.Forms.Web.UI.Fields.FormSubmitButton, Telerik.Sitefinity" || fc.IsLayoutControl == true);

            if (formControls.Count > 0)
            {
                List <CriteriaOption> criteriaOptions = new List <CriteriaOption>();

                CultureInfo uiCulture = CultureInfo.GetCultureInfo(this.GetUICulture());

                foreach (var formControl in formControls)
                {
                    FieldControl fieldControl = FManager.LoadControl(formControl, uiCulture) as FieldControl;

                    CriteriaOption co = new CriteriaOption();

                    if (fieldControl is FormChoiceField)
                    {
                        co.FieldType = "ChoiceField";
                        co.FieldName = Helpers.GetFieldName(fieldControl);
                        co.Options   = ((FormChoiceField)fieldControl).Choices
                                       .Select(c => new SimpleChoiceItem()
                        {
                            Text = c.Text, Value = c.Value
                        }).ToList();

                        co.Conditions = new List <SimpleChoiceItem>()
                        {
                            new SimpleChoiceItem()
                            {
                                Text = "=", Value = "=="
                            },
                            new SimpleChoiceItem()
                            {
                                Text = "!=", Value = "!="
                            }
                        };
                    }

                    if (fieldControl is TextField)
                    {
                        co.FieldType = "TextField";
                        co.FieldName = Helpers.GetFieldName(fieldControl);

                        co.Conditions = new List <SimpleChoiceItem>()
                        {
                            new SimpleChoiceItem()
                            {
                                Text = "=", Value = "=="
                            },
                            new SimpleChoiceItem()
                            {
                                Text = "!=", Value = "!="
                            },
                            new SimpleChoiceItem()
                            {
                                Text = "<", Value = "lt"
                            },
                            new SimpleChoiceItem()
                            {
                                Text = ">", Value = "gt"
                            }
                        };
                    }

                    criteriaOptions.Add(co);
                }

                StringBuilder script = new StringBuilder();

                script.Append(@"<script>");
                script.AppendFormat(@"var currentCultureC = ""{0}"";", this.GetUICulture());
                script.AppendFormat(@"var optionFilter = ""{0}"";", Helpers.GetFieldName((FieldControl)thisControl));
                script.AppendFormat(@"var criteriaOptions = {0};", Helpers.SerializeJSON <List <CriteriaOption> >(criteriaOptions));

                string criteriaSetPropertyValue = ((IConditionalFormControl)thisControl).CriteriaSet;

                string criteriaSet = "[]";

                if (!String.IsNullOrWhiteSpace(criteriaSetPropertyValue))
                {
                    criteriaSet = criteriaSetPropertyValue;
                }

                script.AppendFormat("var criteria = {0};", criteriaSet);

                script.Append(@"</script>");

                Script.Text = script.ToString();
            }
        }
コード例 #11
0
        /// <inheritDocs />
        public override IMetaField GetMetaField(IFormFieldControl formFieldControl)
        {
            var metaField = base.GetMetaField(formFieldControl);

            return(metaField);
        }
コード例 #12
0
        private void RenderFormFields()
        {
            Control control;

            if (this.FormData != null)
            {
                FormsManager manager = FormsManager.GetManager();
                List <IControlsContainer> controlsContainers = new List <IControlsContainer>()
                {
                    this.FormData
                };
                List <ControlData> controlDatas = new List <ControlData>();

                typeof(PageHelper)
                .GetMethod("ProcessControls", BindingFlags.Static | BindingFlags.NonPublic, null, CallingConventions.Any, new Type[] { typeof(IList <ControlData>), typeof(IList <ControlData>), typeof(IList <IControlsContainer>) }, null)
                .Invoke(null, new object[] { new List <ControlData>(), controlDatas, controlsContainers });

                PlaceHoldersCollection placeHoldersCollection = new PlaceHoldersCollection();
                PlaceHolder            placeHolder            = new PlaceHolder()
                {
                    ID = "Body"
                };

                placeHoldersCollection.Add(placeHolder);

                List <ControlData> controlDatas1 = (List <ControlData>) typeof(PageHelper)
                                                   .GetMethod("SortControls", BindingFlags.Static | BindingFlags.NonPublic)
                                                   .Invoke(null, new object[] { controlsContainers.AsEnumerable <IControlsContainer>().Reverse <IControlsContainer>(), controlsContainers.Count });


                if (_isProgressiveForm)
                {
                    ControlData progressiveKeyFieldControlData = controlDatas1.Where(c => ((FormControl)c).Properties.Any(p => p.Name == "IsProgressiveKeyField" && p.Value == "True")).FirstOrDefault();

                    if (progressiveKeyFieldControlData != null)
                    {
                        FieldControl progressiveKeyFieldControl = manager.LoadControl(progressiveKeyFieldControlData, CultureInfo.CurrentUICulture) as FieldControl;

                        _progressiveKeyFieldName = Helpers.GetFieldName(progressiveKeyFieldControl);
                    }
                }

                foreach (ControlData controlDatum in controlDatas1)
                {
                    Control control1 = manager.LoadControl(controlDatum, CultureInfo.CurrentUICulture);

                    if (placeHoldersCollection.TryGetValue(controlDatum.PlaceHolder, out control))
                    {
                        if (control1 is FormSubmitButton)
                        {
                            this.ConfigureSubmitButton(control1, this.ValidationGroup);
                        }

                        bool showProgressiveField = ShowProgressiveField(control1);

                        if (control1 is FormSubmitButton || (_isProgressiveForm ? showProgressiveField : true))
                        {
                            control.Controls.Add(control1);
                        }

                        IFormFieldControl formFieldControl = control1 as IFormFieldControl;

                        if (formFieldControl != null & (control1 is FormSubmitButton || (_isProgressiveForm ? showProgressiveField : true)))
                        {
                            FieldControl fieldName = formFieldControl as FieldControl;

                            if (fieldName != null)
                            {
                                if (formFieldControl.MetaField != null && !string.IsNullOrEmpty(formFieldControl.MetaField.FieldName))
                                {
                                    fieldName.DataFieldName = formFieldControl.MetaField.FieldName;
                                }

                                fieldName.ValidationGroup = this.ValidationGroup;
                                fieldName.ValidatorDefinition.MessageCssClass = "sfError";
                                fieldName.ControlCssClassOnError = "sfErrorWrp";
                            }

                            this.FieldControls.Add(formFieldControl);
                        }
                    }

                    if (!(control1 is LayoutControl))
                    {
                        continue;
                    }

                    LayoutControl layoutControl = (LayoutControl)control1;

                    layoutControl.PlaceHolder = controlDatum.PlaceHolder;
                    placeHoldersCollection.AddRange(layoutControl.Placeholders);
                }
                this.FormControls.Controls.Add(placeHolder);
            }
        }
コード例 #13
0
        /// <summary>
        /// Raises the form field validating event.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <returns>Whether validation succeeded.</returns>
        protected virtual bool RaiseFormFieldValidatingEvent(IFormFieldControl control)
        {
            var formEvent = new FormFieldValidatingEvent()
            {
                FormFieldControl = control
            };

            return !this.ValidationEventFailed(formEvent);
        }
コード例 #14
0
        protected override void InitializeControls(GenericContainer container)
        {
            IFormFieldControl thisControl     = base.ParentDesigner.PropertyEditor.Control as IFormFieldControl;
            FormDraftControl  thisControlData = base.ParentDesigner.PropertyEditor.ControlData as FormDraftControl;

            FormDescription form = FManager.GetFormByName(thisControlData.Form.Name);

            IControlsContainer cc = GetControlsContainer(form.Id);

            List <ControlData> formControls = (List <ControlData>) typeof(PageHelper)
                                              .GetMethod("SortControls", BindingFlags.Static | BindingFlags.NonPublic)
                                              .Invoke(null, new object[] { new[] { cc }, 1 });

            formControls.RemoveAll(fc => fc.ObjectType == "Telerik.Sitefinity.Modules.Forms.Web.UI.Fields.FormSubmitButton, Telerik.Sitefinity" || fc.IsLayoutControl == true);

            ControlData progressiveKeyFieldControlData = formControls.Where(c => ((FormDraftControl)c).Properties.Any(p => p.Name == "IsProgressiveKeyField" && p.Value == "True")).FirstOrDefault();

            if (progressiveKeyFieldControlData != null)
            {
                FieldControl progressiveKeyFieldControl = FManager.LoadControl(progressiveKeyFieldControlData, CultureInfo.CurrentUICulture) as FieldControl;

                _progressiveKeyFieldName = Helpers.GetFieldName(progressiveKeyFieldControl);

                if (!String.IsNullOrEmpty(_progressiveKeyFieldName) && _progressiveKeyFieldName != Helpers.GetFieldName(thisControl as FieldControl))
                {
                    _disableKeyFieldSelector = true;
                }
            }

            if (!(thisControl is FormTextBox))
            {
                _disableKeyFieldSelector = true;
                _wrongTypeForKeyField    = true;
            }

            if (formControls.Count > 0)
            {
                List <CriteriaOption> progressiveCriteriaOptions = new List <CriteriaOption>();

                CultureInfo uiCulture = CultureInfo.GetCultureInfo(this.GetUICulture());

                foreach (var formControl in formControls)
                {
                    FieldControl fieldControl = FManager.LoadControl(formControl, uiCulture) as FieldControl;

                    CriteriaOption co = new CriteriaOption();

                    co.FieldName = Helpers.GetFieldName(fieldControl);

                    progressiveCriteriaOptions.Add(co);
                }

                StringBuilder script = new StringBuilder();

                script.Append(@"<script>");
                script.AppendFormat(@"var currentProgressiveCulture = ""{0}"";", this.GetUICulture());
                script.AppendFormat(@"var progressiveOptionFilter = ""{0}"";", Helpers.GetFieldName((FieldControl)thisControl));
                script.AppendFormat(@"var progressiveCriteriaOptions = {0};", Helpers.SerializeJSON <List <CriteriaOption> >(progressiveCriteriaOptions));

                string progressiveCriteriaSetPropertyValue = ((IProgressiveFormControl)thisControl).ProgressiveCriteriaSet;
                string criteriaSet = "[]";

                if (!String.IsNullOrWhiteSpace(progressiveCriteriaSetPropertyValue))
                {
                    criteriaSet = progressiveCriteriaSetPropertyValue;
                }

                script.AppendFormat("var progressiveCriteria = {0};", criteriaSet);
                script.Append(@"</script>");

                Script.Text = script.ToString();
            }
        }
コード例 #15
0
        /// <inheritDocs />
        public override IMetaField GetMetaField(IFormFieldControl formFieldControl)
        {
            var metaField = base.GetMetaField(formFieldControl);

            if (string.IsNullOrEmpty(metaField.Title))
            {
                metaField.Title = Res.Get<FieldResources>().SelectChoice;
            }

            if (string.IsNullOrEmpty(metaField.DefaultValue))
            {
                var choices = this.DeserializeChoices();
                if (choices.Any())
                {
                    metaField.DefaultValue = choices.FirstOrDefault();
                }
            }

            return metaField;
        }