Пример #1
0
        private async void Submit_Click(object sender, RoutedEventArgs e)
        {
            int    steps    = 0;
            double distance = 0;

            if (!int.TryParse(StepsBox.Text, out steps) ||
                !double.TryParse(DistanceBox.Text, out distance))
            {
                await new MessageDialog("You need to fill in an approximate number of steps and distance.").ShowAsync();
                return;
            }

            Activity activity = new Activity
            {
                Id          = id,
                AccountId   = UserState.CurrentId,
                BeginTime   = BeginDate.Date.DateTime + BeginTime.Time,
                EndTime     = EndDate.Date.DateTime + EndTime.Time,
                Description = "<placeholder>",
                Steps       = steps,
                Distance    = UserState.UseOldUnits ? distance * 3.0 : distance,
                Type        = (ActivityType)TypeBox.SelectedIndex
            };

            var result = await Api.Do.UpdateActivity(activity);

            activity = result;

            PageDispatch.ViewActivity(Frame, activity);
        }
        private async void Submit_Click(object sender, RoutedEventArgs e)
        {
            double amount = 0;

            if (string.IsNullOrEmpty(NameInput.Text) ||
                string.IsNullOrEmpty(Number.Text) ||
                !double.TryParse(Number.Text, out amount))
            {
                MessageDialog dialog = new MessageDialog("You need to fill in all fields.");
                await dialog.ShowAsync();

                return;
            }

            Food food = new Food
            {
                AccountId   = UserState.CurrentId,
                Amount      = amount,
                Date        = DateTime.UtcNow,
                FoodName    = NameInput.Text,
                Measurement = (Measurement)Enum.Parse(typeof(Measurement), (string)((ComboBoxItem)Units.SelectedValue).Tag)
            };
            await Api.Do.PostFood(food);

            PageDispatch.GoHome(Frame);
        }
Пример #3
0
        private async void button_Tapped(object sender, TappedRoutedEventArgs e)
        {
            await Api.Do.GiveAdmin(UserState.CurrentId, (string)((Button)sender).Tag, teamId);

            UserState.ActiveAccount = await Api.Do.GetAccount(UserState.CurrentId);

            PageDispatch.ViewTeam(Frame, teamId);
        }
        private async void DoneButton_Click(object sender, RoutedEventArgs e)
        {
            if (new[] { Name.Text, PreferredName.Text, HeightFeet.Text, HeightInches.Text,
                        Weight.Text, Zip.Text }.Any(string.IsNullOrEmpty))
            {
                MessageDialog dialog = new MessageDialog("You need to fill in all fields.");
                await dialog.ShowAsync();

                return;
            }

            bool?sex = null;

            if (Sex.SelectionBoxItem == null)
            {
            }
            else if ((string)Sex.SelectionBoxItem == "Female")
            {
                sex = true;
            }
            else if ((string)Sex.SelectionBoxItem == "Male")
            {
                sex = false;
            }

            var account = new Account()
            {
                Id            = "",
                FullName      = Name.Text,
                PreferredName = PreferredName.Text,
                UserName      = new string(Name.Text.Where(c => char.IsDigit(c) || char.IsLetter(c)).ToArray()),
                Height        = int.Parse(HeightFeet.Text) * 12 + int.Parse(HeightInches.Text),
                Weight        = UserState.UseOldUnits ? (int.Parse(Weight.Text) * 14) : int.Parse(Weight.Text),
                Sex           = sex,
                Birthdate     = Birthdate.Date.DateTime,
                Zip           = int.Parse(Zip.Text)
            };

            if (info.Authenticator == Authenticator.Twitter)
            {
                account.TwitterId = info.SocialId;
            }
            else
            {
                account.FacebookId = info.SocialId;
            }

            account = await Api.Do.CreateAccount(account);

            UserState.ActiveAccount = account;
            PageDispatch.GoHome(Frame);
        }
Пример #5
0
 private void ChangeUnits_Click(object sender, RoutedEventArgs e)
 {
     UserState.UseOldUnits = !UserState.UseOldUnits;
     if (UserState.UseOldUnits)
     {
         ChangeUnits.Label = "Use modern english units";
     }
     else
     {
         ChangeUnits.Label = "Use ye old units";
     }
     PageDispatch.GoHome(Frame);
 }
