Esempio n. 1
0
        public OverlayDataGridView(OverlayTableSetting setting, List <OverlayDataGridViewItem> backingSource) : base()
        {
            InitializeComponent();

            this.setting       = setting;
            this.backingSource = backingSource;
        }
Esempio n. 2
0
        private void populateTable(OverlayDataGridView dataGridView, List <OverlayDataGridViewItem> dataSource, List <OverlayDataGridViewItem> viewItems, OverlayTableSetting tableSetting)
        {
            if (!tableSetting.ShowTable)
            {
                return;
            }

            if (viewItems == null || viewItems.Count == 0)
            {
                return;
            }

            dataGridView.SuspendLayout();
            dataSource.Clear();

            if (!tableSetting.ShowLimit)
            {
                OverlayDataGridViewItem limit = viewItems.FirstOrDefault(x => x.Job == "LIMIT");

                if (limit != null)
                {
                    viewItems.Remove(limit);
                }
            }

            List <OverlayDataGridViewItem> players = viewItems.Where(x => !string.IsNullOrEmpty(x.Job) && x.Job != "PET").ToList();
            List <OverlayDataGridViewItem> pets    = viewItems.Where(x => x.Job == "PET").ToList();

            foreach (OverlayDataGridViewItem pet in pets)
            {
                string masterName = pet.Name.Substring(pet.Name.IndexOf('(') + 1);
                masterName = masterName.Substring(0, masterName.LastIndexOf(')')).Trim();

                if (masterName == charName)
                {
                    masterName = "YOU";
                }

                pet.Master = players.FirstOrDefault(x => x.Name == masterName);

                if (pet.Master != null && pet.Master.Name == "YOU")
                {
                    pet.HiddenName = pet.Name;
                }
            }

            if (tableSetting.ShowOnlyHealer)
            {
                List <OverlayDataGridViewItem> healers = players.Where(x => healerJobNames.Contains(x.Job)).ToList();
                players = healers;

                List <OverlayDataGridViewItem> healerPets = pets.Where(x => players.Contains(x.Master)).ToList();
                pets = healerPets;
            }

            if (tableSetting.CombinePets)
            {
                foreach (OverlayDataGridViewItem pet in pets)
                {
                    if (pet.Master != null)
                    {
                        pet.Master.PetDPS += pet.EncDPS;
                        pet.Master.PetHPS += pet.EncHPS;

                        pet.Master.PetDamage   += pet.Damage;
                        pet.Master.PetHealed   += pet.Healed;
                        pet.Master.PetOverHeal += pet.OverHeal;

                        pet.Master.PetHits       += pet.Hits;
                        pet.Master.PetDirectHits += pet.DirectHits;
                        pet.Master.PetCritHits   += pet.CritHits;

                        pet.Master.PetHeals     += pet.Heals;
                        pet.Master.PetCritHeals += pet.CritHeals;

                        if (pet.MaxHit > pet.Master.MaxHit)
                        {
                            pet.Master.PetMaxHit       = pet.MaxHit;
                            pet.Master.PetMaxHitString = pet.MaxHitString;
                        }

                        if (pet.MaxHeal > pet.Master.MaxHeal)
                        {
                            pet.Master.PetMaxHeal       = pet.MaxHeal;
                            pet.Master.PetMaxHealString = pet.MaxHealString;
                        }

                        pet.Master.PetSwings += pet.Swings;
                        pet.Master.PetMisses += pet.Misses;
                    }
                }

                foreach (OverlayDataGridViewItem player in players)
                {
                    player.RefreshPrints();
                    dataSource.Add(player);
                }
            }
            else
            {
                foreach (OverlayDataGridViewItem player in players)
                {
                    player.RefreshPrints();
                    dataSource.Add(player);
                }

                foreach (OverlayDataGridViewItem pet in pets)
                {
                    pet.RefreshPrints();
                    dataSource.Add(pet);
                }
            }

            ((BindingList <OverlayDataGridViewItem>)dataGridView.DataSource).ResetBindings();
            dataGridView.ResumeLayout(true);
        }