private async void button_Click(object sender, RoutedEventArgs e)
        {
            Button obj = (Button)sender;

            if ((string)(obj.CommandParameter) == "1")
            {
                await WeBallAPI.joinMatch(match.teams[0]._id);

                if (WeBallAPI.Success == false)
                {
                    return;
                }
            }
            else
            {
                await WeBallAPI.joinMatch(match.teams[1]._id);

                if (WeBallAPI.Success == false)
                {
                    return;
                }
            }
            if (WeBallAPI.Success)
            {
                NavigationService.Navigate(new Uri("/MatchTimingPage.xaml?five=" + JsonConvert.SerializeObject(five), UriKind.Relative));
                setPopup("Succes!");
            }
            else
            {
                setPopup("Erreur");
            }
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            string parameter = string.Empty;

            if (NavigationContext.QueryString.TryGetValue("five", out parameter))
            {
                target = JsonConvert.DeserializeObject <Five>(parameter);
                await WeBallAPI.getMatches(target._id);

                if (WeBallAPI.Success == false)
                {
                    return;
                }
                target = WeBallAPI.FiveList.FirstOrDefault(s => s._id == target._id);
                if (target.matchs != null)
                {
                    target.nTotalMatchs = target.matchs.Count;
                }
                else
                {
                    target.nTotalMatchs = 0;
                }
                FiveGrid.DataContext    = target;
                FiveGridBis.DataContext = target;
            }
        }
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (BoxName.Text != "")
            {
                WeBallAPI.currentUser.fullName = BoxName.Text;
            }
            if (BoxEmail.Text != "")
            {
                WeBallAPI.currentUser.email = BoxEmail.Text;
            }
            char[]   delimiters     = { '/', ' ' };
            string[] parsedBirthday = BoxBirthday.Value.ToString().Split(delimiters);
            string   birthday       = parsedBirthday[2] + ',' + parsedBirthday[1] + ',' + parsedBirthday[0];

            WeBallAPI.currentUser.birthday = birthday;
            await WeBallAPI.updateUser();

            if (WeBallAPI.Success == false)
            {
                return;
            }
            MessageBoxResult result =
                MessageBox.Show("Profil édité!",
                                "Confirmation",
                                MessageBoxButton.OK);

            (Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/ProfilePage.xaml", UriKind.Relative));
        }
        private async void _tooltip_Tapimg(object sender, System.Windows.Input.GestureEventArgs e)
        {
            Image  item         = (Image)sender;
            string selecteditem = item.Tag.ToString();
            await WeBallAPI.getFive(selecteditem);

            if (WeBallAPI.Success == false)
            {
                return;
            }
            var selectedparkdata = WeBallAPI.FiveList.Where(s => s._id == selecteditem).ToList();

            if (selectedparkdata.Count > 0)
            {
                foreach (var items in selectedparkdata)
                {
                    ContextMenu contextMenu =
                        ContextMenuService.GetContextMenu(item);
                    contextMenu.DataContext = items;
                    if (contextMenu.Parent == null)
                    {
                        contextMenu.IsOpen = true;
                    }
                    break;
                }
            }
        }
