private ComboBoxWin ComboBox(ILookupComboBoxMapper mapper) { ComboBoxWin comboBoxWin = null; IControlHabanero control = mapper.Control; if (control is IComboBox) { comboBoxWin = (ComboBoxWin)control; } return(comboBoxWin); }
/// <summary> /// Removes event handlers previously assigned to the ComboBox /// </summary> /// <param name="mapper">The mapper for the lookup ComboBox</param> public void RemoveCurrentHandlers(ILookupComboBoxMapper mapper) { _mapper = mapper; _mapper = mapper; ComboBoxWin comboBoxWin = this.ComboBox(mapper); if (comboBoxWin != null) { comboBoxWin.SelectedIndexChanged -= _mapper.SelectedIndexChangedHandler; } }
/// <summary> /// Removes event handlers previously assigned to the ComboBox /// </summary> /// <param name="mapper">The mapper for the lookup ComboBox</param> public void RemoveCurrentHandlers(ILookupComboBoxMapper mapper) { _mapper = mapper; IControlHabanero control = mapper.Control; if (control is IComboBox) { ComboBoxWin comboBoxWin = (ComboBoxWin)control; comboBoxWin.SelectedIndexChanged -= SelectIndexChangedHandler; _mapper.SelectedIndexChangedHandler = null; } }
public void AddItemSelectedEventHandler(ILookupComboBoxMapper mapper) { _mapper = mapper; IControlHabanero control = mapper.Control; if (control is IComboBox) { ComboBoxWin comboBoxWin = (ComboBoxWin)control; comboBoxWin.SelectedIndexChanged += SelectIndexChangedHandler; _mapper.SelectedIndexChangedHandler = SelectIndexChangedHandler; } }
protected override EnumComboBoxMapper CreateComboBox(string propertyName, bool setBO) { EnumBO bo = new EnumBO(); ComboBoxWin comboBox = new ComboBoxWin(); IControlFactory controlFactory = new ControlFactoryWin(); EnumComboBoxMapper enumComboBoxMapper = new EnumComboBoxMapper(comboBox, propertyName, false, controlFactory); if (setBO) { enumComboBoxMapper.BusinessObject = bo; } return(enumComboBoxMapper); }
/// <summary> /// Adds event handlers to the ComboBox that are suitable for the UI environment /// </summary> /// <param name="mapper">The mapper for the lookup ComboBox</param> public void AddHandlers(ILookupComboBoxMapper mapper) { ComboBoxWin comboBoxWin = this.ComboBox(mapper); if (comboBoxWin != null) { comboBoxWin.KeyPress += delegate(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == 13) { mapper.ApplyChangesToBusinessObject(); mapper.UpdateControlValueFromBusinessObject(); } }; } }
public void Test_RemoveCurrentHandlers_WhenMapperUsingHabaneroControl_ShouldAddBehaviours() { //---------------Set up test pack------------------- var comboBoxWin = new ComboBoxWin { Name = "TestComboBox", Enabled = true }; var comboBoxMapper = new ComboBoxMapperStub(comboBoxWin); //---------------Assert Precondition---------------- Assert.IsInstanceOf <IComboBox>(comboBoxMapper.Control); //---------------Execute Test ---------------------- var comboBoxStrategyWin = new ComboBoxDefaultMapperStrategyWin(); comboBoxStrategyWin.RemoveCurrentHandlers(comboBoxMapper); //---------------Assert Result---------------------- Assert.IsTrue(true, "If an error was not thrown then we are OK"); }