c# 写的 传说OL 暴率修改工具 代码

 

FORM1.CS

 

using  System;
using  System.Collections.Generic;
using  System.ComponentModel;
using  System.Data;
using  System.Drawing;
using  System.Text;
using  System.Windows.Forms;
using  System.IO;
using  System.Threading;

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



        
private string path = "";

        
private void button1_Click(object sender, EventArgs e)
        
{
            
this.openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Title 
= "打开代理文件";

            openFileDialog1.CheckFileExists 
= true;

            openFileDialog1.CheckPathExists 
= true;

            openFileDialog1.AddExtension 
= true;

            openFileDialog1.Multiselect 
= false;

            openFileDialog1.Filter 
= "*.txt|*.txt|*.*|*.*";

            
if (openFileDialog1.ShowDialog() == DialogResult.OK)
            
{

                path 
= openFileDialog1.FileName;

                Thread cool 
= new Thread(new ThreadStart(bihande));

                cool.Start();



                
////FileInfo f = new FileInfo(openFileDialog1.FileName);

                
////StreamReader ce = f.OpenText();

                
////this.richTextBox1.Text = ce.ReadToEnd();

                
////ce.Close();

                
//for (int i = 0; i < richTextBox1.Lines.Length; i++)
                //{
                
//    Thread.Sleep(2);

                
//    this.listBox1.Items.Add(richTextBox1.Lines[i]);


                
//}



            }



        }



        
private void bihande()
        
{


            FileInfo f 
= new FileInfo(openFileDialog1.FileName);

            FileStream a 
= f.OpenRead();

            
byte[] buff=new byte[1024];

            
while (a.Read(buff, 0, buff.Length) > 0)
            
{


                
string nn = Encoding.Default.GetString(buff);



                
this.richTextBox1.BeginInvoke(new System.EventHandler(UpdateUI), nn);

                
            }


            a.Close();

            

        }



        
private void prog(object o, System.EventArgs e)
        
{

            
this.progressBar1.Value = (int)o;


        }


        
private void labelx(object o, System.EventArgs e)
        
{

            
this.label2.Text = o.ToString();


        }



        
private void UpdateUI(object o, System.EventArgs e)
        
{
            
this.richTextBox1.AppendText(o.ToString());




        }



        
private void UpdateUI2(object o, System.EventArgs e)
        
{
            
this.richTextBox1.Text=o.ToString();




        }




        
private string getff(string k)
        
{

            
try
            
{

                
int i = k.IndexOf(' ');


                k 
= k.Remove(0, i + 1);

                i 
= k.IndexOf(" H");

                k 
= k.Remove(i, k.Length - i);

              
                
return k;

            }

            
catch
            
{
                
return "aaa";
            }









            
//try
            
//{
            
//    int i1 = 0;
            
//    int i2 = 0;
            
//    int i3 = 0;


            
//    for (int i = 0; i < k.Length; i++)
            
//    {
            
//        if (k[i] ==' ')
            
//        {
            
//            i1 = i;
            
//        }


            
//    }

            
//    MessageBox.Show(k.Length.ToString());

            
//    string  of = k.Remove(0, i1 + 1);

            
//    int b = 0;

            
//    for (int i = 0; i < of.Length; i++)
            
//    {
            
//        if (k[i] == ' ')
            
//        {
            
//            if (b == 0)
            
//            {
            
//                b++;
            
//            }
            
//            else if (b == 1)
            
//            {
            
//                i3 = i;
            
//            }


            
//        }


            
//    }

               

            
//    return of.Remove(i3, k.Length - i3);

            
//}
            
//catch
            
//{
            
//    return "aaa ";
            
//}


        }



        
private string getffx(string k)
        
{
            
int i = k.IndexOf(' ');

            
return k.Remove(i, k.Length - i);

        }



        
string khhh = "";
        
string zeno = "";

     
//   int full = 0;

        
int abuse = 0;

        
private void button3_Click(object sender, EventArgs e)
        
