示例#1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here

            var container = new LinearLayout(this)
            {
                Background = Android.Graphics.Color.Yellow.ToDrawable(),
            };

            SetContentView(container);

            var table = new TableLayout(this)
            {
                Background        = Android.Graphics.Color.Red.ToDrawable(),
                StretchAllColumns = true,                       // カラムを均等割にする
                WeightSum         = rows,                       // 行を均等割にしたいので行数を指定
            };

            container.AddView(table,
                              new LinearLayout.LayoutParams(
                                  LinearLayout.LayoutParams.MatchParent,        // 幅は親に合わせる
                                  LinearLayout.LayoutParams.MatchParent)        // 高さは親に合わせる
                              );

            for (int i = 0; i < rows; i++)
            {
                var rowlayouts = new TableLayout.LayoutParams(
                    TableLayout.LayoutParams.WrapContent,
                    TableLayout.LayoutParams.WrapContent)
                {
                    Weight = 1,                 // テーブルの中で均等割するので全ての重みを1にする
                    Height = 0                  // 高さを自動指定
                };

                var row = new TableRow(this);
                table.AddView(row, rowlayouts);

                for (int j = 0; j < cols; j++)
                {
                    var buttonlayout = new TableRow.LayoutParams(
                        TableRow.LayoutParams.WrapContent,
                        TableRow.LayoutParams.MatchParent                               // 高さは行に合わせる
                        )
                    {
                        Width       = 0,                                // 幅を自動設定
                        RightMargin = 4,                                // 隙間を開ける
                        TopMargin   = 4                                 // 隙間を開ける
                    };

                    var button = new Button(this)
                    {
                        Text       = $"{i}-{j}",
                        Background = Android.Graphics.Color.Blue.ToButtonPressEffect()
                    };
                    row.AddView(button, buttonlayout);
                }
            }
        }
示例#2
0
 private void SetAutomaticThoughtData(ThoughtRecord thoughtRecord)
 {
     try
     {
         if (_linAutomaticItem != null)
         {
             _linAutomaticItem.RemoveAllViews();
             foreach (var automaticThoughts in thoughtRecord.AutomaticThoughtsList)
             {
                 LayoutParams layoutParams     = new TableLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent);
                 TextView     automaticThought = (TextView)_activity.LayoutInflater.Inflate(Resource.Layout.VTextViewThought, null);
                 automaticThought.LayoutParameters = layoutParams;
                 automaticThought.SetPadding(0, 0, 5, 0);
                 var autoText = automaticThoughts.Thought + (automaticThoughts.IsHotThought ? " " + _activity.GetString(Resource.String.HotThoughtTag) : "");
                 SetTextItem(automaticThought, autoText);
                 _linAutomaticItem.AddView(automaticThought);
             }
         }
     }
     catch (Exception e)
     {
         Log.Error(TAG, "SetAutomaticThoughtData: Exception - " + e.Message);
         if (_activity != null)
         {
             if (GlobalData.ShowErrorDialog)
             {
                 ErrorDisplay.ShowErrorAlert(_activity, e, "Setting Automatic Thought Data", "ViewThoughtRecordsAdapter.SetAutomaticThoughtData");
             }
         }
     }
 }
示例#3
0
        private void AddFormulaItem()
        {
            LinearLayout ll = new LinearLayout(this)
            {
                WeightSum        = 2,
                LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent)
            };

            var lp = new TableLayout.LayoutParams(0, ViewGroup.LayoutParams.WrapContent)
            {
                Weight = 1
            };

            Spinner spSentenceItem = new Spinner(this)
            {
                LayoutParameters = lp
            };
            var adapter = new LObjectListAdapter(this, SentencePart.Instance.List.Values.ToArray());

            spSentenceItem.Adapter       = adapter;
            spSentenceItem.ItemSelected += SpSentenceItem_ItemSelected;
            ll.AddView(spSentenceItem);

            LinearLayout llFormulaItemList = FindViewById <LinearLayout>(Resource.Id.llFormulaItemList);

            llFormulaItemList.AddView(ll);
        }
示例#4
0
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);

			// Create your application here

			var container = new LinearLayout (this) {
				Background=Android.Graphics.Color.Yellow.ToDrawable(),
			};

			SetContentView (container);

			var table = new TableLayout (this) {
				Background=Android.Graphics.Color.Red.ToDrawable(),
				StretchAllColumns=true,		// カラムを均等割にする
				WeightSum=rows,				// 行を均等割にしたいので行数を指定									
			};

			container.AddView (table,
				new LinearLayout.LayoutParams (
					LinearLayout.LayoutParams.MatchParent,	// 幅は親に合わせる
					LinearLayout.LayoutParams.MatchParent)	// 高さは親に合わせる
			);

			for (int i = 0; i < rows; i++) {
				
				var rowlayouts = new TableLayout.LayoutParams (
					TableLayout.LayoutParams.WrapContent,
					TableLayout.LayoutParams.WrapContent)
				{ Weight = 1,	// テーブルの中で均等割するので全ての重みを1にする
					Height=0	// 高さを自動指定
				};

				var row = new TableRow (this);
				table.AddView (row, rowlayouts);

				for (int j = 0; j < cols; j++) {

					var buttonlayout = new TableRow.LayoutParams (
						TableRow.LayoutParams.WrapContent,
						TableRow.LayoutParams.MatchParent	// 高さは行に合わせる
					) {
						Width = 0,			// 幅を自動設定
						RightMargin = 4, 	// 隙間を開ける
						TopMargin = 4		// 隙間を開ける
					};

					var button = new Button (this) {
						Text=$"{i}-{j}",
						Background=Android.Graphics.Color.Blue.ToButtonPressEffect()
					};
					row.AddView (button, buttonlayout);
				}						
			}
		}
示例#5
0
 public void StarPicture(int star)
 {
     for (int i = 0; i < star; i++)
     {
         var       lPar       = new TableLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent, 1);
         ImageView _imageStar = new ImageView(this);
         _imageStar.LayoutParameters = lPar;
         _starsLayout.AddView(_imageStar);
         _imageStar.SetImageResource(Resource.Drawable.star);
     }
 }
        private void SetTableHeader(TableLayout.LayoutParams layoutParameters)
        {
            TableRow tr = new TableRow(this);

            tr.LayoutParameters = layoutParameters;

            TextView site = new TextView(this);

            site.SetTypeface(null, TypefaceStyle.Bold);
            site.Text = "Site";
            tr.AddView(site);

            TextView space1 = new TextView(this);

            space1.Text = "     ";
            tr.AddView(space1);

            TextView plotNo = new TextView(this);

            plotNo.SetTypeface(null, TypefaceStyle.Bold);
            plotNo.Text = "Plot";
            tr.AddView(plotNo);

            TextView space2 = new TextView(this);

            space2.Text = "     ";
            tr.AddView(space2);

            TextView kitchenModel = new TextView(this);

            kitchenModel.SetTypeface(null, TypefaceStyle.Bold);
            kitchenModel.Text = "Kitchen";
            tr.AddView(kitchenModel);

            TextView space3 = new TextView(this);

            space3.Text = "     ";
            tr.AddView(space3);

            TextView imgNo = new TextView(this);

            imgNo.SetTypeface(null, TypefaceStyle.Bold);
            imgNo.Text = "Pics";
            tr.AddView(imgNo);

            table.AddView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.MatchParent,
                                                           TableLayout.LayoutParams.WrapContent));
        }
