public void BindTo(MoleculeList moleculeList) { chkForAll.ToolTip = ToolTips.Observer.SelectAll(BuilderType); _screenBinder.BindToSource(moleculeList); _gridViewIncludedBinder.BindToSource(toDTOString(moleculeList.MoleculeNames)); _gridViewExcludedBinder.BindToSource(toDTOString(moleculeList.MoleculeNamesToExclude)); }
public void Setup( MoleculeList structureList, ListItemSelectedDelegate itemSelectedCallback) { DataTableMx dt; DataRowMx dr; InSetup = true; StructureList = structureList; ListItemSelectedCallback = itemSelectedCallback; // Create DataTable if not done yet if (DataTable == null) { dt = new DataTableMx(); DataTable = dt; // save ref to table dt.Columns.Add("NameCol", typeof(string)); dt.Columns.Add("StructureCol", typeof(MoleculeMx)); dt.Columns.Add("DateCol", typeof(DateTime)); dt.Columns.Add("StructureTypeCol", typeof(string)); MoleculeGrid.SetupDefaultQueryManager(dt); // setup underlying QueryManager/QueryTable for current type MoleculeGrid.SetupUnboundColumns(dt); } dt = DataTable; // Add rows to DataTable bool saveEnabled = dt.EnableDataChangedEventHandlers(false); // turn off change events while filling if (structureList == null) { InSetup = false; return; } for (int ri = 0; ri < structureList.Count; ri++) // fill in the grid { MoleculeListItem sli = structureList[ri]; dr = dt.NewRow(); dr["NameCol"] = sli.Name; dr["StructureCol"] = sli.Molecule; dr["DateCol"] = sli.UpdateDate; dr["StructureTypeCol"] = sli.MoleculeType; dt.Rows.Add(dr); } MoleculeGrid.DataSource = dt; // make the data visible BandedGridView.ClearSelection(); dt.EnableDataChangedEventHandlers(saveEnabled); InSetup = false; return; }
/// <summary> /// Retrieves molecules for which the given observer can be created /// </summary> private IEnumerable <IMoleculeBuilder> moleculeBuildersValidFor(MoleculeList moleculeList, IEnumerable <IMoleculeBuilder> allMolecules) { if (moleculeList.ForAll) { return(allMolecules.Where(molecule => !moleculeList.MoleculeNamesToExclude.Contains(molecule.Name))); } return(allMolecules.Where(molecule => moleculeList.MoleculeNames.Contains(molecule.Name))); }
public SetMoleculeListsCommand(IMoleculeDependentBuilder targetBuilder, MoleculeList newMoleculeList, IBuildingBlock targetBuildingBlock) : base(targetBuildingBlock) { _targetBuilder = targetBuilder; _targetBuilderId = _targetBuilder.Id; _newMoleculeList = newMoleculeList; CommandType = AppConstants.Commands.EditCommand; ObjectType = new ObjectTypeResolver().TypeFor(targetBuilder); Description = AppConstants.Commands.EditDescriptionMoleculeList(ObjectType, newMoleculeList, _targetBuilder.Name); }
protected override void Context() { _builder = new TransportBuilder(); _builder.MoleculeList.AddMoleculeName("A"); _builder.MoleculeList.AddMoleculeName("B"); _newMoleculeList = new MoleculeList(); _newMoleculeList.AddMoleculeName("A"); _newMoleculeList.AddMoleculeName("C"); _newMoleculeList.AddMoleculeNameToExclude("B"); _buildingBlock = A.Fake <IBuildingBlock>(); sut = new SetMoleculeListsCommand(_builder, _newMoleculeList, _buildingBlock); }
/// <summary> /// Save list to preferences /// </summary> /// <param name="list"></param> /// <param name="listName"></param> public static void SaveStructureListToPreferences( MoleculeList list, string listName) { try { list.Name = listName; string serializedList = list.Serialize(); Preferences.Set(listName, serializedList); } catch (Exception ex) { DebugLog.Message(ex); } return; }
/// <summary> /// ShowMruMoleculeMenu /// </summary> /// <param name="location"></param> /// <param name="molEditorCtl"></param> /// <param name="qc"></param> public static void SelectMruMolecule( MoleculeControl molEditorCtl, QueryColumn qc = null) { MoleculeSelectorControl i = new MoleculeSelectorControl(); i.MolEditorCtl = molEditorCtl; i.Qc = qc; MoleculeList sl = GetMruMoleculesList(); i.Text = "Recent Query Structures"; //for (int i1 = 0; i1 < sl.Count; i1++) // rename to integers 1 to N //{ // sl[i1].Name = (i1 + 1).ToString(); //} i.StructureListControl.Setup(sl, i.ListItemSelectedCallback); i.ShowDialog(SessionManager.ActiveForm); return; }
/// <summary> /// Load list from Preferences /// </summary> /// <param name="listName"></param> /// <param name="list"></param> public static void LoadStructureListFromPreferences( string listName, ref MoleculeList list) { if (list != null) { return; } string txt = Preferences.Get(listName); if (String.IsNullOrEmpty(txt)) { list = new MoleculeList(); return; } try { list = MoleculeList.Deserialize(txt); if (list != null) { list.Name = listName; } } catch (Exception ex) { DebugLog.Message(ex); } if (list == null) { list = new MoleculeList(); } return; }
public static MoleculeListItem FindStructure( MoleculeMx query, MoleculeList csl) { MoleculeListItem sli = null; StructureMatcher sm = new StructureMatcher(); for (int si = 0; si < csl.Count; si++) { sli = csl[si]; if (sli.Molecule == null || sli.Molecule.IsNull) { continue; } if (sm.IsFSSMatch(query, sli.Molecule)) { return(sli); } } return(null); }
protected override async Task Because() { _result = await sut.MapToModel(_snapshot, new SnapshotContext()); }
protected override Task Context() { sut = new MoleculeListMapper(); _moleculeList = new MoleculeList(); return(_completed); }
protected override void ExecuteWith(IMoBiContext context) { base.ExecuteWith(context); _oldMoleculeList = _targetBuilder.MoleculeList.Clone(); _targetBuilder.MoleculeList.Update(_newMoleculeList); }
protected override void ClearReferences() { base.ClearReferences(); _targetBuilder = null; _newMoleculeList = null; }
protected override async Task Because() { _result = await sut.MapToModel(_snapshot); }
public static void SaveStructureList( MoleculeList list, string listName) { StructureListControl.SaveStructureListToPreferences(list, listName); }
public static void LoadMoleculeList( string listName, ref MoleculeList list) { StructureListControl.LoadStructureListFromPreferences(listName, ref list); }