{

               
this.saveFileDialog1 = new SaveFileDialog();

                saveFileDialog1.Title 
= "保存代理文件";

                saveFileDialog1.OverwritePrompt 
= true;

                saveFileDialog1.CreatePrompt 
= true;

                saveFileDialog1.AddExtension 
= true;

                saveFileDialog1.Filter 
= "*.txt|*.txt|*.*|*.*";

                
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                
{

                    khhh 
= saveFileDialog1.FileName;

                    zeno 
= this.textBox2.Text;

                    
this.label1.Text = this.richTextBox1.Lines.Length.ToString();

                    
this.progressBar1.Maximum = this.richTextBox1.Lines.Length;



                    Thread no 
= new Thread(new ThreadStart(kull));
                    no.Start();
                    abuse 
= int.Parse(this.textBox1.Text);

                  
//  kull();

                }





          
        }


        
private void kull()
        
{
            FileStream jj 
= new FileStream(khhh, FileMode.OpenOrCreate, FileAccess.ReadWrite);

           

            
for (int i = 0; i < this.richTextBox1.Lines.Length; i++)
            
{
                

                
byte[] nnnc = Encoding.Default.GetBytes(gaila(this.richTextBox1.Lines[i].ToString())+" ");

                jj.Write(nnnc, 
0, nnnc.Length);

                
this.progressBar1.BeginInvoke(new System.EventHandler(prog),i);

                
this.label2.BeginInvoke(new System.EventHandler(labelx), i);

            }


            jj.Close();
            MessageBox.Show(
"完成");
        }


        
private string gaila(string a)
        
{
            
int kafu = a.Length;

            
if (kafu > 2)
            
{

                
if (a.IndexOf('/'> 0)
                
{

                    
if (a[kafu - abuse] == '0')
                    
{

                        
if (a.IndexOf('-'< 0)
                        
{

                            
return a.Remove(kafu - abuse, abuse);

                        }

                        
else
                        
{
                            
return a+zeno;
                        }



                    }

                    
else
                    
{
                        
return a;

                    }



                }

                
else
                
{

                    
return a;
                }



            }

            
else
            
{
                Thread.Sleep(
10);
                
return a;
            }

        }






        
private void button2_Click(object sender, EventArgs e)
        
{

        }




        
//private void button2_Click(object sender, EventArgs e)
        
//{
        
//    this.saveFileDialog1 = new SaveFileDialog();

        
//    saveFileDialog1.Title = "保存代理文件";

        
//    saveFileDialog1.OverwritePrompt = true;

        
//    saveFileDialog1.CreatePrompt = true;

        
//    saveFileDialog1.AddExtension = true;

        
//    saveFileDialog1.Filter = "*.txt|*.txt|*.*|*.*";

        
//    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
        
//    {
        
//        this.richTextBox1.Text = "";


        
//        for (int i = 0; i < this.listBox1.Items.Count; i++)
        
//        {


        
//            this.richTextBox1.AppendText(this.listBox1.Items[i].ToString() + " ");


        
//        }

        
//        StreamWriter nn = new StreamWriter(saveFileDialog1.FileName);

        
//        nn.Write(this.richTextBox1.Text);

        
//        nn.Close();




        
//    }
      
//  }
    }

}

 

Form1.Designer.cs

 

namespace  WindowsApplication3
{
    
partial class Form1
    
{
        
/// <summary>
        
/// 必需的设计器变量。
        
/// </summary>

        private System.ComponentModel.IContainer components = null;

        
/// <summary>
        
/// 清理所有正在使用的资源。
        
/// </summary>
        
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>

        protected override void Dispose(bool disposing)
        
{
            
if (disposing && (components != null))
            
{
                components.Dispose();
            }

            
base.Dispose(disposing);
        }


        
Windows 窗体设计器生成的代码

        
private System.Windows.Forms.Button button1;
        
private System.Windows.Forms.RichTextBox richTextBox1;
        
private System.Windows.Forms.Button button3;
        
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
        
private System.Windows.Forms.OpenFileDialog openFileDialog1;
        
private System.Windows.Forms.ProgressBar progressBar1;
        
private System.Windows.Forms.Label label1;
        
private System.Windows.Forms.Label label2;
        
private System.Windows.Forms.TextBox textBox1;
        
private System.Windows.Forms.Label label3;
        
private System.Windows.Forms.Label label4;
        
private System.Windows.Forms.TextBox textBox2;
    }

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值