示例#7
0
        /*
         * Agrega una fila con columnas en formato string a una tabla
         * Retorna el objecto fila que se agregó en la tabla
         */
        public static TableRow agregarFilaATabla(string[] columnas, FragmentActivity activity, TableLayout table)
        {
            TableRow fila = new TableRow(activity);

            foreach (string text_celda in columnas)
            {
                TextView celda = new TextView(activity);
                celda.Text = text_celda;
                fila.AddView(celda);
            }
            fila.SetPadding(15, 15, 15, 15); // Valor por default
            table.AddView(fila);

            TableLayout.LayoutParams layoutParams = new TableLayout.LayoutParams(TableLayout.LayoutParams.MatchParent, TableLayout.LayoutParams.WrapContent);
            fila.LayoutParameters = layoutParams;

            return(fila);
        }
        public void cargarListaReintentos()
        {
            try
            {
                servicioCheckDB coneccion = new servicioCheckDB();

                var listaReintentos = coneccion.ObtenerListaStrings("https://pjgestionnotificacionmovilservicios.azurewebsites.net/api/ReintentoNotificacion/ListarReintentosNotificacion?PCodNotificacion=" + codigoNotificacionReintento + "", Activity);

                if (listaReintentos != null)
                {
                    TableLayout tablaReintentos = Activity.FindViewById <TableLayout>(Resource.Id.tbNotificadores);

                    TableRow nuevaFila;
                    TableLayout.LayoutParams layoutParams = new TableLayout.LayoutParams(TableLayout.LayoutParams.MatchParent, TableLayout.LayoutParams.MatchParent);

                    for (int k = 0; k < listaReintentos.Count; k++)
                    {
                        nuevaFila = new TableRow(Activity);                                    //Se instancia la nueva fila
                        nuevaFila.LayoutParameters = layoutParams;                             //Se agregan los tamaños del layout
                        nuevaFila.SetPadding(5, 5, 5, 5);                                      //Se agregan los margenes de cada fila
                        nuevaFila.SetBackgroundColor(Android.Graphics.Color.Argb(2, 1, 0, 5)); //Se cambia el color del fondo
                        nuevaFila.Clickable = true;

                        TextView descripcion = new TextView(Activity);
                        descripcion.Text = listaReintentos[k]["Descripcion"].ToString();
                        nuevaFila.AddView(descripcion);

                        TextView fecha = new TextView(Activity);
                        fecha.Text = listaReintentos[k]["Fecha"].ToString();
                        nuevaFila.AddView(fecha);

                        TextView nombre = new TextView(Activity);
                        nombre.Text = listaReintentos[k]["OficialNotificador"]["NombreCompleto"].ToString();
                        nuevaFila.AddView(nombre);

                        tablaReintentos.AddView(nuevaFila);
                    }
                }
            }catch (Exception ex)
            {
                //Se guarda el detalle del error
                Logs.saveLogError("ReintentoNotificacion.cargarListaReintentos" + ex.Message + " " + ex.StackTrace);
            }
        }
示例#9
0
        private void SpSentenceItem_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
        {
            LinearLayout ll = (sender as Spinner).Parent as LinearLayout;

            if (e.Id == SentencePart.spModalVerb ||
                e.Id == SentencePart.spNotionalVerb)
            {
                if (ll.ChildCount == 1)
                {
                    var lp = new TableLayout.LayoutParams(0, ViewGroup.LayoutParams.WrapContent)
                    {
                        Weight = 1
                    };
                    Spinner spSentenceItemType = new Spinner(this)
                    {
                        LayoutParameters = lp
                    };
                    ll.AddView(spSentenceItemType);
                }

                BaseAdapter adapter;
                Spinner     sp = ll.GetChildAt(1) as Spinner;
                if (e.Id == SentencePart.spModalVerb)
                {
                    adapter = new LObjectListAdapter(this, ModalVerb.Instance.List.Values.ToArray());
                }
                else
                {
                    adapter = new LObjectListAdapter(this, NotionalVerb.Instance.List.Values.ToArray());
                }
                sp.Adapter = adapter;
            }
            else
            {
                if (ll.ChildCount == 2)
                {
                    ll.RemoveViewAt(1);
                }
            }
        }
        public LinearLayout SetupLineChart()
        {
            try
            {
                if (_progressLineChartContainer != null)
                {
                    _lineChart = new LineChart(_activity);
                    TableLayout.LayoutParams layoutParams = new TableLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
                    _lineChart.LayoutParameters = layoutParams;
                    _progressLineChartContainer.AddView(_lineChart);
                    Log.Info(TAG, "SetupLineChart: Success adding chart to container _progressLineChartContainer");
                }
            }
            catch (Exception e)
            {
                Log.Error(TAG, "SetupLineChart: Exception - " + e.Message);
                if (GlobalData.ShowErrorDialog)
                {
                    ErrorDisplay.ShowErrorAlert(_activity, e, "Setting up the Line chart", "ProgressChartHelper.SetupLineChart");
                }
            }

            return(_progressLineChartContainer);
        }
