void UpdateStaticInfo() { if (Debater != null) { HBox c = infoWidgets["roleAndClub"] as HBox; if (Debater.Role.IsTeamMember) { SetMarkup(c.Children[1], GLib.Markup.EscapeText(Debater.Role.TeamName) + "\n" + GLib.Markup.EscapeText(Debater.Club.Name)); } else if (Debater.Role.IsJudge) { HBox hboxStars = c.Children[0] as HBox; foreach (Widget w in hboxStars) { hboxStars.Remove(w); } // Display stars for judgeQuality for (int i = 0; i < Debater.Role.JudgeQuality; i++) { hboxStars.Add(new Image(MiscHelpers.LoadIcon("face-smile"))); } if (Debater.Role.JudgeQuality > 0) { c.Spacing = 6; } SetMarkup(c.Children[1], Debater.Club.Name); } } }
public MyButton(IDragDropWidget o, string strLabel, string strIcon1, string strIcon2) { this.Build(); Relief = ReliefStyle.None; FocusOnClick = false; toggled = false; owner = o; label.Text = strLabel; icon1 = MiscHelpers.LoadIcon(strIcon1); icon2 = MiscHelpers.LoadIcon(strIcon2); image.Pixbuf = icon2; DragBegin += delegate(object s, DragBeginArgs args) { // generate nice dragging icon Gdk.Pixbuf pb = Gdk.Pixbuf.FromDrawable(label.GdkWindow, label.Colormap, label.Allocation.X, label.Allocation.Y, 0, 0, label.Allocation.Width, label.Allocation.Height); Gtk.Drag.SourceSetIconPixbuf((Widget)s, pb); }; }
void UpdateGuiSection(string section, int i, object data) { Container c = (Container)GetField("c" + section); if (data == null) { SetDummyLabel(c, section); } else if (data is List <RoundDebater> ) { // Judges or FreeSpeakers (variable number...) MiscHelpers.ClearContainer(c); List <RoundDebater> list = (List <RoundDebater>)data; if (list.Count == 0) { SetDummyLabel(c, section); } else { for (int j = 0; j < list.Count; j++) { UpdateGuiSection(section, j, list[j]); } // append label for adding by D&D if (small) { if (section == "Judges") { SetDummyLabel(c, section, roomData.Judges.Count.ToString()); } else if (section == "FreeSpeakers" && list.Count < 3) { SetDummyLabel(c, section, "F"); } } else if (section == "Judges" || list.Count < 3) { SetDummyLabel(c, section, "Drag here to add"); } } } else { IDragDropWidget w = null; if (data is TeamData) { if (small) { w = Team.Small((TeamData)data); } else { w = new Team((TeamData)data, null); } } else if (data is RoundDebater) { if (small) { w = DebaterWidget.Small((RoundDebater)data, false); } else { w = new DebaterWidget((RoundDebater)data); } } else { throw new NotImplementedException("Don't know how to create widget for data"); } // tell Debater the room for visitedRooms list.. w.SetRoom(roomData.RoundName, roomData); w.SetupDragDropSource(section, data); w.SetDataTrigger += delegate(Widget sender, object data_) { SetItem(section, i, data_); }; // Add to container after source, but before Dest Widget wi = (Widget)w; MiscHelpers.AddToContainer(c, wi, small); // Drag drop DestSet, needs Container for scrolling support... DragDropHelpers.DestSet(wi, DestDefaults.All, DragDropHelpers.TgtFromString(section), Gdk.DragAction.Move); wi.DragDataReceived += delegate(object o, DragDataReceivedArgs args) { object data_ = DragDropHelpers.Deserialize(args.SelectionData); // save data here SetItem(section, i, data_); // delete data there MyButton b = (MyButton)Drag.GetSourceWidget(args.Context); b.Owner.SetData(data); }; } // show judge quality by icons if (section == "Judges" && !small) { int nStars = 0; double sumAvgSpkr = 0.0; double sumAvgTeam = 0.0; int nAvgSpkr = 0; int nAvgTeam = 0; foreach (RoundDebater rd in roomData.Judges) { Debater d = Tournament.I.FindDebater(rd); if (d == null) { continue; } nStars += d.Role.JudgeQuality; if (!double.IsNaN(d.StatsAvg[0])) { sumAvgSpkr += d.StatsAvg[0]; nAvgSpkr++; } if (!double.IsNaN(d.StatsAvg[2])) { sumAvgTeam += d.StatsAvg[2]; nAvgTeam++; } } lblJudgeStats.Markup = "JudgeStats: " + JudgeStatsToMarkup(sumAvgSpkr, nAvgSpkr, 2) + " " + JudgeStatsToMarkup(sumAvgTeam, nAvgTeam, 5); MiscHelpers.ClearTable(tableJudgeStars); tableJudgeStars.NRows = (uint)nStars / 5 + 1; for (int j = 0; j < nStars; j++) { uint col = (uint)j % 5; uint row = (uint)j / 5; tableJudgeStars.Attach(new Image(MiscHelpers.LoadIcon("face-smile")), col, col + 1, row, row + 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); } if (nStars == 0) { tableJudgeStars.HideAll(); } else { tableJudgeStars.ShowAll(); } } }
public void SetRoomConflict(RoomConflict rc) { if (rc == null || rc.IsEmpty) { HideAll(); NoShowAll = true; return; } HBox hbox = new HBox(); hbox.Spacing = 1; m = new Menu(); // this round/room foreach (RoomConflict.Type t in rc.Partners1.Keys) { if (rc.Partners1[t].Count == 0) { continue; } int iconIndex = settings.conflictIcons[(int)t]; if (iconIndex >= 0) { hbox.Add(new Gtk.Image(MiscHelpers.LoadIcon(settings.possibleIcons[iconIndex]))); } MenuItem miType = new MenuItem(t.ToString()); miType.Submenu = new Menu(); foreach (RoundDebater d in rc.Partners1[t]) { (miType.Submenu as Menu).Add(new MenuItem(RoundDebaterToString(d))); } m.Add(miType); } // other Rounds... MenuItem miOther = new MenuItem(); Label lbl = new Label(); lbl.Markup = "<i>Other</i>"; lbl.Xalign = 0; miOther.Add(lbl); Menu mOther = new Menu(); miOther.Submenu = mOther; int validOthers = 0; // in other Conflicts, it should be okay to iterate using Tournament.I.Rounds foreach (RoundData rd in Tournament.I.Rounds) { RoomConflict.Complex cmplx; if (rc.Partners2.TryGetValue(rd.RoundName, out cmplx)) { Dictionary <string, List <RoundDebater> > store = cmplx.Store; List <string> keys = new List <string>(store.Keys); // sorting is a bit nasty, so that "Room 2" is before "Room 11" // this is also inefficient, but performance doesn't matter here keys.Sort(delegate(string x, string y) { // try to extract numbers from string List <string> num_x = new List <string>(Regex.Split(x, @"\D+")); List <string> num_y = new List <string>(Regex.Split(y, @"\D+")); num_x.RemoveAll(item => string.IsNullOrEmpty(item.Trim())); num_y.RemoveAll(item => string.IsNullOrEmpty(item.Trim())); if (num_x.Count != 1 || num_y.Count != 1) { return(x.CompareTo(y)); } return(int.Parse(num_x[0]).CompareTo(int.Parse(num_y[0]))); }); foreach (string room in keys) { MenuItem miRound = new MenuItem(rd.RoundName + ", " + room); miRound.Submenu = new Menu(); foreach (RoundDebater d in store[room]) { (miRound.Submenu as Menu).Add(new MenuItem(RoundDebaterToString(d))); } mOther.Add(miRound); validOthers++; } } } if (validOthers > 0) { int numEnums = Enum.GetNames(typeof(RoomConflict.Type)).Length; int iconIndex = settings.conflictIcons[numEnums]; if (iconIndex >= 0) { hbox.Add(new Gtk.Image(MiscHelpers.LoadIcon(settings.possibleIcons[iconIndex]))); } m.Add(miOther); } m.ShowAll(); m.AttachToWidget(this, null); // always show a (not attracting) icon...even if all are disabled.. if (hbox.Children.Length == 0) { // only loadable over pixbuf Pixbuf dummy = MiscHelpers.LoadIcon("weather-clear-night"); //Stetic.IconLoader.LoadIcon(this,"stock_weather-night-clear",IconSize.Menu); hbox.Add(new Gtk.Image(dummy)); } if (Children.Length > 0) { Remove(Child); } Add(hbox); NoShowAll = false; ShowAll(); }