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;
                }
            }
        }
        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 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));
            }
        }
示例#4
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));
                        }
                    }
                }
            }
        }
示例#5
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));
                        }
                    }
                }
            }
        }