Exemplo n.º 1
0
        private void CreateExerciseLogEntry(FitnessTrackerPlus.Web.Data.Exercise exercise)
        {
            ExerciseLogEntry entry = new ExerciseLogEntry();

            // Setup new exercise log entry with selected date, exercise and current user

            entry.exercise_id = exercise.id;
            entry.entry_date  = Globals.SelectedDate;
            entry.user_id     = Globals.CurrentUser.id;

            context.ExerciseLogEntries.Add(entry);
            context.SubmitChanges((ChangesSubmitted) =>
            {
                if (!ChangesSubmitted.HasError)
                {
                    if (exercise.ExerciseType.type_name == "Cardio")
                    {
                        CardioData.Load();
                    }
                    else if (exercise.ExerciseType.type_name == "Weight Training")
                    {
                        WeightTrainingData.Load();
                    }
                    else
                    {
                        ActivityData.Load();
                    }
                }
            }, null);
        }
Exemplo n.º 2
0
        private void DeleteSelected_Click(object sender, RoutedEventArgs e)
        {
            List <ExerciseLogEntry> entries = new List <ExerciseLogEntry>();

            // First check the cardio grid, then weight training and activities

            foreach (ExerciseLogEntry entry in context.ExerciseLogEntries)
            {
                CheckBox selectItem = null;

                if (entry.Exercise.ExerciseType.type_name == "Cardio")
                {
                    CardioLogGrid.SelectedItem = entry;
                    selectItem = CardioLogGrid.Columns[CardioLogGrid.Columns.Count - 1].GetCellContent(CardioLogGrid.SelectedItem) as CheckBox;
                }
                else if (entry.Exercise.ExerciseType.type_name == "Weight Training")
                {
                    WeightTrainingLogGrid.SelectedItem = entry;
                    selectItem = WeightTrainingLogGrid.Columns[WeightTrainingLogGrid.Columns.Count - 1].GetCellContent(WeightTrainingLogGrid.SelectedItem) as CheckBox;
                }
                else
                {
                    ActivityLogGrid.SelectedItem = entry;
                    selectItem = ActivityLogGrid.Columns[ActivityLogGrid.Columns.Count - 1].GetCellContent(ActivityLogGrid.SelectedItem) as CheckBox;
                }

                if (selectItem != null)
                {
                    if (selectItem.IsChecked == true)
                    {
                        entries.Add(entry);
                    }
                }
            }

            foreach (ExerciseLogEntry entry in entries)
            {
                context.ExerciseLogEntries.Remove(entry);
            }

            context.SubmitChanges((EntriesRemoved) =>
            {
                ProgressBar.Visibility = Visibility.Collapsed;

                CardioData.Load();
                WeightTrainingData.Load();
                ActivityData.Load();
            }, null);
        }
Exemplo n.º 3
0
    public static void Load()
    {
        if (m_DicDatas == null || m_Datas == null || m_DicDatasList == null)
        {
            Stream fs = OpenData("ActivityData.bin");
            if (fs != null)
            {
                BinaryReader br      = new BinaryReader(fs);
                ushort       dataNum = br.ReadUInt16();
                m_DicDatas     = new Dictionary <int, Dictionary <int, ActivityData> >();
                m_Datas        = new List <ActivityData>(dataNum + 1);
                m_DicDatasList = new Dictionary <int, List <ActivityData> >(dataNum + 1);
                for (int i = 0; i < dataNum; ++i)
                {
                    ActivityData data = new ActivityData();
                    data.Load(br);
                                        #if UNITY_EDITOR || UNITY_STANDALONE_WIN
                    /*if (m_DicDatas.ContainsKey(data.iActivityID_KEYID1))
                     * {
                     *      UDebug.Assert(false, "ActivityData encountered duplicate keys, " + data.iActivityID_KEYID1);
                     * }*/
                                        #endif
                    if (!m_DicDatas.ContainsKey(data.iActivityID_KEYID1))
                    {
                        m_DicDatas[data.iActivityID_KEYID1] = new Dictionary <int, ActivityData>();
                    }

                    if (!m_DicDatasList.ContainsKey(data.iActivityID_KEYID1))
                    {
                        m_DicDatasList[data.iActivityID_KEYID1] = new List <ActivityData>();
                    }

                    m_DicDatas[data.iActivityID_KEYID1][data.iActivityPosition_KEYID2] = data;
                    m_DicDatasList[data.iActivityID_KEYID1].Add(data);
                    m_Datas.Add(data);
                }
                br.Close();
                br = null;
                fs.Close();
                fs = null;
            }
        }
    }