//Metoda wywoływana podczas tworzenia obiektu protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.poczatek_); //Sprawdź pozwolenia string[] PERMISSIONS = { "android.permission.READ_EXTERNAL_STORAGE", "android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.CAMERA" }; var permission = ContextCompat.CheckSelfPermission(this, "android.permission.WRITE_EXTERNAL_STORAGE"); var permissionread = ContextCompat.CheckSelfPermission(this, "android.permission.READ_EXTERNAL_STORAGE"); var permissioncamera = ContextCompat.CheckSelfPermission(this, "android.permission.CAMERA"); if (permission != Permission.Granted || permissionread != Permission.Granted) { ActivityCompat.RequestPermissions(this, PERMISSIONS, 1); } if (permissioncamera != Permission.Granted) { ActivityCompat.RequestPermissions(this, PERMISSIONS, 2); } //Przypisz elementy interfejsu do zmiennych Button NowaGra = FindViewById <Button>(Resource.Id.button1); Button Wczytaj = FindViewById <Button>(Resource.Id.button2); //Przypisz przyciskom funkcje NowaGra.Click += (sender, e) => { if (permission != Permission.Granted || permissionread != Permission.Granted) { ActivityCompat.RequestPermissions(this, PERMISSIONS, 1); var intent = new Intent(this, typeof(Poczatek)); Toast.MakeText(this, "Czy na pewno zaakceptowałeś zgody?", ToastLength.Long).Show(); StartActivity(intent); this.Finish(); } else { if (permissioncamera != Permission.Granted) { ActivityCompat.RequestPermissions(this, PERMISSIONS, 2); var intent = new Intent(this, typeof(Poczatek)); Toast.MakeText(this, "Czy na pewno zaakceptowałeś zgody?", ToastLength.Long).Show(); StartActivity(intent); this.Finish(); } else { var intent = new Intent(this, typeof(NazwaIczas)); StartActivity(intent); this.Finish(); } } }; Wczytaj.Click += (sender, e) => { if (permission != Permission.Granted || permissionread != Permission.Granted) { ActivityCompat.RequestPermissions(this, PERMISSIONS, 1); var intent = new Intent(this, typeof(Poczatek)); Toast.MakeText(this, "Czy na pewno zaakceptowałeś zgody?", ToastLength.Long).Show(); StartActivity(intent); this.Finish(); } else { if (permissioncamera != Permission.Granted) { ActivityCompat.RequestPermissions(this, PERMISSIONS, 2); var intent = new Intent(this, typeof(Poczatek)); Toast.MakeText(this, "Czy na pewno zaakceptowałeś zgody?", ToastLength.Long).Show(); StartActivity(intent); this.Finish(); } else { var intent = new Intent(this, typeof(Akcje)); StartActivity(intent); this.Finish(); } } }; if (permission != Permission.Granted || permissionread != Permission.Granted) { ActivityCompat.RequestPermissions(this, PERMISSIONS, 1); } else { if (permissioncamera != Permission.Granted) { ActivityCompat.RequestPermissions(this, PERMISSIONS, 2); } else { Zarzadzanie.ReadGame(); if (Zarzadzanie.czyGraTrwa) { var intent = new Intent(this, typeof(Akcje)); StartActivity(intent); this.Finish(); } } } }
//Metoda wywołuje się w momencie tworzenia obiektu protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.akcje_); //Wczytaj dane Zarzadzanie.ReadGame(); //Przypisz elementy interfejsu do zmiennych roboczych pk[0] = FindViewById <Button>(Resource.Id.button1); pk[1] = FindViewById <Button>(Resource.Id.button2); pk[2] = FindViewById <Button>(Resource.Id.button3); pk[3] = FindViewById <Button>(Resource.Id.button4); pk[4] = FindViewById <Button>(Resource.Id.button5); pk[5] = FindViewById <Button>(Resource.Id.button6); pk[6] = FindViewById <Button>(Resource.Id.button7); pk[7] = FindViewById <Button>(Resource.Id.button8); pk[8] = FindViewById <Button>(Resource.Id.button9); pk[9] = FindViewById <Button>(Resource.Id.button10); pk[10] = FindViewById <Button>(Resource.Id.button11); pk[11] = FindViewById <Button>(Resource.Id.button12); pk[12] = FindViewById <Button>(Resource.Id.button13); pk[13] = FindViewById <Button>(Resource.Id.button14); pk[14] = FindViewById <Button>(Resource.Id.button15); zakoncz = FindViewById <Button>(Resource.Id.buttonZakoncz); empty = FindViewById <Button>(Resource.Id.buttonEmpty); TextView textGodz = FindViewById <TextView>(Resource.Id.textView1); TextView podsumowanie = FindViewById <TextView>(Resource.Id.podsumowanie); ImageView obrazek = FindViewById <ImageView>(Resource.Id.imageView1); //Ustaw nagłówek karty patrolu textGodz.Text = Zarzadzanie.nazwaPatrolu + "\nGodzina startu: " + Zarzadzanie.czasRozpoczecia.ToString(formatGodzina, provider) + " (" + Zarzadzanie.minutaStartowa.ToString(formatGodzina, provider) + ")"; //Ustaw Legendę na dole ekranu string zasady = "Legenda:\nzielony - zebrany Punkt Kontrolny\nżółty - poprawiony Punkt Kontrolny (10 punktów karnych za każdną poprawkę)"; zasady += "\n\nZasady:"; zasady += "\nprawidłowy Punkt Kontrolny - 0 punktów karnych"; zasady += "\nPunkt Stowarzyszony - 25 punktów karnych"; zasady += "\nbrak Punktu Kontrolnego - 90 punktów karnych"; zasady += "\nPunkt Mylny lub o innym numerze - 90+60 punktów karnych\n"; podsumowanie.Text = zasady; //Ustaw obrazek obrazek.SetImageResource(Resource.Drawable.keh_logo); obrazek.Visibility = Android.Views.ViewStates.Gone; //Dodanie funkcji do przycisków do skanerów kodów QR for (int i = 0; i < Zarzadzanie.liczbaPunktow; i++) { //string nr = (i + 1).ToString(); pk[i].Click += (sender, e) => { string nr = ((Button)sender).Text.Split(' ')[1]; wywolajQR(nr); }; } //Dodanie funkcji do przycisku Zakoncz gre/Powrot do menu zakoncz.Click += (sender, e) => { if (Zarzadzanie.czyGraTrwa) { //Okno dialogowe potwierdzające zakończenie gry Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this); Android.App.AlertDialog alert = dialog.Create(); alert.SetTitle("Uwaga!"); alert.SetMessage("Czy na pewno chcesz zakończyć grę?"); alert.SetButton("TAK", (c, ev) => { string zapisGry; //Policz i ustaw falgi zapisGry = Zarzadzanie.zakonczenie(); //Wyswietl wyniki wyswietlPodsumowanie(podsumowanie); //Zmien funkcjonalnosc przycisku zakoncz.Text = "Powrót do menu"; //Generuj i ustaw obrazek z kodem QR generujQR(zapisGry, obrazek); }); alert.SetButton2("ANULUJ", (c, ev) => { }); alert.Show(); } else { var intent = new Intent(this, typeof(Poczatek)); StartActivity(intent); this.Finish(); } }; //Pokoloruj kartę odpowiedzi empty.SetBackgroundColor(Color.White); Zarzadzanie.ustawKolory(); if (Zarzadzanie.czyGraTrwa == false) { //Wyswietl wyniki wyswietlPodsumowanie(podsumowanie); //Zmien funkcjonalnosc przycisku zakoncz.Text = "Powrót do menu"; //Generuj i ustaw obrazek z kodem QR generujQR(Zarzadzanie.ReadGame(), obrazek); } }