private void openToolStripMenuItem_Click(object sender, EventArgs e) { if( this.openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string fileName = openFileDialog1.FileName; using (BinaryReader reader = new BinaryReader(File.Open(openFileDialog1.FileName, FileMode.Open))) { int numberOfReadings = reader.ReadInt32(); readings = new List<TagInfo>(numberOfReadings); for (int i = 0; i < numberOfReadings; i++) { TagInfo tag = new TagInfo(); TagId id; id.Value = reader.ReadString(); tag.ID = id; tag.Time = reader.ReadInt64(); tag.SignalStrenth = reader.ReadSingle(); tag.Antenna = reader.ReadInt32(); tag.Frequency = reader.ReadSingle(); readings.Add(tag); } } this.dataGridView1.DataSource = readings; EnablePlayBack(); } }
private void addPassingButton_Click(object sender, EventArgs e) { long existingTime = 1; int index = -1; if (passingsDataGrid.SelectedRows.Count != 0) { index = passingsDataGrid.SelectedRows[0].Index; PassingsInfo pi = (passingsDataGrid.DataSource as BindingList<PassingsInfo>)[index]; existingTime = pi.Time + 1;//- 1; } Form addPassingDialog = new Form(); addPassingDialog.Text = "Add a new passing"; //addPassingDialog.Width = 300; //addPassingDialog.Height = 150; Button okButton = new Button(); Button cancelButton = new Button(); TextBox tagTextBox = new TextBox(); Label tagLabel = new Label(); tagLabel.Text = "TagID"; okButton.Text = "OK"; cancelButton.Text = "Cancel"; okButton.DialogResult = System.Windows.Forms.DialogResult.OK; cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; addPassingDialog.Width = 400; addPassingDialog.Height = 135; okButton.SetBounds(30, 70, 125, 22); cancelButton.SetBounds(160, 70, 120, 22); tagLabel.SetBounds(30, 20, 50, 22); tagTextBox.SetBounds(85, 20, 196, 22); addPassingDialog.Controls.Add(okButton); addPassingDialog.Controls.Add(cancelButton); addPassingDialog.Controls.Add(tagTextBox); addPassingDialog.Controls.Add(tagLabel); addPassingDialog.CancelButton = cancelButton; if (addPassingDialog.ShowDialog() == DialogResult.OK) { TagId tagID = new TagId(tagTextBox.Text); TagInfo ti = new TagInfo(tagID, 0, 0, 0, existingTime); TagReadEventArgs newTagArgs = new TagReadEventArgs(TagEventType.NewTagDetected, ti); if (index != -1) index += 1; UpdatePassingsGrid(newTagArgs, index); UpdateRaceStandingsGrid(newTagArgs); } addPassingDialog.Dispose(); }
private void FireReadingEvent(TagInfo tagInfo) { //Marshal this over to the connectionThread. readingsQueue.Put(tagInfo); }
// Wrap the tag into a TagReadEventArgs and fire it. private void SendTag(TagInfo tagInfo) { TagReadEventArgs e = new TagReadEventArgs(TagEventType.Read, tagInfo); TagDetected(this, e); }
private void addPassingButton_Click(object sender, EventArgs e) { if(raceInformationControl.GetCurrentRace() == null) { MessageBox.Show("Please select a race in the Race Info tab first!"); return; } long existingTime = 1; int index = -1; if (passingsDataGrid.SelectedRows.Count != 0) { index = passingsDataGrid.SelectedRows[0].Index; PassingsInfo pi = (passingsDataGrid.DataSource as BindingList<PassingsInfo>)[index]; existingTime = pi.Time + 1;//- 1; } CompetitorRace selectedCR = null; if (competitorRaceDataGrid.SelectedRows != null && competitorRaceDataGrid.SelectedRows.Count > 0) { int crIndex = competitorRaceDataGrid.SelectedRows[0].Index; selectedCR = (competitorRaceDataGrid.DataSource as SortableBindingList<CompetitorRace>)[crIndex]; } Form addPassingDialog = new Form(); addPassingDialog.Text = "Add a new passing"; Button okButton = new Button(); Button cancelButton = new Button(); TextBox tagTextBox = new TextBox(); Label tagLabel = new Label(); tagLabel.Text = "TagID"; okButton.Text = "OK"; cancelButton.Text = "Cancel"; okButton.DialogResult = System.Windows.Forms.DialogResult.OK; cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; addPassingDialog.Width = 400; addPassingDialog.Height = 135; okButton.SetBounds(30, 70, 125, 22); cancelButton.SetBounds(160, 70, 120, 22); tagLabel.SetBounds(30, 20, 50, 22); tagTextBox.SetBounds(85, 20, 196, 22); addPassingDialog.Controls.Add(okButton); addPassingDialog.Controls.Add(cancelButton); addPassingDialog.Controls.Add(tagTextBox); addPassingDialog.Controls.Add(tagLabel); addPassingDialog.CancelButton = cancelButton; if (addPassingDialog.ShowDialog() == DialogResult.OK) { TagId tagID = new TagId(tagTextBox.Text); TagInfo ti = new TagInfo(tagID, 0, 0, 0, existingTime); TagReadEventArgs newTagArgs = new TagReadEventArgs(TagEventType.NewTagDetected, ti); if (index != -1) index += 1; raceInformationControl.UpdatePassingsGrid(newTagArgs, index); raceInformationControl.UpdateRaceStandingsGrid(newTagArgs); SelectCompetitorRace(selectedCR); } addPassingDialog.Dispose(); }
//please note that sometimes we may not know competitor, //so the field stays null //private Competitor competitor; //public Competitor Competitor //{ // get { return competitor; } // set // { // if (value != null) // { // //remove listener from old competitor // if (competitor != null) //don't do the very first time // competitor.PropertyChangedEvent -= this.competitor_PropertyChangedEvent; // competitor = value; // this.firstName = value.FirstName; // this.lastName = value.LastName; // this.competitorID = value.ID; // //competitor.PropertyChangedEvent += // // new Hardcard.Scoring.Core.Competitor.PropertyChanged(competitor_PropertyChangedEvent); // competitor.PropertyChangedEvent += this.competitor_PropertyChangedEvent; // } // else // { // //doesn't seem to remove the handler // //competitor.PropertyChangedEvent -= // // new Hardcard.Scoring.Core.Competitor.PropertyChanged(competitor_PropertyChangedEvent); // if (competitor != null) // competitor.PropertyChangedEvent -= this.competitor_PropertyChangedEvent; // competitor = null; // } // } //} //private void competitor_PropertyChangedEvent(Competitor source) //{ // if (source == null) return; // //prevents "resetting" properties when we have already re-associated // //this PassingInfo object to some other competitor object // //proper way of doing this - remove competitor listener at all, but // //it doesn't seem to work all the times, some kind of bug // if (competitorID != source.ID) return; // this.firstName = source.FirstName; // this.lastName = source.LastName; // this.competitorID = source.ID;//should not change, actually // //necessary to send those events so that UI is updated // PropertyChangedEventArgs args1 = new PropertyChangedEventArgs("firstName"); // PropertyChanged(this, args1); // PropertyChangedEventArgs args2 = new PropertyChangedEventArgs("lastName"); // PropertyChanged(this, args2); // PropertyChangedEventArgs args3 = new PropertyChangedEventArgs("competitorID"); // PropertyChanged(this, args3); //} public PassingsInfo(TagInfo tagInfo, int competitorID, String firstName, String lastName, String competitionNum) { this.ID = tagInfo.ID; this.Frequency = tagInfo.Frequency; this.SignalStrength = tagInfo.SignalStrenth; this.Antenna = tagInfo.Antenna; this.Time = tagInfo.Time; this.DateTime = tagInfo.DateTime; this.Hits = tagInfo.Hits; this.competitorID = competitorID; this.firstName = firstName; this.lastName = lastName; this.CompetitionNumber = competitionNum; this.deleted = ""; this.lapTime = "-1"; }
public static bool AreEqual(TagInfo tag1, TagInfo tag2) { if (tag1.ID.Value != tag2.ID.Value) return false; if (FloatsEqual(tag1.Frequency, tag2.Frequency)) return false; if (tag1.Antenna != tag2.Antenna) return false; if (FloatsEqual(tag1.SignalStrenth, tag2.SignalStrenth)) return false; if (tag1.Time != tag2.Time) return false; return true; }
/// <summary> /// Constructor requiring data for each field. /// </summary> /// <param name="id">The <typeparamref name="TadId"/>.</param> /// <param name="frequency">The signals frequency as a float.</param> /// <param name="signalStrength">The signal strength in XXX units as a float.</param> /// <param name="antenna">The antenna id or reference that detected the read.</param> /// <param name="time">The time the tag was detected. Typically encoded as the /// number of milliseconds from a past reference date in time (e.g., 1/1/1990)</param> public TagReadEventArgs(TagEventType eventType, TagInfo tagInfo) { this.EventType = eventType; this.TagInfo = tagInfo; }