コード例 #1
0
        public void WindSpeedClicked(Android.Views.View v)
        {
            var ws = BFCDatabase.GetTable <WindSpeed>();

            CreateSelectDialog <WindSpeed>(ws, x => string.Format("From {0} to {1}", x.Min, x.Max), "Choose wind speed", selected =>
            {
                var b  = (Button)v;
                b.Text = string.Format("From {0} to {1}", selected.Min, selected.Max);
                BFCAndroidGlobal.SelectedWindSpeed = selected;
                RefreshResult();
            });
        }
コード例 #2
0
        public void SprayQualityClicked(Android.Views.View v)
        {
            var sq = BFCDatabase.GetTable <SprayQuality>();

            CreateSelectDialog <SprayQuality>(sq, x => x.Name, "Choose spray quality", selected =>
            {
                var b  = (Button)v;
                b.Text = selected.Name;
                BFCAndroidGlobal.SelectedSprayQuality = selected;
                RefreshResult();
            });
        }
コード例 #3
0
        public void BoomHeightClicked(Android.Views.View v)
        {
            var bh = BFCDatabase.GetTable <BoomHeight>();

            CreateSelectDialog <BoomHeight>(bh, x => x.Name, "Choose boom height", selected =>
            {
                var b  = (Button)v;
                b.Text = selected.Name;
                BFCAndroidGlobal.SelectedBoomHeight = selected;
                RefreshResult();
            });
        }
コード例 #4
0
        protected override void OnListItemClick(ListView l, Android.Views.View v, int position, long id)
        {
            base.OnListItemClick(l, v, position, id);
            switch (_listWhat)
            {
            case "manufacturer":
            {
                BFCAndroidGlobal.SelectedManufacturer = (Manufacturer)_selectionList[position];

                var intent = new Intent(this, typeof(View.SelectItem));
                intent.PutExtra("pick", "nozzle");
                StartActivityForResult(intent, Pick_Nozzle);
            }
            break;

            case "nozzle":
            {
                BFCAndroidGlobal.SelectedNozzle = (Nozzle)_selectionList[position];

                var intent = new Intent(this, typeof(View.SelectItem));
                intent.PutExtra("pick", "pressure");
                StartActivityForResult(intent, Pick_Pressure);
            }
            break;

            case "pressure":
            {
                BFCAndroidGlobal.SelectedPressure = (Pressure)_selectionList[position];

                var intent = new Intent(this, typeof(View.SelectItem));
                intent.PutExtra("pick", "waterflow");
                StartActivityForResult(intent, Pick_Pressure);
            }
            break;

            case "waterflow":
            {
                BFCAndroidGlobal.SelectedWaterFlow = (WaterFlow)_selectionList[position];
                var sq = BFCDatabase.GetSprayQualityFor(BFCAndroidGlobal.SelectedPressure, BFCAndroidGlobal.SelectedWaterFlow);
                BFCAndroidGlobal.SelectedSprayQuality = sq;

                System.Diagnostics.Debug.WriteLine("Selected sq: {0} {1}", sq.Id, sq.Name);

                SetResult(Result.Ok);
                Finish();
            }
            break;

            default:
                throw new InvalidOperationException("Invalid list type");
            }
        }
コード例 #5
0
        private void RefreshResult()
        {
            var bfAquatic       = -1;
            var okBfAquatic     = int.TryParse(View.FindViewById <EditText>(Resource.Id.editBfAquatic).Text, out bfAquatic);
            var bfTerrestrial   = -1;
            var okBfTerrestrial = int.TryParse(View.FindViewById <EditText>(Resource.Id.editBfTerrestrial).Text, out bfTerrestrial);

            var resAquatic     = View.FindViewById <TextView>(Resource.Id.resBfAquaticTextView);
            var resTerrestrial = View.FindViewById <TextView>(Resource.Id.resBfTerrestrialTextView);


            if (BFCAndroidGlobal.SelectedSprayQuality == null ||
                BFCAndroidGlobal.SelectedLabelSprayQuality == null ||
                BFCAndroidGlobal.SelectedBoomHeight == null ||
                BFCAndroidGlobal.SelectedWindSpeed == null ||
                !okBfAquatic || !okBfTerrestrial)
            {
                resAquatic.Text     = "Buffer zone aquatic:";
                resTerrestrial.Text = "Buffer zone terrestrial:";
                return;
            }

            var m = BFCDatabase.GetMultiplierFor(BFCAndroidGlobal.SelectedSprayQuality, BFCAndroidGlobal.SelectedLabelSprayQuality,
                                                 BFCAndroidGlobal.SelectedBoomHeight, BFCAndroidGlobal.SelectedWindSpeed);

            if (!m.HasValue)
            {
                resAquatic.Text     = string.Format("Buffer zone aquatic: {0}", "not found");
                resTerrestrial.Text = string.Format("Buffer zone terrestrial: {0}", "not found");
            }
            else
            {
                resAquatic.Text     = string.Format("Buffer zone aquatic: {0}", m.Value * bfAquatic);
                resTerrestrial.Text = string.Format("Buffer zone terrestrial: {0}", m.Value * bfTerrestrial);
            }
        }
