<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Net;
using System.IO;
using System.Xml;
using RelhaxModpack.UIComponents;

namespace RelhaxModpack.Windows
{
    /// <summary>
    /// Event argument passed back to the caller for when the developer selection window is closed
    /// </summary>
    public class DevleoperSelectionsClosedEWventArgs : EventArgs
    {
        /// <summary>
        /// Determines if a selection should be loaded (for example, if the user closed the window instead of selecting one)
        /// </summary>
        public bool LoadSelection = false;

        /// <summary>
        /// the name of the file to load from the online list of selection files
        /// </summary>
        public string FileToLoad = string.Empty;
    }

    /// <summary>
    /// The delegate callback for when the developer selections window is closed
    /// </summary>
    /// <param name="sender">The sender (this)</param>
    /// <param name="e">The arguments</param>
    public delegate void DeveloperSelectionsClosedDelagate(object sender, DevleoperSelectionsClosedEWventArgs e);

    /// <summary>
    /// Interaction logic for DeveloperSelectionsViewer.xaml
    /// </summary>
    public partial class DeveloperSelectionsViewer : RelhaxWindow
    {
        //public
        /// <summary>
        /// Fires when the developer selection window is closed
        /// </summary>
        public event DeveloperSelectionsClosedDelagate OnDeveloperSelectionsClosed;

        //private
        //init it to false so that it only will get changed to true at that one point when it works
        private bool LoadSelection = false;
        private string FileToLoad = "";
        private WebClient client;

        /// <summary>
        /// Create an instance of the DeveloperSelectionsViewer window
        /// </summary>
        public DeveloperSelectionsViewer()
        {
            InitializeComponent();
        }

        private async void OnApplicationLoading(object sender, RoutedEventArgs e)
        {
            DeveloperSelectionsContinueButton.IsEnabled = false;

            //download and parse xml document
            string selectionsXMlString = string.Empty;
            using (client = new WebClient())
            {
                try
                {
                    selectionsXMlString = await client.DownloadStringTaskAsync(Settings.SelectionsRoot + Settings.SelectionsXml);
                }
                catch(Exception ex)
                {
                    Logging.Exception(ex.ToString());
                    MessageBox.Show(Translations.GetTranslatedString("failedToParseSelections"));
                    Close();
                    return;
                }
            }
            XmlDocument doc = XmlUtils.LoadXmlDocument(selectionsXMlString,XmlLoadType.FromString);
            if(doc == null)
            {
                MessageBox.Show(Translations.GetTranslatedString("failedToParseSelections"));
                Close();
                return;
            }

            //make sure the selection file has selection objects
            XmlNodeList selectionsList = XmlUtils.GetXmlNodesFromXPath(doc, "//selections/selection");
            if(selectionsList == null || selectionsList.Count == 0)
            {
                Logging.Error("selectionsList is null or count is 0 after download");
                MessageBox.Show(Translations.GetTranslatedString("failedToParseSelections"));
                Close();
                return;
            }

            //get windowComponent
            WindowColorset developerSelectionColorset = UISettings.CurrentTheme.WindowColorsets[typeof(DeveloperSelectionsViewer)];

            //load selections into stackpanel
            bool firstOne = true;
            foreach (XmlNode node in selectionsList)
            {
                RadioButton selectionButton = new RadioButton()
                {
                    Content = node.Attributes["displayName"],
                    ToolTip = Translations.GetTranslatedString("lastModified") + ": " + node.Attributes["lastModified"],<commit_msg>i don't think this feature literally ever worked. Must have been legacy from V1.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Net;
using System.IO;
using System.Xml;
using RelhaxModpack.UIComponents;

namespace RelhaxModpack.Windows
{
    /// <summary>
    /// Event argument passed back to the caller for when the developer selection window is closed
    /// </summary>
    public class DevleoperSelectionsClosedEWventArgs : EventArgs
    {
        /// <summary>
        /// Determines if a selection should be loaded (for example, if the user closed the window instead of selecting one)
        /// </summary>
        public bool LoadSelection = false;

        /// <summary>
        /// the name of the file to load from the online list of selection files
        /// </summary>
        public string FileToLoad = string.Empty;
    }

    /// <summary>
    /// The delegate callback for when the developer selections window is closed
    /// </summary>
    /// <param name="sender">The sender (this)</param>
    /// <param name="e">The arguments</param>
    public delegate void DeveloperSelectionsClosedDelagate(object sender, DevleoperSelectionsClosedEWventArgs e);

    /// <summary>
    /// Interaction logic for DeveloperSelectionsViewer.xaml
    /// </summary>
    public partial class DeveloperSelectionsViewer : RelhaxWindow
    {
        //public
        /// <summary>
        /// Fires when the developer selection window is closed
        /// </summary>
        public event DeveloperSelectionsClosedDelagate OnDeveloperSelectionsClosed;

        //private
        //init it to false so that it only will get changed to true at that one point when it works
        private bool LoadSelection = false;
        private string FileToLoad = "";
        private WebClient client;

        /// <summary>
        /// Create an instance of the DeveloperSelectionsViewer window
        /// </summary>
        public DeveloperSelectionsViewer()
        {
            InitializeComponent();
        }

        private async void OnApplicationLoading(object sender, RoutedEventArgs e)
        {
            DeveloperSelectionsContinueButton.IsEnabled = false;

            //download and parse xml document
            string selectionsXMlString = string.Empty;
            using (client = new WebClient())
            {
                try
                {
                    selectionsXMlString = await client.DownloadStringTaskAsync(Settings.SelectionsRoot + Settings.SelectionsXml);
                }
                catch(Exception ex)
                {
                    Logging.Exception(ex.ToString());
                    MessageBox.Show(Translations.GetTranslatedString("failedToParseSelections"));
                    Close();
                    return;
                }
            }
            XmlDocument doc = XmlUtils.LoadXmlDocument(selectionsXMlString,XmlLoadType.FromString);
            if(doc == null)
            {
                MessageBox.Show(Translations.GetTranslatedString("failedToParseSelections"));
                Close();
                return;
            }

            //make sure the selection file has selection objects
            XmlNodeList selectionsList = XmlUtils.GetXmlNodesFromXPath(doc, "//selections/selection");
            if(selectionsList == null || selectionsList.Count == 0)
            {
                Logging.Error("selectionsList is null or count is 0 after download");
                MessageBox.Show(Translations.GetTranslatedString("failedToParseSelections"));
                Close();
                return;
            }

            //get windowComponent
            WindowColorset developerSelectionColorset = UISettings.CurrentTheme.WindowColorsets[typeof(DeveloperSelectionsViewer)];

            //load selections into stackpanel
            bool firstOne = true;
            foreach (XmlNode node in selectionsList)
            {
                RadioButton selectionButton = new RadioButton()
                {
                    Content = node.Attributes["displayName"],
{'fraction_non_alphanumeric': 0.08371350364963503, 'fraction_numerical': 0.0005702554744525547, 'mean_word_length': 2.072529782761037, 'pattern_counts': {'":': 1, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4670870', 'n_tokens_mistral': 2180, 'n_tokens_neox': 2011, 'n_words': 589}