Beispiel #1
0
 private void ButtonClicked(object sender, EventArgs e)
 {
     //decide which button on the form was clicked
     if ((sender as Button) == bCreate)
     {
         //convert DateTime format to a readable string
         getStartDate = startDate.DateTime.ToString("MM/dd/yyyy");
         getEndDate   = endDate.DateTime.ToString("MM/dd/yyyy");
         eventName    = txtEventName.Text;
         try
         {
             //make sure user inputted an event name and id
             if (eventName != null && eventName != "" && txtEventID.Text != null && txtEventID.Text != "")
             {
                 //create new event and add it to the databse
                 newEvent = new Event(getStartDate, getEndDate, eventName, int.Parse(txtEventID.Text), false);
                 eData.AddEvent(newEvent);
                 //go back to the home screen and finish this activity
                 StartActivity(typeof(MainActivity));
                 Finish();
             }
             else
             {
                 Popup.Single("Alert", "Please Enter Event Details", "OK", this);
             }
         }
         //if the database has a duplicate event id, it will throw an exception not allowing the new one to be added
         catch
         {
             Popup.Single("Alert", "Duplicate Event ID Detected.", "OK", this);
         }
     }
 }
Beispiel #2
0
 private void ButtonClicked(object sender, EventArgs e)
 {
     //decide which button was clicked
     if ((sender as Button) == bFinish)
     {
         try
         {
             matchData = new MatchData(
                 currentEvent.eventName,
                 currentEvent.startDate,
                 currentEvent.endDate,
                 int.Parse(vMatchNumber.Text),
                 int.Parse(vTeamNumber.Text),
                 spinnerIndex,
                 table.Checked,
                 sandstormMode,
                 sandHatch.Checked,
                 sandCargo.Checked,
                 sandHab.Checked,
                 sandLevel,
                 cargo.Checked,
                 cargoWell.Checked,
                 cargoBarely.Checked,
                 hatch.Checked,
                 hatchWell.Checked,
                 hatchBarely.Checked,
                 climb,
                 goodDrivers,
                 wouldRecommend,
                 result,
                 comments.Text,
                 true, //keep it current
                 currentEvent.eventID);
             if (vMatchNumber.Text != currentMatch.matchNumber.ToString())
             {
                 //modify if changing match number, check for duplicate first
                 eData.AddMatchData(matchData);
                 eData.DeleteMatchData(currentMatch.ID);
             }
             else
             {
                 //modify the match (without changing ID/match number)
                 eData.DeleteMatchData(currentMatch.ID);
                 eData.AddMatchData(matchData);
             }
             //go back to the main scouting page
             StartActivity(typeof(ViewMatchData));
             Finish();
         }
         //not putting a match or team number will throw an exception; so will a duplicate match number since the MatchData id
         //is based off of match number
         catch
         {
             Popup.Single("Alert", "Please Enter At Least the Match and Team Number//Possible Duplicate Match Number", "OK", this);
         }
     }
 }
Beispiel #3
0
 private void SpinnerClick(object sender, ItemSelectedEventArgs e)
 {
     spinnerIndex  = e.Position;
     selectedEvent = eData.GetEvent(eData.EventIDList()[spinnerIndex]);
     //clear QR codes from previous events
     QR1.SetImageBitmap(null);
     QR2.SetImageBitmap(null);
     Popup.Single("Alert", "Selected event Changed. Please click generate again to update the data", "OK", this);
 }
Beispiel #4
0
 private void gridClicked(object sender, ItemClickEventArgs e)
 {
     //make sure a team number on the left was selected
     if (e.Position % 7 == 0 && e.Position != 0)
     {
         CompiledTeamIndex currentIndex = new CompiledTeamIndex((e.Position / 7) - 1);
         //set where the team is in the compiled event data multidimensional lsit
         eData.setTeamIndex(currentIndex);
         StartActivity(typeof(DetailedTeamData));
     }
     else
     {
         Popup.Single("Alert", "Please click a team number to view detailed data", "OK", this);
     }
 }
