Exemplo n.º 1
0
 public void Clear()
 {
     this.Scores.Clear();
     this.Serialize();
     // invalidate to force redrawing and relayout
     _listContent.Invalidate();
 }
        public void SetActionBar()
        {
            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);
            SupportActionBar.SetHomeButtonEnabled(true);
            drawerToggle = new ActionBarDrawerToggle0(
                this,
                drawerLayout,
                toolbar,
                Resource.String.drawer_open,
                Resource.String.drawer_close)
            {
                DrawerClosed = (View view) =>
                {
                    linearLayout.RemoveAllViews();
                    linearLayout.Invalidate();
                },
                DrawerSlide = (View drawerView, float slideOffset) =>
                {
                    if (slideOffset > 0.6 && linearLayout.ChildCount == 0)
                    {
                        viewAnimator.ShowMenuContent();
                    }
                },
                DrawerOpened = (View drawerView) =>
                {
                }
            };

            drawerLayout.SetDrawerListener(drawerToggle);
        }
Exemplo n.º 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

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

            //create root
            TreeNode root   = TreeNode.InvokeRoot();
            TreeNode parent = new TreeNode("parent");
            TreeNode child0 = new TreeNode("ChildNode0");
            TreeNode child1 = new TreeNode("ChildNode1");

            TreeItem item = new TreeItem()
            {
                text = "abc"
            };
            TreeNode child10 = new TreeNode(item).SetViewHolder(new MyHolder(this));

            child1.AddChild(child10);
            parent.AddChildren(child0, child1);
            root.AddChild(parent);

            AndroidTreeView atv = new AndroidTreeView(this, root);

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

            rootlayout.AddView(atv.View);

            rootlayout.Invalidate();
        }
Exemplo n.º 4
0
        public void UpdateBackgroundViewHeight(int height, LinearLayout layout, int aspect = 1)
        {
            var paramList = layout.LayoutParameters;

            paramList.Height        = height - GetUnderViewHeight(aspect);;
            layout.LayoutParameters = paramList;
            layout.RequestLayout();
            layout.Invalidate();
        }
Exemplo n.º 5
0
        public void SetEnglishTransaltionView(TextView polishView, List <Word> polishWords, string keyword)
        {
            UnsubscribeAll();

            // polishView.Append("English: ");
            //polishView.Append(System.Environment.NewLine);
            //StringBuilder str = new StringBuilder();
            //foreach (var polword in polishWords)
            //{
            //    str.Append($"{polword.word} [{polword.type}] ");
            //}
            //polishView.Append(str.ToString());

            var label = new TextView(this);

            label.Text = $"English translation of '{ keyword }': ";
            polishTranslationLayout.AddView(label);

            tx = new TextView(this);
            tx.SetTextColor(Color.DarkRed);
            tx.SetTextSize(ComplexUnitType.Pt, 12);
            tx.SetTypeface(null, TypefaceStyle.Bold);
            tx.Text   = polishWords[0].word;
            tx.Touch += Tx_Touch;
            polishTranslationLayout.AddView(tx);

            if (polishWords.Count > 1)
            {
                tx1 = new TextView(this);
                tx1.SetTextColor(Color.DarkRed);
                tx1.Text = polishWords[1].word;
                tx1.SetTextSize(ComplexUnitType.Pt, 12);
                tx1.SetTypeface(null, TypefaceStyle.Bold);
                tx1.Touch += Tx1_Touch;
                polishTranslationLayout.AddView(tx1);
            }

            if (polishWords.Count > 2)
            {
                tx2 = new TextView(this);
                tx2.SetTextColor(Color.DarkRed);
                tx2.Text = polishWords[2].word;
                tx2.SetTextSize(ComplexUnitType.Pt, 12);
                tx2.SetTypeface(null, TypefaceStyle.Bold);
                tx2.Touch += Tx2_Touch;
                polishTranslationLayout.AddView(tx2);
            }

            polishTranslationLayout.Invalidate();
        }
Exemplo n.º 6
0
 // ----------------------------------------------------------------------------------------------------------------
 // Reloads the disk back on the pole;
 private void returnDiskToPlacement(DragEvent args)
 {
     //Check validity of Disk placement
     if (!args.Result)
     {
         if (disk.Parent != null)
         {
             (disk.Parent as ViewGroup).RemoveView(disk);
         }
         removedFromLinearLayout.AddView(disk, 0);
         disk.Invalidate();
         removedFromLinearLayout.Invalidate();
     }
 }
