Ejemplo n.º 1
0
 /// <summary>
 /// Gets corresponding widget builder based on input type
 /// </summary>
 /// <param name="field">holds information about input type</param>
 /// <param name="skin">passed to builders to define look of widgets</param>
 /// <returns>corresponding widget builder</returns>
 public AbstractWidgetBuilder getFieldBuilder(AFField field, Skin skin)
 {
     if (Utils.IsFieldWritable(field.getFieldInfo().getWidgetType()))
     {
         return new TextWidgetBuilder(skin, field);
     }
     if (field.getFieldInfo().getWidgetType().Equals(SupportedWidgets.CALENDAR))
     {
         return new DateWidgetBuilder(skin, field);
     }
     if (field.getFieldInfo().getWidgetType().Equals(SupportedWidgets.OPTION))
     {
         return new OptionWidgetBuilder(skin, field);
     }
     if (field.getFieldInfo().getWidgetType().Equals(SupportedWidgets.DROPDOWNMENU))
     {
         return new DropDownWidgetBuilder(skin, field);
     }
     if (field.getFieldInfo().getWidgetType().Equals(SupportedWidgets.CHECKBOX))
     {
         return new CheckboxWidgetBuilder(skin, field);
     }
     if (field.getFieldInfo().getWidgetType().Equals(SupportedWidgets.PASSWORD))
     {
         return new PasswordWidgetBuilder(skin, field);
     }
     Debug.WriteLine("BUILDER FOR " + field.getFieldInfo().getWidgetType() + " NOT FOUND");
     return null;
 }
Ejemplo n.º 2
0
        /// <summary>
        ///  Prepares field with all needed information including UI representation.
        /// </summary>
        /// <param name="properties">information about a field, needed for e.g setting id of field</param>
        /// <param name="road">if not empty, field belongs to some inner class. This fact must be set into fields id.</param>
        /// <param name="skin">defines the look of field</param>
        /// <returns>prepared field with all needed information</returns>
        public AFField prepareField(AFFieldInfo properties, StringBuilder road, Skin skin)
        {

            AFField field = new AFField(properties);
            field.setId(road.ToString() + properties.getId());

            //LABEL
            TextBlock label = buildLabel(properties, skin);
            field.setLabel(label);

            //ERROR TEXT
            TextBlock errorView = buildErrorView(skin);
            field.setErrorView(errorView);

            //Input view
            FrameworkElement widget = null;
            AbstractWidgetBuilder widgetBuilder = WidgetBuilderFactory.getInstance().getFieldBuilder(field, skin);
            if (widgetBuilder != null && (widget = widgetBuilder.buildFieldView()) != null)
            {
                field.setWidgetBuilder(widgetBuilder);
                field.setFieldView(widget);
            }

            //put it all together
            //when field is not visible don't even add it to form;
            FrameworkElement completeView = buildCompleteView(field, skin);
            if (!properties.isVisible())
            {
                completeView.Visibility = Visibility.Collapsed;
            }
            field.setCompleteView(completeView);
            return field;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds a field in component.
 /// </summary>
 /// <param name="field">field to be added</param>
 public void addField(AFField field)
 {
     if (fields == null)
     {
         fields = new List<AFField>();
     }
     field.setParent(this);
     fields.Add(field);
 }
Ejemplo n.º 4
0
 public BasicBuilder(Skin skin, AFField field)
 {
     this.skin = skin;
     this.field = field;
 }
Ejemplo n.º 5
0
 public TextWidgetBuilder(Skin skin, AFField field) : base(skin, field)
 {
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Builds complete view of field. Puts label, active element and validation element togetger in specified order.
        /// </summary>
        /// <param name="field">field of which view is created</param>
        /// <param name="skin">in this case defines dimensions of field parts</param>
        /// <returns>complete graphical representation of field</returns>
        private FrameworkElement buildCompleteView(AFField field, Skin skin)
        {
            StackPanel fullLayout = new StackPanel();
            //fullLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

            Layout layout = field.getFieldInfo().getLayout();
            //set orientation of label and field itself
            if (layout.getLayoutOrientation() != null)
            {
                if (layout.getLayoutOrientation().Equals(LayoutOrientation.AXISY))
                {
                    fullLayout.Orientation = Orientation.Horizontal;
                }
                else if (layout.getLayoutOrientation().Equals(LayoutOrientation.AXISX))
                {
                    fullLayout.Orientation = Orientation.Vertical;
                }
            }
            else {
                fullLayout.Orientation = Orientation.Vertical; //default
            }

            //set label and field view layout params
            if (field.getLabel() != null)
            {
                if (skin.getLabelWidth() >= 0)
                {
                    field.getLabel().Width = skin.getLabelWidth();
                }
                else
                {
                    field.getLabel().HorizontalAlignment = skin.getLabelHorizontalAlignment();
                }
                if(skin.getLabelHeight() >= 0) { 
                    field.getLabel().Height = skin.getLabelHeight();
                }
                else
                {
                    field.getLabel().VerticalAlignment = skin.getLabelVerticalAlignment();
                }
            }
            field.getFieldView().Width = skin.getInputWidth();
            field.getFieldView().VerticalAlignment = VerticalAlignment.Top;

            //LABEL BEFORE
            if (field.getLabel() != null && layout.getLabelPosition() != null && !layout.getLabelPosition().Equals(LabelPosition.NONE))
            {
                if (layout.getLabelPosition().Equals(LabelPosition.BEFORE))
                {
                    fullLayout.Children.Add(field.getLabel());
                }
            }
            else if (field.getLabel() != null && layout.getLabelPosition() == null)
            {
                fullLayout.Children.Add(field.getLabel()); //default is before
            }

            if (field.getFieldView() != null)
            {
                fullLayout.Children.Add(field.getFieldView());
            }
            //LABEL AFTER
            if (field.getLabel() != null && layout.getLabelPosition() != null && !layout.getLabelPosition().Equals(LabelPosition.NONE))
            {
                if (layout.getLabelPosition().Equals(LabelPosition.AFTER))
                {
                    fullLayout.Children.Add(field.getLabel());
                }
            }

            //add errorview on the top of field
            StackPanel fullLayoutWithErrors = new StackPanel();
            fullLayoutWithErrors.HorizontalAlignment = HorizontalAlignment.Stretch;
            fullLayoutWithErrors.VerticalAlignment = VerticalAlignment.Top;
            //fullLayoutWithErrors.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
            fullLayoutWithErrors.Margin = new Thickness(0, 0, 10, 10);
            fullLayoutWithErrors.Orientation = Orientation.Vertical;
            fullLayoutWithErrors.Children.Add(field.getErrorView());
            fullLayoutWithErrors.Children.Add(fullLayout);
            return fullLayoutWithErrors;
        }
Ejemplo n.º 7
0
 public DateWidgetBuilder(Skin skin, AFField field) : base(skin, field)
 {
     this.dateFormat = "dd.MM.yyyy"; //Default date format
 }
Ejemplo n.º 8
0
 public OptionWidgetBuilder(Skin skin, AFField field) : base(skin, field)
 {
 }
Ejemplo n.º 9
0
 public DropDownWidgetBuilder(Skin skin, AFField field) : base(skin, field)
 {
 }
Ejemplo n.º 10
0
 public CheckboxWidgetBuilder(Skin skin, AFField field) : base(skin, field)
 {
 }