Esempio n. 1
0
        internal void ShowSpells(List <PlayerStats> selectedStats, CombinedStats currentStats)
        {
            var raidStats = currentStats?.RaidStats;

            if (selectedStats != null && raidStats != null)
            {
                PlayerList     = selectedStats.Select(stats => stats.OrigName).ToList();
                TheSpellCounts = SpellCountBuilder.GetSpellCounts(PlayerList, raidStats);

                if (TheSpellCounts.PlayerCastCounts.Count > 0)
                {
                    selectAll.IsEnabled = true;
                }

                Display();
            }
        }
Esempio n. 2
0
        internal void Display()
        {
            lock (LockObject)
            {
                if (Running == false)
                {
                    Running = true;
                    showSelfOnly.IsEnabled = castTypes.IsEnabled = spellTypes.IsEnabled = false;

                    Task.Delay(50).ContinueWith(task =>
                    {
                        Dispatcher.InvokeAsync(() =>
                        {
                            foreach (var name in UniqueNames.Keys)
                            {
                                var column = new DataGridTextColumn()
                                {
                                    Header  = name,
                                    Width   = DataGridLength.Auto,
                                    Binding = new Binding(name)
                                };

                                var columnStyle = new Style(typeof(TextBlock));
                                columnStyle.Setters.Add(new Setter(TextBlock.ForegroundProperty, new Binding(name)
                                {
                                    Converter = new ReceivedSpellColorConverter()
                                }));
                                column.ElementStyle = columnStyle;
                                dataGrid.Columns.Add(column);
                            }
                        });

                        var allSpells    = new HashSet <TimedAction>();
                        var startTime    = SpellCountBuilder.QuerySpellBlocks(RaidStats, allSpells);
                        var playerSpells = new Dictionary <string, List <string> >();
                        var helper       = new DictionaryListHelper <string, string>();
                        int max          = 0;

                        double lastTime = double.NaN;
                        foreach (var action in allSpells.OrderBy(action => action.BeginTime).ThenBy(action => (action is ReceivedSpell) ? 1 : -1))
                        {
                            if (!double.IsNaN(lastTime) && action.BeginTime != lastTime)
                            {
                                AddRow(playerSpells, max, lastTime, startTime);
                                playerSpells.Clear();
                                max = 0;
                            }

                            int size = 0;
                            if ((CurrentCastType == 0 || CurrentCastType == 1) && action is SpellCast)
                            {
                                if (action is SpellCast cast && !cast.Interrupted && IsValid(cast, UniqueNames, cast.Caster, out _))
                                {
                                    size = helper.AddToList(playerSpells, cast.Caster, cast.Spell);
                                }
                            }
                            else if ((CurrentCastType == 0 || CurrentCastType == 2) && action is ReceivedSpell)
                            {
                                SpellData replaced = null;
                                if (action is ReceivedSpell received && IsValid(received, UniqueNames, received.Receiver, out replaced))
                                {
                                    if (replaced != null)
                                    {
                                        size = helper.AddToList(playerSpells, received.Receiver, "Received " + replaced.NameAbbrv);
                                    }
                                }
                            }

                            max      = Math.Max(max, size);
                            lastTime = action.BeginTime;
                        }

                        if (playerSpells.Count > 0 && max > 0)
                        {
                            AddRow(playerSpells, max, lastTime, startTime);
                        }

                        Dispatcher.InvokeAsync(() =>
                        {
                            // only enable for current player
                            showSelfOnly.IsEnabled = UniqueNames.ContainsKey(ConfigUtil.PlayerName);
                            castTypes.IsEnabled    = spellTypes.IsEnabled = true;

                            lock (LockObject)
                            {
                                Running = false;
                            }
                        });
                    }, TaskScheduler.Default);
                }
            }
        }