예제 #1
0
        /// <summary>
        /// Sets the content view.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="resourceId">The resource identifier.</param>
        protected void SetContentView(Context context, int resourceId)
        {
            var inflater = LayoutInflater.From(context);

            inflater.Inflate(resourceId, this);
        }
 public Adaptador_Selector_Caballos(List <int> _caballos, Context _context)
 {
     caballos       = _caballos;
     context        = _context;
     layoutinflater = LayoutInflater.From(_context);
 }
        protected override void OnElementChanged(ElementChangedEventArgs <BinSegmentedControl> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                // Instantiate the native control and assign it to the Control property with
                // the SetNativeControl method

                var layoutInflater = LayoutInflater.From(context);

                var view = layoutInflater.Inflate(Resource.Layout.RadioGroup, null);

                nativeControl = (RadioGroup)layoutInflater.Inflate(Resource.Layout.RadioGroup, null);

                for (var i = 0; i < Element.Children.Count; i++)
                {
                    var o  = Element.Children[i];
                    var rb = (RadioButton)layoutInflater.Inflate(Resource.Layout.RadioButton, null);

                    rb.LayoutParameters = new RadioGroup.LayoutParams(0, LayoutParams.WrapContent, 1f);
                    rb.Text             = o.Text;

                    if (i == 0)
                    {
                        rb.SetBackgroundResource(Resource.Drawable.segmented_control_first_background);
                    }
                    else if (i == Element.Children.Count - 1)
                    {
                        rb.SetBackgroundResource(Resource.Drawable.segmented_control_last_background);
                    }

                    ConfigureRadioButton(i, rb);

                    nativeControl.AddView(rb);
                }

                var option = (RadioButton)nativeControl.GetChildAt(Element.SelectedSegment);

                if (option != null)
                {
                    option.Checked = true;
                }

                SetNativeControl(nativeControl);
            }

            if (e.OldElement != null)
            {
                // Unsubscribe from event handlers and cleanup any resources

                if (nativeControl != null)
                {
                    nativeControl.CheckedChange -= NativeControl_ValueChanged;
                }
            }

            if (e.NewElement != null)
            {
                // Configure the control and subscribe to event handlers

                nativeControl.CheckedChange += NativeControl_ValueChanged;
            }
        }
예제 #4
0
 public SponsorImageView(Context context, IAttributeSet attrs, int defStyleAttr) : base(context, attrs, defStyleAttr)
 {
     binding = SponsorImageViewBinding.Inflate(LayoutInflater.From(context), Resource.Layout.view_sponsor_image, this, true);
 }
예제 #5
0
        //public async Task bindImages()
        //{
        //    await
        //}

        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View row = convertView;

            if (row == null)
            {
                row = LayoutInflater.From(myContext).Inflate(Resource.Layout.cell, null, false);
            }
            //else
            //    return row;

            TextView txtName = row.FindViewById <TextView>(Resource.Id.txtName);
            //TextView txtRatings = row.FindViewById<TextView>(Resource.Id.txtRatings);
            TextView txtVintage = row.FindViewById <TextView>(Resource.Id.txtVintage);
            //TextView txtUserRatings = row.FindViewById<TextView>(Resource.Id.txtUserRatings);
            TextView  txtPrice = row.FindViewById <TextView>(Resource.Id.txtPrice);
            ImageView imgWine  = row.FindViewById <ImageView>(Resource.Id.imgWine);
            // ImageView imgPlaceHolder = row.FindViewById<ImageView>(Resource.Id.Placeholder);
            ImageView heartImg = row.FindViewById <ImageView>(Resource.Id.imgHeart);
            RatingBar rating   = row.FindViewById <RatingBar>(Resource.Id.rtbProductRating);

            rating.Rating = (float)myItems[position].AverageRating;
            //RelativeLayout rel = row.FindViewById<RelativeLayout>(Resource.Id.relative);
            //var place11 = new RelativeLayout.LayoutParams(520, 620)
            //rel.LayoutParameters = place11;
            //rel.LayoutParameters = new RelativeLayout.LayoutParams(520, 520);
            txtName.Text = myItems[position].Name;
            //txtName.InputType = Android.Text.InputTypes.TextFlagNoSuggestions;
            //txtRatings.Text = myItems[position].Ratings;
            //txtUserRatings.Text = myItems[position].UserRatings;

            txtPrice.Text = myItems[position].SalePrice.ToString("C", Cultures.UnitedState);

            txtVintage.Text = myItems[position].Vintage.ToString();
            //heartImg.t = myItems[position].s;

            heartImg.SetImageResource(Resource.Drawable.heart_empty);
            var heartLP = new FrameLayout.LayoutParams(80, 80);

            var metrics    = myContext.Resources.DisplayMetrics;
            var widthInDp  = ConvertPixelsToDp(metrics.WidthPixels);
            var heightInDp = ConvertPixelsToDp(metrics.HeightPixels);

            heartLP.LeftMargin        = parent.Resources.DisplayMetrics.WidthPixels / 2 - 110; // 110 = 80 + 30
            heartLP.TopMargin         = 5;
            heartImg.LayoutParameters = heartLP;

            heartImg.Layout(50, 50, 50, 50);


            bool count = Convert.ToBoolean(myItems[position].IsLike);

            if (count == true)
            {
                heartImg.SetImageResource(Resource.Drawable.heart_full);
            }
            else
            {
                heartImg.SetImageResource(Resource.Drawable.heart_empty);
            }

            heartImg.Tag = position;

            if (convertView == null)
            {
                heartImg.Click += async delegate
                {
                    int  actualPosition = Convert.ToInt32(heartImg.Tag);
                    bool x;
                    if (count == false)
                    {
                        heartImg.SetImageResource(Resource.Drawable.heart_full);
                        x     = true;
                        count = true;
                    }
                    else
                    {
                        heartImg.SetImageResource(Resource.Drawable.heart_empty);
                        x     = false;
                        count = false;
                    }
                    SKULike like = new SKULike();
                    like.UserID = Convert.ToInt32(CurrentUser.getUserId());
                    like.SKU    = Convert.ToInt32(myItems[actualPosition].SKU);
                    like.Liked  = x;
                    myItems[actualPosition].IsLike = x;
                    like.WineId = myItems[actualPosition].WineId;
                    ServiceWrapper sw = new ServiceWrapper();
                    await sw.InsertUpdateLike(like);
                };
            }


            //ProfilePicturePickDialog pppd = new ProfilePicturePickDialog();
            //string path = pppd.CreateDirectoryForPictures();
            //var filePath = System.IO.Path.Combine(path + "/" + myItems[position].WineId + ".jpg");
            Bitmap imageBitmap;



            //if (System.IO.File.Exists(filePath))
            //{
            //    imageBitmap = BitmapFactory.DecodeFile(filePath);
            //}
            //else
            //{
            imageBitmap = BlobWrapper.Bottleimages(myItems[position].WineId);
            //}
            //var place1 = new FrameLayout.LayoutParams(650, 650);
            //imgPlaceHolder.SetImageResource(Resource.Drawable.placeholder);
            //place1.LeftMargin = -70;
            //imgPlaceHolder.LayoutParameters = place1;



            var place = new FrameLayout.LayoutParams(650, 650);

            place.LeftMargin         = -70; //-650 + (parent.Resources.DisplayMetrics.WidthPixels - imageBitmap.Width) / 2;
            imgWine.LayoutParameters = place;


            if (imageBitmap != null)
            {
                float ratio = (float)650 / imageBitmap.Height;
                imageBitmap = Bitmap.CreateScaledBitmap(imageBitmap, Convert.ToInt32(imageBitmap.Width * ratio), 650, true);
                //imageBitmap.Recycle();
                //Canvas canvas = new Canvas(imageBitmap);
                //imageBitmap.EraseColor(Color.White);
                //canvas.DrawColor(Color.Transparent, PorterDuff.Mode.Clear);
                //canvas.DrawBitmap(imageBitmap, 0, 0, null);
                imgWine.SetImageBitmap(imageBitmap);

                imageBitmap.Dispose();
            }
            else
            {
                imgWine.SetImageResource(Resource.Drawable.wine7);
            }



            txtName.Focusable = false;

            txtVintage.Focusable = false;
            txtPrice.Focusable   = false;
            imgWine.Focusable    = false;
            //imgPlaceHolder.Focusable = false;
            return(row);
        }
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            var layout = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.CustomCell, parent, false);

            return(new CustomRecyclerViewHolder(layout));
        }
