protected virtual void AddNewObject(LookUpEditEx lookup) { ShowViewParameters svp = new ShowViewParameters(); IObjectSpace newObjectViewObjectSpace = lookup.Properties.Helper.Application.CreateObjectSpace(lookup.Properties.Helper.LookupObjectTypeInfo.Type); object newObject = newObjectViewObjectSpace.CreateObject(lookup.Properties.Helper.LookupObjectTypeInfo.Type); lookupObjectView = lookup.Properties.Helper.Application.CreateDetailView(newObjectViewObjectSpace, newObject, true); svp.CreatedView = lookupObjectView; EventHandler committedEventHandler = (s, e) => { lookup.EditValue = lookup.Properties.Helper.ObjectSpace.GetObject(lookupObjectView.CurrentObject); if (lookup.Properties.DataSource != null) { ((IList)lookup.Properties.DataSource).Add(lookup.EditValue); } }; EventHandler disposedEventHandler = null; disposedEventHandler = (s, e) => { IObjectSpace os = (IObjectSpace)s; os.Disposed -= disposedEventHandler; os.Committed -= committedEventHandler; }; newObjectViewObjectSpace.Committed += committedEventHandler; newObjectViewObjectSpace.Disposed += disposedEventHandler; lookup.Properties.Helper.Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null)); }
private void properties_Enter(object sender, EventArgs e) { LookUpEditEx lookup = (LookUpEditEx)sender; InitializeDataSource(lookup); UpdateButtons(lookup); }
protected virtual void InitializeDataSource(LookUpEditEx lookup) { if (lookup != null && lookup.Properties != null && lookup.Properties.Helper != null) { lookup.InitializeDataSource(); } }
private void UpdateButtons(LookUpEditEx lookup) { bool enabled = (lookup.EditValue != null) && (lookup.EditValue != DBNull.Value); lookup.Properties.Buttons[1].Enabled = enabled; lookup.Properties.Buttons[3].Enabled = enabled; }
protected virtual void OpenCurrentObject(LookUpEditEx lookup) { ShowViewParameters svp = new ShowViewParameters(); IObjectSpace openObjectViewObjectSpace = lookup.Properties.Helper.Application.CreateObjectSpace(); object targetObject = openObjectViewObjectSpace.GetObject(lookup.EditValue); if (targetObject != null) { EventHandler committedEventHandler = (s, e) => { if (lookupObjectView != null) { lookup.EditValue = lookup.Properties.Helper.ObjectSpace.GetObject(lookupObjectView.CurrentObject); } }; EventHandler disposedEventHandler = null; disposedEventHandler = (s, e) => { IObjectSpace os = (IObjectSpace)s; os.Disposed -= disposedEventHandler; os.Committed -= committedEventHandler; }; openObjectViewObjectSpace.Committed += committedEventHandler; openObjectViewObjectSpace.Disposed += disposedEventHandler; lookupObjectView = lookup.Properties.Helper.Application.CreateDetailView(openObjectViewObjectSpace, targetObject, true); svp.CreatedView = lookupObjectView; lookup.Properties.Helper.Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null)); } }
private void RefreshCore(LookUpEditEx lookup) { if (lookup != null) { UpdateButtons(lookup); lookup.RefreshEditValue(); lookup.UpdateDisplayText(); lookup.Refresh(); } }
private void properties_ButtonClick(object sender, ButtonPressedEventArgs e) { LookUpEditEx lookup = (LookUpEditEx)sender; string tag = Convert.ToString(e.Button.Tag); if (tag == OpenButtonTag) { OpenCurrentObject(lookup); } if (tag == MinusButtonTag) { ClearCurrentObject(lookup); } if (tag == AddButtonTag) { AddNewObject(lookup); } }
protected virtual void ClearCurrentObject(LookUpEditEx lookup) { lookup.EditValue = null; DevExpress.ExpressApp.Win.Core.BindingHelper.EndCurrentEdit(lookup); }
private void properties_Closed(object sender, ClosedEventArgs e) { LookUpEditEx lookup = (LookUpEditEx)sender; UpdateButtons(lookup); }
private void properties_EditValueChanged(object sender, EventArgs e) { LookUpEditEx lookup = (LookUpEditEx)sender; UpdateButtons(lookup); }