示例#11
0
        /**
         * Programmatically build up the view hierarchy to avoid the need for resources.
         * @return View hierarchy
         */
        private View generateHierarchy(Context context)
        {
            Resources resources = this.Resources;

            FrameLayout.LayoutParams _params;
            int fivePx   = Util.dpToPx(5, resources);
            int tenPx    = Util.dpToPx(10, resources);
            int twentyPx = Util.dpToPx(20, resources);

            TableLayout.LayoutParams tableLayoutParams = new TableLayout.LayoutParams(
                0,
                ViewGroup.LayoutParams.WrapContent,
                1f);
            tableLayoutParams.SetMargins(0, 0, fivePx, 0);
            LinearLayout seekWrapper;

            FrameLayout root = new FrameLayout(context);

            _params = new LayoutParams(ViewGroup.LayoutParams.MatchParent, Util.dpToPx(300, resources));
            root.LayoutParameters = _params;

            FrameLayout container = new FrameLayout(context);

            _params = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
            _params.SetMargins(0, twentyPx, 0, 0);
            container.LayoutParameters = _params;
            container.SetBackgroundColor(Color.Argb(100, 0, 0, 0));
            root.AddView(container);

            mSpringSelectorSpinner = new Spinner(context, SpinnerMode.Dialog);
            _params         = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);
            _params.Gravity = GravityFlags.Top;
            _params.SetMargins(tenPx, tenPx, tenPx, 0);
            mSpringSelectorSpinner.LayoutParameters = _params;
            container.AddView(mSpringSelectorSpinner);

            LinearLayout linearLayout = new LinearLayout(context);

            _params = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);
            _params.SetMargins(0, 0, 0, Util.dpToPx(80, resources));
            _params.Gravity = GravityFlags.Bottom;
            linearLayout.LayoutParameters = _params;
            linearLayout.Orientation      = Android.Widget.Orientation.Vertical;
            container.AddView(linearLayout);
            seekWrapper = new LinearLayout(context);

            _params = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);
            _params.SetMargins(tenPx, tenPx, tenPx, twentyPx);
            seekWrapper.SetPadding(tenPx, tenPx, tenPx, tenPx);
            seekWrapper.LayoutParameters = _params;
            seekWrapper.Orientation      = Android.Widget.Orientation.Horizontal;
            linearLayout.AddView(seekWrapper);

            mTensionSeekBar = new SeekBar(context);
            mTensionSeekBar.LayoutParameters = tableLayoutParams;
            seekWrapper.AddView(mTensionSeekBar);

            mTensionLabel = new TextView(Context);
            mTensionLabel.SetTextColor(mTextColor);

            _params = new LayoutParams(
                Util.dpToPx(50, resources),
                ViewGroup.LayoutParams.MatchParent);
            mTensionLabel.Gravity          = GravityFlags.CenterVertical | GravityFlags.Left;
            mTensionLabel.LayoutParameters = _params;
            mTensionLabel.SetMaxLines(1);
            seekWrapper.AddView(mTensionLabel);

            seekWrapper = new LinearLayout(context);
            _params     = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);
            _params.SetMargins(tenPx, tenPx, tenPx, twentyPx);
            seekWrapper.SetPadding(tenPx, tenPx, tenPx, tenPx);
            seekWrapper.LayoutParameters = _params;
            seekWrapper.Orientation      = Android.Widget.Orientation.Horizontal;
            linearLayout.AddView(seekWrapper);

            mFrictionSeekBar = new SeekBar(context);
            mFrictionSeekBar.LayoutParameters = tableLayoutParams;
            seekWrapper.AddView(mFrictionSeekBar);

            mFrictionLabel = new TextView(Context);
            mFrictionLabel.SetTextColor(mTextColor);
            _params = new LayoutParams(Util.dpToPx(50, resources), ViewGroup.LayoutParams.MatchParent);
            mFrictionLabel.Gravity          = GravityFlags.CenterVertical | GravityFlags.Left;
            mFrictionLabel.LayoutParameters = _params;
            mFrictionLabel.SetMaxLines(1);
            seekWrapper.AddView(mFrictionLabel);

            View nub = new View(context);

            _params              = new LayoutParams(Util.dpToPx(60, resources), Util.dpToPx(40, resources));
            _params.Gravity      = GravityFlags.Top | GravityFlags.Center;
            nub.LayoutParameters = _params;

            nub.SetOnTouchListener(new OnNubTouchListener()
            {
                Touch = (View, motionEvent) =>
                {
                    if (motionEvent.Action == MotionEventActions.Down)
                    {
                        togglePosition();
                    }
                    return(true);
                }
            });
            nub.SetBackgroundColor(Color.Argb(255, 0, 164, 209));
            root.AddView(nub);
            return(root);
        }