예제 #7
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            var view = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.cell_friend, parent, false);

            return(new FriendViewHolder(view, OnClick));
        }
예제 #8
0
        protected override void OnElementChanged(ElementChangedEventArgs <NewView> e)
        {
            base.OnElementChanged(e);
            if (Control == null)
            {
                //  var context = new NewViewRenderer(Forms.Context);
                //SetNativeControl(context);
                var context = Android.App.Application.Context;
                var view    = LayoutInflater.From(context).Inflate(Resource.Layout.NotificationLayout, null, false);
                //   LayoutInflater minflater = context.GetSystemService(Context.LayoutInflaterService) as LayoutInflater;
                //  var view = minflater.Inflate(Resource.Layout.NotificationLayout, this, false);
                var msgText = view.FindViewById <TextView>(Resource.Id.msgText);
                btnRegion1 = view.FindViewById <Android.Widget.Switch>(Resource.Id.SubscribeToRegion1);
                btnRegion2 = view.FindViewById <Android.Widget.Switch>(Resource.Id.SubscribeToRegion2);
                btnRegion3 = view.FindViewById <Android.Widget.Switch>(Resource.Id.SubscribeToRegion3);
                btnRegion4 = view.FindViewById <Android.Widget.Switch>(Resource.Id.SubscribeToRegion4);
                btnRegion5 = view.FindViewById <Android.Widget.Switch>(Resource.Id.SubscribeToRegion5);
                SetNativeControl(view);

                //show saved settings
                if (Preferences.ContainsKey("R1"))
                {
                    string R1 = Preferences.Get("R1", "");
                    if (R1 == "1")
                    {
                        btnRegion1.Checked = true;
                    }
                    else
                    {
                        btnRegion1.Checked = false;
                    }
                }
                if (Preferences.ContainsKey("R2"))
                {
                    string R2 = Preferences.Get("R2", "");
                    if (R2 == "1")
                    {
                        btnRegion2.Checked = true;
                    }
                    else
                    {
                        btnRegion2.Checked = false;
                    }
                }
                if (Preferences.ContainsKey("R3"))
                {
                    string R3 = Preferences.Get("R3", "");
                    if (R3 == "1")
                    {
                        btnRegion3.Checked = true;
                    }
                    else
                    {
                        btnRegion3.Checked = false;
                    }
                }
                if (Preferences.ContainsKey("R4"))
                {
                    string R4 = Preferences.Get("R4", "");
                    if (R4 == "1")
                    {
                        btnRegion4.Checked = true;
                    }
                    else
                    {
                        btnRegion4.Checked = false;
                    }
                }
                if (Preferences.ContainsKey("R5"))
                {
                    string R5 = Preferences.Get("R5", "");
                    if (R5 == "1")
                    {
                        btnRegion5.Checked = true;
                    }
                    else
                    {
                        btnRegion5.Checked = false;
                    }
                }

                //end remember settings ----------
            }
            if (e.NewElement != null)
            {
                btnRegion1.CheckedChange += (a, b) =>
                {
                    bool isChecked = b.IsChecked;
                    if (isChecked)
                    {
                        FirebaseMessaging.Instance.SubscribeToTopic("R1");
                        Preferences.Set("R1", "1");
                    }
                    else
                    {
                        FirebaseMessaging.Instance.UnsubscribeFromTopic("R1");
                        Preferences.Set("R1", "0");
                    }
                };

                btnRegion2.CheckedChange += (c, d) =>
                {
                    bool isChecked = d.IsChecked;
                    if (isChecked)
                    {
                        FirebaseMessaging.Instance.SubscribeToTopic("R2");
                        Preferences.Set("R2", "1");
                    }
                    else
                    {
                        FirebaseMessaging.Instance.UnsubscribeFromTopic("R2");
                        Preferences.Set("R2", "0");
                    }
                };

                btnRegion3.CheckedChange += (e, f) =>
                {
                    bool isChecked = f.IsChecked;
                    if (isChecked)
                    {
                        FirebaseMessaging.Instance.SubscribeToTopic("R3");
                        Preferences.Set("R3", "1");
                    }
                    else
                    {
                        FirebaseMessaging.Instance.UnsubscribeFromTopic("R3");
                        Preferences.Set("R3", "0");
                    }
                };

                btnRegion4.CheckedChange += (g, h) =>
                {
                    bool isChecked = h.IsChecked;
                    if (isChecked)
                    {
                        FirebaseMessaging.Instance.SubscribeToTopic("R4");
                        Preferences.Set("R4", "1");
                    }
                    else
                    {
                        FirebaseMessaging.Instance.UnsubscribeFromTopic("R4");
                        Preferences.Set("R4", "0");
                    }
                };

                btnRegion5.CheckedChange += (i, j) =>
                {
                    bool isChecked = j.IsChecked;
                    if (isChecked)
                    {
                        FirebaseMessaging.Instance.SubscribeToTopic("R5");
                        Preferences.Set("R5", "1");
                    }
                    else
                    {
                        FirebaseMessaging.Instance.UnsubscribeFromTopic("R5");
                        Preferences.Set("R5", "0");
                    }
                };
            }
        }
