/****************/ /* EntityFilter */ /****************/ private void EntityFilter(object sender, FilterEventArgs e) { FactInstance fact = e.Item as FactInstance; if (fact == null) { return; } int moduleIndex = moduleDataGridView.SelectedIndex; if (moduleIndex < 0) { moduleIndex = 0; } BitArray theArray = scopes[fact.TypeAddress]; if (theArray.Get(moduleIndex)) { if (fact.SearchForString(searchField.Text)) { e.Accepted = true; } else { e.Accepted = false; } } else { e.Accepted = false; } }
/*****************/ /* SaveSelection */ /*****************/ private void SaveSelection() { int theRow; theRow = moduleDataGridView.SelectedIndex; if (theRow != -1) { lastModuleRow = theRow; Module theModule = moduleDataGridView.Items[theRow] as Module; lastModule = theModule.ModuleName; } else { lastModule = null; lastModuleRow = -1; } theRow = entityDataGridView.SelectedIndex; if (theRow != -1) { lastEntityRow = theRow; FactInstance theEntity = entityDataGridView.Items[theRow] as FactInstance; lastEntity = theEntity.Name; } else { lastEntity = null; lastEntityRow = -1; } }
/************************/ /* CreateSlotListSource */ /************************/ private void CreateSlotListSource( FactInstance theEntity) { slotCollection = new SlotValueCollection(theEntity.GetSlotValues()); slotSourceList = new CollectionViewSource() { Source = slotCollection }; slotSourceList.Filter += SlotFilter; slotDataGridView.ItemsSource = slotSourceList.View; }
/**************/ /* AssignData */ /**************/ private void AssignData( List <Module> theModules, List <FactInstance> theEntityList, Dictionary <ulong, BitArray> theScopes) { modules = theModules; entityList = theEntityList; scopes = theScopes; moduleDataGridView.ItemsSource = theModules; CreateEntitySource(); if (theModules.Count == 0) { moduleDataGridView.SelectedItem = null; } else { moduleDataGridView.SelectedItem = theModules.First(); } if (entityDataGridView.Items.Count != 0) { FactInstance theEntity = entityDataGridView.Items[0] as FactInstance; entityDataGridView.SelectedItem = theEntity; CreateSlotListSource(theEntity); if (slotDataGridView.Items.Count != 0) { SlotValue theSlotValue = slotDataGridView.Items[0] as SlotValue; slotDataGridView.SelectedItem = theSlotValue; } } else { slotDataGridView.ItemsSource = null; slotSourceList = null; entitySourceList = null; entityCollection = null; slotCollection = null; } }