Example #5
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            await WeBallAPI.inviteMatch(WeBallAPI.selectedFive, (string)(((Button)sender).CommandParameter));

            if (!WeBallAPI.Success)
            {
                return;
            }
        }
        private async void Menuitem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem item         = (MenuItem)sender;
            string   selecteditem = item.Tag.ToString();
            await WeBallAPI.getFive(selecteditem);

            var selectedparkdata = WeBallAPI.FiveList.Where(s => s._id == selecteditem).ToList();

            NavigationService.Navigate(new Uri("/FiveProfilePage.xaml?five=" + JsonConvert.SerializeObject(selectedparkdata[0]), UriKind.Relative));
        }
        private async Task tryLogin(object sender, RoutedEventArgs e)
        {
            string username;
            string password;

            username = boxEmail.Text;
            password = boxPassword.Password;
            System.Diagnostics.Debug.WriteLine(username + " and " + password);
            await WeBallAPI.login(username, password);
        }
        private async void Image_Tap(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Ceci va retirer cet ami. Continuer?", "Suppression", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {
                System.Diagnostics.Debug.WriteLine("removing");
                await WeBallAPI.eraseRelationship((string)(((Button)sender).CommandParameter));

                (Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/ProfilePage.xaml", UriKind.Relative));
            }
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            await WeBallAPI.getRelations();

            if (WeBallAPI.Success == false)
            {
                return;
            }
            ListFriends.ItemsSource = WeBallAPI.relations;
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            await WeBallAPI.getNotifications();

            if (WeBallAPI.Success == false)
            {
                return;
            }
            ListNotifs.ItemsSource          = WeBallAPI.notifs.notifications;
            ListFriendsRequests.ItemsSource = WeBallAPI.notifs.requests;
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            string parameter = string.Empty;

            if (NavigationContext.QueryString.TryGetValue("five", out parameter))
            {
                target = JsonConvert.DeserializeObject <Five>(parameter);
                FiveGrid.DataContext    = target;
                FiveGridBis.DataContext = target;
                await WeBallAPI.getMatches(target._id);
            }
        }
Example #12
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            string parameter;

            if (NavigationContext.QueryString.TryGetValue("user", out parameter))
            {
                if (parameter == WeBallAPI.currentUser._id)
                {
                    FirstNamePrompt.Text     = WeBallAPI.currentUser.fullName;
                    profileStack.DataContext = WeBallAPI.currentUser;
                }
                else
                {
                    await WeBallAPI.getUser(parameter);

                    addFriend.Opacity   = 100;
                    addFriend.IsEnabled = true;
                    if (WeBallAPI.Success == false)
                    {
                        return;
                    }

/*                    if (WeBallAPI.profileUser.relationStatus.isRelation == 0)
 *                  {
 *                      addFriend.Opacity = 100;
 *                      GridAdd.Background = new SolidColorBrush(Colors.Orange);
 *                  }
 *                  else if (WeBallAPI.profileUser.relationStatus.isRelation == 2)
 *                  {
 *                      addFriend.Opacity = 100;
 *                      GridAdd.Background = new SolidColorBrush(Colors.Green);
 *                  }
 *                  else
 *                  {
 *                      addFriend.Opacity = 100;
 *                      addFriend.IsEnabled = true;
 *                  }*/
                    FirstNamePrompt.Text     = WeBallAPI.profileUser.fullName;
                    profileStack.DataContext = WeBallAPI.profileUser;
                }
            }
            else
            {
                await WeBallAPI.me();

                if (WeBallAPI.Success == false)
                {
                    return;
                }
                FirstNamePrompt.Text     = WeBallAPI.currentUser.fullName;
                profileStack.DataContext = WeBallAPI.currentUser;
            }
        }