示例#12
0
        TableLayout CreateTableReport(System.Collections.Generic.IEnumerable <TransCust> transCustList)
        {
            TableLayout.LayoutParams fillParams = new TableLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent, 1.0f);
            Context     ctx       = this.Activity.ApplicationContext;
            TableLayout tblLayout = new TableLayout(ctx);

            tblLayout.LayoutParameters  = fillParams;
            tblLayout.StretchAllColumns = true;

            TableRow rowHeader = new TableRow(ctx);

            rowHeader.SetBackgroundResource(Resource.Drawable.actionbar_background);

            TextView tvItemKategH = new TextView(ctx);

            tvItemKategH.Text = this.Activity.Resources.GetText(Resource.String.tvHeaderStatisticCustName);
            SetHeaderCellStyle(tvItemKategH);
            rowHeader.AddView(tvItemKategH);

            TextView tvCreditH = new TextView(ctx);

            tvCreditH.Text    = this.Activity.Resources.GetText(Resource.String.tvHeaderStatisticCredit);
            tvCreditH.Gravity = GravityFlags.Right;
            SetHeaderCellStyle(tvCreditH);
            rowHeader.AddView(tvCreditH);

            TextView tvDebitH = new TextView(ctx);

            tvDebitH.Text    = this.Activity.Resources.GetText(Resource.String.tvHeaderStatisticDebit);
            tvDebitH.Gravity = GravityFlags.Right;
            SetHeaderCellStyle(tvDebitH);
            rowHeader.AddView(tvDebitH);

            TextView tvCreditMinusDebitH = new TextView(ctx);

            tvCreditMinusDebitH.Text    = this.Activity.Resources.GetText(Resource.String.tvHeaderStatisticCreditMinusDebit);
            tvCreditMinusDebitH.Gravity = GravityFlags.Right;
            SetHeaderCellStyle(tvCreditMinusDebitH);
            rowHeader.AddView(tvCreditMinusDebitH);

            tblLayout.AddView(rowHeader);

            foreach (TransCust st in transCustList)
            {
                TableRow row = new TableRow(ctx);
                if (st.CreditMinusDebit < 0)
                {
                    row.SetBackgroundResource(Resource.Drawable.red_background);
                }
                else
                {
                    row.SetBackgroundResource(Resource.Drawable.button_selector);
                }

                TextView tvItemKateg = new TextView(ctx);
                tvItemKateg.Text = st.Cst_desc;
                SetCellStyle(tvItemKateg);
                row.AddView(tvItemKateg);

                TextView tvCredit = new TextView(ctx);
                tvCredit.Text    = st.Credit.ToString(Common.CurrencyFormat);
                tvCredit.Gravity = GravityFlags.Right;
                SetCellStyle(tvCredit);
                row.AddView(tvCredit);

                TextView tvDebit = new TextView(ctx);
                tvDebit.Text    = st.Debit.ToString(Common.CurrencyFormat);
                tvDebit.Gravity = GravityFlags.Right;
                SetCellStyle(tvDebit);
                row.AddView(tvDebit);

                TextView tvCreditMinusDebit = new TextView(ctx);
                tvCreditMinusDebit.Text    = st.CreditMinusDebit.ToString(Common.CurrencyFormat);
                tvCreditMinusDebit.Gravity = GravityFlags.Right;
                SetCellStyle(tvCreditMinusDebit);
                row.AddView(tvCreditMinusDebit);

                tblLayout.AddView(row);
            }

            return(tblLayout);
        }
        private void AutoComplete_ItemClick(object sender, EventArgs eventArgs)
        {
            var itemView = sender as TextView;

            if (itemView.Text == limitRows.limValueText)
            {
                autocomplete.SetText("", TextView.BufferType.Normal);
                return;
            }

            if (хdoc == null)
            {
                хdoc = XDocument.Load(Resources.GetXml(Resource.Xml.codes));
            }

            var search = itemView.Text.Split('|').Select(p => p.Trim()).ToList();

            var item  = хdoc.Root.Elements("item").Where(x => (string)x.Attribute("order") == search[0] && (string)x.Attribute("type") == search[1]).FirstOrDefault();
            var brend = item.FirstAttribute.Value;

            textView2.SetText(Html.FromHtml("<b>Бренд:</b> " + brend), TextView.BufferType.Editable);

            tableLayout.RemoveAllViewsInLayout();
            tableLayout.RemoveAllViews();

            TableLayout.LayoutParams par = new TableLayout.LayoutParams(TableLayout.LayoutParams.WrapContent, TableLayout.LayoutParams.MatchParent);
            par.SetMargins(20, 0, 20, 0);
            tableLayout.LayoutParameters = par;

            if (item != null)
            {
                var codeData = new List <string>()
                {
                    item.Attribute("series").Value,
                    item.Attribute("custom").Value,
                    item.Attribute("model").Value
                };

                var isVacon = (brend == "Vacon" ? true : false);

                txtView = new TextView(this);
                txtView.SetText(Html.FromHtml("<b>Аналог марки VLT</b>"), TextView.BufferType.Editable);
                txtView.Gravity = GravityFlags.Left;
                txtView.SetPadding(25, 25, 25, 25);
                txtView.SetTextColor(Color.Black);
                txtView.SetTextSize(Android.Util.ComplexUnitType.Dip, 20);

                var tableRow = new TableRow(this);
                tableRow.AddView(txtView);
                tableLayout.AddView(tableRow);

                for (int i = 0; i < codeData.Count; i++)
                {
                    var txt = "<b>";
                    if (i == 0)
                    {
                        txt += "Серия:";
                    }
                    else if (i == 1)
                    {
                        txt += "Заказной код:";
                    }
                    else if (i == 2)
                    {
                        txt += "Типовой код:";
                    }
                    txt += "</b> ";

                    txtView = new TextView(this);
                    txtView.SetText(Html.FromHtml(txt + (i == 0 && isVacon ? "Micro Drive" : codeData[i])), TextView.BufferType.Editable);
                    txtView.SetBackgroundResource(Resource.Layout.finded);
                    txtView.Gravity = GravityFlags.Left;
                    txtView.SetPadding(25, 25, 25, 25);
                    txtView.SetTextColor(Color.Black);

                    tableRow = new TableRow(this);
                    tableRow.LayoutParameters = new TableRow.LayoutParams(TableRow.LayoutParams.WrapContent, TableRow.LayoutParams.MatchParent);
                    tableRow.AddView(txtView);
                    tableLayout.AddView(tableRow);
                }

                if (!isVacon)
                {
                    var items = хdoc.Root.Elements("item")
                                .Where(x => (string)x.Attribute("brend") == "Vacon" &&
                                       (string)x.Attribute("custom") == item.Attribute("custom").Value &&
                                       (string)x.Attribute("series") != "VACON 10" && (string)x.Attribute("series") != "VACON NXL")
                                .ToList();

                    if (items != null && items.Count > 0)
                    {
                        txtView = new TextView(this);
                        txtView.SetText(Html.FromHtml("<b>Аналог марки Vacon</b>"), TextView.BufferType.Editable);
                        txtView.Gravity = GravityFlags.Left;
                        txtView.SetPadding(25, 50, 25, 25);
                        txtView.SetTextColor(Color.Black);
                        txtView.SetTextSize(Android.Util.ComplexUnitType.Dip, 20);

                        tableRow = new TableRow(this);
                        tableRow.AddView(txtView);

                        tableLayout.AddView(tableRow);

                        drawItems(items, tableLayout, tableRow);
                    }
                }

                Toast.MakeText(this, "Поиск завершен", ToastLength.Short).Show();

                hideKeyBoard();

                bntSendFromMain.Visibility = ViewStates.Visible;
            }
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            report.output_error = null;

            var  ignored = base.OnCreateView(inflater, container, savedInstanceState);
            View self    = inflater.Inflate(Resource.Layout.CommonReportOutput, null);

            if (!report.getFillCommonInfo(self, true, false, ref report.output_error))
            {
                reportErrorGoBack(report.output_error);
                return(self);
            }

            TableLayout table = self.FindViewById <TableLayout>(Resource.Id.tbReporte);

            // Asegura que ningun parametro este vacío
            if (String.IsNullOrEmpty(report.input_oficina))
            {
                reportErrorGoBack("El campo de oficina no puede ser vacío");
                return(self);
            }

            // Consulta
            // Cambiar las fechas al formato admitido por la BD
            string fecha_inicio = report.input_fecha_inicio.ToString("yyyyMMdd");
            string fecha_fin    = report.input_fecha_fin.ToString("yyyyMMdd");

            string query = @"https://pjgestionnotificacionmovilservicios.azurewebsites.net/api/Reportes/NotificacionesEnviadasADespachos" +
                           "?PCodOficina=" + report.input_oficina +
                           "&PCodDespacho=" + // FIXME
                           "&PFecha1=" + fecha_inicio +
                           "&PFecha2=" + fecha_fin;

            // Verificar si la conección a internet esta disponible
            if (!coneccionInternet.verificaConeccion(this.Context))
            {
                ReportUtils.alertNoInternetMessage(this.Context);
            }

            WebRequest request = HttpWebRequest.Create(query);

            request.ContentType = "application/json";
            request.Method      = "GET";
            string content = "";

            Console.Out.WriteLine("--XDEBUG " + query);
            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            {
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    Console.Out.WriteLine("Error fetching data. Server returned status code: {0}", response.StatusCode);
                    reportErrorGoBack("No fue posible obtener la información requerida para le reporte");
                    return(self);
                }

                using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                {
                    content = reader.ReadToEnd();

                    if (string.IsNullOrWhiteSpace(content))
                    {
                        Console.Out.WriteLine("fzeledon -- Response contained empty body...");
                        reportErrorGoBack("Los valores de entrada de la consulta no generaron resultado");
                        return(self);
                    }

                    try
                    {
                        var jsonParsed = JArray.Parse(content);
                        if ((jsonParsed.Count % 2) == 1) // Esperamos un número par de elementos del array
                        {
                            reportErrorGoBack("La información obtenida para le informe no puede ser procesada");
                            return(self);
                        }
                        Dictionary <string, int>    despacho_deligencia_true  = new Dictionary <string, int>();
                        Dictionary <string, int>    despacho_deligencia_false = new Dictionary <string, int>();
                        Dictionary <string, string> despacho_nombre           = new Dictionary <string, string>();
                        for (int i = 0; i < jsonParsed.Count; ++i)
                        {
                            string codigo = jsonParsed[i].Value <string>("Codigo");
                            despacho_nombre[codigo] = jsonParsed[i].Value <string>("Descripcion");

                            if (jsonParsed[i].Value <Boolean>("Diligenciada"))
                            {
                                despacho_deligencia_true[codigo] = jsonParsed[i].Value <int>("Total");
                            }
                            else
                            {
                                despacho_deligencia_false[codigo] = jsonParsed[i].Value <int>("Total");
                            }
                        }

                        // Por cada despacho encontrada
                        TableLayout.LayoutParams layoutParams = new TableLayout.LayoutParams(TableLayout.LayoutParams.MatchParent, TableLayout.LayoutParams.WrapContent);

                        foreach (string codigo in despacho_nombre.Keys)
                        {
                            // Cantidad
                            int total_cantidad = despacho_deligencia_true[codigo] + despacho_deligencia_false[codigo];

                            // Crea las columnas
                            TextView nombre_label = new TextView(Activity);
                            nombre_label.Text = "Nombre del despacho";
                            TextView text_nombre = new TextView(Activity);
                            text_nombre.Text = despacho_nombre[codigo];
                            // FIXME. Buscar una mejor manera de acomodar los nombres largos
                            if (despacho_nombre[codigo].Length > 20)
                            {
                                text_nombre.Text = despacho_nombre[codigo].Substring(0, 20);
                            }
                            TextView pad = new TextView(Activity);
                            pad.Text = "";
                            TextView pad2 = new TextView(Activity);
                            pad.Text = "";
                            TextView positivas = new TextView(Activity);
                            positivas.Text = "Positivas";
                            TextView negativas = new TextView(Activity);
                            negativas.Text = "Negativas";
                            TextView total = new TextView(Activity);
                            total.Text = "Total";
                            TextView cantidad = new TextView(Activity);
                            cantidad.Text = "Cantidad";
                            TextView porcentaje = new TextView(Activity);
                            porcentaje.Text = "Porcentaje";
                            TextView text_positivas_cantidad = new TextView(Activity);
                            text_positivas_cantidad.Text = despacho_deligencia_true[codigo].ToString();
                            TextView text_negativas_cantidad = new TextView(Activity);
                            text_negativas_cantidad.Text = despacho_deligencia_false[codigo].ToString();
                            TextView text_positivas_porcentaje = new TextView(Activity);
                            text_positivas_porcentaje.Text = (100.0 * despacho_deligencia_true[codigo] / total_cantidad).ToString("N3") + '%';
                            TextView text_negativas_porcentaje = new TextView(Activity);
                            text_negativas_porcentaje.Text = (100.0 * despacho_deligencia_false[codigo] / total_cantidad).ToString("N3") + '%';
                            TextView text_total_cantidad = new TextView(Activity);
                            text_total_cantidad.Text = total_cantidad.ToString();

                            // La Fila Nombre
                            TableRow filaNombre = new TableRow(Activity); //Se instancia la nueva fila
                            filaNombre.LayoutParameters = layoutParams;   //Se agregan los tamaños del layout
                            filaNombre.AddView(nombre_label);
                            filaNombre.AddView(text_nombre);
                            filaNombre.SetPadding(15, 15, 15, 15);
                            filaNombre.SetBackgroundColor(Android.Graphics.Color.Argb(50, 1, 0, 5));

                            // La file de nombre de columnas
                            TableRow filaNombreColumnas = new TableRow(Activity); //Se instancia la nueva fila
                            filaNombreColumnas.LayoutParameters = layoutParams;   //Se agregan los tamaños del layout
                            filaNombreColumnas.AddView(pad2);
                            filaNombreColumnas.AddView(cantidad);
                            filaNombreColumnas.AddView(porcentaje);
                            filaNombreColumnas.SetPadding(15, 15, 15, 15);
                            filaNombreColumnas.SetBackgroundColor(Android.Graphics.Color.Argb(30, 1, 0, 5));

                            // La Fila positivas
                            TableRow filaPositivas = new TableRow(Activity); //Se instancia la nueva fila
                            filaPositivas.LayoutParameters = layoutParams;   //Se agregan los tamaños del layout
                            filaPositivas.AddView(positivas);
                            filaPositivas.AddView(text_positivas_cantidad);
                            filaPositivas.AddView(text_positivas_porcentaje);
                            filaPositivas.SetPadding(15, 15, 15, 15);

                            // La Fila negativas
                            TableRow filaNegativa = new TableRow(Activity); //Se instancia la nueva fila
                            filaNegativa.LayoutParameters = layoutParams;   //Se agregan los tamaños del layout
                            filaNegativa.AddView(negativas);
                            filaNegativa.AddView(text_negativas_cantidad);
                            filaNegativa.AddView(text_negativas_porcentaje);
                            filaNegativa.SetPadding(15, 15, 15, 15);

                            // La Fila total
                            TableRow filatotal = new TableRow(Activity); //Se instancia la nueva fila
                            filatotal.LayoutParameters = layoutParams;   //Se agregan los tamaños del layout
                            filatotal.AddView(total);
                            filatotal.AddView(text_total_cantidad);
                            filatotal.AddView(pad);
                            filatotal.SetPadding(15, 15, 15, 15);

                            // Agregar a la tabla
                            table.AddView(filaNombre);
                            table.AddView(filaNombreColumnas);
                            table.AddView(filaPositivas);
                            table.AddView(filaNegativa);
                            table.AddView(filatotal);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error descargando datos de usuario: " + ex.ToString());
                        reportErrorGoBack("Error descargando datos de usuario");
                        return(self);
                    }
                }
            }

            Button btnGen = self.FindViewById <Button>(Resource.Id.btnRegresarNotificacionesEnviadas);

            btnGen.Click += (sender, e) => {
                report.output_error = null;
                Fragment frag = report.getInputReportFragment();
                FragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, frag).Commit();
            };

            return(self);
        }
