private void BuildParametroTextboxLivre( ComandoParametroDto paramItem , ref TableSection paramDiv ) { try { CustomEntryCell entry = new CustomEntryCell() { CellLabel = paramItem.Label, CellPlaceholder = paramItem.ToolTip }; if (!String.IsNullOrWhiteSpace(paramItem.Valor)) { entry.CellText = paramItem.Valor; } if (paramItem.TamanhoMaximo.HasValue) { EntryLengthValidatorBehavior maxLength = new EntryLengthValidatorBehavior(); maxLength.MaxLength = paramItem.TamanhoMaximo.Value; entry.Behaviors.Add(maxLength); } if (!String.IsNullOrWhiteSpace(paramItem.Dominio)) { String[] minMax = paramItem.Dominio.Split('>'); Int32 min = 0; Int32 max = 0; if (minMax.Count() == 2) { min = Convert.ToInt32(minMax[0]); max = Convert.ToInt32(minMax[1]); } else { min = 0; max = Convert.ToInt32(minMax[0]); } entry.Keyboard = Keyboard.Numeric; EntryMaxMinValidatorBehavior maxLength = new EntryMaxMinValidatorBehavior(); maxLength.MinNumber = min; maxLength.MaxNumber = max; entry.Behaviors.Add(maxLength); } ListParametros.Add( paramItem.IdParametro.ToString() , entry ); entry.Tapped += Entry_Tapped; paramDiv.Add(entry); } catch { } }
public List <ComandoParametroDto> RecuperaValor() { List <ComandoParametroDto> lstReturn = new List <ComandoParametroDto>(); try { Dictionary <Int32, ComandoParametroDto> dic = new Dictionary <int, ComandoParametroDto>(); foreach (KeyValuePair <String, Cell> item in Form.ListParametros) { ComandoParametroDto temp; String[] parts = item.Key.Split('-'); Int32 idParametro = Convert.ToInt32(parts[0]); if (dic.ContainsKey(idParametro)) { temp = dic[idParametro]; dic.Remove(idParametro); } else { temp = new ComandoParametroDto() { IdParametro = idParametro }; } String valor = ""; Type tipo = item.Value.GetType(); Layout <View> tempView; if (tipo == typeof(CustomSwitchCell)) { CustomSwitchCell tempCell = (CustomSwitchCell)item.Value; tempView = (Grid)tempCell.View; } else if (tipo == typeof(CustomPickerCell)) { CustomPickerCell tempCell = (CustomPickerCell)item.Value; tempView = (StackLayout)tempCell.View; } else { CustomEntryCell tempCell = (CustomEntryCell)item.Value; tempView = (StackLayout)tempCell.View; } foreach (View itemView in tempView.Children) { Type tipoChildren = itemView.GetType(); if (tipoChildren != typeof(Label)) { if (tipoChildren == typeof(Switch)) { valor = Convert.ToInt32(((Switch)itemView).IsToggled).ToString(); } else if (tipoChildren == typeof(Picker)) { FormularioDinamicoElementDto tempPicker = ((Picker)itemView).SelectedItem as FormularioDinamicoElementDto; if (tempPicker != null) { valor = tempPicker.Id; } } else { valor = ((Entry)itemView).Text; } break; } } temp.Valor += valor; dic.Add(temp.IdParametro, temp); } lstReturn = dic.Values.ToList(); } catch { } return(lstReturn); }