private void saveMe() { Trace.WriteLine("FCompetitors: saveMe() " + "started on thread \"" + Thread.CurrentThread.Name + "\" ( " + Thread.CurrentThread.ManagedThreadId.ToString() + " )"); Structs.Team team; if ((int)this.DdTeams.SelectedValue != -1) { team = CommonCode.GetTeam((int)this.DdTeams.SelectedValue); team.CompetitorIds = new ArrayList(); } else { team = new Structs.Team(); team.CompetitorIds = new ArrayList(); team.TeamId = -1; } team.Name = this.txtName.Text; team.WClass = (Structs.ResultWeaponsClass)(int) this.ddWeaponClass.SelectedValue; team.ClubId = (string)this.DdClubs.SelectedValue; if ((int)ddCompetitor1.SelectedValue != -1) { team.CompetitorIds.Add((int)ddCompetitor1.SelectedValue); } if ((int)ddCompetitor2.SelectedValue != -1) { team.CompetitorIds.Add((int)this.ddCompetitor2.SelectedValue); } if ((int)ddCompetitor3.SelectedValue != -1) { team.CompetitorIds.Add((int)this.ddCompetitor3.SelectedValue); } if ((int)ddCompetitor4.SelectedValue != -1) { team.CompetitorIds.Add((int)this.ddCompetitor4.SelectedValue); } if ((int)ddCompetitor5.SelectedValue != -1) { team.CompetitorIds.Add((int)this.ddCompetitor5.SelectedValue); } if (team.TeamId == -1) { CommonCode.NewTeam(team); } else { CommonCode.UpdateTeam(team); } clearEverything(); Trace.WriteLine("FCompetitors: saveMe() ended."); }
private float calculateTeamHeight(ResultsReturnTeam result) { float teamHeight = printCompetitorHeaderFont.GetHeight(); Structs.Team team = CommonCode.GetTeam(result.TeamId); int nrCompetitors = team.CompetitorIds.Count; return(teamHeight * (2 + nrCompetitors)); }
private void printTeamMembersResults(PrintPageEventArgs ev, ref float yPos, ResultsReturnTeam result) { Structs.Team team = CommonCode.GetTeam(result.TeamId); foreach (int compid in (int[])team.CompetitorIds.ToArray(typeof(int))) { Structs.Competitor comp = CommonCode.GetCompetitor(compid); printTeamMemberResults(ev, ref yPos, comp); yPos += printCompetitorFont.GetHeight(); } }
double calculateTeamHeight(ResultsReturnTeam result) { Structs.Team team = myInterface.GetTeam(result.TeamId); if (team.CompetitorIds == null) { return(conversionPixelsToMM * fontSize); } else { return(conversionPixelsToMM * fontSize * (1 + team.CompetitorIds.Count)); } }
private void btnDelete_Click(object sender, System.EventArgs e) { DialogResult res = MessageBox.Show("Är du säker?", "Är du säker?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (res != DialogResult.Yes) { return; } int teamId = (int)this.DdTeams.SelectedValue; Structs.Team team = CommonCode.GetTeam(teamId); CommonCode.DelTeam(team); clearEverything(); }
private string createTeamResults(Structs.ResultsReturnTeam[] results, Structs.ResultWeaponsClass wclass) { StringBuilder html = new StringBuilder(); html.Append("<h1>Lagtävling</h1>"); html.Append("Vapenklass " + wclass.ToString() + ":"); html.Append("<table>\r\n"); html.Append("<tr>" + "<td><b>Pl</b></td>" + "<td><b>Klubb</b></td>" + "<td><b>Lag</b></td>" + "<td><b>Resultat</b></td>" + "</tr>\r\n"); int place = 0; foreach (Structs.ResultsReturnTeam result in results) { place++; html.Append("<tr>"); html.Append("<td class=\"resultevenline\">" + place.ToString() + "</td>"); html.Append("<td class=\"resultevenline\">" + myInterface.GetClub(result.ClubId).Name + "</td>"); html.Append("<td class=\"resultevenline\">" + result.TeamName + "</td>"); if (myInterface.GetCompetitions()[0].NorwegianCount) { html.Append("<td class=\"resultevenline\">" + (result.Hits + result.FigureHits).ToString() + "</td>"); } else { html.Append("<td class=\"resultevenline\">" + result.Hits.ToString() + "/" + result.FigureHits.ToString() + "</td>"); } html.Append("</tr>\r\n"); // The total results html.Append("<tr><td colspan=2></td>"); html.Append("<td colspan=2>" + result.HitsPerStn.Replace(";", " ") + "</td>"); html.Append("</tr>\r\n"); Structs.Team team = myInterface.GetTeam(result.TeamId); ArrayList comps = new ArrayList(); if (team.CompetitorId1 != -1) { comps.Add(team.CompetitorId1); } if (team.CompetitorId2 != -1) { comps.Add(team.CompetitorId2); } if (team.CompetitorId3 != -1) { comps.Add(team.CompetitorId3); } if (team.CompetitorId4 != -1) { comps.Add(team.CompetitorId4); } foreach (int compId in (int[])comps.ToArray(typeof(int))) { Structs.Competitor comp = myInterface.GetCompetitor(compId); html.Append("<tr><td colspan=2></td>"); html.Append("<td>" + GetNameForCompetitor(comp) + "</td>"); html.Append("<td>" + GetResultForCompetitor(comp) + "</td>"); html.Append("</tr>\r\n"); } } html.Append("</table>"); return(html.ToString()); }
private double writeResultsTeam(pdfPage page, double yPos, ResultsReturnTeam result, int place) { double newYPos = yPos; Structs.Club club = myInterface.GetClub(result.ClubId); if (competition.CompetitionId == 0) { competition = myInterface.GetCompetitions()[0]; } addText(page, place.ToString(), this.leftMargin, yPos, font, fontResultSize); addText(page, result.TeamName, this.colResultNamePos, yPos, colResultClubPos - colResultNamePos, font, fontResultSize); addText(page, club.Name, this.colResultClubPos, yPos, colResultResultPos - colResultClubPos, font, fontResultSize); switch (competition.Type) { case Structs.CompetitionTypeEnum.Field: { if (competition.NorwegianCount) { addText(page, (result.Hits + result.FigureHits).ToString(), colResultTotPos, yPos, font, fontResultSize); } else { addText(page, result.Hits.ToString() + "/" + result.FigureHits.ToString(), colResultTotPos, yPos, font, fontResultSize); } addText(page, result.Points.ToString(), this.colResultPointsPos, yPos, font, fontResultSize); break; } case Structs.CompetitionTypeEnum.Precision: { addText(page, result.Hits.ToString(), this.colResultPointsPos, yPos, font, fontResultSize); break; } default: throw new ApplicationException("Not implemented yet"); } /*if (competition.UsePriceMoney && * result.PriceMoney != 0) * { * newYPos = addText(page, result.PriceMoney.ToString() + ":-", * this.colResultPricePos, yPos, font, fontResultSize); * }*/ string[] HitsPerStn = result.HitsPerStn.Split(';'); double xPos = colResultResultPos; double xMaxPos = colResultTotPos; foreach (string thisStn in HitsPerStn) { int maxXSizeInPoints = (int)((xMaxPos - xPos) / conversionPixelsToMM); if (font.getWordWidth(thisStn, fontSize) > maxXSizeInPoints) { xPos = colResultResultPos; yPos = newYPos; } newYPos = addText(page, thisStn, xPos, yPos, font, fontResultSize); xPos += conversionPixelsToMM * font.getWordWidth(thisStn, fontSize); } Structs.Team team = myInterface.GetTeam(result.TeamId); foreach (int compid in (int[])team.CompetitorIds.ToArray(typeof(int))) { newYPos = writeResultsTeam(page, newYPos, colResultResultPos, colResultTotPos, compid); } return(newYPos); }
private void DdTeams_SelectedIndexChanged(object sender, System.EventArgs e) { if (this.ddWeaponClass.SelectedValue == null) { return; } if (this.DdTeams.SelectedValue.GetType() != typeof(int)) { return; } if ((int)this.DdTeams.SelectedValue == -1) { this.DdClubs.SelectedIndex = 0; this.txtName.Text = ""; this.ddWeaponClass.SelectedIndex = 0; this.ddCompetitor1.SelectedIndex = 0; this.ddCompetitor2.SelectedIndex = 0; this.ddCompetitor3.SelectedIndex = 0; this.ddCompetitor4.SelectedIndex = 0; this.ddCompetitor5.SelectedIndex = 0; } else { Structs.Team team = CommonCode.GetTeam((int)this.DdTeams.SelectedValue); this.DdClubs.SelectedValue = team.ClubId; this.txtName.Text = team.Name; this.ddWeaponClass.SelectedValue = team.WClass; this.ddCompetitor1.SelectedIndex = 0; this.ddCompetitor2.SelectedIndex = 0; this.ddCompetitor3.SelectedIndex = 0; this.ddCompetitor4.SelectedIndex = 0; this.ddCompetitor5.SelectedIndex = 0; int i = 1; foreach (int competitorId in team.CompetitorIds) { switch (i) { case 1: ddCompetitor1.SelectedValue = competitorId; break; case 2: ddCompetitor2.SelectedValue = competitorId; break; case 3: ddCompetitor3.SelectedValue = competitorId; break; case 4: ddCompetitor4.SelectedValue = competitorId; break; case 5: ddCompetitor5.SelectedValue = competitorId; break; } i++; } } }
private string createTeamResults(ResultsReturnTeam[] results, Structs.ResultWeaponsClass wclass) { StringBuilder html = new StringBuilder(); html.Append("<h1>Lagtävling</h1>"); html.Append("Vapengrupp " + wclass.ToString() + ":"); html.Append("<table>\r\n"); html.Append("<tr>" + "<td><b>Pl</b></td>" + "<td><b>Klubb</b></td>" + "<td><b>Lag</b></td>" + "<td><b>Resultat</b></td>" + "</tr>\r\n"); int place = 0; foreach (ResultsReturnTeam result in results) { place++; html.Append("<tr>"); html.Append("<td class=\"resultevenline\">" + place.ToString() + "</td>"); html.Append("<td class=\"resultevenline\">" + myInterface.GetClub(result.ClubId).Name + "</td>"); html.Append("<td class=\"resultevenline\">" + result.TeamName + "</td>"); switch (myInterface.GetCompetitions()[0].Type) { case Structs.CompetitionTypeEnum.Field: { if (myInterface.GetCompetitions()[0].NorwegianCount) { html.Append("<td class=\"resultevenline\">" + (result.Hits + result.FigureHits).ToString() + "</td>"); } else { html.Append("<td class=\"resultevenline\">" + result.Hits.ToString() + "/" + result.FigureHits.ToString() + "</td>"); } break; } case Structs.CompetitionTypeEnum.Precision: { html.Append("<td class=\"resultevenline\">" + result.Hits.ToString() + "</td>"); break; } } html.Append("</tr>\r\n"); // The total results html.Append("<tr><td colspan=2></td>"); html.Append("<td colspan=2>" + result.HitsPerStn.Replace(";", " ") + "</td>"); html.Append("</tr>\r\n"); Structs.Team team = myInterface.GetTeam(result.TeamId); foreach (int compId in (int[])team.CompetitorIds.ToArray(typeof(int))) { Structs.Competitor comp = myInterface.GetCompetitor(compId); html.Append("<tr><td colspan=2></td>"); html.Append("<td>" + GetNameForCompetitor(comp) + "</td>"); html.Append("<td>" + GetResultForCompetitor(comp) + "</td>"); html.Append("</tr>\r\n"); } } html.Append("</table>"); return(html.ToString()); }