/// <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; }
/// <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; }