Beispiel #1
0
        private void GatherData(LogList logList, ProgressBar progressBar, Label progressLabel,
                                GridView <SpeciesData> speciesGridView, GridView <SkillData> skillGridView,
                                GridViewSorter <SpeciesData> speciesSorter, GridViewSorter <SkillData> skillSorter)
        {
            cancellationTokenSource?.Cancel();
            cancellationTokenSource = new CancellationTokenSource();

            var logs = logList.DataStore.ToArray();

            ParseLogs(
                logs,
                cancellationTokenSource.Token,
                new Progress <(int done, int totalLogs, int failed)>(progress =>
            {
                (int done, int totalLogs, int failed) = progress;
                Application.Instance.Invoke(() =>
                {
                    progressBar.MaxValue = totalLogs;
                    progressBar.Value    = done;
                    progressLabel.Text   = $"{done}/{totalLogs} ({failed} failed)";
                });
            })
                ).ContinueWith(task =>
            {
                if (task.Status == TaskStatus.RanToCompletion)
                {
                    Application.Instance.Invoke(() =>
                    {
                        var(species, skills)      = task.Result;
                        speciesGridView.DataStore = new FilterCollection <SpeciesData>(species);
                        skillGridView.DataStore   = new FilterCollection <SkillData>(skills);

                        speciesSorter.UpdateDataStore();
                        skillSorter.UpdateDataStore();
                    });
                }
            });
        }
Beispiel #2
0
        public Statistics(LogList logList, ImageProvider imageProvider)
        {
            var refreshButton = new Button {
                Text = "Refresh statistics for current filter"
            };

            BeginVertical(new Padding(5));
            {
                BeginHorizontal();
                {
                    Add(null, true);
                    Add(refreshButton);
                    Add(null, true);
                }
                EndHorizontal();
            }
            EndVertical();

            BeginVertical();
            {
                BeginHorizontal();
                {
                    BeginGroup("Profession counts", new Padding(5), new Size(5, 5), xscale: true);
                    {
                        foreach (var profession in GameData.Professions.Select(x => x.profession))
                        {
                            professionCountLabels[profession] = new Label {
                                Text = "Unknown"
                            };

                            BeginHorizontal();
                            {
                                var imageView = new ImageView {
                                    Image = imageProvider.GetTinyProfessionIcon(profession)
                                };
                                Add(imageView);
                                Add(professionCountLabels[profession]);
                            }
                            EndHorizontal();
                        }

                        Add(null);
                    }
                    EndGroup();

                    BeginGroup("Specialization counts", xscale: true);
                    {
                        // Core specializations (no elite)
                        BeginHorizontal();
                        {
                            BeginVertical(new Padding(5), new Size(5, 5));
                            {
                                foreach (var profession in GameData.Professions.Select(x => x.profession))
                                {
                                    specializationCoreCountLabels[profession] = new Label {
                                        Text = "Unknown"
                                    };

                                    BeginHorizontal();
                                    {
                                        var imageView = new ImageView
                                        {
                                            Image = imageProvider.GetTinyProfessionIcon(profession)
                                        };
                                        Add(imageView);
                                        Add(specializationCoreCountLabels[profession]);
                                    }
                                    EndHorizontal();
                                }

                                Add(null);
                            }
                            EndVertical();

                            // Heart of Thorns elite specializations
                            BeginVertical(new Padding(5), new Size(5, 5));
                            {
                                foreach (var specialization in GameData.Professions.Select(x => x.hot))
                                {
                                    specializationEliteCountLabels[specialization] = new Label {
                                        Text = "Unknown"
                                    };

                                    BeginHorizontal();
                                    {
                                        var imageView = new ImageView
                                        {
                                            Image = imageProvider.GetTinyProfessionIcon(specialization)
                                        };
                                        Add(imageView);
                                        Add(specializationEliteCountLabels[specialization]);
                                    }
                                    EndHorizontal();
                                }

                                Add(null);
                            }
                            EndVertical();

                            // Path of Fire elite specializations
                            BeginVertical(new Padding(5), new Size(5, 5));
                            {
                                foreach (var specialization in GameData.Professions.Select(x => x.pof))
                                {
                                    specializationEliteCountLabels[specialization] = new Label {
                                        Text = "Unknown"
                                    };

                                    BeginHorizontal();
                                    {
                                        var imageView = new ImageView
                                        {
                                            Image = imageProvider.GetTinyProfessionIcon(specialization)
                                        };
                                        Add(imageView);
                                        Add(specializationEliteCountLabels[specialization]);
                                    }
                                    EndHorizontal();
                                }

                                Add(null);
                            }
                            EndVertical();
                        }
                        EndHorizontal();
                    }
                    EndGroup();
                }
                EndHorizontal();
            }
            EndVertical();
            AddSeparateRow(null);

            refreshButton.Click += (sender, args) =>
            {
                var professionCounts = new Dictionary <Profession, int>();

                var specializationCoreCounts  = new Dictionary <Profession, int>();
                var specializationEliteCounts = new Dictionary <EliteSpecialization, int>();
                int logCount = 0;

                foreach (Profession profession in Enum.GetValues(typeof(Profession)))
                {
                    professionCounts[profession]         = 0;
                    specializationCoreCounts[profession] = 0;
                }

                foreach (EliteSpecialization specialization in Enum.GetValues(typeof(EliteSpecialization)))
                {
                    specializationEliteCounts[specialization] = 0;
                }

                foreach (var log in logList.DataStore)
                {
                    if (log.ParsingStatus != ParsingStatus.Parsed)
                    {
                        continue;
                    }

                    foreach (var player in log.Players)
                    {
                        professionCounts[player.Profession]++;
                        if (player.EliteSpecialization == EliteSpecialization.None)
                        {
                            specializationCoreCounts[player.Profession]++;
                        }
                        else
                        {
                            specializationEliteCounts[player.EliteSpecialization]++;
                        }
                    }

                    logCount++;
                }

                foreach (var pair in professionCountLabels)
                {
                    var profession = pair.Key;
                    var label      = pair.Value;
                    var count      = professionCounts[profession];
                    label.Text = $"{count} ({count / (float) logCount:0.00} on average)";
                }

                foreach (var pair in specializationCoreCountLabels)
                {
                    var profession = pair.Key;
                    var label      = pair.Value;
                    var count      = specializationCoreCounts[profession];
                    label.Text = $"{count}";
                }

                foreach (var pair in specializationEliteCountLabels)
                {
                    var specialization = pair.Key;
                    var label          = pair.Value;
                    var count          = specializationEliteCounts[specialization];
                    label.Text = $"{count}";
                }
            };
        }