예제 #9
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            if (holder is ScriptsViewHolder vh)
            {
                vh.ScriptName.Text = list[position].ScriptName;

                //check if button has the OnClick listener for set it only once

                if (!vh.Delete.HasOnClickListeners)
                {
                    vh.Delete.Click -= BtnDeleteOnClick;

                    vh.Delete.Click += BtnDeleteOnClick;
                }

                void BtnDeleteOnClick(object sender, EventArgs e)
                {
                    vh.ScriptForeground.TranslationX = 0;
                    vh.BtnPlus.SetImageResource(Resource.Drawable.plus_btn);
                    Scripts.ItemTouchHelperAttach(true);
                    DeleteScriptConnection.StartConnectionAsync(MainActivity.Ip, list[position]);
                    list.RemoveAt(position);
                    NotifyDataSetChanged();
                    NotifyItemChanged(position);
                    NotifyItemRangeChanged(position, list.Count);
                    NotifyItemRemoved(position);
                }

                //event unsubscription to don't repeat the subscription

                if (!vh.BtnPlus.HasOnClickListeners)
                {
                    vh.BtnPlus.Click -= BtnPlusOnClick;

                    vh.BtnPlus.Click += BtnPlusOnClick;
                }

                if (!vh.ScriptName.HasOnClickListeners)
                {
                    vh.ScriptName.Click -= ScriptOnClick;

                    vh.ScriptName.Click += ScriptOnClick;
                }

                //when click on "+" button in script item
                void BtnPlusOnClick(object sender, EventArgs args)
                {
                    if (vh.BtnPlusIsClicked == false)
                    {
                        vh.BtnPlusIsClicked = true;
                        ScriptSelectedCounter++;

                        Scripts.SetRunBarVisibility(VisibilityFlags.Visible);

                        //change "+" to check mark
                        vh.BtnPlus.SetImageResource(Resource.Drawable.chech_mark);

                        Scripts.SelectedScripts.Add(list[position]);
                    }
                    else
                    {
                        vh.BtnPlusIsClicked = false;
                        ScriptSelectedCounter--;

                        //change check mark to "+"
                        vh.BtnPlus.SetImageResource(Resource.Drawable.plus_btn);

                        Scripts.SelectedScripts.Remove(list[position]);
                    }

                    if (ScriptSelectedCounter == 0)
                    {
                        Scripts.SetRunBarVisibility(VisibilityFlags.Invisible);
                    }
                }

                if (!vh.BtnBack.HasOnClickListeners)
                {
                    vh.BtnBack.Click -= BtnBackOnClick;
                    vh.BtnBack.Click += BtnBackOnClick;
                }

                void BtnBackOnClick(object sender, EventArgs e)
                {
                    vh.ScriptBackground.Visibility   = ViewStates.Gone;
                    vh.ScriptForeground.TranslationX = 0;
                    Scripts.ItemTouchHelperAttach(true);
                    vh.BtnBack.Visibility = ViewStates.Gone;
                    vh.BtnPlus.Visibility = ViewStates.Visible;
                }
            }

            //when click on item
            void ScriptOnClick(object sender, EventArgs e)
            {
                //create the "Script Info" dialog
                LayoutInflater layoutInflater = LayoutInflater.From(context);
                View           v           = layoutInflater.Inflate(Resource.Layout.file_info_dialog, null);
                Button         okayBtn     = v.FindViewById <Button>(Resource.Id.ok_btn);
                TextView       dateCreated = v.FindViewById <TextView>(Resource.Id.creating_date);
                TextView       content     = v.FindViewById <TextView>(Resource.Id.script_info);

                dateCreated.Text = list[position].ScriptDateCreated;
                content.Text     = list[position].ScriptData;

                AlertDialog.Builder builder = new AlertDialog.Builder(context, Resource.Style.AlertDialogTheme);
                builder.SetView(v);
                var dialog = builder.Create();

                dialog.Show();
                dialog.Window.SetBackgroundDrawableResource(Resource.Drawable.script_info_background);

                //if click on "Okay" — close "Script Info" dialog
                okayBtn.Click += delegate { dialog.Hide(); };
            }
        }