コード例 #6
0
        private void UpdateDatabase()
        {
            Task.Factory.StartNew(() =>
            {
                //BFCDatabase.DropTables();
                //BFCDatabase.CreateTables();

                //var n = new BFCNetwork();
                //n.GetSprayQuality(data =>
                //{
                //    BFCDatabase.AddToDb(data);
                //    Activity.RunOnUiThread(() =>
                //    {
                //        Toast.MakeText(Activity, string.Format("Done updating {0}", data.First().GetType().Name), ToastLength.Short).Show();
                //    });
                //});

                //n.GetLabelSprayQuality(data =>
                //{
                //    BFCDatabase.AddToDb(data);
                //    Activity.RunOnUiThread(() =>
                //    {
                //        Toast.MakeText(Activity, string.Format("Done updating {0}", data.First().GetType().Name), ToastLength.Short).Show();
                //    });
                //});

                //n.GetBoomHeight(data =>
                //{
                //    BFCDatabase.AddToDb(data);
                //    Activity.RunOnUiThread(() =>
                //    {
                //        Toast.MakeText(Activity, string.Format("Done updating {0}", data.First().GetType().Name), ToastLength.Short).Show();
                //    });
                //});

                //n.GetWindSpeed(data =>
                //{
                //    BFCDatabase.AddToDb(data);
                //    Activity.RunOnUiThread(() =>
                //    {
                //        Toast.MakeText(Activity, string.Format("Done updating {0}", data.First().GetType().Name), ToastLength.Short).Show();
                //    });
                //});

                //n.GetMultiplier(data =>
                //{
                //    BFCDatabase.AddToDb(data);
                //    Activity.RunOnUiThread(() =>
                //    {
                //        Toast.MakeText(Activity, string.Format("Done updating {0}", data.First().GetType().Name), ToastLength.Short).Show();
                //    });
                //});

                //var manufacturers = new List<Manufacturer> {
                //    new Manufacturer{Id = 1, Name = "Tee jet"}
                //};
                //BFCDatabase.AddToDb(manufacturers);

                //var nozzle = new List<Nozzle> {
                //    new Nozzle{Id = 1, ManufacturerId = 1, Name = "abc"},
                //    new Nozzle{Id = 2, ManufacturerId = 1, Name = "bcd"},
                //    new Nozzle{Id = 3, ManufacturerId = 1, Name = "cde"},
                //};
                //BFCDatabase.AddToDb(nozzle);

                //var pressure = new List<Pressure> {
                //    new Pressure{Id = 1, NozzleId = 1, Value = 15},
                //    new Pressure{Id = 2, NozzleId = 1, Value = 25},
                //    new Pressure{Id = 3, NozzleId = 1, Value = 35},
                //};
                //BFCDatabase.AddToDb(pressure);

                //var wf = new List<WaterFlow> {
                //    new WaterFlow{Id = 1, NozzleId = 1, Value = "wf1"},
                //    new WaterFlow{Id = 2, NozzleId = 1, Value = "wf2"},
                //    new WaterFlow{Id = 3, NozzleId = 1, Value = "wf3"},
                //};
                //BFCDatabase.AddToDb(wf);

                //var csq = new List<CalcSprayQuality> {
                //    new CalcSprayQuality{WaterFlowId = 1, PressureId = 1, SprayQualityId = 1},
                //    new CalcSprayQuality{WaterFlowId = 2, PressureId = 2, SprayQualityId = 2},
                //    new CalcSprayQuality{WaterFlowId = 3, PressureId = 3, SprayQualityId = 3},
                //};
                //BFCDatabase.AddToDb(csq);

                BFCDatabase.CreateDummyData();

                Activity.RunOnUiThread(() =>
                {
                    Toast.MakeText(Activity, "Done updating database", ToastLength.Long).Show();
                });
            });
        }
コード例 #7
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            // Create your application here
            SetContentView(Resource.Layout.SelectItem);

            var adap = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, _items);

            ListAdapter = adap;
            ListView.TextFilterEnabled = true;
            ListView.ChoiceMode        = ChoiceMode.Multiple;

            _listWhat = Intent.GetStringExtra("pick");

            switch (_listWhat)
            {
            case "manufacturer":
            {
                Title = "Pick Manufacturer";
                var manu = BFCDatabase.GetTable <Manufacturer>();
                DisplayListOnUI(manu);
            }
            break;

            case "nozzle":
            {
                Title = "Pick nozzle";
                var n = BFCDatabase.GetNozzleFor(BFCAndroidGlobal.SelectedManufacturer);
                DisplayListOnUI(n);
            }
            break;

            case "pressure":
            {
                Title = "Pick pressure";
                var p = BFCDatabase.GetPressureFor(BFCAndroidGlobal.SelectedNozzle);
                DisplayListOnUI(p);
            }
            break;

            case "waterflow":
            {
                Title = "Pick water flow";
                var wf = BFCDatabase.GetWaterFlowFor(BFCAndroidGlobal.SelectedNozzle);
                DisplayListOnUI(wf);
            }
            break;

            default:
                throw new InvalidOperationException("Invalid list type");
            }
            ((ArrayAdapter)ListAdapter).NotifyDataSetChanged();

            var filterEditText = FindViewById <EditText>(Resource.Id.filterEditText);

            filterEditText.TextChanged += (sender, arg) =>
            {
                var et = (EditText)sender;
                ((ArrayAdapter <string>)ListAdapter).Filter.InvokeFilter(et.Text);
            };
        }