Beispiel #3
0
        public GameDataCollecting(LogList logList, LogCache logCache, ApiData apiData, LogDataProcessor logProcessor,
                                  UploadProcessor uploadProcessor, ImageProvider imageProvider, ILogNameProvider nameProvider)
        {
            var gatherButton = new Button {
                Text = "Collect data"
            };
            var cancelButton = new Button {
                Text = "Cancel"
            };
            var exportSpeciesButton = new Button {
                Text = "Export species data to csv"
            };
            var exportSkillsButton = new Button {
                Text = "Export skill data to csv"
            };
            var progressBar   = new ProgressBar();
            var progressLabel = new Label {
                Text = ""
            };
            var speciesGridView = new GridView <SpeciesData>();
            var skillGridView   = new GridView <SkillData>();

            var dataTabs = new TabControl();

            dataTabs.Pages.Add(new TabPage {
                Text = "Species", Content = speciesGridView
            });
            dataTabs.Pages.Add(new TabPage {
                Text = "Skills", Content = skillGridView
            });

            BeginVertical(new Padding(5), new Size(5, 5));
            {
                AddCentered(
                    "Collects a list of all different agent species and skills found in logs (uses current filters).");
                AddCentered("Requires all logs to be processed again as this data is not cached.");
                BeginCentered(spacing: new Size(5, 5));
                {
                    AddRow(gatherButton, cancelButton);
                }
                EndCentered();
                BeginCentered(spacing: new Size(5, 5));
                {
                    AddRow(progressBar);
                    AddRow(progressLabel);
                }
                EndCentered();

                BeginHorizontal(true);
                Add(dataTabs);
                EndHorizontal();
                BeginCentered(spacing: new Size(5, 5));
                {
                    AddRow(exportSpeciesButton, exportSkillsButton);
                }
                EndCentered();
            }
            EndVertical();

            speciesGridView.Columns.Add(new GridColumn
            {
                HeaderText = "Species ID",
                DataCell   = new TextBoxCell()
                {
                    Binding = new DelegateBinding <SpeciesData, string>(x => x.SpeciesId.ToString())
                }
            });
            speciesGridView.Columns.Add(new GridColumn
            {
                HeaderText = "Name",
                DataCell   = new TextBoxCell()
                {
                    Binding = new DelegateBinding <SpeciesData, string>(x => x.Name)
                }
            });
            speciesGridView.Columns.Add(new GridColumn
            {
                HeaderText = "Times seen",
                DataCell   = new TextBoxCell()
                {
                    Binding = new DelegateBinding <SpeciesData, string>(x => x.Logs.Count.ToString())
                }
            });

            var speciesLogsColumn = new GridColumn
            {
                HeaderText = "Logs",
                DataCell   = new TextBoxCell()
                {
                    Binding = new DelegateBinding <SpeciesData, string>(x => "Click me to open log list"),
                }
            };

            speciesGridView.Columns.Add(speciesLogsColumn);

            speciesGridView.CellClick += (sender, args) =>
            {
                if (args.GridColumn == speciesLogsColumn)
                {
                    if (args.Item is SpeciesData speciesData)
                    {
                        var form = new Form
                        {
                            Content = new LogList(logCache, apiData, logProcessor, uploadProcessor, imageProvider,
                                                  nameProvider)
                            {
                                DataStore = new FilterCollection <LogData>(speciesData.Logs)
                            },
                            Width  = 900,
                            Height = 700,
                            Title  = $"arcdps Log Manager: logs containing species {speciesData.Name} (ID {speciesData.SpeciesId})"
                        };
                        form.Show();
                    }
                }
            };

            skillGridView.Columns.Add(new GridColumn
            {
                HeaderText = "Skill ID",
                DataCell   = new TextBoxCell()
                {
                    Binding = new DelegateBinding <SkillData, string>(x => x.SkillId.ToString())
                }
            });
            skillGridView.Columns.Add(new GridColumn
            {
                HeaderText = "Name",
                DataCell   = new TextBoxCell()
                {
                    Binding = new DelegateBinding <SkillData, string>(x => x.Name)
                }
            });
            skillGridView.Columns.Add(new GridColumn
            {
                HeaderText = "Times seen",
                DataCell   = new TextBoxCell()
                {
                    Binding = new DelegateBinding <SkillData, string>(x => x.Logs.Count.ToString())
                }
            });
            var skillLogsColumn = new GridColumn
            {
                HeaderText = "Logs",
                DataCell   = new TextBoxCell()
                {
                    Binding = new DelegateBinding <SkillData, string>(x => "Click me to open log list"),
                }
            };

            skillGridView.Columns.Add(skillLogsColumn);

            skillGridView.CellClick += (sender, args) =>
            {
                if (args.GridColumn == skillLogsColumn)
                {
                    if (args.Item is SkillData skillData)
                    {
                        var form = new Form
                        {
                            Content = new LogList(logCache, apiData, logProcessor, uploadProcessor, imageProvider,
                                                  nameProvider)
                            {
                                DataStore = new FilterCollection <LogData>(skillData.Logs)
                            },
                            Width  = 900,
                            Height = 700,
                            Title  = $"arcdps Log Manager: logs containing skill {skillData.Name} (ID {skillData.SkillId})"
                        };
                        form.Show();
                    }
                }
            };

            var speciesSorter = new GridViewSorter <SpeciesData>(speciesGridView);
            var skillSorter   = new GridViewSorter <SkillData>(skillGridView);

            speciesSorter.EnableSorting();
            skillSorter.EnableSorting();

            cancelButton.Click += (sender, args) => cancellationTokenSource?.Cancel();
            gatherButton.Click += (sender, args) =>
                                  GatherData(logList, progressBar, progressLabel, speciesGridView, skillGridView, speciesSorter,
                                             skillSorter);
            exportSkillsButton.Click += (sender, args) =>
                                        SaveToCsv(skillGridView.DataStore ?? Enumerable.Empty <SkillData>());
            exportSpeciesButton.Click += (sender, args) =>
                                         SaveToCsv(speciesGridView.DataStore ?? Enumerable.Empty <SpeciesData>());
        }