예제 #10
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View view = convertView;

            view = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.plazafoodlistadapterlayout, parent, false);

            var prod = productos[position];

            ImageView prodimage = view.FindViewById <ImageView>(Resource.Id.fotoproductoiv);

            //var imagebit = GetBitmap(prod.FotoProducto);
            //prodimage.SetImageBitmap(imagebit);
            byte[] veremos = prod.FotoProducto;
            Bitmap mdg     = BitmapFactory.DecodeByteArray(veremos, 0, veremos.Length);

            prodimage.SetImageBitmap(mdg);

            TextView prodnombre = view.FindViewById <TextView>(Resource.Id.productonametv);

            prodnombre.Text = prod.NombreProducto;

            TextView proddescripcion = view.FindViewById <TextView>(Resource.Id.productdescriptiontv);

            proddescripcion.Text = prod.Descripcion;

            TextView proddeadline = view.FindViewById <TextView>(Resource.Id.deadlinetv);

            proddeadline.Text = prod.TiempoEntrega.ToString() + " Min.";

            TextView proddescuento = view.FindViewById <TextView>(Resource.Id.descuentotv);

            proddescuento.Text = "Descuento " + prod.Descuento.ToString() + "%";

            int   descuento      = (Int32)prod.Descuento;
            int   precio         = (Int32)prod.PrecioProducto;
            float coner          = precio / 100;
            float atrio          = coner * descuento;
            float preciodescuent = precio - atrio;

            if (descuento == 0)
            {
                TextView prodprecio = view.FindViewById <TextView>(Resource.Id.pricetv);
                prodprecio.Text = "$" + prod.PrecioProducto.ToString();
            }
            else
            {
                TextView prodprecio = view.FindViewById <TextView>(Resource.Id.pricetv);
                // int precio = (Int32)prod.PrecioProducto;
                //int final = precio - (precio / 100 * descuento);
                prodprecio.SetTextColor(Color.Red);
                prodprecio.Text = preciodescuent.ToString();
            }


            Button button = view.FindViewById <Button>(Resource.Id.agregarbtn);

            button.SetTag(Resource.Id.agregarbtn, position);
            button.Click += delegate
            {
                var    election = productos[position];
                Dialog popup    = new Dialog(context);
                popup.SetContentView(Resource.Layout.popupfoodselectlayout);
                popup.Window.SetSoftInputMode(SoftInput.AdjustResize);
                popup.Show();
                popup.Window.SetBackgroundDrawableResource(Android.Resource.Color.Transparent);
                var image          = popup.FindViewById <ImageView>(Resource.Id.fotoproductopopup);
                var productoname   = popup.FindViewById <TextView>(Resource.Id.nameproducto);
                var descr          = popup.FindViewById <TextView>(Resource.Id.descripcionpopup);
                var agregar        = popup.FindViewById <Button>(Resource.Id.agregarproducto);
                var quitar         = popup.FindViewById <Button>(Resource.Id.quitarproducto);
                var cantidad       = popup.FindViewById <TextView>(Resource.Id.cantidadpedido);
                var agregarcarrito = popup.FindViewById <Button>(Resource.Id.agregaracarrito);

                byte[] imgpopu = election.FotoProducto;
                Bitmap bitm    = BitmapFactory.DecodeByteArray(imgpopu, 0, imgpopu.Length);
                image.SetImageBitmap(bitm);

                productoname.Text = election.NombreProducto;
                descr.Text        = election.Descripcion;

                int x = 0;
                cantidad.Text = x.ToString();

                agregar.Click += delegate
                {
                    if (cantidad.Text == "0")
                    {
                        cantidad.Text = "0";
                    }
                    else
                    {
                        int y = x--;
                        cantidad.Text = y.ToString();
                    }
                };
                quitar.Click += delegate
                {
                    int y = x++;
                    cantidad.Text = y.ToString();
                };
                agregarcarrito.Click += delegate
                {
                    string  idproducto       = election.IdProducto;
                    string  nombreproducto   = election.NombreProducto;
                    float   precioproducto   = election.PrecioProducto;
                    string  idrestaurante    = election.IdRestaurante;
                    int     cantidadproducto = Int32.Parse(cantidad.Text.ToString());
                    byte [] fotoproudcto     = election.FotoProducto as byte[];
                    string  please           = Base64.EncodeToString(fotoproudcto, Base64Flags.Default);

                    ISharedPreferences       preff = PreferenceManager.GetDefaultSharedPreferences(context);
                    ISharedPreferencesEditor edit  = preff.Edit();
                    edit.PutString("IDPRODUCTO", idproducto);
                    edit.PutString("IDRESTAURANTE", idrestaurante);
                    edit.PutString("NOMBREPRODUCTO", nombreproducto);
                    edit.PutFloat("PRECIOPRODUCTO", precioproducto);
                    edit.PutInt("CANTIDADPRODUCTO", cantidadproducto);
                    edit.PutString("FOTOPRODUCTO", encodebase64(fotoproudcto));
                    edit.Apply();
                    popup.Dismiss();
                    context.addData();
                };
            };

            return(view);
        }
        //set the view
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View row = convertView;

            if (row == null)
            {
                row = LayoutInflater.From(Context).Inflate(Resource.Layout.SalariesWagesTable, null, false);
            }
            //retrieve the shared preferences to edit the row attributes such as text size, colour or if the the data has to be sorted by date
            ISharedPreferences getidpreferences = Application.Context.GetSharedPreferences("UserInformation", FileCreationMode.Private);
            string             UserID           = getidpreferences.GetString("LatestUserID", String.Empty);
            ISharedPreferences preferences      = Application.Context.GetSharedPreferences("UserInformation" + UserID, FileCreationMode.Private);
            int  textSize        = preferences.GetInt("TextSize", 1);
            bool NightSwitchMode = preferences.GetBoolean("NightSwitchMode", false);
            bool DateSwitchMode  = preferences.GetBoolean("DateSwitchMode", false);

            TextView txtDateSalariesWages         = row.FindViewById <TextView>(Resource.Id.txtDateSalariesWages);
            TextView txtRosteredCostSalariesWages = row.FindViewById <TextView>(Resource.Id.txtActualCostSalariesWages);
            TextView txtBudgetSalariesWages       = row.FindViewById <TextView>(Resource.Id.txtBudgetCostSalariesWages);
            TextView txtVarianceSalariesWages     = row.FindViewById <TextView>(Resource.Id.txtVarianceSalariesWages);

            switch (textSize)
            {
            case 0:
                txtDateSalariesWages.TextSize         = 10;
                txtRosteredCostSalariesWages.TextSize = 10;
                txtBudgetSalariesWages.TextSize       = 10;
                txtVarianceSalariesWages.TextSize     = 10;
                break;

            case 1:
                txtDateSalariesWages.TextSize         = 15;
                txtRosteredCostSalariesWages.TextSize = 15;
                txtBudgetSalariesWages.TextSize       = 15;
                txtVarianceSalariesWages.TextSize     = 15;
                break;

            case 2:
                txtDateSalariesWages.TextSize         = 20;
                txtRosteredCostSalariesWages.TextSize = 20;
                txtBudgetSalariesWages.TextSize       = 20;
                txtVarianceSalariesWages.TextSize     = 20;
                break;
            }

            if (NightSwitchMode)
            {
                txtDateSalariesWages.SetTextColor(Color.White);
                txtRosteredCostSalariesWages.SetTextColor(Color.White);
                txtBudgetSalariesWages.SetTextColor(Color.White);
                txtVarianceSalariesWages.SetTextColor(Color.White);
            }
            else
            {
                txtDateSalariesWages.SetTextColor(Color.Black);
                txtRosteredCostSalariesWages.SetTextColor(Color.Black);
                txtBudgetSalariesWages.SetTextColor(Color.Black);
                txtVarianceSalariesWages.SetTextColor(Color.Black);
            }

            if (DateSwitchMode)
            {
                Items.Sort(delegate(SalariesWagesData one, SalariesWagesData two) {
                    return(DateTime.Compare(one.GetDate(), two.GetDate()));
                });
            }

            //for every item
            txtDateSalariesWages.Text         = Items[position].GetDate().ToShortDateString();
            txtRosteredCostSalariesWages.Text = "$ " + Items[position].GetActualCost().ToString("#,#", CultureInfo.InvariantCulture);
            txtVarianceSalariesWages.Text     = "$ " + Items[position].GetVariance().ToString("#,#", CultureInfo.InvariantCulture);
            txtBudgetSalariesWages.Text       = "$ " + Items[position].GetBudget().ToString("#,#", CultureInfo.InvariantCulture);
            //set indicator colours
            if (Items[position].IsGreen())
            {
                if (NightSwitchMode)
                {
                    row.SetBackgroundColor(Color.DarkGreen);
                }
                else
                {
                    row.SetBackgroundColor(Color.LightGreen);
                }
            }
            else if (Items[position].IsRed())
            {
                if (NightSwitchMode)
                {
                    row.SetBackgroundColor(Color.DarkRed);
                }
                else
                {
                    row.SetBackgroundColor(Color.Argb(80, 255, 128, 128));
                }
            }
            else
            {
                if (NightSwitchMode)
                {
                    row.SetBackgroundColor(Color.DarkOrange);
                }
                else
                {
                    row.SetBackgroundColor(Color.LightYellow);
                }
            }

            return(row);
        }
예제 #12
0
        public LegacyBar(Context context, IAttributeSet attrs)
            : base(context, attrs)
        {
            ResourceIdManager.UpdateIdValues();

            _inflater = LayoutInflater.From(Context);
            //_inflater = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService);

            _barView = (RelativeLayout)_inflater.Inflate(Resource.Layout.actionbar, null);
            AddView(_barView);

            _logoView      = _barView.FindViewById(Resource.Id.actionbar_home_logo) as ImageView;
            _homeLayout    = _barView.FindViewById <RelativeLayout>(Resource.Id.actionbar_home_bg);
            _homeBtn       = _barView.FindViewById <ImageButton>(Resource.Id.actionbar_home_btn);
            _backIndicator = _barView.FindViewById(Resource.Id.actionbar_home_is_back);

            _titleView   = _barView.FindViewById <TextView>(Resource.Id.actionbar_title);
            _actionsView = _barView.FindViewById <LinearLayout>(Resource.Id.actionbar_actions);

            _progress      = _barView.FindViewById <ProgressBar>(Resource.Id.actionbar_progress);
            _titleLayout   = _barView.FindViewById <RelativeLayout>(Resource.Id.actionbar_title_layout);
            _titleDropdown = _barView.FindViewById <Spinner>(Resource.Id.actionbar_spinner);

            _overflowLegacyBarAction = new OverflowLegacyBarAction(Context);

            //Custom Attributes (defined in Attrs.xml)
            var a = Context.ObtainStyledAttributes(attrs,
                                                   Resource.Styleable.actionbar);

            //grab theme attributes
            Theme      = (LegacyBarTheme)a.GetInt(Resource.Styleable.actionbar_theme, 0);
            IsBottom   = a.GetBoolean(Resource.Styleable.actionbar_is_bottom, false);
            LightIcons = a.GetBoolean(Resource.Styleable.actionbar_light_icons, false);

            //if we are not custom don't let them set it.
            if (Theme != LegacyBarTheme.Custom)
            {
                LightIcons = Theme == LegacyBarTheme.HoloLight;
            }

            _overflowLegacyBarAction.SetIconColor(LightIcons);

            var title = a.GetString(Resource.Styleable.actionbar_title);

            if (null != title)
            {
                Title = title;
            }

            var titleColor = a.GetColor(Resource.Styleable.actionbar_title_color, Resources.GetColor(Resource.Color.actionbar_title));

            TitleColor = titleColor;

            var separatorColor = a.GetColor(Resource.Styleable.actionbar_separator, Resources.GetColor(Resource.Color.actionbar_separator));

            _actionsView.SetBackgroundColor(separatorColor);
            _homeLayout.SetBackgroundColor(separatorColor);

            using (var background = a.GetDrawable(Resource.Styleable.actionbar_background)) //recycling the drawable immediately
            {
                if (null != background)
                {
                    BackgroundDrawable = background;
                }
            }

            var backgroundItem = a.GetDrawable(Resource.Styleable.actionbar_background_item);

            if (null != backgroundItem)
            {
                ItemBackgroundDrawable = backgroundItem;
            }

            if (IsBottom)
            {
                LegacyBarUtils.SetBottomLegacyBarTheme(this, Theme);
            }
            else
            {
                LegacyBarUtils.SetLegacyBarTheme(this, Theme);
            }

            a.Recycle();

            _titleView.Click += (s, e) => { if (null != TitleClick)
                                            {
                                                TitleClick(s, e);
                                            }
            };
            _titleView.LongClick += (s, e) => { if (null != TitleLongClick)
                                                {
                                                    TitleLongClick(s, e);
                                                }
            };
        }