示例#15
0
        /// <summary>
        /// Se cargan la lista de notificadores
        /// </summary>
        public void cargarNotificadores()
        {
            try
            {
                ManejoBaseDatos.Abrir();
                //Se consulta en la base de datos la lista de los usuarios notificadores
                ICursor cursor = ManejoBaseDatos.Seleccionar("SELECT NombreCompleto, CodigoNotificador, RolNocturno FROM OficialesNotificadores");
                //Instancia de la tabla de notificadores
                TableLayout tablaNotificadores = Activity.FindViewById <TableLayout>(Resource.Id.tbNotificadores);
                //Se crea el objeto para las fila que se van a ingresar en la tabla
                TableRow nuevaFila;
                TableLayout.LayoutParams layoutParams = new TableLayout.LayoutParams(TableLayout.LayoutParams.MatchParent, TableLayout.LayoutParams.MatchParent);

                List <int> listaIndices = new List <int>();
                //Se guardan los indices que se van a eliminar de la tabla de notificadores
                for (int i = 1; i < tablaNotificadores.ChildCount; tablaNotificadores.RemoveViewAt(1))
                {
                    ;
                }

                if (cursor.MoveToFirst())//Se posiciona el cursor en la primera posición
                {
                    do
                    {
                        nuevaFila = new TableRow(Activity);                                    //Se instancia la nueva fila
                        nuevaFila.LayoutParameters = layoutParams;                             //Se agregan los tamaños del layout
                        nuevaFila.SetPadding(5, 5, 5, 5);                                      //Se agregan los margenes de cada fila
                        nuevaFila.SetBackgroundColor(Android.Graphics.Color.Argb(2, 1, 0, 5)); //Se cambia el color del fondo
                        nuevaFila.Clickable = true;
                        nuevaFila.Click    += (s, args) => { };

                        //Se agrega el nombre del notificador
                        TextView nombreNotificador = new TextView(Activity);
                        nombreNotificador.Text = cursor.GetString(0);
                        //Se agrega el rol
                        CheckBox rolNocturno = new CheckBox(Activity);
                        rolNocturno.Gravity = GravityFlags.CenterHorizontal;
                        rolNocturno.Text    = "";
                        //Se obtiene el valor del rol nocturno
                        string check = cursor.GetString(2);
                        //Si es verdadero el check se marca y si no, se deja sin marcar
                        rolNocturno.Checked = check == "True" || check == "true" ? true : false;
                        //Se guarda el codigo del notificador
                        string codigoNotificador = cursor.GetString(1);

                        rolNocturno.CheckedChange += (s, args) =>
                        {
                            ManejoBaseDatos.Abrir();
                            //Se actualiza el rol nocturno
                            string msj = ManejoBaseDatos.Actualizar("OficialesNotificadores", "RolNocturno", "'" + args.IsChecked + "'", "CodigoNotificador='" + codigoNotificador + "'");
                            ManejoBaseDatos.Cerrar();

                            try
                            {
                                if (args.IsChecked)
                                {
                                    string         consulta = @"https://pjgestionnotificacionmovilservicios.azurewebsites.net/api/OficialNotificador/AsignarRolNocturno?PCodNotificador=" + codigoNotificador + "";
                                    HttpWebRequest request  = (HttpWebRequest)WebRequest.Create(consulta);
                                    request.Method      = "GET";
                                    request.ContentType = "application/json";
                                    HttpWebResponse myResp = (HttpWebResponse)request.GetResponse();
                                    string          responseText;

                                    using (var response = request.GetResponse())
                                    {
                                        using (var reader = new StreamReader(response.GetResponseStream()))
                                        {
                                            responseText = reader.ReadToEnd();
                                            Console.WriteLine("Respuesta de web service: " + responseText);
                                            if (responseText.Equals("true") || responseText.Equals("True"))
                                            {
                                                Toast.MakeText(this.Activity, "Cambio a Rol Nocturno Exitoso", ToastLength.Short).Show();
                                            }
                                        }
                                    }
                                }
                            }
                            catch (WebException webEx)
                            {
                                Toast.MakeText(this.Activity, "Error al actualizar datos", ToastLength.Short).Show();
                                Console.WriteLine("Error al asignar rol nocturno: " + webEx.ToString());
                            }

                            Toast.MakeText(Activity, msj, ToastLength.Short).Show();
                        };
                        //Se agregan las dos columnas a la fila
                        nuevaFila.AddView(nombreNotificador);
                        nuevaFila.AddView(rolNocturno);
                        //Se agrega la nueva fila a la tabla
                        tablaNotificadores.AddView(nuevaFila);
                    } while (cursor.MoveToNext());
                }
                cursor.Close();

                ManejoBaseDatos.Cerrar();
            }catch (Exception ex)
            {
                //Se guarda el detalle del error
                Logs.saveLogError("RolNocturno.cargarNotificadores " + ex.Message + " " + ex.StackTrace);
            }
        }
