<commit_before>﻿using LiveSplit.Model;
using LiveSplit.Options;
using LiveSplit.TimeFormatters;
using LiveSplit.UI;
using LiveSplit.Web;
using LiveSplit.Web.Share;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LiveSplit.View
{
    public partial class BrowseSplitsIODialog : Form
    {
        delegate void CategoryNodeAction();
        public IRun Run { get; set; }
        public BrowseSplitsIODialog(bool isImporting = false)
        {
            InitializeComponent();
            chkIncludeTimes.Visible = chkDownloadEmpty.Visible = !isImporting;
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            splitsTreeView.Nodes.Clear();
            try
            {
                var searchText = txtSearch.Text;
                if (!String.IsNullOrEmpty(searchText))
                {
                    var games = SplitsIO.Instance.SearchGame(searchText);
                    foreach (var game in games)
                    {
                        var gameNode = new TreeNode(game.name);
                        var categories = game.categories;
                        foreach (var category in categories)
                        {
                            var categoryNode = new TreeNode(category.name);
                            categoryNode.Nodes.Add(new TreeNode(""));
                            categoryNode.Tag = new CategoryNodeAction(() =>
                            {
                                categoryNode.Nodes.Clear();
                                IEnumerable<dynamic> runs = SplitsIO.Instance.GetRunsForCategory(category.id);
                                runs = runs.OrderBy(x => x.time != SplitsIO.NoTime ? Double.Parse(x.time) : Double.MaxValue);
                                foreach (var run in runs)
                                {
                                    var runText = run.time != SplitsIO.NoTime ? (new ShortTimeFormatter()).Format(TimeSpan.FromSeconds(Double.Parse(run.time))) : "No Final Time";
                                    if (run.user != null)
                                        runText += " by " + run.user.name;
                                    var runNode = new TreeNode(runText);
                                    runNode.Tag = run;
                                    categoryNode.Nodes.Add(runNode);
                                }
                            });
                            gameNode.Nodes.Add(categoryNode);
                        }
                        splitsTreeView.Nodes.Add(gameNode);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                MessageBox.Show("Search Failed!", "Search Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void btnDownload_Click(object sender, EventArgs e)
        {<commit_msg>Fixed times being displayed wrong for Germans<commit_after>﻿using LiveSplit.Model;
using LiveSplit.Options;
using LiveSplit.TimeFormatters;
using LiveSplit.UI;
using LiveSplit.Web;
using LiveSplit.Web.Share;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LiveSplit.View
{
    public partial class BrowseSplitsIODialog : Form
    {
        delegate void CategoryNodeAction();
        public IRun Run { get; set; }
        public BrowseSplitsIODialog(bool isImporting = false)
        {
            InitializeComponent();
            chkIncludeTimes.Visible = chkDownloadEmpty.Visible = !isImporting;
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            splitsTreeView.Nodes.Clear();
            try
            {
                var searchText = txtSearch.Text;
                if (!String.IsNullOrEmpty(searchText))
                {
                    var games = SplitsIO.Instance.SearchGame(searchText);
                    foreach (var game in games)
                    {
                        var gameNode = new TreeNode(game.name);
                        var categories = game.categories;
                        foreach (var category in categories)
                        {
                            var categoryNode = new TreeNode(category.name);
                            categoryNode.Nodes.Add(new TreeNode(""));
                            categoryNode.Tag = new CategoryNodeAction(() =>
                            {
                                categoryNode.Nodes.Clear();
                                IEnumerable<dynamic> runs = SplitsIO.Instance.GetRunsForCategory(category.id);
                                runs = runs.OrderBy(x => x.time != SplitsIO.NoTime ? Double.Parse(x.time, CultureInfo.InvariantCulture) : Double.MaxValue);
                                foreach (var run in runs)
                                {
                                    var runText = run.time != SplitsIO.NoTime ? (new ShortTimeFormatter()).Format(TimeSpan.FromSeconds(Double.Parse(run.time, CultureInfo.InvariantCulture))) : "No Final Time";
                                    if (run.user != null)
                                        runText += " by " + run.user.name;
                                    var runNode = new TreeNode(runText);
                                    runNode.Tag = run;
                                    categoryNode.Nodes.Add(runNode);
                                }
                            });
                            gameNode.Nodes.Add(categoryNode);
                        }
                        splitsTreeView.Nodes.Add(gameNode);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                MessageBox.Show("Search Failed!", "Search Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void btnDownload_Click(object sender, EventArgs e)
        {
{'fraction_non_alphanumeric': 0.08116778954122554, 'fraction_numerical': 0.0, 'mean_word_length': 1.2822108345534406, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2398251', 'n_tokens_mistral': 1476, 'n_tokens_neox': 1413, 'n_words': 306}