Beispiel #4
0
        public GameDataCollecting(LogList logList)
        {
            var gatherButton = new Button {
                Text = "Collect data"
            };
            var cancelButton = new Button {
                Text = "Cancel"
            };
            var exportSpeciesButton = new Button {
                Text = "Export species data to csv"
            };
            var exportSkillsButton = new Button {
                Text = "Export skill data to csv"
            };
            var progressBar   = new ProgressBar();
            var progressLabel = new Label {
                Text = ""
            };
            var speciesGridView = new GridView <SpeciesData>();
            var skillGridView   = new GridView <SkillData>();

            var dataTabs = new TabControl();

            dataTabs.Pages.Add(new TabPage {
                Text = "Species", Content = speciesGridView
            });
            dataTabs.Pages.Add(new TabPage {
                Text = "Skills", Content = skillGridView
            });

            BeginVertical(new Padding(5), new Size(5, 5));
            {
                AddCentered(
                    "Collects a list of all different agent species and skills found in logs (uses current filters).");
                AddCentered("Requires all logs to be processed again as this data is not cached.");
                BeginCentered(spacing: new Size(5, 5));
                {
                    AddRow(gatherButton, cancelButton);
                }
                EndCentered();
                BeginCentered(spacing: new Size(5, 5));
                {
                    AddRow(progressBar);
                    AddRow(progressLabel);
                }
                EndCentered();

                BeginHorizontal(true);
                Add(dataTabs);
                EndHorizontal();
                BeginCentered(spacing: new Size(5, 5));
                {
                    AddRow(exportSpeciesButton, exportSkillsButton);
                }
                EndCentered();
            }
            EndVertical();

            speciesGridView.Columns.Add(new GridColumn
            {
                HeaderText = "Species ID",
                DataCell   = new TextBoxCell()
                {
                    Binding = new DelegateBinding <SpeciesData, string>(x => x.SpeciesId.ToString())
                }
            });
            speciesGridView.Columns.Add(new GridColumn
            {
                HeaderText = "Name",
                DataCell   = new TextBoxCell()
                {
                    Binding = new DelegateBinding <SpeciesData, string>(x => x.Name)
                }
            });
            speciesGridView.Columns.Add(new GridColumn
            {
                HeaderText = "Times seen",
                DataCell   = new TextBoxCell()
                {
                    Binding = new DelegateBinding <SpeciesData, string>(x => x.Count.ToString())
                }
            });

            skillGridView.Columns.Add(new GridColumn
            {
                HeaderText = "Skill ID",
                DataCell   = new TextBoxCell()
                {
                    Binding = new DelegateBinding <SkillData, string>(x => x.SkillId.ToString())
                }
            });
            skillGridView.Columns.Add(new GridColumn
            {
                HeaderText = "Name",
                DataCell   = new TextBoxCell()
                {
                    Binding = new DelegateBinding <SkillData, string>(x => x.Name)
                }
            });
            skillGridView.Columns.Add(new GridColumn
            {
                HeaderText = "Times seen",
                DataCell   = new TextBoxCell()
                {
                    Binding = new DelegateBinding <SkillData, string>(x => x.Count.ToString())
                }
            });

            var speciesSorter = new GridViewSorter <SpeciesData>(speciesGridView);
            var skillSorter   = new GridViewSorter <SkillData>(skillGridView);

            speciesSorter.EnableSorting();
            skillSorter.EnableSorting();

            cancelButton.Click += (sender, args) => cancellationTokenSource?.Cancel();
            gatherButton.Click += (sender, args) =>
                                  GatherData(logList, progressBar, progressLabel, speciesGridView, skillGridView, speciesSorter,
                                             skillSorter);
            exportSkillsButton.Click += (sender, args) =>
                                        SaveToCsv(skillGridView.DataStore ?? Enumerable.Empty <SkillData>());
            exportSpeciesButton.Click += (sender, args) =>
                                         SaveToCsv(speciesGridView.DataStore ?? Enumerable.Empty <SpeciesData>());
        }