using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace ComboBuddy
{
public partial class ComboBuddy : Form
{
public ComboBuddy()
{
InitializeComponent();
}
private void _okLabel1_Click(object sender, EventArgs e)
{
}
private void fButton1_Click(object sender, EventArgs e)
{
int dupeCounter = 0;
OpenFileDialog diag = new OpenFileDialog();
String text = "";
if (diag.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
StreamReader sr = new StreamReader(File.OpenRead(diag.FileName));
while (sr.Peek() >= 0)
{
text = sr.ReadLine();
if (listBox1.Items.Contains(text))
{
dupeCounter += 1;
}
else if (text != null)
{
listBox1.Items.Add(text);
}
}
sr.Close();
}
else
{
MessageBox.Show("Please Select a File Path");
}
MessageBox.Show(dupeCounter + " Duplicates Removed");
}
private void fButton2_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
}
private void fButton3_Click(object sender, EventArgs e)
{
OpenFileDialog diag2 = new OpenFileDialog();
if (diag2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
StreamWriter sw = new StreamWriter(File.OpenWrite(diag2.FileName));
foreach (string item in listBox1.Items)
{
sw.Write(item);
}
sw.Dispose();
MessageBox.Show("Export Complete");
}
}
private void meteButtonBlue2_Click(object sender, EventArgs e)
{
string user, pass;
int pos;
if (delimText.Text == "" || delimText.Text.Length > 1)
{
MessageBox.Show("Delimeter is empty or contains more than 1 character", "Error");
}
else
{
foreach (string item in listBox1.Items)
{
pos = item.IndexOf(delimText.Text);
if (pos != -1)
{
user = item.Substring(0, pos);
pass = item.Substring(pos + 1);
ListViewItem lvi = new ListViewItem(user);
lvi.SubItems.Add(pass);
listView1.Items.Add(lvi);
}
}
}
}
private void meteButtonBlue3_Click(object sender, EventArgs e)
{
listBox1.Sorted = true;
MessageBox.Show("Put in order A->Z");
}
private void meteButtonBlue4_Click(object sender, EventArgs e)
{
if (listBox1.Sorted == true)
{
for (int i = 0; i < listBox1.Items.Count / 2; i++)
{
var tmp = listBox1.Items[i];
listBox1.Items[i] = listBox1.Items[listBox1.Items.Count - i - 1];
listBox1.Items[listBox1.Items.Count - i - 1] = tmp;
}
MessageBox.Show("Put in Z->A Order");
}
else
{
listBox1.Sorted = true;
for (int i = 0; i < listBox1.Items.Count / 2; i++)
{
var tmp = listBox1.Items[i];
listBox1.Items[i] = listBox1.Items[listBox1.Items.Count - i - 1];
listBox1.Items[listBox1.Items.Count - i - 1] = tmp;
}
MessageBox.Show("Put in Z->A Order");
}
}
private void meteButtonGreen1_Click(object sender, EventArgs e)
{
listView1.Items.Clear();
}
private void meteButtonGreen2_Click(object sender, EventArgs e)
{
OpenFileDialog diag3 = new OpenFileDialog();
if (diag3.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
StreamWriter sw2 = new StreamWriter(File.OpenWrite(diag3.FileName));
foreach (ListViewItem item in listView1.Items)
{
sw2.WriteLine(item.Text);
}
sw2.WriteLine();
sw2.WriteLine();
//Code that exports the subitems as well
sw2.Dispose();
}
else
{
MessageBox.Show("Error occurred. Did not write.");
}
}
}
}