async void TakePhoto(object sender, System.EventArgs e) { string dpPath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "ScoutingApp.db3"); var db = new SQLiteConnection(dpPath); db.CreateTable <ISTable>(); ISTable tbl = new ISTable(); await CrossMedia.Current.Initialize(); var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions { PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium, CompressionQuality = 40, Name = "icon.jpg", Directory = "sample" }); if (file == null) { return; } byte[] imageArray = System.IO.File.ReadAllBytes(file.Path); tbl.Image = imageArray; db.Insert(tbl); Bitmap bitmap = BitmapFactory.DecodeByteArray(tbl.Image, 0, tbl.Image.Length); robotImage.SetImageBitmap(bitmap); LayoutInflater layoutInflater = LayoutInflater.From(this); View view = layoutInflater.Inflate(Resource.Layout.photo_alert, null); Android.Support.V7.App.AlertDialog.Builder alertbuilder = new Android.Support.V7.App.AlertDialog.Builder(this); alertbuilder.SetView(view); var userdata = view.FindViewById <EditText>(Resource.Id.edittextT); alertbuilder.SetCancelable(false).SetPositiveButton("Submit", delegate { int numberT; Int32.TryParse(userdata.Text, out numberT); tbl.Team = numberT; db.Insert(tbl); string numstring = tbl.Team.ToString(); test.Text = numstring; ScoreTest.Text = tbl.Score.ToString(); Toast.MakeText(this, "Submit Input: " + userdata.Text, ToastLength.Short).Show(); //TakePhoto(); }); Android.Support.V7.App.AlertDialog dialog = alertbuilder.Create(); dialog.Show(); }
protected override void OnCreate(Bundle savedInstanceState) { string dpPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "ScoutingApp.db3"); var db = new SQLiteConnection(dpPath); db.CreateTable <ISTable>(); ISTable tbl = new ISTable(); db.CreateTable <PitsTable>(); PitsTable pits = new PitsTable(); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.scores_layout); listviewI = FindViewById <ListView>(Resource.Id.listViewIS); listis = db.Table <ISTable>().OrderBy(item => item.Team).ToList(); ImageViewAdapter adapterI = new ImageViewAdapter(this, listis); listviewI.Adapter = adapterI; }
private void Create_Click(object sender, EventArgs e) { try { string dpPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "ScoutingApp.db3"); var db = new SQLiteConnection(dpPath); db.CreateTable <PitsTable>(); PitsTable tbl = new PitsTable(); db.CreateTable <ISTable>(); ISTable ist = new ISTable(); ScoresTable st = new ScoresTable(); int finalScore; int firstScore; int secondScore; secondScore = 0; finalScore = 0; firstScore = 0; int number = Int32.Parse(teamNumber.Text); tbl.Team = number; st.Team = number; ist.Team = number; //interesting issue-- it's not storing anything for the ints tbl.RobotWeight = weight.Text; if (mech.Checked) { tbl.Drivetrain = "Mechanum"; firstScore = 1; } if (holo.Checked) { tbl.Drivetrain = "Holonomic"; firstScore = 2; } if (tank.Checked) { tbl.Drivetrain = "Tank"; firstScore = 3; } if (swerve.Checked) { tbl.Drivetrain = "Swerve"; firstScore = 4; } if (slide.Checked) { tbl.Drivetrain = "Slide"; firstScore = 0; } tbl.Notes = notes.Text; db.Insert(tbl); Toast.MakeText(this, "Record Added Successfully", ToastLength.Short).Show(); items = db.Table <PitsTable>().OrderBy(item => item.Team).ToList(); PitsViewAdapter adapterP = new PitsViewAdapter(this, items); listviewP.Adapter = adapterP; int numberW = Int32.Parse(weight.Text); if (numberW < 50) { secondScore = 1; } if (numberW >= 50) { secondScore = 3; } finalScore = firstScore + secondScore; ist.Score = finalScore; st.TotalScore = finalScore; System.Diagnostics.Debug.WriteLine(finalScore); db.Insert(tbl); db.Insert(ist); db.Insert(st); } catch (Exception ex) { Toast.MakeText(this, ex.ToString(), ToastLength.Long).Show(); } }