示例#16
0
        protected async override void OnCreate(Bundle bundle)
        {
            // string path = "C:/Users/mof1/Documents/Visual Studio 2015/Projects/NDSSF/NDSSF/recordings/test.3gpp";
            System.Diagnostics.Debug.Write("------------------------->OnCreate()");
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.STE5);
            string[] array = { "sun", "moon", "try", "sun", "moon", "try" };
            int      m     = array.Length;

            LinearLayout Dp = FindViewById <LinearLayout>(Resource.Id.linearLayout1);

            LinearLayout.LayoutParams li = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);
            TableLayout.LayoutParams  lp = new TableLayout.LayoutParams(TableLayout.LayoutParams.MatchParent, TableLayout.LayoutParams.WrapContent);
            TableLayout linear           = new TableLayout(this);

            //   TableRow row = FindViewById<TableRow>(Resource.Id.row1);
            TableRow.LayoutParams tableRowParams = new TableRow.LayoutParams();
            tableRowParams.SetMargins(1, 1, 1, 1);
            tableRowParams.Weight = 1;

            TableRow tableRow = new TableRow(this);

            tableRow.SetGravity(GravityFlags.Top);
            tableRow.SetBackgroundColor(Color.Black);



            for (int i = 0; i < m; i++)
            {
                TextView tv = new TextView(this);
                tv.SetBackgroundColor(Color.Gray);
                tv.SetTextColor(Color.Black);
                tv.SetTypeface(null, TypefaceStyle.Bold);
                tv.Gravity = GravityFlags.Center;


                tv.Id = i;
                //int id = tv.FindViewById<Button>(i);

                int n = tv.Id;

                //   tv.SetText(Resource.Id.textView1_tab);
                lp.SetMargins(1, 1, 1, 1);
                tv.Text = array[i];

                tv.SetWidth(50);
                tv.SetHeight(50);
                li.RightMargin  = 5;
                li.LeftMargin   = 5;
                li.TopMargin    = 5;
                li.BottomMargin = 5;
                tableRow.AddView(tv, tableRowParams);
                tableRow.SetGravity(GravityFlags.Top);
                tv.SetBackgroundColor(Color.Beige);
                tv.SetSelectAllOnFocus(true);
                tv.RequestFocus();

                // tv.SetSelectAllOnFocus(FocusablesFlags.TouchMode);
            }
            //tv.SetBackgroundColor("red");

            linear.AddView(tableRow, lp);
            Dp.AddView(linear, li);
            //  Dp.SetGravity(GravityFlags.Top);
            // Dp.SetGravity.



            //  l1.AddView(tv);



            Toast.MakeText(this, "Database is updated", ToastLength.Short).Show();
            nlistview = FindViewById <ListView>(Resource.Id.listViewR);


            wordList = (await DataRepository.Words.GetAll());
            // wordStrings = new List<string>();

            MyServiceItemsAdapter       = new MyAdapter3(this, wordList);
            nlistview.Adapter           = MyServiceItemsAdapter;
            nlistview.FastScrollEnabled = true;
            Button btn = FindViewById <Button>(Resource.Id.button1);

            btn.Click += delegate { StartActivity(typeof(STE4_tokens)); };

            Button btn2 = FindViewById <Button>(Resource.Id.button3);

            btn2.Click += delegate { StartActivity(typeof(STE5_custom)); };
            Button btn3 = FindViewById <Button>(Resource.Id.button4);

            btn3.Click += delegate { StartActivity(typeof(tester)); };
        }
        static TableLayout CreateTableReport(View view, StatisticList statList)
        {
            TableLayout.LayoutParams fillParams = new TableLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent, 1.0f);
            TableLayout tblLayout = new TableLayout(view.Context);

            tblLayout.LayoutParameters  = fillParams;
            tblLayout.StretchAllColumns = true;

            TableRow rowHeader = new TableRow(view.Context);

            rowHeader.SetBackgroundResource(Resource.Drawable.actionbar_background);

            TextView tvItemKategH = new TextView(view.Context);

            tvItemKategH.Text = view.Resources.GetText(Resource.String.tvHeaderItemKategory);
            SetHeaderCellStyle(tvItemKategH);
            rowHeader.AddView(tvItemKategH);

            TextView tvAmountCurrH = new TextView(view.Context);

            tvAmountCurrH.Text    = DateTime.Now.ToString("MMM yyyy");
            tvAmountCurrH.Gravity = GravityFlags.Right;
            SetHeaderCellStyle(tvAmountCurrH);
            rowHeader.AddView(tvAmountCurrH);

            TextView tvAmountPrevH = new TextView(view.Context);

            tvAmountPrevH.Text    = DateTime.Now.AddYears(-1).ToString("MMM yyyy");
            tvAmountPrevH.Gravity = GravityFlags.Right;
            SetHeaderCellStyle(tvAmountPrevH);
            rowHeader.AddView(tvAmountPrevH);

            tblLayout.AddView(rowHeader);

            foreach (Statistic st in statList)
            {
                TableRow row = new TableRow(view.Context);
                row.SetBackgroundResource(Resource.Drawable.button_selector);

                TextView tvItemKateg = new TextView(view.Context);
                tvItemKateg.Text = st.ItemKategDesc;
                StatisticTabMonthly.SetCellStyle(tvItemKateg);
                row.AddView(tvItemKateg);

                TextView tvAmountCurr = new TextView(view.Context);
                tvAmountCurr.Gravity = GravityFlags.Right;
                tvAmountCurr.Text    = st.AmountCurrText;
                StatisticTabMonthly.SetCellStyle(tvAmountCurr);
                row.AddView(tvAmountCurr);

                TextView tvAmountPrev = new TextView(view.Context);
                tvAmountPrev.Gravity = GravityFlags.Right;
                tvAmountPrev.Text    = st.AmountPrevText;
                StatisticTabMonthly.SetCellStyle(tvAmountPrev);
                row.AddView(tvAmountPrev);

                tblLayout.AddView(row);
            }

            return(tblLayout);
        }
        private void AddLastKitchenInformation(string userName)
        {
            var lastKitchenInfo = GetLastDayKitchenInfo(userName);

            if (lastKitchenInfo != null)
            {
                TableLayout.LayoutParams layoutParameters = new TableLayout.LayoutParams(
                    TableLayout.LayoutParams.MatchParent, TableLayout.LayoutParams.WrapContent);
                layoutParameters.SetMargins(5, 5, 5, 5);
                layoutParameters.Weight = 1;

                SetTableHeader(layoutParameters);

                foreach (var lki in lastKitchenInfo)
                {
                    TableRow tr = new TableRow(this);
                    tr.LayoutParameters = layoutParameters;

                    TextView site = new TextView(this);
                    site.Text = lki.SiteName;
                    tr.AddView(site);

                    TextView space1 = new TextView(this);
                    space1.Text = "     ";
                    tr.AddView(space1);

                    TextView plotNo = new TextView(this);
                    plotNo.Text = lki.PlotNumber;
                    tr.AddView(plotNo);

                    TextView space2 = new TextView(this);
                    space2.Text = "     ";
                    tr.AddView(space2);

                    TextView kitchenModel = new TextView(this);
                    kitchenModel.Text = lki.KitchenModel.ToString();
                    tr.AddView(kitchenModel);

                    TextView space3 = new TextView(this);
                    space3.Text = "     ";
                    tr.AddView(space3);

                    TextView imgNo = new TextView(this);
                    imgNo.Text = lki.ImageNumber.ToString() + (lki.ImageNumber == 1 ? "pic" : "pics");
                    tr.AddView(imgNo);

                    table.AddView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.MatchParent,
                                                                   TableLayout.LayoutParams.WrapContent));
                }

                // getting last kitchen images

                HttpWebRequest request = WebRequest.Create(Constant.STORAGE_URL + "/lastKitchenImages") as HttpWebRequest;
                request.Headers.Add("Authorization", "Bearer " + accessToken);

                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    Stream       responseStream     = response.GetResponseStream();
                    StreamReader reader             = new StreamReader(responseStream);
                    var          responseFromServer = reader.ReadToEnd();

                    List <ImageViewModel> images = JsonConvert.DeserializeObject <List <ImageViewModel> >(responseFromServer);

                    CloudStorageAccount account = StorageHelpers.StorageAccount(accessToken);

                    CloudBlobClient blobClient = account.CreateCloudBlobClient();

                    CloudBlobContainer container = blobClient.GetContainerReference(Constant.IMAGE_STORAGE_CONTAINER_NAME);

                    Bitmap[] bitmaps  = new Bitmap[images.Count];
                    int      position = 0;
                    foreach (var image in images)
                    {
                        using (MemoryStream ms = new MemoryStream())
                        {
                            CloudBlockBlob blockBlob = container.GetBlockBlobReference(image.Name);
                            blockBlob.DownloadToStream(ms);
                            byte[] data = ms.ToArray();
                            bitmaps[position] = BitmapHelpers.DecodeSampledBitmapFromByteArray(data, 100, 100);
                        }
                        position++;
                    }

                    var gridView = FindViewById <GridView>(Resource.Id.gridView1);
                    gridView.Adapter = new ImageAdapter(this, bitmaps);
                }
            }
        }