예제 #13
0
 private void Initialize(Context context, IAttributeSet attrs, int?defSyleAttr, int?defStyleRes)
 {
     LayoutInflater.From(context).Inflate(Resource.Layout.Widget_SideScrollingList, this, true);
     _label        = FindViewById <TextView>(Resource.Id.SideScrollingList_Label);
     _recyclerView = FindViewById <RecyclerView>(Resource.Id.SideScrollingList_Recycler);
 }
예제 #14
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            View view = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.menu_index_view_items_recycler, parent, false);

            return(new MenuItemViewHolder(view));
        }
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            var layout = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.SubCategoryRow, parent, false);

            return(new SubCategoryViewHolder(layout, OnItemClick));
        }
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.list_item_syncitem, parent, false);

            return(new RecyclerViewHolder(itemView));
        }
예제 #17
0
            public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
            {
                var view = LayoutInflater.From(_context).Inflate(Resource.Layout.item_simple, parent, false);

                return(new MyViewHolder(view));
            }
예제 #18
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            View view = LayoutInflater.From(parent.Context).Inflate(Android.Resource.Layout.SimpleListItem1, parent, false);

            return(new CellViewHolder(view, onClickEvent));
        }
예제 #19
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            JournalDayVM vm = this[position];

            vm.Sync(vm.Date);

            if (scrollNeed == ScrollNeed.none)
            {
                if (position == 0 && false)                 //12/29/15 - disabling future scrolling untill we get to FJA-95
                {
                    scrollNeed = ScrollNeed.up;
                }

                if (position > CurrentMax - CurrentMin - PageSize)
                {
                    scrollNeed = ScrollNeed.down;
                }
            }

            View view = holder.ItemView;

            ((VMViewHolder <JournalDayVM>)holder).ViewModel = vm;

            var binding = DataContext <JournalDayVM> .FromView(view);

            binding.VM = vm;

            if (binding.Bindings.Count == 0)
            {
                binding.Add(Resource.Id.text_journal_day, x => x.DateText);
                binding.Add(Resource.Id.text_journal_total, x => x.SelectedPropertyTotal);
                binding.Add(Resource.Id.text_journal_delta, x => x.SelectedPropertyDelta);
                binding.Add(Resource.Id.text_journal_date, x => x.DateShort);
            }

            LinearLayout content_periods = view.FindViewById <LinearLayout>(Resource.Id.content_periods);
            var          btnSendReport   = view.FindViewById <ImageView>(Resource.Id.image_send_report);
            var          btnEditToday    = view.FindViewById <ImageView>(Resource.Id.image_go_today);


            btnSendReport.Click += (sender, e) =>
            {
                if (OnSendReportClick != null)
                {
                    OnSendReportClick(sender, vm);
                }
            };

            btnEditToday.Click += (sender, e) =>
            {
                if (OnCardItemClick != null)
                {
                    OnCardItemClick(DateTime.Now.Period(), vm);
                }
            };

            // Add Periods as needed
            var periods = vm.Periods;

            while (content_periods.ChildCount < periods.Count)
            {
                View pview = LayoutInflater.From(view.Context).Inflate(Resource.Layout.item_journal_period, content_periods, false);
                content_periods.AddView(pview);
            }

            Paint paint = new Paint {
                Color = Color.Rgb(25, 118, 210), StrokeWidth = 12
            };
            var   goalAmount = UserSettings.Current.GetGoal(jvm.SelectedProperty);
            float lastDrawn  = 0;

            // sync periods
            for (int i = 0; i < content_periods.ChildCount; i++)
            {
                LinearLayout periodview = content_periods.GetChildAt(i) as LinearLayout;

                // unneeded periods are hidden
                periodview.Visibility = (i < periods.Count) ? ViewStates.Visible : ViewStates.Gone;

                if (i < periods.Count)
                {
                    var b = DataContext <JournalPeriodVM> .FromView(periodview);

                    b.VM = periods[i];
                    b.VM.RelatedProperty = jvm.SelectedProperty;
                    var p = periods[i].Period;

                    Task.Run(() =>
                    {
                        Platform.RunSafeOnUIThread("JournalFragment.OnResume", () =>
                        {
                            //  var width = periodview.LayoutParameters.Width;
                            var width = periodview.Width;
                            var pBar  = periodview.FindViewById <ImageView>(Resource.Id.progressBar_period);

                            Bitmap bitmap = Bitmap.CreateBitmap(width, 8, Bitmap.Config.Argb8888);
                            Canvas canvas = new Canvas(bitmap);

                            Func <string, float> getNumber = delegate(string val)
                            {
                                try
                                {
                                    var raw = string.IsNullOrEmpty(val) ? "0" : val;
                                    if (raw.Contains("/"))
                                    {
                                        var tempArr = raw.Split(new char[] { '/' });
                                        return((float)(System.Convert.ToDecimal(tempArr[0]) / System.Convert.ToDecimal(tempArr[1])));
                                    }
                                    else
                                    {
                                        return((float)(System.Convert.ToDecimal(raw)));
                                    }
                                }
                                catch (Exception ex)
                                {
                                    LittleWatson.ReportException(ex);
                                    return(0);
                                }
                            };

                            float total = (float.IsNaN(goalAmount) || goalAmount == 0) ? getNumber(vm.SelectedPropertyTotal)
                                : goalAmount;

                            if (total != 0)
                            {
                                var thisContribution = getNumber(b.VM.Value);
                                var startx           = lastDrawn;
                                var endx             = (float)Math.Ceiling((thisContribution / total) * width) + startx;
                                pBar.SetImageBitmap(bitmap);
                                if (endx > 0)
                                {
                                    lastDrawn = endx;
                                    canvas.DrawLine(startx, 0, endx, 0, paint);
                                    // System.Diagnostics.Debug.WriteLine(jvm.SelectedProperty + "- drawing for " + p.ToString() + " from:" + startx + " to:" + endx);
                                }
                            }
                        });
                    });

                    periodview.Click += (sender, e) =>
                    {
                        if (OnCardItemClick != null)
                        {
                            OnCardItemClick(p, vm);
                        }
                    };

                    if (b.Bindings.Count == 0)
                    {
                        // Period:
                        b.Add(Resource.Id.text_journal_period_text, x => x.Text);
                        b.Add(Resource.Id.text_journal_period_value, x => x.Value);
                        b.Add(Resource.Id.text_journal_period_time, x => x.Time);
                        b.Add(Resource.Id.text_journal_period_time, x => x.TimeVisibility);
                        b.Add(Resource.Id.text_journal_period_note, x => x.Note);
                        b.Add(Resource.Id.text_journal_period_note, x => x.NoteVisibility);
                    }

                    LinearLayout content_entries = periodview.FindViewById <LinearLayout>(Resource.Id.content_entries);

                    // Add entry views as needed
                    var lines = b.VM.Lines;
                    while (content_entries.ChildCount < lines.Count)
                    {
                        View eview = LayoutInflater.From(view.Context).Inflate(Resource.Layout.item_journal_entry, content_periods, false);
                        content_entries.AddView(eview);
                    }

                    // sync entries
                    for (int j = 0; j < content_entries.ChildCount; j++)
                    {
                        LinearLayout entryview = content_entries.GetChildAt(j) as LinearLayout;

                        // unneeded periods are hidden
                        entryview.Visibility = (j < lines.Count) ? ViewStates.Visible : ViewStates.Gone;

                        if (j < lines.Count)
                        {
                            // Line
                            entryview.FindViewById <TextView>(Resource.Id.text_journal_text).Text  = lines[j].Text;
                            entryview.FindViewById <TextView>(Resource.Id.text_journal_value).Text = lines[j].Value;
                        }
                    }
                }
            }
        }
