public WelcomePageTipOfTheDaySection() : base(GettextCatalog.GetString("Did you know?")) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(System.IO.Path.Combine(System.IO.Path.Combine(PropertyService.DataPath, "options"), "TipsOfTheDay.xml")); foreach (XmlNode xmlNode in xmlDocument.DocumentElement.ChildNodes) { tips.Add(StringParserService.Parse(xmlNode.InnerText)); } if (tips.Count != 0) { currentTip = new Random().Next() % tips.Count; } else { currentTip = -1; } Gtk.VBox box = new Gtk.VBox(false, 12); label = new Gtk.Label(); label.Xalign = 0; label.Wrap = true; label.WidthRequest = 200; label.ModifyFont(FontService.SansFont.CopyModified(Gui.Styles.FontScale11)); label.SetPadding(0, 10); label.Text = currentTip != -1 ? tips[currentTip] : ""; box.PackStart(label, true, true, 0); var next = new Gtk.Button(GettextCatalog.GetString("Next Tip")); next.Relief = Gtk.ReliefStyle.Normal; next.Clicked += delegate { if (tips.Count == 0) { return; } currentTip = currentTip + 1; if (currentTip >= tips.Count) { currentTip = 0; } label.Text = tips[currentTip]; }; var al = new Gtk.Alignment(0, 0, 0, 0); al.Add(next); box.PackStart(al, false, false, 0); SetContent(box); }
public WelcomePageTipOfTheDaySection (): base (GettextCatalog.GetString ("Did you know?")) { XmlDocument xmlDocument = new XmlDocument (); xmlDocument.Load (System.IO.Path.Combine (System.IO.Path.Combine (PropertyService.DataPath, "options"), "TipsOfTheDay.xml")); foreach (XmlNode xmlNode in xmlDocument.DocumentElement.ChildNodes) { tips.Add (StringParserService.Parse (xmlNode.InnerText)); } if (tips.Count != 0) currentTip = new Random ().Next () % tips.Count; else currentTip = -1; Gtk.VBox box = new Gtk.VBox (false, 12); label = new Gtk.Label (); label.Xalign = 0; label.Wrap = true; label.WidthRequest = 200; label.ModifyFont (FontService.SansFont.CopyModified (Gui.Styles.FontScale11)); label.SetPadding (0, 10); label.Text = currentTip != -1 ? tips[currentTip] : ""; box.PackStart (label, true, true, 0); var next = new Gtk.Button (GettextCatalog.GetString ("Next Tip")); next.Relief = Gtk.ReliefStyle.Normal; next.Clicked += delegate { if (tips.Count == 0) return; currentTip = currentTip + 1; if (currentTip >= tips.Count) currentTip = 0; label.Text = tips[currentTip]; }; var al = new Gtk.Alignment (0, 0, 0, 0); al.Add (next); box.PackStart (al, false, false, 0); SetContent (box); }