//Generuj Excel void generuj_excel(object sender, EventArgs e) { //Create an instance of ExcelEngine. using (ExcelEngine excelEngine = new ExcelEngine()) { //Set the default application version as Excel 2013. excelEngine.Excel.DefaultVersion = ExcelVersion.Excel2013; //Create a workbook with a worksheet IWorkbook workbook = excelEngine.Excel.Workbooks.Create(1); //Access first worksheet from the workbook instance. IWorksheet worksheet = workbook.Worksheets[0]; //Adding text Zarzadzanie.wyslijExcel(ref worksheet); //Save the workbook to stream in xlsx format. MemoryStream stream = new MemoryStream(); workbook.SaveAs(stream); workbook.Close(); //Save the stream as a file in the device and invoke it for viewing SaveAndroid androidSave = new SaveAndroid(); //androidSave.SaveAndView("CreateExcel.xlsx", "application/msexcel", stream, this); androidSave.JustSave("CreateExcel.xlsx", "application/msexcel", stream, this); } }
public void HandleResult(ZXing.Result rawResult) { String dodany = rawResult.ToString(); //Toast.MakeText(qrakcja, dodany, ToastLength.Long).Show(); //Dodaj kod do bazy i zapisz grę Zarzadzanie.danePatroli.Add(new Patrol(dodany)); Zarzadzanie.SaveGame(); Akcje.wyswietlPodsumowanie(); qrakcja.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 dodajPatrol = FindViewById <Button>(Resource.Id.btndodaj); powrot = FindViewById <Button>(Resource.Id.btnwroc); excel_gen = FindViewById <Button>(Resource.Id.btn_excel); ranking = FindViewById <TextView>(Resource.Id.ranking); podsumowanie = FindViewById <TextView>(Resource.Id.listap); //Dodanie funkcji do przycisku Zakoncz gre/Powrot do menu powrot.Click += (sender, e) => { Zarzadzanie.czyWynikiTrwaja = false; Zarzadzanie.SaveGame(); var intent = new Intent(this, typeof(Poczatek)); StartActivity(intent); this.Finish(); }; //Dodanie funkcji do przycisku Zakoncz gre/Powrot do menu dodajPatrol.Click += (sender, e) => { Zarzadzanie.czyWynikiTrwaja = true; var intent = new Intent(this, typeof(QRakcja)); StartActivity(intent); }; //Dodanie funkcji do przycisku generuj excel excel_gen.Click += generuj_excel; //Wyswietl wyniki wyswietlPodsumowanie(); }
//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 { //Okno dialogowe potwierdzające zbieranie nowych wyników 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 rozpocząć zbieranie wyników od nowa?"); alert.SetButton("TAK", (c, ev) => { Zarzadzanie.reset(); Zarzadzanie.czyWynikiTrwaja = true; Zarzadzanie.SaveGame(); var intent = new Intent(this, typeof(Akcje)); StartActivity(intent); this.Finish(); }); alert.SetButton2("ANULUJ", (c, ev) => { }); alert.Show(); } } }; 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.czyWynikiTrwaja) { var intent = new Intent(this, typeof(Akcje)); StartActivity(intent); this.Finish(); } } } }
//Wyświetla podsumowanie na koniec public static void wyswietlPodsumowanie() { ranking.Text = Zarzadzanie.ranking(); podsumowanie.Text = Zarzadzanie.drukujPatrole(); }
//Funkcja wywołująca zapisywanie w kluczowych momentach (np przed zabiciem obiektu klasy Akcje) protected override void OnSaveInstanceState(Bundle outState) { Zarzadzanie.SaveGame(); base.OnSaveInstanceState(outState); }