Beispiel #5
0
 private void ButtonClicked(object sender, EventArgs e)
 {
     //decide which button was clicked
     if ((sender as Button) == bFinish)
     {
         try
         {
             matchData = new MatchData(
                 currentEvent.eventName,
                 currentEvent.startDate,
                 currentEvent.endDate,
                 int.Parse(vMatchNumber.Text),
                 int.Parse(vTeamNumber.Text),
                 spinnerIndex,
                 table.Checked,
                 sandstormMode,
                 sandHatch.Checked,
                 sandCargo.Checked,
                 sandHab.Checked,
                 sandLevel,
                 cargo.Checked,
                 cargoWell.Checked,
                 cargoBarely.Checked,
                 hatch.Checked,
                 hatchWell.Checked,
                 hatchBarely.Checked,
                 climb,
                 goodDrivers,
                 wouldRecommend,
                 result,
                 comments.Text,
                 false,
                 currentEvent.eventID);
             //add the new match
             eData.AddMatchData(matchData);
             //go back to the main scouting page
             StartActivity(typeof(ScoutLandingPage));
             Finish();
         }
         //not putting a match or team number will throw an exception; so will a duplicate match number since the MatchData id
         //is based off of match number
         catch
         {
             Popup.Single("Alert", "Please Enter At Least the Match and Team Number//Possible Duplicate Match Number", "OK", this);
         }
     }
 }
Beispiel #6
0
 private void ButtonClicked(object sender, EventArgs e)
 {
     try
     {
         //decide which button was pressed
         if ((sender as Button) == bSelect)
         {
             //set the current event and go to the scouting page
             eData.SetCurrentEvent(selectedEvent.eventID);
             StartActivity(typeof(ScoutLandingPage));
         }
     }
     //if no event is selected, it will throw an exception
     catch
     {
         Popup.Single("Alert", "Please select an event to scout", "OK", this);
     }
 }
Beispiel #7
0
 private void ButtonClicked(object sender, EventArgs e)
 {
     //decide which button was clicked
     if ((sender as Button) == bConfirm)
     {
         try
         {
             //change the id based on entered value
             eData.ChangeEventID(currentEvent.eventID, int.Parse(newID.Text));
             Finish();
         }
         //if the database has a duplicate id, it will throw an exception
         catch
         {
             Popup.Single("Alert", "Please enter a new ID not used by an existing event", "OK", this);
         }
     }
 }
Beispiel #8
0
 private void ButtonClicked(object sender, EventArgs e)
 {
     try
     {
         if ((sender as Button) == bSelect)
         {
             //set current compiled event data to the selected one
             eData.SetCurrentCompiled(selectedCompiled.cID);
             Finish();
             //go to general display page for event
             StartActivity(typeof(GeneralCompiledData));
         }
     }
     //if no event is selected, it throws an exception
     catch
     {
         Popup.Single("Alert", "Please select an event to view data for", "OK", this);
     }
 }
Beispiel #9
0
 private void ButtonClicked(object sender, EventArgs e)
 {
     //decide which button was clicked
     if ((sender as Button) == bRefresh)
     {
         this.Recreate();
     }
     else if ((sender as Button) == bAddTeam)
     {
         //each event can have a max of 80 matches; more makes reading QR codes difficult
         if (eData.GetMatchDataForEvent(currentEvent.eventID).Count > 79)
         {
             Popup.Single("Alert", "Max 80 matches per event reached", "OK", this);
         }
         //if ok, go to scout form
         else
         {
             StartActivity(typeof(ScoutForm));
             Finish();
         }
     }
     else if ((sender as Button) == bViewEvent)
     {
         try
         {
             //set the current match to view to the selected match
             eData.SetCurrentMatch(eData.GetMatchDataForEvent(currentEvent.eventID)[selectedIndex].ID);
             StartActivity(typeof(ViewMatchData));
         }
         //if no event is selected, it throws an exception
         catch
         {
             Popup.Single("Alert", "Please select a match to view", "OK", this);
         }
     }
 }
Beispiel #10
0
 private void ButtonClicked(object sender, EventArgs e)
 {
     try
     {
         //decide which button was pressed
         if ((sender as Button) == bDeleteEvent)
         {
             Popup.Double("Alert", "Are you sure you want to delete the event '" +
                          selectedEvent.eventName + "' AND all associated matches?", "Yes", "CANCEL", this, Delete);
             //if user presses delete
             void Delete()
             {
                 eData.DeleteEvent(selectedEvent.eventID);
                 eData.DeleteMatchDataForEvent(selectedEvent.eventID);
                 Popup.Single("Alert", "Event Deleted", "OK", this);
             }
         }
         else if ((sender as Button) == bEditID)
         {
             //set current event so it can be accessed by the next activity
             eData.SetCurrentEvent(selectedEvent.eventID);
             Finish();
             StartActivity(typeof(EventID));
         }
         else if ((sender as Button) == bRefresh)
         {
             //refresh
             Recreate();
         }
     }
     //if no event is selected, selected event will be null and throw an exception
     catch
     {
         Popup.Single("Alert", "Please select an event to edit", "OK", this);
     }
 }