示例#19
0
        //int count = 1;



        protected override void OnCreate(Bundle bundle)
        {
            // string path = "C:/Users/mof1/Documents/Visual Studio 2015/Projects/NDSSF/NDSSF/recordings/test.3gpp";
            System.Diagnostics.Debug.Write("------------------------->OnCreate()");
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.STE4_tokens);
            //  Context context= new Context(BaseContext);
            int borderWidth  = 10;
            int borderHeight = 5;
            int thickness    = 2;
            // LinearLayout l1 = FindViewById<LinearLayout>(Resource.Id)
            ImageView selectionBorder = BorderDrawer.generateBorderImageView(this, borderWidth, borderHeight, thickness, Color.White);

            //  string next;
            // Get our button from the layout resource,
            // and attach an event to it
            string[] array = { "sun", "moon", "try", "sun", "moon", "try" };
            int      m     = array.Length;

            LinearLayout Dp = FindViewById <LinearLayout>(Resource.Id.linearLayout1);

            LinearLayout.LayoutParams li = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);
            TableLayout.LayoutParams  lp = new TableLayout.LayoutParams(TableLayout.LayoutParams.MatchParent, TableLayout.LayoutParams.WrapContent);
            TableLayout linear           = new TableLayout(this);

            //   TableRow row = FindViewById<TableRow>(Resource.Id.row1);
            TableRow.LayoutParams tableRowParams = new TableRow.LayoutParams();
            tableRowParams.SetMargins(1, 1, 1, 1);
            tableRowParams.Weight = 1;

            TableRow tableRow = new TableRow(this);

            tableRow.SetGravity(GravityFlags.Top);
            tableRow.SetBackgroundColor(Color.Black);



            for (int i = 0; i < m; i++)
            {
                TextView tv = new TextView(this);
                tv.SetBackgroundColor(Color.Gray);
                tv.SetTextColor(Color.Black);
                tv.SetTypeface(null, TypefaceStyle.Bold);
                tv.Gravity = GravityFlags.Center;


                tv.Id = i;
                //int id = tv.FindViewById<Button>(i);

                int n = tv.Id;

                //   tv.SetText(Resource.Id.textView1_tab);
                lp.SetMargins(1, 1, 1, 1);
                tv.Text = array[i];

                tv.SetWidth(50);
                tv.SetHeight(50);
                li.RightMargin  = 5;
                li.LeftMargin   = 5;
                li.TopMargin    = 5;
                li.BottomMargin = 5;
                tableRow.AddView(tv, tableRowParams);
                tableRow.SetGravity(GravityFlags.Top);
            }
            //tv.SetBackgroundColor("red");

            linear.AddView(tableRow, lp);
            Dp.AddView(linear, li);
            ImageButton next_ste5 = FindViewById <ImageButton>(Resource.Id.imageButton_next);
        }
        private Button GenerateButton(MenuItem item)
        {
            Button btn = new Button (_context);
            btn.Text = item.Text;

            var param = new TableLayout.LayoutParams (0, LayoutParams.WrapContent, 1f);
            if (margin >= 0) {
                marginBottom = marginLeft = marginTop = marginRight = margin;
            }
            param.BottomMargin = MarginBottom;
            param.LeftMargin = MarginLeft;
            param.TopMargin = MarginTop;
            param.RightMargin = MarginRight;

            btn.LayoutParameters = param;

            if (item.IconId != 0) {
                btn.SetCompoundDrawablesWithIntrinsicBounds (null,
                    Resources.GetDrawable (item.IconId),
                    null, null);
            }
            btn.SetTypeface (tabTypeface, typefaceStyle);
            btn.SetTextColor (TextColor);
            btn.TextSize = TextSize;
            btn.SetBackgroundColor (ItemBgColor);
            btn.SetBackgroundResource (ItemBg);
            if (padding != 0) {
                paddingLeft = paddingTop = paddingRight = paddingBottom = padding;
            }
            btn.SetPadding (paddingLeft, paddingTop, paddingRight, paddingBottom);
            btn.Click += (o, e) => {
                if (ItemClicked != null) {
                    ItemClicked (this, item.ItemId);
                }
            };
            return btn;
        }