예제 #20
0
 public void SetProgressView(int progressView)
 {
     mProgressView.RemoveAllViews();
     LayoutInflater.From(Context).Inflate(progressView, mProgressView);
 }
 public MomentListAdapter(Context context, int textViewResourceId, List <IMoment> objects)
     : base(context, textViewResourceId, objects)
 {
     mLayoutInflater = LayoutInflater.From(context);
     mItems          = objects;
 }
예제 #22
0
 public void SetErrorView(int errorView)
 {
     mErrorView.RemoveAllViews();
     LayoutInflater.From(Context).Inflate(errorView, mErrorView);
 }
예제 #23
0
        public override ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            View view = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.ListItem, parent, false);

            return(new OpSystemViewHolder(view));
        }
예제 #24
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            var section = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.ItemSectionLayout, parent, false);

            return(new ItemSectionViewHolder(section));
        }
예제 #25
0
        public override Android.Views.View GetSampleContent(Android.Content.Context context)
        {
            var deviceDensity = (int)context.Resources.DisplayMetrics.Density;
            // Set our view from the "main" layout resource
            var layoutInflater = LayoutInflater.From(context);

            view = layoutInflater.Inflate(Resource.Layout.EditorCustomization, null);


            FrameLayout mainLayout = view.FindViewById <FrameLayout>
                                         (Resource.Id.CustomizationMain);

            editor               = new SfImageEditor(context);
            editor.Bitmap        = BitmapFactory.DecodeResource(context.Resources, Resource.Drawable.Customize);
            editor.ItemSelected += Editor_ItemSelected;
            editor.ToolbarSettings.IsVisible = false;
            editor.SetBackgroundColor(Color.Black);


            var bottomview = layoutInflater.Inflate(Resource.Layout.BottomView, mainLayout, true);
            var topview    = layoutInflater.Inflate(Resource.Layout.TopView, mainLayout, true);
            var rightview  = layoutInflater.Inflate(Resource.Layout.RightView, mainLayout, true);


            //Bottom View------------------------------------
            var bottomView = bottomview.FindViewById <LinearLayout>(Resource.Id.bottomView);

            bottomView.SetGravity(GravityFlags.Bottom);
            var bParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MatchParent, 50 * deviceDensity, GravityFlags.Bottom);

            bottomView.SetBackgroundColor(Color.Transparent);
            bParams.SetMargins(0, 0, 0, 10 * deviceDensity);
            bottomView.LayoutParameters = bParams;


            //Top View------------------------------------
            var topView = topview.FindViewById <LinearLayout>(Resource.Id.topView);
            var tParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MatchParent, 50 * deviceDensity, GravityFlags.Top);

            tParams.SetMargins(0, 10 * deviceDensity, 0, 0);
            topView.LayoutParameters = tParams;


            //Right View------------------------------------

            var rightView = rightview.FindViewById <LinearLayout>(Resource.Id.rightView);
            var rParams   = new FrameLayout.LayoutParams(65 * deviceDensity, FrameLayout.LayoutParams.MatchParent, GravityFlags.Right);

            rParams.SetMargins(0, 250, 0, 250);
            rightView.SetBackgroundColor(Color.Transparent);
            rightView.SetPadding(0, 0, 15 * deviceDensity, 15 * deviceDensity);
            rightView.LayoutParameters = rParams;
            rightView.Visibility       = ViewStates.Invisible;
            topView.Visibility         = ViewStates.Invisible;
            mainLayout.RemoveAllViews();
            (mainLayout.Parent as ViewGroup)?.RemoveAllViews();


            mainLayout.AddView(editor);
            mainLayout.AddView(topView);
            mainLayout.AddView(bottomView);
            mainLayout.AddView(rightView);

            Button dummyLayout = new Button(context);

            dummyLayout.SetBackgroundColor(Color.Transparent);
            dummyLayout.Alpha = 0.5F;
            mainLayout.AddView(dummyLayout);
            dummyLayout.Click += (sender, e) =>
            {
                topView.Visibility     = ViewStates.Visible;
                dummyLayout.Visibility = ViewStates.Invisible;
            };


            //Top view

            var reset = topView.FindViewById <ImageButton>(Resource.Id.resetButton);
            var undo  = topView.FindViewById <ImageButton>(Resource.Id.undoButton);
            var rect  = topView.FindViewById <ImageButton>(Resource.Id.rectButton);
            var text  = topView.FindViewById <ImageButton>(Resource.Id.textButton);
            var path  = topView.FindViewById <ImageButton>(Resource.Id.pathButton);

            reset.Click += (sender, e) =>
            {
                if (editor.IsImageEdited)
                {
                    editor.Reset();
                }
                rightView.Visibility   = ViewStates.Invisible;
                topView.Visibility     = ViewStates.Invisible;
                dummyLayout.Visibility = ViewStates.Visible;
                isPath = false;
                isText = false;
                isRect = false;
            };
            undo.Click += (sender, e) =>
            {
                if (editor.IsImageEdited)
                {
                    editor.Undo();
                }
            };
            rect.Click += (sender, e) =>
            {
                isPath = false;
                isText = false;
                isRect = true;
                AddShapes();
                rightView.Visibility = ViewStates.Visible;
            };
            text.Click += (sender, e) =>
            {
                isPath = false;
                isRect = false;
                isText = true;
                AddShapes();
                rightView.Visibility = ViewStates.Visible;
            };
            path.Click += (sender, e) =>
            {
                isPath = true;
                isRect = false;
                isText = false;
                rightView.Visibility = ViewStates.Visible;
                editor.AddShape();
            };



            // colorLayout
            var firstBut   = rightview.FindViewById <Button>(Resource.Id.firstButton);
            var secondBut  = rightview.FindViewById <Button>(Resource.Id.secondButton);
            var thirdBut   = rightview.FindViewById <Button>(Resource.Id.thirdButton);
            var fourthBut  = rightview.FindViewById <Button>(Resource.Id.fourthButton);
            var fifthBut   = rightview.FindViewById <Button>(Resource.Id.fifthButton);
            var sixthBut   = rightview.FindViewById <Button>(Resource.Id.sixthButton);
            var seventhBut = rightview.FindViewById <Button>(Resource.Id.seventhButton);
            var eightBut   = rightview.FindViewById <Button>(Resource.Id.eightButton);
            var ninthBut   = rightview.FindViewById <Button>(Resource.Id.ninthButton);
            var tenthBut   = rightview.FindViewById <Button>(Resource.Id.tenthButton);

            firstBut.Click += (sender, e) =>
            {
                var color = Color.ParseColor("#4472c4");
                setting(Settings, color);
                if (isPath)
                {
                    editor.AddShape(Syncfusion.SfImageEditor.Android.ShapeType.Path, new PenSettings()
                    {
                        Color = color
                    });
                }
            };
            secondBut.Click += (sender, e) =>
            {
                var color = Color.ParseColor("#ed7d31");
                setting(Settings, color);
                if (isPath)
                {
                    editor.AddShape(Syncfusion.SfImageEditor.Android.ShapeType.Path, new PenSettings()
                    {
                        Color = color
                    });
                }
            };
            thirdBut.Click += (sender, e) =>
            {
                var color = Color.ParseColor("#ffc000");
                setting(Settings, color);
                if (isPath)
                {
                    editor.AddShape(Syncfusion.SfImageEditor.Android.ShapeType.Path, new PenSettings()
                    {
                        Color = color
                    });
                }
            };
            fourthBut.Click += (sender, e) =>
            {
                var color = Color.ParseColor("#70ad47");
                setting(Settings, color);
                if (isPath)
                {
                    editor.AddShape(Syncfusion.SfImageEditor.Android.ShapeType.Path, new PenSettings()
                    {
                        Color = color
                    });
                }
            };
            fifthBut.Click += (sender, e) =>
            {
                var color = Color.ParseColor("#5b9bd5");
                setting(Settings, color);
                if (isPath)
                {
                    editor.AddShape(Syncfusion.SfImageEditor.Android.ShapeType.Path, new PenSettings()
                    {
                        Color = color
                    });
                }
            };
            sixthBut.Click += (sender, e) =>
            {
                var color = Color.ParseColor("#c1c1c1");
                setting(Settings, color);
                if (isPath)
                {
                    editor.AddShape(Syncfusion.SfImageEditor.Android.ShapeType.Path, new PenSettings()
                    {
                        Color = color
                    });
                }
            };
            seventhBut.Click += (sender, e) =>
            {
                var color = Color.ParseColor("#6f6fe2");
                setting(Settings, color);
                if (isPath)
                {
                    editor.AddShape(Syncfusion.SfImageEditor.Android.ShapeType.Path, new PenSettings()
                    {
                        Color = color
                    });
                }
            };
            eightBut.Click += (sender, e) =>
            {
                var color = Color.ParseColor("#e269ae");
                setting(Settings, color);
                if (isPath)
                {
                    editor.AddShape(Syncfusion.SfImageEditor.Android.ShapeType.Path, new PenSettings()
                    {
                        Color = color
                    });
                }
            };
            ninthBut.Click += (sender, e) =>
            {
                var color = Color.ParseColor("#9e480e");
                setting(Settings, color);
                if (isPath)
                {
                    editor.AddShape(Syncfusion.SfImageEditor.Android.ShapeType.Path, new PenSettings()
                    {
                        Color = color
                    });
                }
            };
            tenthBut.Click += (sender, e) =>
            {
                var color = Color.ParseColor("#997300");
                setting(Settings, color);
                if (isPath)
                {
                    editor.AddShape(Syncfusion.SfImageEditor.Android.ShapeType.Path, new PenSettings()
                    {
                        Color = color
                    });
                }
            };


            //Share

            var share = bottomView.FindViewById <ImageButton>(Resource.Id.sharecustomization);

            editText     = bottomView.FindViewById <EditText>(Resource.Id.captionText);
            share.Click += async(sender, e) =>
            {
                await ShareImageAsync();
            };
            return(mainLayout);
        }
