public void Initialize (EditSession session) { this.session = session; //if standard values are supported by the converter, then //we list them in a combo if (session.Property.Converter.GetStandardValuesSupported (session)) { ListStore store = new ListStore (typeof (string)); ComboBoxEntry combo = new ComboBoxEntry (store, 0); PackStart (combo, true, true, 0); combo.Changed += TextChanged; entry = combo.Entry; entry.HeightRequest = combo.SizeRequest ().Height; //but if the converter doesn't allow nonstandard values, // then we make the entry uneditable if (session.Property.Converter.GetStandardValuesExclusive (session)) { entry.IsEditable = false; entry.CanFocus = false; } //fill the list foreach (object stdValue in session.Property.Converter.GetStandardValues (session)) { store.AppendValues (session.Property.Converter.ConvertToString (session, stdValue)); } //a value of "--" gets rendered as a --, if typeconverter marked with UsesDashesForSeparator object[] atts = session.Property.Converter.GetType () .GetCustomAttributes (typeof (StandardValuesSeparatorAttribute), true); if (atts.Length > 0) { string separator = ((StandardValuesSeparatorAttribute)atts[0]).Separator; combo.RowSeparatorFunc = delegate (TreeModel model, TreeIter iter) { return separator == ((string) model.GetValue (iter, 0)); }; } } // no standard values, so just use an entry else { entry = new Entry (); PackStart (entry, true, true, 0); } //either way we have an entry to play with entry.HasFrame = false; entry.Activated += TextChanged; if (ShouldShowDialogButton ()) { Button button = new Button ("..."); PackStart (button, false, false, 0); button.Clicked += ButtonClicked; } Spacing = 3; ShowAll (); }
public void Initialize(EditSession session) { this.session = session; //if standard values are supported by the converter, then //we list them in a combo if (session.Property.Converter.GetStandardValuesSupported(session)) { ListStore store = new ListStore(typeof(string)); ComboBoxEntry combo = new ComboBoxEntry(store, 0); PackStart(combo, true, true, 0); combo.Changed += TextChanged; entry = combo.Entry; entry.HeightRequest = combo.SizeRequest().Height; //but if the converter doesn't allow nonstandard values, // then we make the entry uneditable if (session.Property.Converter.GetStandardValuesExclusive(session)) { entry.IsEditable = false; entry.CanFocus = false; } //fill the list foreach (object stdValue in session.Property.Converter.GetStandardValues(session)) { store.AppendValues(session.Property.Converter.ConvertToString(session, stdValue)); } //a value of "--" gets rendered as a --, if typeconverter marked with UsesDashesForSeparator object[] atts = session.Property.Converter.GetType() .GetCustomAttributes(typeof(StandardValuesSeparatorAttribute), true); if (atts.Length > 0) { string separator = ((StandardValuesSeparatorAttribute)atts[0]).Separator; combo.RowSeparatorFunc = delegate(TreeModel model, TreeIter iter) { return(separator == ((string)model.GetValue(iter, 0))); }; } } // no standard values, so just use an entry else { entry = new Entry(); PackStart(entry, true, true, 0); } //either way we have an entry to play with entry.HasFrame = false; entry.Activated += TextChanged; if (ShouldShowDialogButton()) { Button button = new Button("..."); PackStart(button, false, false, 0); button.Clicked += ButtonClicked; } Spacing = 3; ShowAll(); }