Пример #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();
                    });
                }
            });
        }
Пример #2
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>());
        }
Пример #3
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>());
        }