Example #13
0
        private async void Image_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (searchQuery.Text.Length >= 3)
            {
                await WeBallAPI.searchUser(searchQuery.Text);

                if (WeBallAPI.Success == false)
                {
                    return;
                }
                ListSearch.ItemsSource = WeBallAPI.search;
            }
        }
        private async void ListFive_DoubleTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            var  list = sender as ListBox;
            Five obj  = list.SelectedItem as Five;

            if (obj != null)
            {
                await WeBallAPI.getFive(obj._id);

                var selectedparkdata = WeBallAPI.FiveList.Where(s => s._id == obj._id).ToList();
                NavigationService.Navigate(new Uri("/FiveProfilePage.xaml?five=" + JsonConvert.SerializeObject(selectedparkdata[0]), UriKind.Relative));
            }
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            string MatchId = (string)(((Button)sender).CommandParameter);

            if (MatchId != null)
            {
                await WeBallAPI.getMatch(MatchId, 1);
                System.Diagnostics.Debug.WriteLine("aaa");
                if (WeBallAPI.Success == false)
                    return;
                Match currentMatch = WeBallAPI.FiveList[WeBallAPI.returnedIndex].matchs.FirstOrDefault(s => s._id == MatchId);
                (Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/ProfileMatchPage.xaml?match=" + JsonConvert.SerializeObject(currentMatch) + "&five=" + WeBallAPI.FiveList[WeBallAPI.returnedIndex]._id, UriKind.Relative));
            }
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            string parameter;

            if (NavigationContext.QueryString.TryGetValue("match", out parameter))
            {
                match = JsonConvert.DeserializeObject <Match>(parameter);
            }
            await WeBallAPI.getRelations();

            if (WeBallAPI.Success == false)
            {
                return;
            }
            ListFriends.ItemsSource = WeBallAPI.relations;
        }
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (teamId == -1)
            {
                return;
            }
            await WeBallAPI.leaveMatch(match.teams[teamId]._id);

            if (WeBallAPI.Success == false)
            {
                return;
            }
            MessageBoxResult result =
                MessageBox.Show("Match quitté!",
                                "Confirmation",
                                MessageBoxButton.OK);

            NavigationService.Navigate(new Uri("/FiveProfilePage.xaml?five=" + JsonConvert.SerializeObject(five), UriKind.Relative));
        }
        private async void buttonLogin_Click(object sender, RoutedEventArgs e)
        {
            await tryLogin(sender, e);

            if (WeBallAPI.Success == false)
            {
                return;
            }
            await WeBallAPI.me();

            if (WeBallAPI.Success == false)
            {
                return;
            }
            System.Diagnostics.Debug.WriteLine("Logging in");
            if (!string.IsNullOrEmpty(WeBallAPI.Token))
            {
                try {
                    await WeBallAPI.updatePos();
                }
                catch (Exception exception)
                {
                    MessageBoxResult result =
                        MessageBox.Show("Problème de localisation, vérifiez vos paramètres.",
                                        "Location",
                                        MessageBoxButton.OK);
                    return;
                }
                System.Diagnostics.Debug.WriteLine("get Fives");
                await WeBallAPI.getFives();

                if (WeBallAPI.Success == false)
                {
                    return;
                }
                NavigationService.Navigate(new Uri("/ProfilePage.xaml", UriKind.Relative));
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Problem");
            }
        }
