<commit_before>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Scripting.Hosting;

namespace CurtainFireMakerPlugin.Forms
{
    public partial class PresetSequenceEditorControl : UserControl
    {
        private Dictionary<string, FileSystemWatcher> FileWatcherDict { get; } = new Dictionary<string, FileSystemWatcher>();

        private List<string> Sequence { get; set; } = new List<string>();
        private int SelectedIndex { get => listBoxSequence.SelectedIndex; set => listBoxSequence.SelectedIndex = value; }
        private bool IsSelected => 0 <= SelectedIndex && SelectedIndex < Sequence.Count;

        public string SelectedFilePath => IsSelected ? Sequence[SelectedIndex] : "";

        private string SectedScriptText { set => textBoxSelectedScript.Text = value; }

        public List<string> RecentDirectories { get; set; }

        public PresetSequenceEditorControl()
        {
            InitializeComponent();

            Win32Wrapper.SetTabLength(textBoxSelectedScript.Handle, 16);
        }

        public void LoadConfig(PluginConfig config)
        {
            RecentDirectories = config.RecentScriptDirectories.ToList();
        }

        public void SaveConfig(PluginConfig config)
        {
            config.RecentScriptDirectories = RecentDirectories.Distinct().ToArray();
        }

        public void LoadPreset(Preset preset)
        {
            List<string> sequence = preset.SequenceScripts.ToList();
            Sequence = sequence.ToList();

            UpdateSequenceDataSource();

            SelectedIndex = Sequence.Count == 0 ? -1 : 0;
        }

        public void SavePreset(Preset preset)
        {
            preset.SequenceScripts = Sequence.ToArray();
        }

        private void AddScript(string path)
        {
            Sequence.Add(path);
            UpdateSequenceDataSource();
            SelectedIndex = Sequence.Count - 1;
        }

        private void MoveScript(int count)
        {
            if (!IsSelected || SelectedIndex + count >= Sequence.Count || 0 > SelectedIndex + count || Sequence.Count < 2) return;<commit_msg>[Update] ファイルが存在しているかの判定を挟む<commit_after>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Scripting.Hosting;

namespace CurtainFireMakerPlugin.Forms
{
    public partial class PresetSequenceEditorControl : UserControl
    {
        private Dictionary<string, FileSystemWatcher> FileWatcherDict { get; } = new Dictionary<string, FileSystemWatcher>();

        private List<string> Sequence { get; set; } = new List<string>();
        private int SelectedIndex { get => listBoxSequence.SelectedIndex; set => listBoxSequence.SelectedIndex = value; }
        private bool IsSelected => 0 <= SelectedIndex && SelectedIndex < Sequence.Count;

        public string SelectedFilePath => IsSelected ? Sequence[SelectedIndex] : "";

        private string SectedScriptText { set => textBoxSelectedScript.Text = value; }

        public List<string> RecentDirectories { get; set; }

        public PresetSequenceEditorControl()
        {
            InitializeComponent();

            Win32Wrapper.SetTabLength(textBoxSelectedScript.Handle, 16);
        }

        public void LoadConfig(PluginConfig config)
        {
            RecentDirectories = config.RecentScriptDirectories.ToList();
        }

        public void SaveConfig(PluginConfig config)
        {
            config.RecentScriptDirectories = RecentDirectories.Distinct().ToArray();
        }

        public void LoadPreset(Preset preset)
        {
            Sequence = preset.SequenceScripts.Where(File.Exists).ToList();

            UpdateSequenceDataSource();

            SelectedIndex = Sequence.Count == 0 ? -1 : 0;
        }

        public void SavePreset(Preset preset)
        {
            preset.SequenceScripts = Sequence.ToArray();
        }

        private void AddScript(string path)
        {
            Sequence.Add(path);
            UpdateSequenceDataSource();
            SelectedIndex = Sequence.Count - 1;
        }

        private void MoveScript(int count)
        {
            if (!IsSelected || SelectedIndex + count >= Sequence.Count || 0 > SelectedIndex + count || Sequence.Count < 2) return;
{'fraction_non_alphanumeric': 0.09116871704745166, 'fraction_numerical': 0.0048330404217926184, 'mean_word_length': 2.674737691686844, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7148314', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1122, 'n_words': 267}