예제 #26
0
        private void updateSSRSubscribe(string serverList)
        {
            List <string> urls = new List <string>();

            Server.URL_Split(serverList, ref urls);
            for (int i = urls.Count - 1; i >= 0; --i)
            {
                if (!urls[i].StartsWith("ssr"))
                {
                    urls.RemoveAt(i);
                }
            }

            if (urls.Count > 0)
            {
                LinearLayout   serverListView = FindViewById <LinearLayout>(Resource.Id.serverListView);
                LayoutInflater inflater       = LayoutInflater.From(serverListView.Context);

                foreach (string url in urls)
                {
                    Server server = new Server(url, null);

                    var entityView = inflater.Inflate(Resource.Layout.ServerEntity, null);
                    entityView.FindViewById <TextView>(Resource.Id.textServerName).Text    = server.remarks;
                    entityView.FindViewById <TextView>(Resource.Id.textServerAddress).Text = server.server;

                    entityView.FindViewById <Button>(Resource.Id.useServerButton).Click += delegate
                    {
                        if (merlinSsh.IsConnected())
                        {
                            ssrConfigText.Text = String.Format(@"{{
    ""server"": ""{0}"",
    ""server_port"": {1},
    ""local_port"": 1080,
    ""password"": ""{2}"",
    ""timeout"": 60,
    ""method"" : ""{3}"",
    ""obfs"" : ""{4}"",
    ""obfs_param"" : ""{5}"",
    ""protocol"" : ""{6}"",
    ""protocol_param"" : ""{7}"",
}}
",
                                                               server.server,
                                                               server.server_port,
                                                               server.password,
                                                               server.method,
                                                               server.obfs,
                                                               server.obfsparam,
                                                               server.protocol,
                                                               server.protocolparam);

                            merlinSsh.scpUpload("/jffs/scripts/ssrm.json", ssrConfigText.Text);

                            merlinSsh.restartSSR();
                        }
                    };

                    serverListView.AddView(entityView);
                }
            }
        }
 public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
 {
     bindContext(parent.Context);//.getContext());
     return(new ItemViewHolder(LayoutInflater.From(getContext()).
                               Inflate(Resource.Layout.item_video_strip, parent, false)));
 }