Example #19
0
        private async void ListMatchs_DoubleTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            Match   match;
            creator creator;

            match = (Match)(((ListBox)sender).SelectedItem);
            if (match != null)
            {
//                creator = match.createdBy;
                await WeBallAPI.getMatch(match._id);

                if (WeBallAPI.Success == false)
                {
                    return;
                }
                var five = WeBallAPI.FiveList.FirstOrDefault(s => s._id == fiveId);

                NavigationService.Navigate(new Uri("/ProfileMatchPage.xaml?match=" + JsonConvert.SerializeObject(five.matchs.FirstOrDefault(s => s._id == match._id)) + "&five=" + fiveId, UriKind.Relative));
            }
        }
        public static async Task updatePos()
        {
            Geolocator geolocator = new Geolocator();

            geolocator.DesiredAccuracyInMeters = 50;
            float[] coord = new float[2];
            try
            {
                Geoposition geoposition = await geolocator.GetGeopositionAsync(
                    maximumAge : TimeSpan.FromMinutes(5),
                    timeout : TimeSpan.FromSeconds(10)
                    );

                coord[0] = float.Parse(geoposition.Coordinate.Latitude.ToString("0.00"));
                coord[1] = float.Parse(geoposition.Coordinate.Longitude.ToString("0.00"));
            }
            catch (Exception ex)
            {
                if ((uint)ex.HResult == 0x80004004)
                {
                    System.Diagnostics.Debug.WriteLine("Cant get location");
                    coord[0] = 50.0f;
                    coord[1] = 50.0f;
                    throw new Exception();
                }
                else
                {
                    if (IsolatedStorageSettings.ApplicationSettings.Contains("LastLocation"))
                    {
                        coord = (float[])IsolatedStorageSettings.ApplicationSettings["LastLocation"];
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
            }
            WeBallAPI.currentUser.gps = coord;
            IsolatedStorageSettings.ApplicationSettings["LastLocation"] = coord;
            await WeBallAPI.updateUser();
        }
Example #21
0
        private async void doRegister()
        {
            if (checkRegister())
            {
                Geolocator geolocator = new Geolocator();
                geolocator.DesiredAccuracyInMeters = 50;
                float[] coord = new float[2];
                try
                {
                    Geoposition geoposition = await geolocator.GetGeopositionAsync(
                        maximumAge : TimeSpan.FromMinutes(5),
                        timeout : TimeSpan.FromSeconds(10)
                        );

                    coord[0] = float.Parse(geoposition.Coordinate.Latitude.ToString("0.00"));
                    coord[1] = float.Parse(geoposition.Coordinate.Longitude.ToString("0.00"));
                }
                catch (Exception ex)
                {
                    if ((uint)ex.HResult == 0x80004004)
                    {
                        System.Diagnostics.Debug.WriteLine("Cant get location");
                        coord[0] = 50.0f;
                        coord[1] = 50.0f;
                    }
                    else
                    {
                    }
                }
                char[]   delimiters     = { '/', ' ' };
                string[] parsedBirthday = BoxBirthday.Value.ToString().Split(delimiters);
                string   birthday       = parsedBirthday[2] + ',' + parsedBirthday[1] + ',' + parsedBirthday[0];
                await WeBallAPI.register(BoxPassword.Password, BoxEmail.Text,
                                         BoxNom_Complet.Text, birthday, imageInput.Source, coord);

                NavigationService.Navigate(new Uri("/LoginPage.xaml", UriKind.Relative));
            }
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            if (OldPasswordBox.Password.Length == 0)
            {
                setPopup("Merci de saisir votre ancien mot de passe.");
                return;
            }
            if (OldPasswordBox.Password != WeBallAPI.currentUser.password)
            {
                setPopup("Ancien mot de passe incorrect.");
                return;
            }
            if (NewPasswordBox.Password.Length <= 2)
            {
                setPopup("Nouveau mot de passe trop court.");
                return;
            }
            if (NewPasswordBox.Password != VerifyPassword.Password)
            {
                setPopup("Mot de passe différent de la validation.");
                return;
            }
            WeBallAPI.currentUser.password = NewPasswordBox.Password;
            await WeBallAPI.updateUser();

            if (WeBallAPI.Success == false)
            {
                return;
            }
            MessageBoxResult result =
                MessageBox.Show("Mot de passe changé!",
                                "Confirmation",
                                MessageBoxButton.OK);

            NavigationService.Navigate(new Uri("/ProfilePage.xaml", UriKind.Relative));
        }
Example #23
0
        private async void ValidateMatch(object sender, RoutedEventArgs e)
        {
            List <Field>  fields        = five.fields;
            string        selectedField = "";
            List <string> invalid       = new List <string>();

            if (NameBox.Text == "" || NumberBox.Text == "")
            {
                setPopup("Merci de renseinger tous les champs!");
            }
            else if (Int32.Parse(NumberBox.Text) < 2 || Int32.Parse(NumberBox.Text) > 5)
            {
                setPopup("Merci de renseinger un nombre de joueurs entre 2 et 5!");
            }
            else if (DateTime.Compare(date, DateTime.Today) < 0)
            {
                setPopup("Date du match dépassée!");
            }
            else
            {
                if (five != null)
                {
                    foreach (Match elem in (five.matchs.Where(match => (match.startDate.Day == date.Day) &&
                                                              (match.startDate.Month == date.Month) &&
                                                              (match.startDate.Year == date.Year) &&
                                                              (match.startDate.Hour == ((DateTime)BoxHour.Value).Hour)).ToList()))
                    {
                        if (!invalid.Any(s => (s == elem.field)))
                        {
                            invalid.Add(elem.field);
                        }
                    }
                    foreach (Field field in fields)
                    {
                        if (!invalid.Any(s => (s == field._id)))
                        {
                            selectedField = field._id;
                        }
                    }
                    if (selectedField == "")
                    {
                        setPopup("Impossible de créer un match a cette horaire.");
                    }
                    else
                    {
                        await WeBallAPI.addMatch(NameBox.Text, date, (DateTime)BoxHour.Value, ((DateTime)(BoxHour.Value)).AddHours(1),
                                                 Int32.Parse(NumberBox.Text) * 2, selectedField);

                        if (!WeBallAPI.Success)
                        {
                            setPopup("Erreur. Impossible de créer un match!");
                        }
                        else
                        {
                            await WeBallAPI.getFive(five._id);

                            var selectedparkdata = WeBallAPI.FiveList.Where(s => s._id == five._id).ToList();
                            NavigationService.Navigate(new Uri("/FiveProfilePage.xaml?five=" + JsonConvert.SerializeObject(selectedparkdata[0]), UriKind.Relative));
                        }
                    }
                }
            }
        }
Example #24
0
 private async void Button_Click(object sender, RoutedEventArgs e)
 {
     match.name      = MatchName.Text;
     match.startDate = MatchTime.Value.Value;
     await WeBallAPI.updateMatch(match, int.Parse(MatchLength.Text));
 }
 private async void Button_Click_1(object sender, RoutedEventArgs e)
 {
     await WeBallAPI.denyRequest((string)(((Button)sender).CommandParameter));
 }
Example #26
0
 private async void addFriend_Click(object sender, RoutedEventArgs e)
 {
     await WeBallAPI.sendRequest(WeBallAPI.profileUser._id);
 }
Example #27
0
        private async void ValidateMatch(object sender, RoutedEventArgs e)
        {
            List <Field>  fields        = five.fields;
            string        selectedField = "";
            List <string> invalid       = new List <string>();

            if (NameBox.Text == "" || NumberBox.Text == "") // you may want to check for null too. Use String.IsEmptyOrNull
            {
                setPopup("Merci de renseinger tous les champs!");
            }
            else if (Int32.Parse(NumberBox.Text) < 2 || Int32.Parse(NumberBox.Text) > 5) // tryparse allow to handle error
            {
                setPopup("Merci de renseinger un nombre de joueurs entre 2 et 5!");
            }
            else if (DateTime.Compare(date, DateTime.Today) < 0)
            {
                setPopup("Date du match dépassée!");
            }
            else
            {
                if (five != null)
                {
                    foreach (Match elem in (five.matchs.Where(match =>
                                                              (match.startDate.Day == date.Day) && // you can use a DateTime comparer
                                                              (match.startDate.Month == date.Month) &&
                                                              (match.startDate.Year == date.Year) &&
                                                              (match.startDate.Hour == date.Hour)).ToList())) // ToList() is useless here
                    {
                        if (!invalid.Any(s => s == elem.field))                                               // you can add this to the where cause and remove the foreach
                        {
                            invalid.Add(elem.field);
                        }
                    }

                    foreach (Field field in fields)
                    {
                        if (!invalid.Any(s => s == field._id)) // wtf?
                        {
                            selectedField = field._id;
                        }
                    }
                    //if (String.IsNullOrEmpty(selectedField)) ;)
                    if (selectedField == "")
                    {
                        setPopup("Impossible de créer un match a cette horaire.");
                    }
                    else
                    {
                        await WeBallAPI.addMatch(NameBox.Text, date, date.AddHours(1),
                                                 Int32.Parse(NumberBox.Text) * 2, selectedField);

                        if (!WeBallAPI.Success)
                        {
                            setPopup("Erreur. Impossible de créer un match !");
                        }
                        else
                        {
                            await WeBallAPI.getFive(five._id);

                            if (WeBallAPI.Success == false)
                            {
                                return;
                            }
                            var selectedparkdata    = WeBallAPI.FiveList.Where(s => s._id == five._id).ToList();
                            MessageBoxResult result =
                                MessageBox.Show("Match créé!",
                                                "Confirmation",
                                                MessageBoxButton.OK);
                            NavigationService.Navigate(new Uri("/FiveProfilePage.xaml?five=" + JsonConvert.SerializeObject(selectedparkdata[0]), UriKind.Relative));
                        }
                    }
                }
            }
        }