<commit_before>﻿
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Threading.Tasks;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System.Security.Cryptography;

using FireCrypt.Network;
using FireCrypt.NewVolumeWizard;


namespace FireCrypt
{
	/// <summary>
	/// Description of MainForm.
	/// </summary>
	public partial class MainForm : Form
	{
		FireCryptVolume currentVolume;
		List<string> CryptListItemLocations;
		
		public MainForm()
		{
			CryptListItemLocations = new List<string>();
			Form.CheckForIllegalCrossThreadCalls = false;
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
		}
		async void Button2Click(object sender, EventArgs e)
		{
			DialogResult dr = MessageBox.Show("Are you sure you want to remove the selected item?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
			if (dr == DialogResult.Yes)
			{
				await Task.Run(()=>RemoveCryptBox());
			}
		}
		void RemoveCryptBox()
		{
			try
			{
				cryptList.Items.RemoveAt(cryptList.SelectedIndex);
			}
			catch
			{}
			SaveCryptList();
			
		}
		void Label1Click(object sender, EventArgs e)
		{
	
		}
		
		void MainFormLoad(object sender, EventArgs e1)
		{
			//automatic versioning
			label1.Text = string.Format("Version {0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version);
			//Properties.Settings.Default.Reload();
			string volListJ = Properties.Settings.Default.VolumeList;
			try
			{
				CryptListItemLocations = JsonConvert.DeserializeObject<List<string>>(volListJ);
				foreach (string cli in CryptListItemLocations)
				{
					cryptList.Items.Add(new CryptListItem(new FireCryptVolume(cli)));
				}
			}
			catch (Exception e)
			{
				
			}
			SaveCryptList();
		}
		void Label2Click(object sender, EventArgs e)
		{
			
		}
		async void Button3Click(object sender, EventArgs e)
		{
			try
			{
				if (!currentVolume.Unlocked)
				{
					label5.Text = "Unlocking...";
					await Task.Run(()=>TryUnlockVolume());
					//TryUnlockVolume();
				}
				else
				{
					label5.Text = "Locking...";
					await Task.Run(()=>TryLockVolume());
					//TryLockVolume();
				}
			}
			catch (NullReferenceException)
			{
				MessageBox.Show("Please select a volume.");
			}
		}
		List<char> GetFreeDriveLetters()
		{
			List<char> driveLetters = new List<char>(); // Allocate space for alphabet<commit_msg>disable button while running action<commit_after>﻿
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Threading.Tasks;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System.Security.Cryptography;

using FireCrypt.Network;
using FireCrypt.NewVolumeWizard;


namespace FireCrypt
{
	/// <summary>
	/// Description of MainForm.
	/// </summary>
	public partial class MainForm : Form
	{
		FireCryptVolume currentVolume;
		List<string> CryptListItemLocations;
		
		public MainForm()
		{
			CryptListItemLocations = new List<string>();
			Form.CheckForIllegalCrossThreadCalls = false;
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
		}
		async void Button2Click(object sender, EventArgs e)
		{
			DialogResult dr = MessageBox.Show("Are you sure you want to remove the selected item?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
			if (dr == DialogResult.Yes)
			{
				await Task.Run(()=>RemoveCryptBox());
			}
		}
		void RemoveCryptBox()
		{
			try
			{
				cryptList.Items.RemoveAt(cryptList.SelectedIndex);
			}
			catch
			{}
			SaveCryptList();
			
		}
		void Label1Click(object sender, EventArgs e)
		{
	
		}
		
		void MainFormLoad(object sender, EventArgs e1)
		{
			//automatic versioning
			label1.Text = string.Format("Version {0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version);
			//Properties.Settings.Default.Reload();
			string volListJ = Properties.Settings.Default.VolumeList;
			try
			{
				CryptListItemLocations = JsonConvert.DeserializeObject<List<string>>(volListJ);
				foreach (string cli in CryptListItemLocations)
				{
					cryptList.Items.Add(new CryptListItem(new FireCryptVolume(cli)));
				}
			}
			catch (Exception e)
			{
				
			}
			SaveCryptList();
		}
		void Label2Click(object sender, EventArgs e)
		{
			
		}
		async void Button3Click(object sender, EventArgs e)
		{
			try
			{
				button3.Enabled = false;
				if (!currentVolume.Unlocked)
				{
					label5.Text = "Unlocking...";
					await Task.Run(()=>TryUnlockVolume());
					//TryUnlockVolume();
				}
				else
				{
					label5.Text = "Locking...";
					await Task.Run(()=>TryLockVolume());
					//TryLockVolume();
				}
			}
			catch (NullReferenceException)
			{
				MessageBox.Show("Please select a volume.");
			}
			finally
			{
				button3.Enabled = true;
			}
		}
		List<char> GetFreeDriveLetters()
		{
			List<char> driveLetters = new List<char>(); // Allocate space for alphabet
{'fraction_non_alphanumeric': 0.11792975970425139, 'fraction_numerical': 0.004066543438077634, 'mean_word_length': 3.3461847389558232, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, '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': '497142', 'n_tokens_mistral': 2065, 'n_tokens_neox': 1648, 'n_words': 364}