00001 00002 using System; 00003 using Foodolini.BusinessLogic; 00004 using Gtk; 00005 00006 namespace Foodolini.Activities.Ingredients 00007 { 00008 public partial class IngredientSelector : Gtk.Dialog 00009 { 00010 00011 public Ingredient SelectedIngredient { 00012 get { return this.ingredientsactivity.SelectedIngredient; } 00013 } 00014 00015 public double Quantity { 00016 get { return this.sbQuantity.Value; } 00017 set {this.sbQuantity.Value = value;} 00018 } 00019 00020 public IngredientSelector() : this(null,false){} 00021 00029 public IngredientSelector(Ingredient defaultSelection) : this(defaultSelection,false) {} 00030 00031 public IngredientSelector(bool showQuantity):this(null,showQuantity){} 00032 00033 public IngredientSelector (Ingredient defaultSelection, bool showQuantity) 00034 { 00035 this.Build (); 00036 this.Title = "Select ingredient"; 00037 this.sbQuantity.Value = 100; 00038 this.hbox.Visible=showQuantity; 00039 00040 if(defaultSelection != null){ 00041 this.ingredientsactivity.SelectIngredient(defaultSelection); 00042 this.buttonOk.Sensitive = true; 00043 } 00044 00045 this.ingredientsactivity.OnIngredientSelectionChanged += delegate(object sender, EventArgs e) { 00046 if(SelectedIngredient!=null) 00047 this.buttonOk.Sensitive = true; 00048 else 00049 this.buttonOk.Sensitive=false; 00050 }; 00051 00052 } 00053 } 00054 }