Пример #6
0
        private async void RecordButton_Tapped(object sender, TappedRoutedEventArgs e)
        {
            if (recording)
            {
                DateTime end = DateTime.UtcNow;

                Activity activity = new Activity
                {
                    AccountId = UserState.CurrentId,
                    BeginTime = begin,
                    EndTime   = end,
                    Steps     = pedometer.Steps,
                    Distance  = path.Distance
                };

                GPSSpinner.IsActive         = true;
                ((Button)sender).IsEnabled  = false;
                geolocator.PositionChanged -= geolocator_PositionChanged;
                pedometer.Stepped          -= pedometer_Stepped;
                activity.Type = await Api.Do.Predict(activity);

                activity = (await Api.Do.SendActivity(activity)).Item1;

                path.ActivityId = activity.Id;

                path = await Api.Do.PostPath(path);

                PageDispatch.ViewActivity(Frame, activity);
            }
            else
            {
                begin   = DateTime.UtcNow;
                current = DateTime.UtcNow;

                timer = new Timer((o) =>
                {
                    current = current.AddSeconds(1);
                    Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => DurationDisplay.Text = "Duration: " + (current - begin).ToString("hh':'mm':'ss"));
                }, null, 1000, 1000);

                ((Button)sender).Content = "Stop Activity";

                pedometer.Start();
                begin = DateTime.UtcNow;

                pedometer.Stepped += pedometer_Stepped;
                recording          = true;

                geolocator.PositionChanged += geolocator_PositionChanged;
            }
        }
        private async void SubmitButtonTapped(object sender, TappedRoutedEventArgs e)
        {
            var item = ((TextBlock)MoodOptions.SelectionBoxItem).Text;

            var mood = moods.First(m => m.Description == item);

            await Api.Do.CreateStatus(new Status
            {
                MoodId    = mood.Id,
                Date      = DateTime.UtcNow,
                AccountId = UserState.CurrentId
            });

            PageDispatch.GoHome(Frame);
        }
        private async void DoneButton_Click(object sender, RoutedEventArgs e)
        {
            if (Name.Text.Length == 0)
            {
                MessageDialog dialog = new MessageDialog("You need to fill in a name.");
            }

            Team team = new Team()
            {
                Id      = id,
                Deleted = false,
                Name    = Name.Text
            };

            await Api.Do.EditTeam(team);

            PageDispatch.ViewTeam(Frame, id);
        }
        private async void AppBarButton_Click_Leave(object sender, RoutedEventArgs e)
        {
            var membership = (UserState.ActiveAccount.Memberships.Where(m => m.TeamId == teamId)).FirstOrDefault();

            if (membership != null &&
                membership.Status == MembershipStatus.Admin &&
                (await Api.Do.GetTeam(teamId)).Memberships.Where(m => m.Status == MembershipStatus.Member || m.Status == MembershipStatus.Admin ||
                                                                 m.Status == MembershipStatus.Invited).Count() > 1)
            {
                await new MessageDialog("You can't leave the group until you make someone else admin.").ShowAsync();
                return;
            }

            Api.Do.LeaveTeam(UserState.CurrentId, teamId);
            JoinButton.Visibility  = Windows.UI.Xaml.Visibility.Visible;
            LeaveButton.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            PageDispatch.GoHome(Frame);
        }
        private async void DoneButton_Click(object sender, RoutedEventArgs e)
        {
            if (Name.Text.Length == 0)
            {
                MessageDialog dialog = new MessageDialog("You need to fill in a name.");
                await dialog.ShowAsync();

                return;
            }

            Team team = new Team()
            {
                Deleted = false,
                Name    = Name.Text
            };

            var result = await Api.Do.CreateTeam(team, UserState.CurrentId);

            PageDispatch.ViewTeam(Frame, result.Id);
        }
        private async void Submit(object sender, TappedRoutedEventArgs e)
        {
            int number;

            if (MeasureBox.SelectedValue == null ||
                TimelineBox.SelectedValue == null ||
                TypeBox.SelectedValue == null ||
                !int.TryParse(NumberBox.Text, out number) ||
                number <= 0)
            {
                MessageDialog dialog = new MessageDialog("Your count must be a natural number and all fields must be filled in.");
                await dialog.ShowAsync();

                return;
            }

            Target target = new Target
            {
                TargetNumber = (UIType() == TargetType.Distance && UserState.UseOldUnits) ? number / 3.0 : number,
                ActivityType = UIActivityType(),
                Type         = UIType()
            };

            target = await Api.Do.PostTarget(target);

            Goal goal = new Goal
            {
                TargetId  = target.Id,
                AccountId = challenged != null ? challenged.Id : UserState.CurrentId,
                Timeline  = UITimeline(),
                BeginDate = DateTime.UtcNow,
                EndDate   = DateTime.UtcNow + UITimeline().Span(),
                Status    = challenged != null ? GoalStatus.Challenged : GoalStatus.Current,
            };

            await Api.Do.PostGoal(goal);

            goal.Target = target;
            PageDispatch.GoHome(Frame);
        }
