void MySpinbuttonChangedTeam(object s, EventArgs e) { MySpinButton sb = (MySpinButton)s; int k = sb.DebaterIndex; int i = sb.JudgeIndex; if (k == 9) { // Gov // all speakers foreach (int p in posGov) { results[p].TeamScores[i] = sb.ValueAsInt; } } else if (k == 10) { // Opp // all speakers foreach (int p in posOpp) { results[p].TeamScores[i] = sb.ValueAsInt; } } else { throw new IndexOutOfRangeException(); } // judges resultsJudges[i].TeamScores[k - 9] = sb.ValueAsInt; // UpdateInfo of affected Widgets dataWidgets[k].UpdateInfo(); dataWidgets[11 + i].UpdateInfo(); }
MySpinButton SetupSbSpeaker(int i, int k) { MySpinButton sb = new MySpinButton(-1, 100, 1, i, k); sb.NumberChanged += MySpinbuttonChangedSpeaker; sb.Value = results[k].SpeakerScores[i]; return(sb); }
void MySpinbuttonChangedSpeaker(object s, EventArgs e) { MySpinButton sb = (MySpinButton)s; int k = sb.DebaterIndex; int i = sb.JudgeIndex; // save at speaker results[k].SpeakerScores[i] = sb.ValueAsInt; // save at judge resultsJudges[i].SpeakerScores[k] = sb.ValueAsInt; // update info dataWidgets[k].UpdateInfo(); dataWidgets[11 + i].UpdateInfo(); }
MySpinButton SetupSbTeam(int i, int k) { MySpinButton sb = new MySpinButton(-1, 200, 1, i, k); sb.NumberChanged += MySpinbuttonChangedTeam; if (k == 9) { sb.Value = GetTeamScore(i, posGov); } else if (k == 10) { sb.Value = GetTeamScore(i, posOpp); } else { throw new IndexOutOfRangeException(); } return(sb); }
void SetupJudgeColumn(int i) { // Setup small DebaterWidget (keep colsize small...) DebaterWidget dw = DebaterWidget.Small(roomData.Judges[(int)i], false); // add to results, nJudges doesnt matter for judges resultsJudges.Add(dw.Debater.GetRoundResult(roomData.RoundName, i, -1)); dataWidgets.Add(dw); // default position uint pos = (uint)(i + judgesOffset); // THE FOLLOWING ORDER FOR DRAG DROP IS IMPORTANT, see DragDropHelpers // DragDrop SOURCE // we send always the fixed index i if (roomData.Judges.Count > 1) { dw.SetupDragDropSource("Judge", i); } //DragDropHelpers.SourceSet(dw, "Judge", i); // Container ATTACH table.Attach(dw, pos, pos + 1, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); // DragDrop DEST if (roomData.Judges.Count > 1) { DragDropHelpers.DestSet(dw, DestDefaults.All, DragDropHelpers.TgtFromString("Judge"), Gdk.DragAction.Move); dw.DragDataReceived += delegate(object o, DragDataReceivedArgs args) { int j = (int)DragDropHelpers.Deserialize(args.SelectionData); // Swap Columns SwapTableCols((uint)(resultsJudges[i].Index + judgesOffset), (uint)(resultsJudges[j].Index + judgesOffset)); // save this in results int tmp = resultsJudges[i].Index; resultsJudges[i].Index = resultsJudges[j].Index; resultsJudges[j].Index = tmp; // update infos dataWidgets[i + 11].UpdateInfo(); dataWidgets[j + 11].UpdateInfo(); }; } // Setup Spinbuttons int k = 0; foreach (uint row in debaterRows) { Alignment al = null; if (dataWidgets[k].HasResult) { // k denotes speaker position // k=9, k=10 are team points // i denotes judgeIndex MySpinButton sb = k < 9 ? SetupSbSpeaker(i, k) : SetupSbTeam(i, k); // spinbuttons are parents for avg labels.. labels[k].AddParent(sb); // nice alignment al = new Alignment(0f, 0f, 1f, 1f); al.LeftPadding = 6; al.RightPadding = 6; al.Add(sb); } table.Attach(MiscHelpers.MakeBackground(al, colBg[RoundResultData.PosToRoleType[k]]), pos, pos + 1, row, row + 1, AttachOptions.Fill, AttachOptions.Fill, 0, 0); k++; } }