Exemple #1
0
        /**********************/
        /* CreateEntitySource */
        /**********************/
        private void CreateEntitySource()
        {
            entityCollection = new FactInstanceCollection(entityList);
            entitySourceList = new CollectionViewSource()
            {
                Source = entityCollection
            };

            entitySourceList.Filter += EntityFilter;

            entityDataGridView.ItemsSource = entitySourceList.View;
        }
Exemple #2
0
        /**************/
        /* 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;
            }
        }
Exemple #3
0
        /********************/
        /* RestoreSelection */
        /********************/
        private void RestoreSelection()
        {
            int          i, count;
            bool         found;
            Module       theModule;
            FactInstance theEntity;

            moduleDataGridView.SelectedItem = null;
            entityDataGridView.SelectedItem = null;

            if (lastModuleRow == -1)
            {
                if (moduleDataGridView.Items.Count > 0)
                {
                    theModule = moduleDataGridView.Items[0] as Module;
                    moduleDataGridView.SelectedItem = theModule;
                }
            }
            else
            {
                count = moduleDataGridView.Items.Count;
                found = false;

                if (lastModuleRow < count)
                {
                    theModule = moduleDataGridView.Items[lastModuleRow] as Module;

                    if (theModule.ModuleName.Equals(lastModule))
                    {
                        moduleDataGridView.SelectedItem = theModule;
                        found = true;
                    }
                }

                if (!found)
                {
                    for (i = 0; i < count; i++)
                    {
                        theModule = moduleDataGridView.Items[i] as Module;

                        if (theModule.ModuleName.Equals(lastModule))
                        {
                            found = true;
                            moduleDataGridView.SelectedItem = theModule;
                            break;
                        }
                    }
                }

                if (!found)
                {
                    lastEntityRow = -1;
                    lastEntity    = null;
                    if (count > 0)
                    {
                        if (lastModuleRow < count)
                        {
                            theModule = moduleDataGridView.Items[lastModuleRow] as Module;
                            moduleDataGridView.SelectedItem = theModule;
                        }
                        else
                        {
                            theModule = moduleDataGridView.Items[count - 1] as Module;
                            moduleDataGridView.SelectedItem = theModule;
                        }
                    }
                }
            }

            if (lastEntityRow == -1)
            {
                if (entityDataGridView.Items.Count > 0)
                {
                    theEntity = entityDataGridView.Items[0] as FactInstance;
                    entityDataGridView.SelectedItem = theEntity;
                }
            }
            else
            {
                count = entityDataGridView.Items.Count;
                found = false;

                if (lastEntityRow < count)
                {
                    theEntity = entityDataGridView.Items[lastEntityRow] as FactInstance;

                    if (theEntity.Name.Equals(lastEntity))
                    {
                        entityDataGridView.SelectedItem = theEntity;
                        found = true;
                    }
                }

                if (!found)
                {
                    for (i = 0; i < count; i++)
                    {
                        theEntity = entityDataGridView.Items[i] as FactInstance;

                        if (theEntity.Name.Equals(lastEntity))
                        {
                            found = true;
                            entityDataGridView.SelectedItem = theEntity;
                            break;
                        }
                    }
                }

                if (!found)
                {
                    if (count > 0)
                    {
                        if (lastEntityRow < count)
                        {
                            theEntity = entityDataGridView.Items[lastEntityRow] as FactInstance;
                            entityDataGridView.SelectedItem = theEntity;
                        }
                        else
                        {
                            theEntity = entityDataGridView.Items[count - 1] as FactInstance;
                            entityDataGridView.SelectedItem = theEntity;
                        }
                    }
                }
            }

            if (entityDataGridView.SelectedItem != null)
            {
                theEntity = entityDataGridView.SelectedItem as FactInstance;

                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;
            }

            lastModuleRow = -1;
            lastModule    = null;
            lastEntity    = null;
            lastEntityRow = -1;
        }