public HeaderWidget(Shuffler shuffler, string shuffle_mode_id, string source_name) : base(0, 0, 0, 0) { ThreadAssist.AssertInMainThread (); var box = new HBox (); box.Spacing = 6; var fill_label = new Label (Catalog.GetString ("_Fill")); mode_combo = new DictionaryComboBox<RandomBy> (); foreach (var random_by in shuffler.RandomModes.OrderBy (r => r.Adverb)) { mode_combo.Add (random_by.Adverb, random_by); if (random_by.Id == "off") { mode_combo.Default = random_by; } } fill_label.MnemonicWidget = mode_combo; mode_combo.Changed += OnModeComboChanged; var from_label = new Label (Catalog.GetString ("f_rom")); var source_combo_box = new QueueableSourceComboBox (source_name); from_label.MnemonicWidget = source_combo_box; sensitive_widgets.Add (source_combo_box); sensitive_widgets.Add (from_label); source_combo_box.Changed += delegate { var handler = SourceChanged; if (handler != null) { handler (this, new EventArgs<DatabaseSource> (source_combo_box.Source)); } }; box.PackStart (fill_label, false, false, 0); box.PackStart (mode_combo, false, false, 0); box.PackStart (from_label, false, false, 0); box.PackStart (source_combo_box, false, false, 0); this.SetPadding (0, 0, 6, 6); this.Add (box); // Select the saved population mode. var default_randomby = shuffler.RandomModes.FirstOrDefault (r => r.Id == shuffle_mode_id); if (default_randomby != null) { mode_combo.ActiveValue = default_randomby; } else if (mode_combo.Default != null) { mode_combo.ActiveValue = mode_combo.Default; } shuffler.RandomModeAdded += (r) => mode_combo.Add (r.Adverb, r); shuffler.RandomModeRemoved += (r) => mode_combo.Remove (r); }
public HeaderWidget(PlaybackShuffleMode mode, string source_name) : base() { this.Spacing = 6; var fill_label = new Label(Catalog.GetString("_Fill")); var mode_combo = new ComboBox(modes.Keys.OrderBy(s => modes[s]).ToArray()); fill_label.MnemonicWidget = mode_combo; mode_combo.Changed += delegate { var value = modes[mode_combo.ActiveText]; foreach (var widget in sensitive_widgets) { widget.Sensitive = value != PlaybackShuffleMode.Linear; } var handler = ModeChanged; if (handler != null) { handler(this, new ModeChangedEventArgs(value)); } }; var from_label = new Label(Catalog.GetString("f_rom")); sensitive_widgets.Add(from_label); var source_combo_box = new QueueableSourceComboBox(source_name); from_label.MnemonicWidget = source_combo_box; sensitive_widgets.Add(source_combo_box); source_combo_box.Changed += delegate { var handler = SourceChanged; if (handler != null) { handler(this, new SourceChangedEventArgs(source_combo_box.Source)); } }; PackStart(fill_label, false, false, 0); PackStart(mode_combo, false, false, 0); PackStart(from_label, false, false, 0); PackStart(source_combo_box, false, false, 0); // Select the population mode. mode_combo.Model.Foreach(delegate(TreeModel model, TreePath path, TreeIter iter) { if (modes[(string)model.GetValue(iter, 0)] == mode) { mode_combo.SetActiveIter(iter); return(true); } return(false); }); }
public HeaderWidget(Shuffler shuffler, string shuffle_mode_id, string source_name) : base(0, 0, 0, 0) { ThreadAssist.AssertInMainThread(); var box = new HBox(); box.Spacing = 6; var fill_label = new Label(Catalog.GetString("_Fill")); mode_combo = new DictionaryComboBox <RandomBy> (); foreach (var random_by in shuffler.RandomModes.OrderBy(r => r.Adverb)) { mode_combo.Add(random_by.Adverb, random_by); if (random_by.Id == "off") { mode_combo.Default = random_by; } } fill_label.MnemonicWidget = mode_combo; mode_combo.Changed += OnModeComboChanged; var from_label = new Label(Catalog.GetString("f_rom")); var source_combo_box = new QueueableSourceComboBox(source_name); from_label.MnemonicWidget = source_combo_box; sensitive_widgets.Add(source_combo_box); sensitive_widgets.Add(from_label); source_combo_box.Changed += delegate { var handler = SourceChanged; if (handler != null) { handler(this, new EventArgs <DatabaseSource> (source_combo_box.Source)); } }; box.PackStart(fill_label, false, false, 0); box.PackStart(mode_combo, false, false, 0); box.PackStart(from_label, false, false, 0); box.PackStart(source_combo_box, false, false, 0); this.SetPadding(0, 0, 6, 6); this.Add(box); // Select the saved population mode. var default_randomby = shuffler.RandomModes.FirstOrDefault(r => r.Id == shuffle_mode_id); if (default_randomby != null) { mode_combo.ActiveValue = default_randomby; } else if (mode_combo.Default != null) { mode_combo.ActiveValue = mode_combo.Default; } shuffler.RandomModeAdded += (r) => mode_combo.Add(r.Adverb, r); shuffler.RandomModeRemoved += (r) => mode_combo.Remove(r); }