示例#21
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var svvl = FindViewById<LinearLayout>(Resource.Id.VerticalLayoutScroll);
            var addButton = FindViewById<Button>(Resource.Id.AddNewFields);
            var calcBtn = FindViewById(Resource.Id.Calculate);

            var layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent,
                    ViewGroup.LayoutParams.WrapContent);
            var textFieldLayoutParams = new TableLayout.LayoutParams(0, ViewGroup.LayoutParams.MatchParent, 1);

            //Add Button Click Event
            addButton.Click += (sender, eventArgs) =>
            {
                var linearLayout = new LinearLayout(this)
                {
                    Orientation = Orientation.Horizontal,
                    LayoutParameters = layoutParams,
                    WeightSum = 2
                };

                var nameField = new EditText(this)
                {
                    InputType = InputTypes.ClassText,
                    LayoutParameters = textFieldLayoutParams,
                    Hint = "Name of a Person"
                };

                var moneyField = new EditText(this)
                {
                    InputType = InputTypes.ClassNumber,
                    LayoutParameters = textFieldLayoutParams,
                    Hint = "Spent Money"
                };

                linearLayout.AddView(nameField);
                linearLayout.AddView(moneyField);
                svvl.AddView(linearLayout);
            };

            calcBtn.Click += (sender, eventArgs) =>
            {
                var personsList = new List<Person>();
                for (var i = 0; i < svvl.ChildCount; i++)
                {
                    var child = svvl.GetChildAt(i);

                    if (!(child is LinearLayout)) continue;
                    var editText = (child as LinearLayout).GetChildAt(0) as EditText;
                    var text = (child as LinearLayout).GetChildAt(1) as EditText;
                    if (editText != null && text != null && !string.IsNullOrEmpty(editText.Text))
                    {
                        personsList.Add(new Person
                        {
                            Name = editText.Text,
                            SpentMoney = !string.IsNullOrEmpty(text.Text) ? Convert.ToDecimal(text.Text) : 0,
                        });
                    }
                }
                var finalList = Person.CalculateMoney(personsList);
                var intent = new Intent(this, typeof (ResultActivity));
                string result = null;
                if (finalList != null)
                {
                    foreach (var person in finalList)
                    {
                        if (person.WhoAndHow != null)
                            result = person.WhoAndHow.Aggregate(result,
                                (current, item) =>
                                    current +
                                    (person.Name + " needs to give " + item.Value + " AMD to " + item.Key +
                                     System.Environment.NewLine));
                    }
                }
                intent.PutExtra("Result", result);
                StartActivity(intent);
            };
        }