Beispiel #1
0
        public StartPage()
        {
            // setup the page with the data that we need
            vm              = new CalendarVM();
            vm.Date         = DateTime.Now;
            stopwatch       = new Stopwatch();
            tbItem          = new ToolbarItem();
            tbItem.Text     = "Save";
            tbItem.Clicked += saveButtonOnClick;
            vm.Workout      = database.GetWorkouts(vm.Date);

            this.BindingContext = vm;


            InitializeComponent();

            // if there is not workout.  Display a message
            if (vm.Workout.Count == 0)
            {
                System.Diagnostics.Debug.WriteLine("No workout today");
                Label l = new Label
                {
                    Text              = "No workout scheduled today!",
                    VerticalOptions   = LayoutOptions.CenterAndExpand,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    FontSize          = Device.GetNamedSize(NamedSize.Large, typeof(Label))
                };
                MainContent.Children.Add(l);
            }
            else
            {
                startStopButton.IsVisible = true;
                startStopButton.IsEnabled = true;
                startStopButton.Clicked  += startStopButtonOnClick;
            }
        }
Beispiel #2
0
        /*
         * If we are graphing the exercises, a line graph won't do, so we use a
         * column graph to display each set in different colors
         */
        private PlotModel CreatePlotModel()
        {
            var    data = database.GetWorkouts(name);
            GoalDB goal = database.GetGoal(name);

            System.Diagnostics.Debug.WriteLine("GOAL: ", goal);
            var subtitle = "";

            // make sure the goal is set before trying to display it
            if (goal == null)
            {
                subtitle = "Goal not set";
            }
            else
            {
                subtitle = goal.goal.ToString() + goal.unit;
            }

            var model = new PlotModel
            {
                Title                 = name,
                Subtitle              = subtitle,
                LegendPlacement       = LegendPlacement.Outside,
                LegendPosition        = LegendPosition.BottomCenter,
                LegendOrientation     = LegendOrientation.Horizontal,
                LegendBorderThickness = 0
            };
            var categoryAxis = new CategoryAxis {
                Position = AxisPosition.Left
            };

            //We have to iterate over each data point to see how many columns we have to create per date
            //Also, create category for each date
            int max = 0;

            foreach (WorkoutItem _data in data)            //Iterate over each date
            {
                int thisMax = 0;
                //Iterate over each set
                foreach (Double amount in _data.Set)
                {
                    thisMax++;
                }
                if (thisMax > max)
                {
                    max = thisMax;
                }
                categoryAxis.Labels.Add(_data.Date.ToString("M/d/yy"));
            }

            // Create number of columns corresponding to the maximum number of columns needed
            for (int i = 0; i < max; i++)             // Iterate over set #'s
            {
                var series = new BarSeries {
                    Title = "Set " + (i + 1), StrokeColor = OxyColors.Black, StrokeThickness = 1
                };
                foreach (WorkoutItem _data in data)               // Iterate over dates
                {
                    if (_data.Set.Count <= i)                     //If this set does not exist
                    {
                        series.Items.Add(new BarItem {
                            Value = 0
                        });
                    }
                    else
                    {
                        series.Items.Add(new BarItem {
                            Value = _data.Set[i]
                        });
                    }
                }
                model.Series.Add(series);
            }


            var valueAxis = new LinearAxis {
                Position = AxisPosition.Bottom, MinimumPadding = 0, MaximumPadding = 0.06, AbsoluteMinimum = 0, Title = data[0].Unit
            };

            model.Axes.Add(categoryAxis);
            model.Axes.Add(valueAxis);


            return(model);
        }