Exemplo n.º 7
0
        public void DeleteAdvancedString(View view)
        {
            var          section   = view.Parent;
            LinearLayout container = (LinearLayout)FindViewById(Resource.Id.advanced_container);

            State.EntryModified = true;
            for (int i = 0; i < container.ChildCount; i++)
            {
                var ees = container.GetChildAt(i);
                if (ees == section)
                {
                    container.RemoveViewAt(i);
                    container.Invalidate();
                    break;
                }
            }
        }
Exemplo n.º 8
0
 void GetUser()
 {
     Android.App.AlertDialog dialog = new SpotsDialog(this);
     dialog.Show();
     try {
         user = LocalProvider.GetCurrentUser();
         using (var p = new Handler(Looper.MainLooper)) {
             p.Post(() => {
                 firstName.Text = user.FirstName;
                 lastName.Text  = user.LastName;
                 city.Text      = user.City;
                 country.Text   = user.Country;
                 birthDate.Text = user.DateOfBirth?.ToString("dd MMMM yyyy");
                 linearLayout.Invalidate();
             });
         }
     } catch (Exception ex) { }
     dialog.Dismiss();
 }
Exemplo n.º 9
0
        private void UpdateBightnessPosition()
        {
            // Only update position if not previously updated
            if (Constants.BrightnessContainerWidth == -1)
            {
                Constants.UpdateBrightnessControlDimensions(_toolbar, FindViewById <ActionMenuItemView>(Resource.Id.action_brightness));
                // Set the brightness control container width
                _brightnessControlContainer.LayoutParameters.Width = Constants.BrightnessContainerWidth;
                // Set the layout margin for the brightness control container to bring it just under the menu item icon
                var lp = (ViewGroup.MarginLayoutParams)_brightnessControlContainer.LayoutParameters;
                lp.SetMargins(0, -Constants.BrightnessToolbarItemIconBottomPadding, 0, 0);
                _brightnessControlContainer.LayoutParameters = lp;

                var lp1 = _brightnessControl.LayoutParameters;
                lp1.Width = Constants.EventGaugeAreaHeightPx - _moon.Height + Resources.GetDimensionPixelSize(Resource.Dimension.response_carousel_area_padding_top);
                _brightnessControl.LayoutParameters = lp1;

                _brightnessControlContainer.Invalidate();
            }
        }
Exemplo n.º 10
0
 void GetUser()
 {
     Android.App.AlertDialog dialog = new SpotsDialog(this);
     dialog.Show();
     try {
         //var response = await AccountsApi.GetCurentUser();
         var user = LocalProvider.GetCurrentUser();
         using (var p = new Handler(Looper.MainLooper)) {
             p.Post(() => {
                 txtWelcome.Text = "Welcome , " + user.Email;
                 firstName.Text  = user.FirstName;
                 lastName.Text   = user.LastName;
                 City.Text       = user.City;
                 Country.Text    = user.Country;
                 birthDate.Text  = user.DateOfBirth?.ToString("dd MMMM yyyy");
                 linearLayout.Invalidate();
             });
         }
     } catch (Exception ex) { }
     dialog.Dismiss();
 }
Exemplo n.º 11
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

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

            TreeNode root = TreeNode.InvokeRoot();

            TreeItem parent_item = new TreeItem()
            {
                text = "parent2"
            };

            parent = new TreeNode(parent_item).SetViewHolder(new MyHolder(this));

            ///Parent2 root children
            TreeItem child1_item = new TreeItem()
            {
                text = "Child1"
            };
            TreeNode child1 = new TreeNode(child1_item).SetViewHolder(new MyHolder(this));

            TreeItem item = new TreeItem()
            {
                text = " Level1"
            };
            TreeNode child10 = new TreeNode(item).SetViewHolder(new MyHolder(this));

            child1.AddChild(child10);

            TreeItem item1 = new TreeItem()
            {
                text = " Level2"
            };
            TreeNode child11 = new TreeNode(item1).SetViewHolder(new MyHolder(this));

            child10.AddChild(child11);

            TreeItem item2 = new TreeItem()
            {
                text = " Level2-1"
            };
            TreeNode child111_1 = new TreeNode(item2).SetViewHolder(new MyHolder(this));

            child11.AddChild(child111_1);

            TreeItem item3 = new TreeItem()
            {
                text = " Level2-2"
            };
            TreeNode child111_2 = new TreeNode(item3).SetViewHolder(new MyHolder(this));

            child11.AddChild(child111_2);

            ///

            parent.AddChildren(child1);
            root.AddChild(parent);


            AndroidTreeView atv        = new AndroidTreeView(this, root);
            LinearLayout    rootlayout = FindViewById <LinearLayout>(Resource.Id.rootlayout);

            rootlayout.AddView(atv.View);
            rootlayout.Invalidate();
            parent.SetClickListener(this);
        }
