/// <summary> /// Crea el control para los parametros de tipo <c>bool</c>. /// </summary> /// <param name="desc"> /// La descripcion del parametro. /// </param> private void CreateBoolWidget(BitmapProcessPropertyDescription desc) { CheckButton check = new CheckButton(desc.Description); check.Active = (bool)info.GetValue(process, null); widget = check; }
/// <summary> /// Inicializa el control. /// </summary> /// <returns> /// <c>true</c> si el parametro a editar tiene descripcion, /// <c>false</c> en caso contrario. /// </returns> private bool InitializeWidget() { layout = new HBox(); layout.Spacing = 4; object [] attr; attr = info.GetCustomAttributes( typeof(BitmapProcessPropertyDescription), true); BitmapProcessPropertyDescription desc = null; try { // Aquí fallará si la propiedad no tiene el atributo desc = (BitmapProcessPropertyDescription)attr[0]; } catch (Exception) { return(false); } if (desc != null) { // Si no ha fallado, entra por aquí if (info.PropertyType == typeof(int)) { CreateIntWidget(desc); } else if (info.PropertyType == typeof(bool)) { CreateBoolWidget(desc); } layout.Add(widget); this.Add(layout); this.ShowAll(); return(true); } return(false); }
/// <summary> /// Crea el control para los parametros de tipo <c>int</c>. /// </summary> /// <param name="desc"> /// A <see cref="BitmapProcessPropertyDescription"/> /// </param> private void CreateIntWidget(BitmapProcessPropertyDescription desc) { layout.Add(new Label(desc.Description + ":")); SpinButton spin = new Gtk.SpinButton(0, 1000, 1); spin.Numeric = false; if (desc.Min != -1 && desc.Max != -1) { spin.SetRange(desc.Min, desc.Max); } int val = (int)info.GetValue(process, null); spin.Value = val; widget = spin; }