Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Index_Checker
- {
- public partial class Form1 : Form
- {
- int maxCnt = 0;
- List<string> addrList;
- public Form1()
- {
- InitializeComponent();
- maxCnt = 100;
- addrList = new List<string>();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- using (OpenFileDialog ofd = new OpenFileDialog() { Filter = "TXT|*.txt|CSV|*.csv" })
- {
- if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- string file = ofd.FileName;
- if (file.EndsWith("txt"))
- {
- radioButton1.Checked = true;
- }
- else radioButton2.Checked = true;
- textBox1.Text = file;
- }
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- using (SaveFileDialog ofd = new SaveFileDialog() { Filter = "TXT|*.txt|CSV|*.csv" })
- {
- if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- string file = ofd.FileName;
- if (file.EndsWith("txt"))
- {
- radioButton4.Checked = true;
- }
- else radioButton3.Checked = true;
- textBox2.Text = file;
- }
- }
- }
- private void button6_Click(object sender, EventArgs e)
- {
- if (!File.Exists(textBox1.Text)) { MessageBox.Show("Входной файл не существует"); return; }
- addrList = new List<string>(File.ReadAllLines(textBox1.Text));
- maxCnt = addrList.Count;
- progressBar1.Maximum = maxCnt;
- label4.Text = string.Format("0/{0} (0%)", maxCnt);
- }
- private void button3_Click(object sender, EventArgs e)
- {
- Task task = new Task(() =>
- {
- for (int i = 0; i < 100; i++)
- {
- UpdateResults(i);
- Thread.Sleep(1000);
- }
- });
- task.Start();
- }
- void UpdateResults(int current)
- {
- BeginInvoke(new Action(() =>
- {
- progressBar1.Value = current;
- label4.Text = string.Format("{0}/{1} ({2}%)", current, maxCnt, current * 100 / maxCnt);
- }));
- }
- void UpdateInfo(string addr, string index)
- {
- BeginInvoke(new Action(() =>
- {
- label9.Text = index;
- label8.Text = addr;
- }));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement