Esempio n. 1
0
 public void activityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
 {
     if (resultCode == Result.Ok)
     {
         var tmp = new Perscription[((MainActivity)Activity).GetPerscriptSize()];
         Array.Copy(((MainActivity)Activity).getPerscript(), tmp, tmp.Length);
         perscription = new PerscriptionListing(tmp);
         mAdapter     = new PerscriptionsAdapter(perscription);
         _recycler.SetAdapter(mAdapter);
         mAdapter.NotifyDataSetChanged();
     }
 }
Esempio n. 2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            var ignored = base.OnCreateView(inflater, container, savedInstanceState);
            var v       = inflater.Inflate(Resource.Layout.analytics, container, false);

            PlotView view = v.FindViewById <PlotView>(Resource.Id.plot_view);

            prescriptions = new PerscriptionListing(((MainActivity)Activity).getPerscript());
            DateTime[] dateTimesTaken = new DateTime[]
            {
                new DateTime(2018, 6, 30, 9, 0, 0),
                new DateTime(2018, 7, 30, 11, 0, 0)
            };

            //view.Model = CreatePlotModel(prescriptions, dateTimesTaken);
            view.Model = CreatePlotModel();

            return(v);
        }
Esempio n. 3
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            var ignored = base.OnCreateView(inflater, container, savedInstanceState);
            var v       = inflater.Inflate(Resource.Layout.prescriptions, container, false);

            Button addPerscriptionButton = (Button)v.FindViewById(Resource.Id.plusbtn);

            addPerscriptionButton.SetOnClickListener(this);

            _recycler = (RecyclerView)v.FindViewById(Resource.Id.recyclerViewPerscription);

            perscription = new PerscriptionListing(((MainActivity)Activity).getPerscript());

            // use a linear layout manager
            mLayoutManager = new LinearLayoutManager(this.Context);
            _recycler.SetLayoutManager(mLayoutManager);

            mAdapter = new PerscriptionsAdapter(perscription);
            _recycler.SetAdapter(mAdapter);

            return(v);
        }
Esempio n. 4
0
 // Load the adapter with the data set (perscriptions) at construction time:
 public PerscriptionsAdapter(PerscriptionListing p)
 {
     _PListing = p;
 }
Esempio n. 5
0
        private PlotModel CreatePlotModel(PerscriptionListing prescriptions, DateTime[] DateTimesTaken)
        {
            //Create dynamic plot model from passed prescriptions
            var model = new PlotModel
            {
                Title                 = "Medication Analytics",
                LegendPlacement       = LegendPlacement.Outside,
                LegendPosition        = LegendPosition.BottomCenter,
                LegendOrientation     = LegendOrientation.Horizontal,
                LegendBorderThickness = 0,
            };

            var s1 = new BarSeries {
                Title = "Taken on time", StrokeColor = OxyColors.Black, StrokeThickness = 1, BarWidth = 10, LabelPlacement = LabelPlacement.Outside, LabelMargin = 3, LabelFormatString = "{0:}"
            };

            for (int i = 0; i < prescriptions.numPerscriptions; i++)
            {
                List <string> IntervalsInTimePeriod = prescriptions[i].schedule;
                var           StartDate             = prescriptions[i].start;
                string        IntervalType          = prescriptions[i].interval;
                int           TakenCount            = CalculateTaken(IntervalsInTimePeriod, StartDate, DateTimesTaken, IntervalType);
                s1.Items.Add(new BarItem {
                    Value = TakenCount
                });
            }

            var s2 = new BarSeries {
                Title = "Taken late", StrokeColor = OxyColors.Black, StrokeThickness = 1, BarWidth = 10, LabelPlacement = LabelPlacement.Outside, LabelMargin = 3, LabelFormatString = "{0:}"
            };

            s2.Items.Add(new BarItem {
                Value = 1
            });
            s2.Items.Add(new BarItem {
                Value = 5
            });

            var s3 = new BarSeries {
                Title = "Not taken", StrokeColor = OxyColors.Black, StrokeThickness = 1, BarWidth = 10, LabelPlacement = LabelPlacement.Outside, LabelMargin = 3, LabelFormatString = "{0:}"
            };

            s3.Items.Add(new BarItem {
                Value = 3
            });
            s3.Items.Add(new BarItem {
                Value = 4
            });

            var categoryAxis = new CategoryAxis {
                Position = AxisPosition.Left
            };

            categoryAxis.Labels.Add("Medicine A");
            categoryAxis.Labels.Add("Medicine B");
            var valueAxis = new LinearAxis {
                Position = AxisPosition.Bottom, MinimumPadding = 0, MaximumPadding = 0.06, AbsoluteMinimum = 0
            };

            model.Series.Add(s1);
            model.Series.Add(s2);
            model.Series.Add(s3);
            model.Axes.Add(categoryAxis);
            model.Axes.Add(valueAxis);


            return(model);
        }