void OnSelection(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem == null) { return; } selektierteAufgabe = (Aufgabe)e.SelectedItem; }
public MainPage() { InitializeComponent(); try { string url = "https://cloud-11.datenbanken24.de/apps/tab/public.nsf/mobileRequest?openagent&callback=db24&FN=F3"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "GET"; request.ContentType = "application/jsonp"; HttpWebResponse myResp = (HttpWebResponse)request.GetResponse(); string responseText; using (var response = request.GetResponse()) { using (var reader = new StreamReader(response.GetResponseStream())) { responseText = reader.ReadToEnd(); int anzahl = CountChar(responseText, '{'); int endPosition = 1; int startPosition = 0; string word42 = ""; Task[] arrayt = new Task[anzahl - 1]; Aufgabe[] arraya = new Aufgabe[anzahl - 1]; int y = 0; do { startPosition = responseText.IndexOf("{", endPosition) + 1; endPosition = responseText.IndexOf("}", startPosition); string word22 = responseText.Substring(startPosition, endPosition - startPosition); string word32 = word22.Replace("\"", "\'"); word42 = "{ " + word32 + "}"; arrayt[y] = JsonConvert.DeserializeObject <Task>(word42); arraya[y] = new Aufgabe { Quartier = ConvertF7_to_Quartier(arrayt[y].F7), Kategorie = ConvertF1_to_Kategorie(arrayt[y].F1), Aufgabenbeschreibung = arrayt[y].F3, Kategoriebild = ConvertF1_to_Kategoriebild(arrayt[y].F1) }; y++; }while (y < anzahl - 1); var layout1 = new StackLayout { Padding = new Thickness(5, 10) }; layout1.BackgroundColor = Color.FromHex("e8e8e8"); var IconImage = new Image { Source = "ic_launcher_round.png", WidthRequest = 65, HeightRequest = 65, MinimumHeightRequest = 65, MinimumWidthRequest = 65, // VerticalOptions = LayoutOptions.Start, // HorizontalOptions = LayoutOptions.Start, // BackgroundColor = Color.White, //FromHex("94C123"), }; // layout1.HorizontalOptions = LayoutOptions.Fill; var label1 = new Label { Text = "Taschengeldbörse", TextColor = Color.FromHex("#2D8B29"), FontFamily = "Cookie", FontSize = 30, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center }; var ImpressumImageButton = new Image { Source = "icons8_information_100.png", WidthRequest = 25, HeightRequest = 25, MinimumHeightRequest = 25, MinimumWidthRequest = 25, // BackgroundColor = Color.FromHex("94C123"), }; var tapGestureRecognizer5 = new TapGestureRecognizer(); tapGestureRecognizer5.Command = new Command(ButtonImpressumClicked); ImpressumImageButton.GestureRecognizers.Add(tapGestureRecognizer5); var horizontalLayout2 = new StackLayout() { }; // BackgroundColor = Color.FromHex("94C123") }; horizontalLayout2.Orientation = StackOrientation.Horizontal; horizontalLayout2.HorizontalOptions = LayoutOptions.Center; horizontalLayout2.Children.Add(IconImage); horizontalLayout2.Children.Add(label1); horizontalLayout2.Children.Add(ImpressumImageButton); layout1.Children.Add(horizontalLayout2); // layout1.Children.Add(label1); aufgaben = new ObservableCollection <Aufgabe>(); ListView lstView = new ListView(); lstView.RowHeight = 100; lstView.ItemTapped += OnTap; lstView.ItemSelected += OnSelection; this.Title = "Aufgaben der Taschengeldbörse Münster"; lstView.ItemTemplate = new DataTemplate(typeof(CustomAufgabeCell)); var tap2 = new TapGestureRecognizer(); tap2.NumberOfTapsRequired = 2; tap2.Command = new Command(ButtonTap2Clicked); lstView.GestureRecognizers.Add(tap2); int i = 0; do { aufgaben.Add(arraya[i]); i++; }while (i < anzahl - 1); lstView.ItemsSource = aufgaben; layout1.Children.Add(lstView); var CallImageButton = new Image { Source = "icons8telefon100.png", WidthRequest = 75, HeightRequest = 75, MinimumHeightRequest = 75, MinimumWidthRequest = 75, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, BackgroundColor = Color.FromHex("94C123"), }; var tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.Command = new Command(ButtonCallClicked); CallImageButton.GestureRecognizers.Add(tapGestureRecognizer); var SMSImageButton = new Image { Source = "icons8sms100.png", WidthRequest = 75, HeightRequest = 75, MinimumHeightRequest = 75, MinimumWidthRequest = 75, BackgroundColor = Color.FromHex("94C123"), }; var tapGestureRecognizer2 = new TapGestureRecognizer(); tapGestureRecognizer2.Command = new Command(ButtonSMSClicked); SMSImageButton.GestureRecognizers.Add(tapGestureRecognizer2); var MailImageButton = new Image { Source = "icons8nachricht100.png", WidthRequest = 75, HeightRequest = 75, MinimumHeightRequest = 75, MinimumWidthRequest = 75, BackgroundColor = Color.FromHex("94C123"), }; var tapGestureRecognizer3 = new TapGestureRecognizer(); tapGestureRecognizer3.Command = new Command(ButtonMailClicked); MailImageButton.GestureRecognizers.Add(tapGestureRecognizer3); var InfoImageButton = new Image { Source = "icons8_info_100_ugr.png", WidthRequest = 75, HeightRequest = 75, MinimumHeightRequest = 75, MinimumWidthRequest = 75, BackgroundColor = Color.FromHex("94C123"), }; var tapGestureRecognizer4 = new TapGestureRecognizer(); tapGestureRecognizer4.Command = new Command(ButtonInfoClicked); InfoImageButton.GestureRecognizers.Add(tapGestureRecognizer4); var horizontalLayout = new StackLayout() { BackgroundColor = Color.White }; horizontalLayout.Orientation = StackOrientation.Horizontal; horizontalLayout.HorizontalOptions = LayoutOptions.Center; horizontalLayout.Children.Add(MailImageButton); horizontalLayout.Children.Add(CallImageButton); horizontalLayout.Children.Add(SMSImageButton); horizontalLayout.Children.Add(InfoImageButton); layout1.Children.Add(horizontalLayout); this.Content = layout1; } } } catch (WebException exception) { string responseText; using (var reader = new StreamReader(exception.Response.GetResponseStream())) { responseText = reader.ReadToEnd(); DisplayAlert(responseText, "Fehler", "OK"); } } }