<commit_before>﻿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 Superscrot
{
    /// <summary>
    /// Shows a preview of a screenshot, and allows the user to change the filename, as well as to 
    /// save the screenshot to a file or copy it to the clipboard.
    /// </summary>
    public partial class PreviewDialog : Form
    {
        private Screenshot _screenshot;

        /// <summary>
        /// Gets or sets the filename on the form.
        /// </summary>
        public string FileName
        {
            get { return FileNameInput.Text; }
            set { FileNameInput.Text = value; }
        }

        /// <summary>
        /// Initializes a new instance of the preview dialog for the specified screenshot.
        /// </summary>
        /// <param name="s">The screenshot to preview.</param>
        public PreviewDialog(Screenshot s)
        {
            _screenshot = s;

            InitializeComponent();
            FileNameInput.SetCue("Enter a filename");
        }

        /// <summary>
        /// Displays the screenshot and filename when the form loads.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UploadDialog_Load(object sender, EventArgs e)
        {
            if (_screenshot != null)
            {
                ScreenshotPreview.Image = _screenshot.Bitmap;

                string defaultFileName = _screenshot.GetFileName();
                FileNameInput.Text = defaultFileName;

                // Select only the filename itself
                int iFileNameStart = defaultFileName.LastIndexOfAny(new char[] { '\\', '/' }) + 1;
                if (iFileNameStart < 1)
                    iFileNameStart = 0;

                int iFileNameEnd = defaultFileName.IndexOf('.', iFileNameStart);
                if (iFileNameEnd <= iFileNameStart)
                    iFileNameEnd = defaultFileName.Length;

                FileNameInput.Select(iFileNameStart, iFileNameEnd - iFileNameStart);
                FileNameInput.Focus();
            }
        }

        /// <summary>
        /// Saves the "Don't show this dialog again" setting and closes the form when the Upload button is clicked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UploadButton_Click(object sender, EventArgs e)
        {
            if (DontShowAgain.Checked)
            {
                Program.Config.ShowPreviewDialog = false;
                Program.Config.SaveSettings(Program.SettingsPath);
            }<commit_msg>Actually, this makes more sense<commit_after>﻿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 Superscrot
{
    /// <summary>
    /// Shows a preview of a screenshot, and allows the user to change the filename, as well as to 
    /// save the screenshot to a file or copy it to the clipboard.
    /// </summary>
    public partial class PreviewDialog : Form
    {
        private Screenshot _screenshot;

        /// <summary>
        /// Gets or sets the filename on the form.
        /// </summary>
        public string FileName
        {
            get { return FileNameInput.Text; }
            set { FileNameInput.Text = value; }
        }

        /// <summary>
        /// Initializes a new instance of the preview dialog for the specified screenshot.
        /// </summary>
        /// <param name="s">The screenshot to preview.</param>
        public PreviewDialog(Screenshot s)
        {
            _screenshot = s;

            InitializeComponent();
            FileNameInput.SetCue("Enter a filename");
        }

        /// <summary>
        /// Displays the screenshot and filename when the form loads.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UploadDialog_Load(object sender, EventArgs e)
        {
            if (_screenshot != null)
            {
                ScreenshotPreview.Image = _screenshot.Bitmap;

                string defaultFileName = _screenshot.GetFileName();
                FileNameInput.Text = defaultFileName;

                // Select only the filename itself
                string fileName = System.IO.Path.GetFileNameWithoutExtension(defaultFileName);
                int iStart = defaultFileName.IndexOf(fileName);
                if (iStart < 0)
                    iStart = 0;

                FileNameInput.Select(iStart, fileName.Length);
                FileNameInput.Focus();
            }
        }

        /// <summary>
        /// Saves the "Don't show this dialog again" setting and closes the form when the Upload button is clicked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UploadButton_Click(object sender, EventArgs e)
        {
            if (DontShowAgain.Checked)
            {
                Program.Config.ShowPreviewDialog = false;
                Program.Config.SaveSettings(Program.SettingsPath);
            }
{'fraction_non_alphanumeric': 0.10200262025079543, 'fraction_numerical': 0.0009358038555118847, 'mean_word_length': 1.7405128205128204, 'pattern_counts': {'":': 0, '<': 46, '<?xml version=': 0, '>': 43, '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': '5699550', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1304, 'n_words': 393}