Beispiel #11
0
 //create a new CompiledEventData
 private void compileData(object sender, EventArgs e)
 {
     try
     {
         bool isDuplicate = false;
         //get a list of already existing CompiledEventData items
         IEnumerable <CompiledEventData> currentData = eData.GetCompiledEventData();
         foreach (CompiledEventData q in currentData)
         {
             if (q.cID == selectedEvent.eventID)
             {
                 isDuplicate = true;
                 break;
             }
         }
         //add data from the master device
         List <MatchData> scoutListArray = eData.GetMatchDataForEvent(selectedEvent.eventID);
         for (int i = 0; i < scoutListArray.Count; i++)
         {
             concatedQR += scoutListArray[i].teamNumber.ToString() + "," +
                           scoutListArray[i].matchNumber.ToString() + "," +
                           scoutListArray[i].result.ToString() +
                           scoutListArray[i].position.ToString() +
                           Convert.ToByte(scoutListArray[i].isTable).ToString() +
                           scoutListArray[i].sandstormStartLevel.ToString() +
                           scoutListArray[i].sandstormMode.ToString() +
                           Convert.ToByte(scoutListArray[i].sandstormHatch).ToString() +
                           Convert.ToByte(scoutListArray[i].sandstormCargo).ToString() +
                           Convert.ToByte(scoutListArray[i].sandstormLine).ToString() +
                           Convert.ToByte(scoutListArray[i].cargo).ToString() +
                           Convert.ToByte(scoutListArray[i].cargoWell).ToString() +
                           Convert.ToByte(scoutListArray[i].cargoBarely).ToString() +
                           Convert.ToByte(scoutListArray[i].hatch).ToString() +
                           Convert.ToByte(scoutListArray[i].hatchWell).ToString() +
                           Convert.ToByte(scoutListArray[i].hatchBarely).ToString() +
                           scoutListArray[i].climb.ToString() +
                           Convert.ToByte(scoutListArray[i].goodDrivers).ToString() +
                           scoutListArray[i].wouldRecommend.ToString();
         }
         //make sure there is some data
         if (concatedQR != null)
         {
             //make sure it isnt a duplicate
             if (!isDuplicate)
             {
                 //create a new compiled event data and add it to the database
                 CompiledEventData newCompilation = new CompiledEventData(selectedEvent.eventName, selectedEvent.startDate, selectedEvent.endDate, concatedQR, false, selectedEvent.eventID);
                 eData.AddCompiledEventData(newCompilation);
                 Popup.Single("Alert", "Successfully generated data for event '" + selectedEvent.eventName + "'.", "OK", this);
                 //StartActivity(typeof(MainActivity));
                 //Finish();
             }
             //if it is a duplicate
             else
             {
                 Popup.Single("Alert", "Data for this event has already been generated on this device. " +
                              "Please delete it in 'View Data' from the home screen first if you want to generate new data", "OK", this);
                 //reset, clear QR data, etc
                 //this.Recreate();
                 concatedQR = null;
             }
         }
         //if the QR data is completely blank
         else
         {
             Popup.Single("Alert", "No data collected, please start over", "OK", this);
             //reset
             //this.Recreate();
             concatedQR = null;
         }
     }
     catch
     {
         AlertDialog.Builder dialog         = new AlertDialog.Builder(this);
         AlertDialog         missingDetails = dialog.Create();
         missingDetails.SetTitle("Alert");
         missingDetails.SetMessage("No event selected");
         ;
         missingDetails.SetButton("OK", (c, ev) =>
         {
         });
         missingDetails.Show();
     }
 }
