Example #1
0
        public EditGoalPage(string name)
        {
            InitializeComponent();
            valueEntryFinished     = false;
            unitEntryFinished      = false;
            finishButton.IsEnabled = false;

            unitEntry.Items.Add("Minutes");
            unitEntry.Items.Add("Repetitions");
            unitEntry.Items.Add("Kgs");
            unitEntry.Items.Add("Lbs");
            unitEntry.SelectedIndex = 0;

            valueEntry.TextChanged += OnTextChanged;

            finishButton.Clicked += (sender, e) =>
            {
                GoalDB gdb = new GoalDB
                {
                    Name = name,
                    unit = unitEntry.Items[unitEntry.SelectedIndex],
                    goal = Double.Parse(valueEntry.Text)
                };
                database.WriteGoal(gdb);
                Navigation.PopAsync();
            };
        }
Example #2
0
        public void WriteGoal(GoalDB g)
        {
            //Delete the old goal if there is one
            GoalDB del = new GoalDB
            {
                Name = g.Name
            };

            _connection.Delete(del);

            //Insert the goal
            _connection.Insert(g);
        }
Example #3
0
        private void Refresh()
        {
            database = new FitAppDatabase(DependencyService.Get <IFileHelper>().GetLocalFilePath("fitAppDatabase.db3"));
            GoalDB gdb = database.GetGoal(_name);

            if (gdb == null)
            {
                goalValue.Text = "  None";
            }
            else
            {
                goalValue.Text = gdb.goal.ToString() + " " + gdb.unit.ToString();
            }
        }
Example #4
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);
        }