Exemplo n.º 12
0
 public override void OnDrawerClosed(View view)
 {
     base.OnDrawerClosed(view);
     layout.RemoveAllViews();
     layout.Invalidate();
 }
Exemplo n.º 13
0
 public static void ClearSubViews(this LinearLayout linearLayout)
 {
     linearLayout.RemoveAllViews();
     linearLayout.Invalidate();
 }
        private void LoadDataInScrollLayouts(DateTime date, bool pressure = true)
        {
            Drawable bloodPressureIconDrawable = Resources.GetDrawable(Resource.Drawable.heart, Theme);
            Drawable pulseRateIconDrawable     = Resources.GetDrawable(Resource.Drawable.heart_pulse, Theme);
            Drawable glucoseIconDrawable       = Resources.GetDrawable(Resource.Drawable.water, Theme);

            verticalScrollLinearLayout.RemoveAllViewsInLayout();
            horizontalScrollLinearLayout.RemoveAllViewsInLayout();
            horizontalScrollLinearLayout.Invalidate();
            verticalScrollLinearLayout.Invalidate();
            //for (int i = 0; i < horizontalScrollLinearLayout.ChildCount; i++)
            //{
            //    horizontalScrollLinearLayout.RemoveViewAt(i);
            //}

            var verticalScrollLayoutParams = new LinearLayoutCompat.LayoutParams(
                ViewGroup.LayoutParams.MatchParent,
                ViewGroup.LayoutParams.WrapContent)
            {
                MarginStart  = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 1, Resources.DisplayMetrics),
                MarginEnd    = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 1, Resources.DisplayMetrics),
                BottomMargin = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 20, Resources.DisplayMetrics)
            };

            var horizontalScrollLayoutParams = new LinearLayoutCompat.LayoutParams(
                ViewGroup.LayoutParams.MatchParent,
                ViewGroup.LayoutParams.WrapContent)
            {
                Width       = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 220, Resources.DisplayMetrics),
                MarginStart = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 1, Resources.DisplayMetrics),
                MarginEnd   = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 5, Resources.DisplayMetrics)
            };

            if (pressure)
            {
                try
                {
                    Task.Run(async() =>
                    {
                        string result = await WebServices.WebServices.Post($"{Constants.PublicServerAddress}/api/getDayRec", new JSONObject().Put("imei", _imei).Put("dataType", "bloodPressure").Put("date", date.ToString("yyyy-MM-dd")), Utils.GetDefaults("Token"));

                        if (!string.IsNullOrEmpty(result))
                        {
                            try
                            {
                                var array = new JSONArray(result);
                                for (var i = 0; i < array.Length(); i++)
                                {
                                    var obj  = new JSONObject(array.Get(i).ToString());
                                    var time = Convert.ToDateTime(obj.GetString("date"));
                                    RunOnUiThread(() =>
                                    {
                                        verticalScrollLinearLayout.AddView(CreateCard(bloodPressureIconDrawable, $"{obj.GetString("systolic")}/{obj.GetString("diastolic")}", "mmHg", time.ToShortTimeString(), verticalScrollLayoutParams));
                                        horizontalScrollLinearLayout.AddView(CreateCard(pulseRateIconDrawable, $"{obj.GetString("pulseRate")}", "bpm", time.ToShortTimeString(), horizontalScrollLayoutParams));
                                    });
                                }
                            }
                            catch (Exception ex)
                            {
                                Log.Error("result error", ex.Message);
                            }
                        }
                    });
                }
                catch (Exception ex)
                {
                    Log.Error("Task error", ex.Message);
                }
                //var size = new Random().Next(5, 20);
                //for (int i = 0; i < size; i++)
                //{
                //    verticalScrollLinearLayout.AddView(CreateCard(bloodPressureIconDrawable, $"{new Random().Next(100, 180)}/{new Random().Next(20, 80)}", "mmHg", $"{new Random().Next(10, 24)}:{new Random().Next(10, 59)}", verticalScrollLayoutParams));
                //    horizontalScrollLinearLayout.AddView(CreateCard(pulseRateIconDrawable, $"{new Random().Next(45, 140)}", "bpm", $"{new Random().Next(10, 24)}:{new Random().Next(10, 59)}", horizontalScrollLayoutParams));
                //}
            }
            else
            {
                horizontalScrollLinearLayout.Visibility = ViewStates.Gone;
                //var size = new Random().Next(5, 20);
                //for (var i = 0; i < size; i++)
                //{
                //    verticalScrollLinearLayout.AddView(CreateCard(glucoseIconDrawable, $"{new Random().Next(100, 180)}", "mg/dL", $"{new Random().Next(10, 24)}:{new Random().Next(10, 59)}", verticalScrollLayoutParams));
                //}
                try
                {
                    Task.Run(async() =>
                    {
                        string result = await WebServices.WebServices.Post($"{Constants.PublicServerAddress}/api/getDayRec", new JSONObject().Put("imei", _imei).Put("dataType", "bloodGlucose").Put("date", date.ToString("yyyy-MM-dd")), Utils.GetDefaults("Token"));

                        if (!string.IsNullOrEmpty(result))
                        {
                            try
                            {
                                var array = new JSONArray(result);
                                for (var i = 0; i < array.Length(); i++)
                                {
                                    var obj  = new JSONObject(array.Get(i).ToString());
                                    var time = Convert.ToDateTime(obj.GetString("date"));
                                    RunOnUiThread(() =>
                                    {
                                        verticalScrollLinearLayout.AddView(CreateCard(glucoseIconDrawable, $"{obj.GetInt("bloodGlucose")}", "mg/dL", time.ToShortTimeString(), verticalScrollLayoutParams));
                                    });
                                }
                            }
                            catch (Exception ex)
                            {
                                Log.Error("result error", ex.Message);
                            }
                        }
                    });
                }
                catch (Exception ex)
                {
                    Log.Error("Task error", ex.Message);
                }
            }
        }
