Do not automatically create objects from references when selecting from a list

This commit is contained in:
Michael Becker 2014-12-18 10:07:28 -05:00
parent 25f43684ff
commit 2b4ef099eb
2 changed files with 21 additions and 12 deletions

View File

@ -98,7 +98,7 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
}
foreach (ObjectModelReference dfr in omrs)
{
dlg.AvailableObjects.Add(dfr.Create());
dlg.AvailableObjects.Add(dfr);
}
dlg.SelectionChanged += dlgObjectModel_SelectionChanged;
dlg.Show();
@ -117,7 +117,17 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
if (mvarMode == DocumentPropertiesDialogMode.Save)
{
// show all dataformats for the current object model
dfrs = UniversalEditor.Common.Reflection.GetAvailableDataFormats(mvarObjectModel.MakeReference());
Association[] assocs = Association.FromCriteria(new AssociationCriteria() { ObjectModel = mvarObjectModel.MakeReference() });
List<DataFormatReference> dfrlist = new List<DataFormatReference>();
foreach (Association assoc in assocs)
{
foreach(DataFormatReference dfr in assoc.DataFormats)
{
dlg.AvailableObjects.Add(dfr);
}
}
dlg.SelectionChanged += dlgDataFormat_SelectionChanged;
dlg.Show();
}
else if (mvarMode == DocumentPropertiesDialogMode.Open)
{
@ -146,7 +156,7 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
}
foreach (DataFormatReference dfr in dfrs)
{
dlg.AvailableObjects.Add(dfr.Create());
dlg.AvailableObjects.Add(dfr);
}
dlg.SelectionChanged += dlgDataFormat_SelectionChanged;
dlg.Show();
@ -205,7 +215,7 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
foreach (AccessorReference ar in ars)
{
if (!ar.Visible) continue;
dlg.AvailableObjects.Add(ar.Create());
dlg.AvailableObjects.Add(ar);
}
dlg.SelectionChanged += dlgAccessor_SelectionChanged;
dlg.Show();

View File

@ -21,12 +21,12 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
protected override void OnDeactivate(EventArgs e)
{
// base.OnDeactivate(e);
// this.Close();
base.OnDeactivate(e);
this.Close();
}
private System.Collections.ObjectModel.Collection<TObj> mvarAvailableObjects = new System.Collections.ObjectModel.Collection<TObj>();
public System.Collections.ObjectModel.Collection<TObj> AvailableObjects { get { return mvarAvailableObjects; } }
private System.Collections.ObjectModel.Collection<TRef> mvarAvailableObjects = new System.Collections.ObjectModel.Collection<TRef>();
public System.Collections.ObjectModel.Collection<TRef> AvailableObjects { get { return mvarAvailableObjects; } }
private TObj mvarSelectedObject = default(TObj);
public TObj SelectedObject { get { return mvarSelectedObject; } set { mvarSelectedObject = value; } }
@ -40,12 +40,11 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
private void UpdateSearch()
{
lv.Items.Clear();
foreach (TObj item in mvarAvailableObjects)
foreach (TRef item in mvarAvailableObjects)
{
TRef itmr = item.MakeReference();
if (String.IsNullOrEmpty(txtSearch.Text.Trim()) || itmr.ShouldFilterObject(txtSearch.Text))
if (String.IsNullOrEmpty(txtSearch.Text.Trim()) || item.ShouldFilterObject(txtSearch.Text))
{
AddObjectToList(itmr);
AddObjectToList(item);
}
}