private void BuildParametroListCheckboxGenerico(
            ComandoParametroDto paramItem
            , ref TableSection paramDiv
            )
        {
            try
            {
                paramDiv.Title = paramItem.Label;
                List <String> dominio      = paramItem.Dominio.Split(';').ToList();
                List <char>   valorDefault = paramItem.Valor.ToCharArray().Reverse().ToList();

                for (Int32 i = 0; i < dominio.Count(); i++)
                {
                    CustomSwitchCell entry = new CustomSwitchCell()
                    {
                        CellLabel = dominio[i],
                        CellText  = valorDefault[i].ToString()
                    };

                    ListParametros.Add(
                        paramItem.IdParametro.ToString() + "-" + i.ToString()
                        , entry
                        );

                    entry.Tapped += Entry_Tapped;
                    paramDiv.Add(entry);
                }
            } catch
            {
            }
        }
        async void SetImage(CustomSwitchCell cell, CellTableViewCell target)
        {
            var source = cell.ImageSource;

            target.ImageView.Image = null;

            IImageSourceHandler handler = GetHandler(source);

            if (source != null && handler != null)
            {
                UIImage uiimage;
                try
                {
                    uiimage = await handler.LoadImageAsync(source).ConfigureAwait(false);
                }
                catch (TaskCanceledException)
                {
                    uiimage = null;
                }

                NSRunLoop.Main.BeginInvokeOnMainThread(() =>
                {
                    target.ImageView.Image = uiimage;
                    target.SetNeedsLayout();
                });
            }
            else
            {
                target.ImageView.Image = null;
            }
        }
        private void BuildParametroCheckboxGenerico(
            ComandoParametroDto paramItem
            , ref TableSection paramDiv
            )
        {
            try
            {
                CustomSwitchCell entry = new CustomSwitchCell()
                {
                    CellLabel = paramItem.Label,
                    CellText  = paramItem.Valor
                };

                ListParametros.Add(
                    paramItem.IdParametro.ToString()
                    , entry
                    );

                entry.Tapped += Entry_Tapped;
                paramDiv.Add(entry);
            } catch { }
        }
Exemplo n.º 4
0
        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);
        }