Exemplo n.º 15
0
 protected override void OnCreate(Bundle bundle)
 {
     base.OnCreate(bundle);
     SetContentView(Resource.Layout.Main);
     mLinearLayout = FindViewById < LinearLayout >(Resource.Id.main_layout);
     mTextView = FindViewById<TextView>(Resource.Id.textview);
     mTitle = FindViewById<TextView>(Resource.Id.title);
     mSpinner = FindViewById<Spinner>(Resource.Id.spinner);
     mSpinner.Adapter = ArrayAdapter.CreateFromResource(this, Resource.Array.leonidstest, Android.Resource.Layout.SimpleSpinnerDropDownItem);
     mSpinner.ItemSelected += delegate (object s, AdapterView.ItemSelectedEventArgs e)
     {
         if (e.Position == 0)
             return;
         if (mParticleSystem1 != null)
         {
             mParticleSystem1.StopEmitting();
             mParticleSystem1.Cancel();
             mParticleSystem1.Dispose();
             mParticleSystem1 = null;
         }
         if (mParticleSystem2 != null)
         {
             mParticleSystem2.StopEmitting();
             mParticleSystem2.Cancel();
             mParticleSystem2.Dispose();
             mParticleSystem2 = null;
         }
         mLinearLayout.Invalidate();
         mTitle.Text = mSpinner.SelectedItem.ToString();
         mShouldFollowTouch = false;
         switch (e.Position)
         {
             case 1:
                 OneShotSimple();
                 break;
             case 2:
                 OneShotAdvanced();
                 break;
             case 3:
                 EmiterSimple();
                 break;
             case 4:
                 EmitBackgroundSimple();
                 break;
             case 5:
                 EmiterIntermediate();
                 break;
             case 6:
                 EmitTimeLimited();
                 break;
             case 7:
                 EmitWithGravity();
                 break;
             case 8:
                 mShouldFollowTouch = true;
                 break;
             case 9:
                 AnimatedParticles();
                 break;
             case 10:
                 Fireworks();
                 break;
             case 11:
                 Confetti();
                 break;
             case 12:
                 Dust();
                 break;
             case 13:
                 Stars();
                 break;
             default:
                 break;
         }
         mSpinner.SetSelection(0);
     };
 }