winform格式转换器

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{

}

private void richTextBox1_TextChanged(object sender, EventArgs e)
{

}

private void richTextBox2_TextChanged(object sender, EventArgs e)
{

}

private void Switch_Select()
{
//string str = comboBox1.SelectedItem.ToString();
List<string> midList = new List<string>();
foreach (string item in richTextBox1.Lines)
{
if (!midList.Contains(item)) { midList.Add(item); }
}

if (midList[midList.Count - 1] == "")
{
midList.RemoveAt(midList.Count - 1);
}

// Display the ProgressBar control.
progressBar1.Visible = true;
// Set Minimum to 1 to represent the first file being copied.
progressBar1.Minimum = 1;
// Set Maximum to the total number of files to copy.
progressBar1.Maximum = 5000;
// Set the initial value of the ProgressBar.
progressBar1.Value = 1;
// Set the Step property to a value of 1 to represent each file being copied.
progressBar1.Step = 1;

//int i = 0;
switch (comboBox1.SelectedItem.ToString())
{
case "A => ‘A‘":
foreach (string items in midList)
{
//i = 0;
string input_links = Regex.Replace(items, " ", "");
richTextBox2.Text += "‘" + input_links + "‘" + "\r\n";
//i++;
//if(i > 200) { i = 0; Application.DoEvents(); }
progressBar1.PerformStep();
Application.DoEvents();
}
break;
case "A => ‘A‘,":
foreach (string items in midList)
{
string input_links = Regex.Replace(items, " ", "");
richTextBox2.Text += "‘" + input_links + "‘," + "\r\n";
//Application.DoEvents();
progressBar1.PerformStep();
Application.DoEvents();
}
break;
case "A => ‘6JA‘":
foreach (string items in midList)
{
string input_links = Regex.Replace(items, " ", "");
richTextBox2.Text += "‘6J" + input_links + "‘" + "\r\n";
//Application.DoEvents();
progressBar1.PerformStep();
Application.DoEvents();
}
break;
case "A => ‘6JA‘,":
foreach (string items in midList)
{
string input_links = Regex.Replace(items, " ", "");
richTextBox2.Text += "‘6J" + input_links + "‘," + "\r\n";
//Application.DoEvents();
progressBar1.PerformStep();
Application.DoEvents();
}
break;
case "A => ‘A:ZA‘,":
foreach (string items in midList)
{
string input_links = Regex.Replace(items, " ", "");
richTextBox2.Text += "‘" + input_links + ":ZA‘," + "\r\n";
//Application.DoEvents();
progressBar1.PerformStep();
Application.DoEvents();
}
break;
case "A => ‘A:ZB‘,":
foreach (string items in midList)
{
string input_links = Regex.Replace(items, " ", "");
richTextBox2.Text += "‘" + input_links + ":ZB‘," + "\r\n";
//Application.DoEvents();
progressBar1.PerformStep();
Application.DoEvents();
}
break;
case "A => ‘A:ZC‘,":
foreach (string items in midList)
{
string input_links = Regex.Replace(items, " ", "");
richTextBox2.Text += "‘" + input_links + ":ZC‘," + "\r\n";
//Application.DoEvents();
progressBar1.PerformStep();
Application.DoEvents();
}
break;
case "A => ‘A:ZD‘,":
foreach (string items in midList)
{
string input_links = Regex.Replace(items, " ", "");
richTextBox2.Text += "‘" + input_links + ":ZD‘," + "\r\n";
//Application.DoEvents();
progressBar1.PerformStep();
Application.DoEvents();
}
break;
case "A => ‘6JA:ZA‘,":
foreach (string items in midList)
{
string input_links = Regex.Replace(items, " ", "");
richTextBox2.Text += "‘6J" + input_links + ":ZA‘," + "\r\n";
//Application.DoEvents();
progressBar1.PerformStep();
Application.DoEvents();
}
break;
case "A => ‘6JA:ZB‘,":
foreach (string items in midList)
{
string input_links = Regex.Replace(items, " ", "");
richTextBox2.Text += "‘6J" + input_links + ":ZB‘," + "\r\n";
//Application.DoEvents();
progressBar1.PerformStep();
Application.DoEvents();
}
break;
case "A => ‘6JA:ZC‘,":
foreach (string items in midList)
{
string input_links = Regex.Replace(items, " ", "");
richTextBox2.Text += "‘6J" + input_links + ":ZC‘," + "\r\n";
//Application.DoEvents();
progressBar1.PerformStep();
Application.DoEvents();
}
break;
case "A => ‘6JA:ZD‘,":
foreach (string items in midList)
{
string input_links = Regex.Replace(items, " ", "");
richTextBox2.Text += "‘6J" + input_links + ":ZD‘," + "\r\n";
//Application.DoEvents();
progressBar1.PerformStep();
Application.DoEvents();
}
break;
case "A => A.CSV":
foreach (string items in midList)
{
string input_links = Regex.Replace(items, " ", "");
richTextBox2.Text += input_links + ".CSV" + "\r\n";
//Application.DoEvents();
progressBar1.PerformStep();
Application.DoEvents();
}
break;
default:
Console.WriteLine("Default case");
break;
}
}

private void button1_Click(object sender, EventArgs e)
{
richTextBox2.Clear();
this.richTextBox1.Text = Regex.Replace(this.richTextBox1.Text, @"(?s)\n\s*\n", "\n");
this.richTextBox1.Text = Regex.Replace(this.richTextBox1.Text, " ", "");
Switch_Select();
progressBar1.Step = 10000;
progressBar1.PerformStep();
}

private void progressBar1_Click(object sender, EventArgs e)
{

}

//private void CopyWithProgress(string[] filenames)
//{

// // Loop through all files to copy.
// for (int x = 1; x <= progressBar1.Maximum; x++)
// {
// // Copy the file and increment the ProgressBar if successful.
// if (CopyFile(filenames[x - 1]) == true)
// {
// // Perform the increment on the ProgressBar.
// progressBar1.PerformStep();
// }
// }
//}
}
}

winform格式转换器

上一篇:C# datatable 中 根据条件修改某个字段的值


下一篇:如何给衣帽间装修?衣帽间装修效果图欣赏