Beispiel #12
0
 private void ButtonClicked(object sender, EventArgs e)
 {
     if ((sender as Button) == bGenerate)
     {
         try
         {
             string QRdata1 = null;
             string QRdata2 = null;
             //get the MatchData for the selected event
             List <MatchData> scoutList = eData.GetMatchDataForEvent(selectedEvent.eventID);
             for (int i = 0; i < scoutList.Count; i++)
             {
                 //split data into two
                 if (i < Math.Round((double)scoutList.Count / 2))
                 {
                     QRdata1 += scoutList[i].teamNumber.ToString() + "," +
                                scoutList[i].matchNumber.ToString() + "," +
                                scoutList[i].result.ToString() +
                                scoutList[i].position.ToString() +
                                Convert.ToByte(scoutList[i].isTable).ToString() +
                                scoutList[i].sandstormStartLevel.ToString() +
                                scoutList[i].sandstormMode.ToString() +
                                Convert.ToByte(scoutList[i].sandstormHatch).ToString() +
                                Convert.ToByte(scoutList[i].sandstormCargo).ToString() +
                                Convert.ToByte(scoutList[i].sandstormLine).ToString() +
                                Convert.ToByte(scoutList[i].cargo).ToString() +
                                Convert.ToByte(scoutList[i].cargoWell).ToString() +
                                Convert.ToByte(scoutList[i].cargoBarely).ToString() +
                                Convert.ToByte(scoutList[i].hatch).ToString() +
                                Convert.ToByte(scoutList[i].hatchWell).ToString() +
                                Convert.ToByte(scoutList[i].hatchBarely).ToString() +
                                scoutList[i].climb.ToString() +
                                Convert.ToByte(scoutList[i].goodDrivers).ToString() +
                                scoutList[i].wouldRecommend.ToString();
                 }
                 else
                 {
                     QRdata2 += scoutList[i].teamNumber.ToString() + "," +
                                scoutList[i].matchNumber.ToString() + "," +
                                scoutList[i].result.ToString() +
                                scoutList[i].position.ToString() +
                                Convert.ToByte(scoutList[i].isTable).ToString() +
                                scoutList[i].sandstormStartLevel.ToString() +
                                scoutList[i].sandstormMode.ToString() +
                                Convert.ToByte(scoutList[i].sandstormHatch).ToString() +
                                Convert.ToByte(scoutList[i].sandstormCargo).ToString() +
                                Convert.ToByte(scoutList[i].sandstormLine).ToString() +
                                Convert.ToByte(scoutList[i].cargo).ToString() +
                                Convert.ToByte(scoutList[i].cargoWell).ToString() +
                                Convert.ToByte(scoutList[i].cargoBarely).ToString() +
                                Convert.ToByte(scoutList[i].hatch).ToString() +
                                Convert.ToByte(scoutList[i].hatchWell).ToString() +
                                Convert.ToByte(scoutList[i].hatchBarely).ToString() +
                                scoutList[i].climb.ToString() +
                                Convert.ToByte(scoutList[i].goodDrivers).ToString() +
                                scoutList[i].wouldRecommend.ToString();
                 }
             }
             //get QR code writer
             Writer writer = new QRCodeWriter();
             int    width  = this.Resources.DisplayMetrics.WidthPixels;
             //create the QR codes
             try
             {
                 BitMatrix      bm1  = writer.encode(QRdata1, BarcodeFormat.QR_CODE, width, width);
                 BitmapRenderer bit1 = new BitmapRenderer();
                 QR1.SetImageBitmap(bit1.Render(bm1, BarcodeFormat.QR_CODE, QRdata1));
                 Popup.Single("Alert", "Data for Event: '" + selectedEvent.eventName + "' Event ID: " +
                              selectedEvent.eventID.ToString() + " Generated. Please make sure that the receiving " +
                              "device has the correct event selected and that the event ids match", "OK", this);
             }
             //exception thrown if QR data strings are empty
             catch
             {
                 Popup.Single("Alert", "No data for this match", "OK", this);
             }
             //try to generate a second QR code
             try
             {
                 BitMatrix      bm2  = writer.encode(QRdata2, BarcodeFormat.QR_CODE, width, width);
                 BitmapRenderer bit2 = new BitmapRenderer();
                 QR2.SetImageBitmap(bit2.Render(bm2, BarcodeFormat.QR_CODE, QRdata2));
             }
             //do nothing if there is not enough data for a second QR code
             catch
             {
             }
         }
         //if no event is selected, it throws an exception
         catch
         {
             Popup.Single("Alert", "Please select an event to generate data for", "OK", this);
         }
     }
 }