예제 #28
0
        //TODO:应该把这个改成TableView
        //可以参考扣分规则 基类改成双层循环 减少重复性代码
        private void InitExamItem()
        {
            try
            {
                mainLinerLayout = (LinearLayout)this.FindViewById(Resource.Id.ExamItemTable);
                mainLinerLayout.RemoveAllViews();
                TextView txt;
                int      ListID = 0;

                //所有的考试
                //所有的考试项目但是不包含综合评判的
                int ExamItemCount = lstExamItem.Count;
                for (int i = 0; i < ExamItemCount / 5; i++)
                {
                    relativeLayout = (LinearLayout)LayoutInflater.From(this).Inflate(Resource.Layout.ExamItemNew, null);
                    txt            = (TextView)relativeLayout.FindViewById(Resource.Id.list_1_1);
                    txt.SetText(lstExamItem[i * 5], TextView.BufferType.Normal);
                    txt.SetTextColor(lstExamItemColor[i * 5]);
                    txt.Click += ExamItemClick;
                    txt        = (TextView)relativeLayout.FindViewById(Resource.Id.list_1_2);
                    txt.SetText(lstExamItem[i * 5 + 1], TextView.BufferType.Normal);
                    txt.SetTextColor(lstExamItemColor[i * 5 + 1]);
                    txt.Click += ExamItemClick;

                    txt = (TextView)relativeLayout.FindViewById(Resource.Id.list_1_3);
                    txt.SetText(lstExamItem[i * 5 + 2], TextView.BufferType.Normal);
                    txt.SetTextColor(lstExamItemColor[i * 5 + 2]);
                    txt.Click += ExamItemClick;

                    txt = (TextView)relativeLayout.FindViewById(Resource.Id.list_1_4);
                    txt.SetText(lstExamItem[i * 5 + 3], TextView.BufferType.Normal);
                    txt.SetTextColor(lstExamItemColor[i * 5 + 3]);
                    txt.Click += ExamItemClick;

                    txt = (TextView)relativeLayout.FindViewById(Resource.Id.list_1_5);
                    txt.SetText(lstExamItem[i * 5 + 4], TextView.BufferType.Normal);
                    txt.SetTextColor(lstExamItemColor[i * 5 + 4]);
                    txt.Click += ExamItemClick;

                    mainLinerLayout.AddView(relativeLayout);
                }
                //4如果余数大
                int Count = ExamItemCount - (ExamItemCount / 5) * 5;
                if (Count > 0)
                {
                    int StartIndex = (ExamItemCount / 5) * 5;
                    relativeLayout = (LinearLayout)LayoutInflater.From(this).Inflate(Resource.Layout.ExamItemNew, null);
                    for (int i = 0; i < 5; i++)
                    {
                        switch (i)
                        {
                        case 0:
                            ListID = Resource.Id.list_1_1;
                            break;

                        case 1:
                            ListID = Resource.Id.list_1_2;
                            break;

                        case 2:
                            ListID = Resource.Id.list_1_3;
                            break;

                        case 3:
                            ListID = Resource.Id.list_1_4;
                            break;

                        case 4:
                            ListID = Resource.Id.list_1_5;
                            break;

                        default:
                            break;
                        }

                        if (i >= Count)
                        {
                            txt = (TextView)relativeLayout.FindViewById(ListID);
                            txt.SetText("", TextView.BufferType.Normal);
                            txt.Visibility = ViewStates.Invisible;
                        }
                        else
                        {
                            txt = (TextView)relativeLayout.FindViewById(ListID);
                            txt.SetTextColor(lstExamItemColor[StartIndex + i]);
                            txt.SetText(lstExamItem[StartIndex + i], TextView.BufferType.Normal);
                            txt.Click += ExamItemClick;
                        }
                    }
                    mainLinerLayout.AddView(relativeLayout);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, GetType().ToString());
            }
        }
        protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (nativeControl == null || Element == null)
            {
                return;
            }

            switch (e.PropertyName)
            {
            case "Renderer":
                Element?.SendValueChanged();
                break;

            case "SelectedSegment":
                var option = (RadioButton)nativeControl.GetChildAt(Element.SelectedSegment);

                if (option != null)
                {
                    option.Checked = true;
                }

                if (Element.SelectedSegment < 0)
                {
                    var layoutInflater = LayoutInflater.From(context);

                    nativeControl = (RadioGroup)layoutInflater.Inflate(Resource.Layout.RadioGroup, null);

                    for (var i = 0; i < Element.Children.Count; i++)
                    {
                        var o  = Element.Children[i];
                        var rb = (RadioButton)layoutInflater.Inflate(Resource.Layout.RadioButton, null);

                        rb.LayoutParameters = new RadioGroup.LayoutParams(0, LayoutParams.WrapContent, 1f);
                        rb.Text             = o.Text;

                        if (i == 0)
                        {
                            rb.SetBackgroundResource(Resource.Drawable.segmented_control_first_background);
                        }
                        else if (i == Element.Children.Count - 1)
                        {
                            rb.SetBackgroundResource(Resource.Drawable.segmented_control_last_background);
                        }

                        ConfigureRadioButton(i, rb);

                        nativeControl.AddView(rb);
                    }

                    nativeControl.CheckedChange += NativeControl_ValueChanged;

                    SetNativeControl(nativeControl);
                }

                Element.SendValueChanged();
                break;

            case "TintColor":
                OnPropertyChanged();
                break;

            case "IsEnabled":
                OnPropertyChanged();
                break;

            case "SelectedTextColor":
                var v = (RadioButton)nativeControl.GetChildAt(Element.SelectedSegment);
                v.SetTextColor(Element.SelectedTextColor.ToAndroid());
                break;
            }
        }
        protected override void OnFinishInflate()
        {
            base.OnFinishInflate();

            editText = FindEditTextChild();
            if (editText == null)
            {
                return;
            }

            AddView(LayoutInflater.From(Context).Inflate(Resource.Layout.mtf_layout, this, false));

            editTextLayout = (ViewGroup)FindViewById(Resource.Id.mtf_editTextLayout);
            RemoveView(editText);
            editTextLayout.AddView(editText);

            // replaced ViewCompat.SetPivotX and Y as they are deprecated.
            label        = (TextView)FindViewById(Resource.Id.mtf_label);
            label.PivotX = 0;
            label.PivotY = 0;

            if (editText.Hint != null)
            {
                label.Text    = editText.Hint;
                editText.Hint = "";
            }

            card = FindViewById(Resource.Id.mtf_card);

            if (backgroundColor != -1)
            {
                Color c;

                try
                {
                    c = new Color(this.backgroundColor);
                }
                catch
                {
                    c = Color.White;
                }

                card.SetBackgroundColor(c);
            }

            int expandedHeight = Context.Resources.GetDimensionPixelOffset(Resource.Dimension.mtf_cardHeight_final);
            int reducedHeight  = cardCollapsedHeight;

            reducedScale = (float)(reducedHeight * 1.0 / expandedHeight);
            card.ScaleY  = reducedScale;
            card.PivotY  = expandedHeight;

            image        = (ImageView)FindViewById(Resource.Id.mtf_image);
            image.Alpha  = 0;
            image.ScaleX = 0.4f;
            image.ScaleY = 0.4f;

            editText.Alpha = 0f;

            editText.SetBackgroundColor(Color.Transparent);

            // Converted below code, so needs testing.
            // FrameLayout.LayoutParams.class.cast(label.getLayoutParams()).topMargin;
            ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams)label.LayoutParameters;
            labelTopMargin = lp.TopMargin;

            CustomizeFromAttributes();

            this.Click += (s, e) =>
            {
                Toggle();
            };

            SetHasFocus(hasFocus);
        }