Пример #12
0
 private void EatFood_Click(object sender, RoutedEventArgs e)
 {
     PageDispatch.RecordFood(Frame);
 }
Пример #13
0
 private void SetGoalTapped(object sender, RoutedEventArgs e)
 {
     PageDispatch.SetGoal(Frame);
 }
Пример #14
0
 private void StatusTapped(object sender, RoutedEventArgs e)
 {
     PageDispatch.ShareStatus(Frame);
 }
Пример #15
0
 private void CreateTeamTapped(object sender, RoutedEventArgs e)
 {
     PageDispatch.CreateTeam(Frame);
 }
Пример #16
0
 private void FindTapped(object sender, RoutedEventArgs e)
 {
     PageDispatch.SearchTeams(Frame);
 }
Пример #17
0
 private void HomeTapped(object sender, RoutedEventArgs e)
 {
     PageDispatch.GoHome(Frame);
 }
Пример #18
0
 private void LogoutTapped(object sender, RoutedEventArgs e)
 {
     PageDispatch.Logout(Frame);
 }
Пример #19
0
 private void EditTapped(object sender, RoutedEventArgs e)
 {
     PageDispatch.EditUser(Frame);
 }
Пример #20
0
        private void TeamTapped(object sender, TappedRoutedEventArgs e)
        {
            long teamId = long.Parse(((Button)sender).Name);

            PageDispatch.ViewTeam(Frame, teamId);
        }
 private void GiveAdmin_Click(object sender, RoutedEventArgs e)
 {
     PageDispatch.GiveAdmin(Frame, teamId);
 }
        private async void button_Tapped(object sender, TappedRoutedEventArgs e)
        {
            await Api.Do.Invite(UserState.CurrentId, (string)((Button)sender).Tag, teamId);

            PageDispatch.ViewTeam(Frame, teamId);
        }
 private void EditButton_Tapped(object sender, TappedRoutedEventArgs e)
 {
     PageDispatch.EditActivity(Frame, activity);
 }
Пример #24
0
 private void ManualActivity_Click(object sender, RoutedEventArgs e)
 {
     PageDispatch.RecordManualActibity(Frame);
 }
 void button_Tapped(object sender, TappedRoutedEventArgs e)
 {
     PageDispatch.ViewUser(Frame, ((Button)sender).Name);
 }
 private async void button_Tapped(object sender, TappedRoutedEventArgs e)
 {
     PageDispatch.ViewTeam(Frame, (long)((Button)sender).Tag);
 }
Пример #27
0
 private void ChallengeClick(object sender, RoutedEventArgs e)
 {
     PageDispatch.SearchChallenge(Frame);
 }
 private void ClickInvite(object sender, RoutedEventArgs e)
 {
     PageDispatch.Invite(Frame, teamId);
 }
 private void Edit_Click(object sender, RoutedEventArgs e)
 {
     PageDispatch.EditTeam(Frame, teamId);
 }
 private async static void ActivityTapped(object sender, TappedRoutedEventArgs e)
 {
     PageDispatch.ViewActivity(frame, await Api.Do.GetActivity(long.Parse(((Grid)sender).Name.Split()[0])));
 }