Пример #1
0
        protected void OnBtnAddClicked(object sender, System.EventArgs e)
        {
            // create combobox selection by aggregating clubs
            List <string> clubs    = new List <string>();
            List <string> debaters = new List <string>();

            foreach (Debater d in Tournament.I.Debaters)
            {
                if (!clubs.Contains("@" + d.Club.Name))
                {
                    clubs.Add("@" + d.Club.Name);
                }
                debaters.Add(d.Name.ToString());
            }
            clubs.Sort();
            debaters.Sort();

            //AppendCombobox(clubs);
            //AppendCombobox(debaters);


            ListStore store = new ListStore(typeof(string));

            foreach (string c in clubs)
            {
                store.AppendValues(c);
            }
            foreach (string d in debaters)
            {
                store.AppendValues(d);
            }

            ComboBoxEntry cb = new ComboBoxEntry(store, 0);

            cb.Entry.Completion                  = new EntryCompletion();
            cb.Entry.Completion.Model            = store;
            cb.Entry.Completion.TextColumn       = 0;
            cb.Entry.Completion.InlineCompletion = true;
            HBox hbox = new HBox();
            // btnOk
            Button btnOk = new Button();
            Image  im    = new Image();

            im.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-apply", IconSize.Menu);
            btnOk.Add(im);
            btnOk.Clicked += delegate {
                try {
                    pattern.ParsePattern(pattern + "; " + cb.ActiveText);
                }
                catch (Exception ex) {
                    MiscHelpers.ShowMessage(this,
                                            "Could not add pattern: " + ex.Message,
                                            MessageType.Error);
                    return;
                }
                UpdateGui();
            };
            hbox.PackStart(btnOk, false, false, 0);
            // btnCancel
            Button btnCancel = new Button();

            im        = new Image();
            im.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-cancel", IconSize.Menu);
            btnCancel.Add(im);
            btnCancel.Clicked += delegate {
                UpdateGui();
            };
            hbox.PackStart(btnCancel, false, false, 0);
            // cb as last element
            hbox.PackStart(cb, false, false, 0);
            hbox.ShowAll();
            vbox.PackStart(hbox, false, false, 0);
            alAdd.Hide();
            GtkScrolledWindow.Vadjustment.Value = GtkScrolledWindow.Vadjustment.Upper;
        }