Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.VisualBasic;
- using Microsoft.VisualBasic.CompilerServices;
- using Microsoft.VisualBasic.FileIO;
- using System;
- using System.ComponentModel;
- using System.Diagnostics;
- using System.Drawing;
- using System.IO;
- using System.Media;
- using System.Net;
- using System.Net.Sockets;
- using System.Runtime.CompilerServices;
- using System.Security.Cryptography;
- using System.Text;
- using System.Threading;
- using System.Windows.Forms;
- using WindowsApplication1.My;
- namespace WindowsApplication1
- {
- [DesignerGenerated]
- public class Form1 : Form
- {
- private IContainer components;
- [AccessedThroughProperty("Timer1")]
- private System.Windows.Forms.Timer _Timer1;
- [AccessedThroughProperty("NotifyIcon1")]
- private NotifyIcon _NotifyIcon1;
- [AccessedThroughProperty("Gioca")]
- private Button _Gioca;
- [AccessedThroughProperty("Opzioni")]
- private Button _Opzioni;
- [AccessedThroughProperty("Forum")]
- private Button _Forum;
- [AccessedThroughProperty("Esci")]
- private Button _Esci;
- [AccessedThroughProperty("BoxTesto")]
- private Label _BoxTesto;
- [AccessedThroughProperty("ProgressBarTotal")]
- private ProgressBar _ProgressBarTotal;
- [AccessedThroughProperty("ProgressBarCurrent")]
- private ProgressBar _ProgressBarCurrent;
- [AccessedThroughProperty("Label4")]
- private Label _Label4;
- [AccessedThroughProperty("Label3")]
- private Label _Label3;
- [AccessedThroughProperty("percentageParz")]
- private Label _percentageParz;
- [AccessedThroughProperty("percentageTot")]
- private Label _percentageTot;
- [AccessedThroughProperty("TextBox1")]
- private TextBox _TextBox1;
- [AccessedThroughProperty("Label2")]
- private Label _Label2;
- [AccessedThroughProperty("velocita")]
- private Label _velocita;
- [AccessedThroughProperty("rapportoByte")]
- private Label _rapportoByte;
- [AccessedThroughProperty("cmbBoxLingua")]
- private ComboBox _cmbBoxLingua;
- [AccessedThroughProperty("Label1")]
- private Label _Label1;
- private string ip_add;
- private string linkForum;
- private string linkPatchlist;
- private string linkPosFileDown;
- public string nomeLauncher;
- private string linkSitoWebVersioneUpdater;
- private string linkWebDownPatchUpdater;
- private string argumentLauncher;
- private string Virtual_log;
- private int Virtual_id;
- private int ProcesID;
- private Process myProcess;
- public string localFileMD5;
- public string localFileName;
- public string filePath;
- public string grafica;
- public string lingua;
- public bool controllore;
- [AccessedThroughProperty("download")]
- private WebClient _download;
- [AccessedThroughProperty("client")]
- private WebClient _client;
- public int ciclon;
- public string[] vettoreNomi;
- public string[] vettorePeso;
- public string[] vettoreCrc;
- public string[] vettoreMD5;
- public string[] vettoreLink;
- public short numRows;
- public short puntoDiArrivo;
- public int tP;
- public int bitPrec;
- private double vel;
- public SoundPlayer audio;
- public SoundPlayer audio2;
- public SoundPlayer avvia;
- public SoundPlayer dig;
- public bool avvia2;
- public bool esciaudio;
- public bool wirp;
- public bool voing;
- internal virtual System.Windows.Forms.Timer Timer1
- {
- get
- {
- return this._Timer1;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- EventHandler value2 = new EventHandler(this.Timer1_Tick);
- if (this._Timer1 != null)
- {
- this._Timer1.Tick -= value2;
- }
- this._Timer1 = value;
- if (this._Timer1 != null)
- {
- this._Timer1.Tick += value2;
- }
- }
- }
- internal virtual NotifyIcon NotifyIcon1
- {
- get
- {
- return this._NotifyIcon1;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- this._NotifyIcon1 = value;
- }
- }
- internal virtual Button Gioca
- {
- get
- {
- return this._Gioca;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- EventHandler value2 = new EventHandler(this.Gioca_Click);
- EventHandler value3 = new EventHandler(this.Sopra_Gioca);
- if (this._Gioca != null)
- {
- this._Gioca.Click -= value2;
- this._Gioca.MouseHover -= value3;
- }
- this._Gioca = value;
- if (this._Gioca != null)
- {
- this._Gioca.Click += value2;
- this._Gioca.MouseHover += value3;
- }
- }
- }
- internal virtual Button Opzioni
- {
- get
- {
- return this._Opzioni;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- EventHandler value2 = new EventHandler(this.Opzioni_Click);
- EventHandler value3 = new EventHandler(this.Sopra_opzioni);
- if (this._Opzioni != null)
- {
- this._Opzioni.Click -= value2;
- this._Opzioni.MouseHover -= value3;
- }
- this._Opzioni = value;
- if (this._Opzioni != null)
- {
- this._Opzioni.Click += value2;
- this._Opzioni.MouseHover += value3;
- }
- }
- }
- internal virtual Button Forum
- {
- get
- {
- return this._Forum;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- EventHandler value2 = new EventHandler(this.Forum_Click);
- EventHandler value3 = new EventHandler(this.Sopra_forum);
- if (this._Forum != null)
- {
- this._Forum.Click -= value2;
- this._Forum.MouseHover -= value3;
- }
- this._Forum = value;
- if (this._Forum != null)
- {
- this._Forum.Click += value2;
- this._Forum.MouseHover += value3;
- }
- }
- }
- internal virtual Button Esci
- {
- get
- {
- return this._Esci;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- EventHandler value2 = new EventHandler(this.Esci_Click);
- EventHandler value3 = new EventHandler(this.Sopra_Esci);
- if (this._Esci != null)
- {
- this._Esci.Click -= value2;
- this._Esci.MouseHover -= value3;
- }
- this._Esci = value;
- if (this._Esci != null)
- {
- this._Esci.Click += value2;
- this._Esci.MouseHover += value3;
- }
- }
- }
- internal virtual Label BoxTesto
- {
- get
- {
- return this._BoxTesto;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- this._BoxTesto = value;
- }
- }
- internal virtual ProgressBar ProgressBarTotal
- {
- get
- {
- return this._ProgressBarTotal;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- this._ProgressBarTotal = value;
- }
- }
- internal virtual ProgressBar ProgressBarCurrent
- {
- get
- {
- return this._ProgressBarCurrent;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- this._ProgressBarCurrent = value;
- }
- }
- internal virtual Label Label4
- {
- get
- {
- return this._Label4;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- this._Label4 = value;
- }
- }
- internal virtual Label Label3
- {
- get
- {
- return this._Label3;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- this._Label3 = value;
- }
- }
- internal virtual Label percentageParz
- {
- get
- {
- return this._percentageParz;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- this._percentageParz = value;
- }
- }
- internal virtual Label percentageTot
- {
- get
- {
- return this._percentageTot;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- this._percentageTot = value;
- }
- }
- internal virtual TextBox TextBox1
- {
- get
- {
- return this._TextBox1;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- this._TextBox1 = value;
- }
- }
- internal virtual Label Label2
- {
- get
- {
- return this._Label2;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- this._Label2 = value;
- }
- }
- internal virtual Label velocita
- {
- get
- {
- return this._velocita;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- this._velocita = value;
- }
- }
- internal virtual Label rapportoByte
- {
- get
- {
- return this._rapportoByte;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- this._rapportoByte = value;
- }
- }
- internal virtual ComboBox cmbBoxLingua
- {
- get
- {
- return this._cmbBoxLingua;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- EventHandler value2 = new EventHandler(this.cmbBoxLingua_SelectedIndexChanged);
- if (this._cmbBoxLingua != null)
- {
- this._cmbBoxLingua.SelectedIndexChanged -= value2;
- }
- this._cmbBoxLingua = value;
- if (this._cmbBoxLingua != null)
- {
- this._cmbBoxLingua.SelectedIndexChanged += value2;
- }
- }
- }
- internal virtual Label Label1
- {
- get
- {
- return this._Label1;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- this._Label1 = value;
- }
- }
- public virtual WebClient download
- {
- get
- {
- return this._download;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- this._download = value;
- }
- }
- public virtual WebClient client
- {
- get
- {
- return this._client;
- }
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- AsyncCompletedEventHandler value2 = new AsyncCompletedEventHandler(this.client_DownloadFileCompleted);
- DownloadProgressChangedEventHandler value3 = new DownloadProgressChangedEventHandler(this.client_DownloadProgressChanged);
- if (this._client != null)
- {
- this._client.DownloadFileCompleted -= value2;
- this._client.DownloadProgressChanged -= value3;
- }
- this._client = value;
- if (this._client != null)
- {
- this._client.DownloadFileCompleted += value2;
- this._client.DownloadProgressChanged += value3;
- }
- }
- }
- public Form1()
- {
- base.Load += new EventHandler(this.Form1_Load);
- this.ip_add = "91.121.204.49";
- this.linkForum = "http://kingofworldmt2thereborn.com/bo/";
- this.linkPatchlist = "http://kingofworldmt2thereborn.com/patch/clientVersion1/patchlist";
- this.linkPosFileDown = "http://kingofworldmt2thereborn.com/patch/clientVersion1/patchfiles/";
- this.nomeLauncher = "metin2client.exe";
- this.linkSitoWebVersioneUpdater = "http://kingofworldmt2thereborn.com/patch/clientVersion1/patcherUpdater/version.txt";
- this.linkWebDownPatchUpdater = "http://kingofworldmt2thereborn.com/patch/clientVersion1/patcherUpdater/NuovoPatcherUpdater/patcherUpdater.exe";
- this.argumentLauncher = " --DFGGH435FGSD";
- this.Virtual_log = "aX2fww5dM";
- this.Virtual_id = 1;
- this.myProcess = new Process();
- this.grafica = "nulla";
- this.lingua = "Italiano";
- this.controllore = true;
- this.download = new WebClient();
- this.client = new WebClient();
- this.ciclon = 0;
- this.vettoreNomi = new string[51];
- this.vettorePeso = new string[51];
- this.vettoreCrc = new string[51];
- this.vettoreMD5 = new string[51];
- this.vettoreLink = new string[51];
- this.puntoDiArrivo = 0;
- this.tP = 0;
- this.bitPrec = 0;
- this.vel = 0.0;
- this.audio = new SoundPlayer();
- this.audio2 = new SoundPlayer();
- this.avvia = new SoundPlayer();
- this.dig = new SoundPlayer();
- this.avvia2 = true;
- this.esciaudio = true;
- this.wirp = true;
- this.voing = true;
- this.InitializeComponent();
- }
- [DebuggerNonUserCode]
- protected override void Dispose(bool disposing)
- {
- try
- {
- if (disposing && this.components != null)
- {
- this.components.Dispose();
- }
- }
- finally
- {
- base.Dispose(disposing);
- }
- }
- [DebuggerStepThrough]
- private void InitializeComponent()
- {
- this.components = new Container();
- ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(Form1));
- this.Timer1 = new System.Windows.Forms.Timer(this.components);
- this.NotifyIcon1 = new NotifyIcon(this.components);
- this.Gioca = new Button();
- this.Opzioni = new Button();
- this.Forum = new Button();
- this.Esci = new Button();
- this.BoxTesto = new Label();
- this.ProgressBarTotal = new ProgressBar();
- this.ProgressBarCurrent = new ProgressBar();
- this.Label4 = new Label();
- this.Label3 = new Label();
- this.percentageParz = new Label();
- this.percentageTot = new Label();
- this.TextBox1 = new TextBox();
- this.Label2 = new Label();
- this.velocita = new Label();
- this.rapportoByte = new Label();
- this.cmbBoxLingua = new ComboBox();
- this.Label1 = new Label();
- this.SuspendLayout();
- componentResourceManager.ApplyResources(this.NotifyIcon1, "NotifyIcon1");
- this.Gioca.BackColor = Color.Transparent;
- componentResourceManager.ApplyResources(this.Gioca, "Gioca");
- this.Gioca.FlatAppearance.BorderSize = 0;
- this.Gioca.ForeColor = Color.Transparent;
- this.Gioca.Name = "Gioca";
- this.Gioca.UseVisualStyleBackColor = false;
- this.Opzioni.BackColor = Color.Transparent;
- componentResourceManager.ApplyResources(this.Opzioni, "Opzioni");
- this.Opzioni.FlatAppearance.BorderSize = 0;
- this.Opzioni.ForeColor = Color.Transparent;
- this.Opzioni.Name = "Opzioni";
- this.Opzioni.UseVisualStyleBackColor = false;
- this.Forum.BackColor = Color.Transparent;
- componentResourceManager.ApplyResources(this.Forum, "Forum");
- this.Forum.FlatAppearance.BorderSize = 0;
- this.Forum.ForeColor = Color.Transparent;
- this.Forum.Name = "Forum";
- this.Forum.UseVisualStyleBackColor = false;
- this.Esci.BackColor = Color.Transparent;
- componentResourceManager.ApplyResources(this.Esci, "Esci");
- this.Esci.FlatAppearance.BorderSize = 0;
- this.Esci.ForeColor = Color.Transparent;
- this.Esci.Name = "Esci";
- this.Esci.UseVisualStyleBackColor = false;
- this.BoxTesto.BackColor = Color.Transparent;
- componentResourceManager.ApplyResources(this.BoxTesto, "BoxTesto");
- this.BoxTesto.ForeColor = Color.FromArgb(224, 224, 224);
- this.BoxTesto.Name = "BoxTesto";
- this.ProgressBarTotal.ForeColor = Color.FromArgb(0, 192, 192);
- componentResourceManager.ApplyResources(this.ProgressBarTotal, "ProgressBarTotal");
- this.ProgressBarTotal.Name = "ProgressBarTotal";
- this.ProgressBarCurrent.ForeColor = Color.FromArgb(0, 192, 192);
- componentResourceManager.ApplyResources(this.ProgressBarCurrent, "ProgressBarCurrent");
- this.ProgressBarCurrent.Name = "ProgressBarCurrent";
- componentResourceManager.ApplyResources(this.Label4, "Label4");
- this.Label4.BackColor = Color.Transparent;
- this.Label4.ForeColor = SystemColors.Highlight;
- this.Label4.Name = "Label4";
- componentResourceManager.ApplyResources(this.Label3, "Label3");
- this.Label3.BackColor = Color.Transparent;
- this.Label3.ForeColor = SystemColors.Highlight;
- this.Label3.Name = "Label3";
- componentResourceManager.ApplyResources(this.percentageParz, "percentageParz");
- this.percentageParz.BackColor = Color.Transparent;
- this.percentageParz.ForeColor = SystemColors.Highlight;
- this.percentageParz.Name = "percentageParz";
- componentResourceManager.ApplyResources(this.percentageTot, "percentageTot");
- this.percentageTot.BackColor = Color.Transparent;
- this.percentageTot.ForeColor = SystemColors.Highlight;
- this.percentageTot.Name = "percentageTot";
- this.TextBox1.BackColor = Color.Black;
- this.TextBox1.ForeColor = Color.FromArgb(0, 192, 192);
- componentResourceManager.ApplyResources(this.TextBox1, "TextBox1");
- this.TextBox1.Name = "TextBox1";
- componentResourceManager.ApplyResources(this.Label2, "Label2");
- this.Label2.BackColor = Color.Transparent;
- this.Label2.ForeColor = SystemColors.Highlight;
- this.Label2.Name = "Label2";
- componentResourceManager.ApplyResources(this.velocita, "velocita");
- this.velocita.BackColor = Color.Transparent;
- this.velocita.ForeColor = SystemColors.Highlight;
- this.velocita.Name = "velocita";
- componentResourceManager.ApplyResources(this.rapportoByte, "rapportoByte");
- this.rapportoByte.BackColor = Color.Transparent;
- this.rapportoByte.ForeColor = SystemColors.Highlight;
- this.rapportoByte.Name = "rapportoByte";
- this.cmbBoxLingua.DropDownStyle = ComboBoxStyle.DropDownList;
- this.cmbBoxLingua.FormattingEnabled = true;
- this.cmbBoxLingua.Items.AddRange(new object[]
- {
- componentResourceManager.GetString("cmbBoxLingua.Items"),
- componentResourceManager.GetString("cmbBoxLingua.Items1"),
- componentResourceManager.GetString("cmbBoxLingua.Items2"),
- componentResourceManager.GetString("cmbBoxLingua.Items3")
- });
- componentResourceManager.ApplyResources(this.cmbBoxLingua, "cmbBoxLingua");
- this.cmbBoxLingua.Name = "cmbBoxLingua";
- componentResourceManager.ApplyResources(this.Label1, "Label1");
- this.Label1.BackColor = Color.Transparent;
- this.Label1.ForeColor = Color.Orange;
- this.Label1.Name = "Label1";
- componentResourceManager.ApplyResources(this, "$this");
- this.AutoScaleMode = AutoScaleMode.Font;
- this.BackColor = SystemColors.ControlDarkDark;
- this.Controls.Add(this.Label1);
- this.Controls.Add(this.cmbBoxLingua);
- this.Controls.Add(this.rapportoByte);
- this.Controls.Add(this.velocita);
- this.Controls.Add(this.Label2);
- this.Controls.Add(this.TextBox1);
- this.Controls.Add(this.percentageTot);
- this.Controls.Add(this.percentageParz);
- this.Controls.Add(this.Label3);
- this.Controls.Add(this.Label4);
- this.Controls.Add(this.ProgressBarCurrent);
- this.Controls.Add(this.ProgressBarTotal);
- this.Controls.Add(this.BoxTesto);
- this.Controls.Add(this.Esci);
- this.Controls.Add(this.Forum);
- this.Controls.Add(this.Opzioni);
- this.Controls.Add(this.Gioca);
- this.DoubleBuffered = true;
- this.FormBorderStyle = FormBorderStyle.None;
- this.Name = "Form1";
- this.TransparencyKey = Color.FromArgb(255, 128, 0);
- this.ResumeLayout(false);
- this.PerformLayout();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- this.TransparencyKey = this.BackColor;
- this.FormBorderStyle = FormBorderStyle.None;
- this.Timer1.Interval = 1000;
- if (MyProject.Computer.FileSystem.FileExists(Microsoft.VisualBasic.FileSystem.CurDir() + "\\BGM\\Whirrp.wav"))
- {
- this.audio.SoundLocation = Microsoft.VisualBasic.FileSystem.CurDir() + "\\BGM\\Whirrp.wav";
- this.audio.Load();
- }
- else
- {
- this.wirp = false;
- }
- if (MyProject.Computer.FileSystem.FileExists(Microsoft.VisualBasic.FileSystem.CurDir() + "\\BGM\\jaeryun_fail.wav"))
- {
- this.avvia.SoundLocation = Microsoft.VisualBasic.FileSystem.CurDir() + "\\BGM\\jaeryun_fail.wav";
- this.avvia.Load();
- }
- else
- {
- this.avvia2 = false;
- }
- if (MyProject.Computer.FileSystem.FileExists(Microsoft.VisualBasic.FileSystem.CurDir() + "\\BGM\\dig.wav"))
- {
- this.dig.SoundLocation = Microsoft.VisualBasic.FileSystem.CurDir() + "\\BGM\\dig.wav";
- this.dig.Load();
- }
- else
- {
- this.esciaudio = false;
- }
- if (MyProject.Computer.FileSystem.FileExists(Microsoft.VisualBasic.FileSystem.CurDir() + "\\BGM\\swing_2.wav"))
- {
- this.audio2.SoundLocation = Microsoft.VisualBasic.FileSystem.CurDir() + "\\BGM\\swing_2.wav";
- this.audio2.Load();
- }
- else
- {
- this.voing = false;
- }
- if (MyProject.Computer.FileSystem.FileExists(Microsoft.VisualBasic.FileSystem.CurDir() + "/KingOfWorld - TheReborn - Patch.exe"))
- {
- MyProject.Computer.FileSystem.DeleteFile(Microsoft.VisualBasic.FileSystem.CurDir() + "/KingOfWorld - TheReborn - Patch.exe");
- }
- if (this.checkRun("patcherUpdater"))
- {
- Interaction.MsgBox("Il client non deve essere avviato\r\nprima dell'avvio del Autopatcher!", MsgBoxStyle.OkOnly, null);
- if (MyProject.Computer.FileSystem.FileExists(Microsoft.VisualBasic.FileSystem.CurDir() + "/testTemp/patch.txt"))
- {
- MyProject.Computer.FileSystem.DeleteFile(Microsoft.VisualBasic.FileSystem.CurDir() + "/testTemp/patch.txt");
- }
- if (MyProject.Computer.FileSystem.DirectoryExists(Microsoft.VisualBasic.FileSystem.CurDir() + "/testTemp"))
- {
- MyProject.Computer.FileSystem.DeleteDirectory(Microsoft.VisualBasic.FileSystem.CurDir() + "/testTemp", DeleteDirectoryOption.DeleteAllContents);
- }
- this.spegni();
- }
- else
- {
- if (MyProject.Computer.FileSystem.FileExists(Microsoft.VisualBasic.FileSystem.CurDir() + "/versionNet.txt"))
- {
- MyProject.Computer.FileSystem.DeleteFile(Microsoft.VisualBasic.FileSystem.CurDir() + "/versionNet.txt");
- }
- MyProject.Computer.Network.DownloadFile(this.linkSitoWebVersioneUpdater, Microsoft.VisualBasic.FileSystem.CurDir() + "\\versionNet.txt");
- string left;
- if (MyProject.Computer.FileSystem.FileExists(Microsoft.VisualBasic.FileSystem.CurDir() + "\\version.ast"))
- {
- left = File.ReadAllText(Microsoft.VisualBasic.FileSystem.CurDir() + "\\version.ast");
- }
- else
- {
- left = "0";
- }
- string right = File.ReadAllText(Microsoft.VisualBasic.FileSystem.CurDir() + "\\versionNet.txt");
- if (Operators.CompareString(left, right, false) == 0)
- {
- if (MyProject.Computer.FileSystem.FileExists(Microsoft.VisualBasic.FileSystem.CurDir() + "\\versionNet.txt"))
- {
- MyProject.Computer.FileSystem.DeleteFile(Microsoft.VisualBasic.FileSystem.CurDir() + "\\versionNet.txt");
- }
- }
- else if (MyProject.Computer.FileSystem.FileExists(Microsoft.VisualBasic.FileSystem.CurDir() + "/patcherUpdater.exe"))
- {
- string pathName = Microsoft.VisualBasic.FileSystem.CurDir() + "\\patcherUpdater.exe";
- if (MyProject.Computer.FileSystem.FileExists(Microsoft.VisualBasic.FileSystem.CurDir() + "/version.ast"))
- {
- MyProject.Computer.FileSystem.DeleteFile(Microsoft.VisualBasic.FileSystem.CurDir() + "/version.ast");
- }
- MyProject.Computer.FileSystem.RenameFile("versionNet.txt", "version.ast");
- if (MyProject.Computer.FileSystem.FileExists(Microsoft.VisualBasic.FileSystem.CurDir() + "\\versionNet.txt"))
- {
- MyProject.Computer.FileSystem.DeleteFile(Microsoft.VisualBasic.FileSystem.CurDir() + "\\versionNet.txt");
- }
- this.ProcesID = Interaction.Shell(pathName, AppWinStyle.NormalFocus, false, -1);
- this.spegni();
- }
- else
- {
- MyProject.Computer.Network.DownloadFile(this.linkWebDownPatchUpdater, "patcherUpdater.exe");
- string pathName2 = Microsoft.VisualBasic.FileSystem.CurDir() + "\\patcherUpdater.exe";
- if (MyProject.Computer.FileSystem.FileExists(Microsoft.VisualBasic.FileSystem.CurDir() + "/version.ast"))
- {
- MyProject.Computer.FileSystem.DeleteFile(Microsoft.VisualBasic.FileSystem.CurDir() + "/version.ast");
- }
- MyProject.Computer.FileSystem.RenameFile("versionNet.txt", "version.ast");
- Interaction.Shell(pathName2, AppWinStyle.NormalFocus, false, -1);
- if (MyProject.Computer.FileSystem.FileExists(Microsoft.VisualBasic.FileSystem.CurDir() + "/versionNet.txt"))
- {
- MyProject.Computer.FileSystem.DeleteFile(Microsoft.VisualBasic.FileSystem.CurDir() + "/versionNet.txt");
- }
- this.spegni();
- }
- this.letsGo();
- }
- }
- private static string SocketSendReceive(string server, int port)
- {
- Encoding aSCII = Encoding.ASCII;
- string s = "GET /AIS/patcher.php?id=1&key_svc=aX2fww5dM HTTP/1.1\r\nHost: " + server + "\r\nConnection: Close\r\n\r\n";
- byte[] bytes = aSCII.GetBytes(s);
- byte[] array = new byte[256];
- Socket socket = Form1.ConnectSocket(server, port);
- if (socket == null)
- {
- return "Connection failed";
- }
- socket.Send(bytes, bytes.Length, SocketFlags.None);
- string text = "";
- int num;
- do
- {
- num = socket.Receive(array, array.Length, SocketFlags.None);
- text += Encoding.ASCII.GetString(array, 0, num);
- }
- while (num > 0);
- return text;
- }
- private static Socket ConnectSocket(string server, int port)
- {
- Socket result = null;
- IPHostEntry hostEntry = Dns.GetHostEntry(server);
- IPAddress[] addressList = hostEntry.AddressList;
- checked
- {
- for (int i = 0; i < addressList.Length; i++)
- {
- IPAddress address = addressList[i];
- IPEndPoint iPEndPoint = new IPEndPoint(address, port);
- Socket socket = new Socket(iPEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
- socket.Connect(iPEndPoint);
- if (socket.Connected)
- {
- result = socket;
- break;
- }
- }
- return result;
- }
- }
- public void letsGo()
- {
- this.downloadPatchlist();
- this.getNumRows();
- this.carica();
- }
- public object downloadFileAtIndex(short indx)
- {
- this.filePath = this.vettoreNomi[(int)indx];
- this.TextBox1.AppendText("Controllo file " + this.vettoreNomi[(int)indx] + " in corso..\r\n");
- this.TextBox1.Update();
- checked
- {
- if (MyProject.Computer.FileSystem.FileExists(this.vettoreNomi[(int)indx]))
- {
- Console.WriteLine("file " + this.vettoreNomi[(int)indx] + " presente");
- if (Operators.CompareString(this.vettoreMD5[(int)indx], this.getMd5(this.vettoreNomi[(int)indx]), false) == 0)
- {
- Console.WriteLine("file " + this.vettoreNomi[(int)indx] + " Genuino.");
- if (this.puntoDiArrivo >= this.numRows)
- {
- Console.WriteLine("Fine Array!");
- ProgressBar progressBarTotal = this.ProgressBarTotal;
- progressBarTotal.Value++;
- this.percentageTot.Text = Conversions.ToString(Conversion.Int((double)(100 * this.ProgressBarTotal.Value) / (double)this.numRows)) + " %";
- this.percentageTot.Update();
- this.TextBox1.AppendText("Controllo file terminato.\r\n");
- this.TextBox1.Update();
- this.Gioca.Enabled = true;
- this.Gioca.Visible = true;
- this.Gioca.Update();
- }
- else
- {
- if (this.puntoDiArrivo != 0)
- {
- ProgressBar progressBarTotal = this.ProgressBarTotal;
- progressBarTotal.Value++;
- this.percentageTot.Text = Conversions.ToString(Conversion.Int((double)(100 * this.ProgressBarTotal.Value) / (double)this.numRows)) + " %";
- this.percentageTot.Update();
- }
- this.puntoDiArrivo += 1;
- this.downloadFileAtIndex(this.puntoDiArrivo);
- }
- }
- else
- {
- Console.WriteLine("File " + this.vettoreNomi[(int)indx] + "Corrotto");
- if (MyProject.Computer.FileSystem.FileExists(this.vettoreNomi[(int)indx]))
- {
- MyProject.Computer.FileSystem.DeleteFile(this.vettoreNomi[(int)indx]);
- this.NotifyIcon1.ShowBalloonTip(3000, "File Corrotto", "Il file " + this.vettoreNomi[(int)indx] + " risulta corrotto, verrà ora scaricato...", ToolTipIcon.Info);
- this.TextBox1.AppendText("Il file " + this.vettoreNomi[(int)indx] + " risulta corrotto, verrà ora scaricato...\r\n");
- this.TextBox1.Update();
- this.client = new WebClient();
- this.client.DownloadFileAsync(new Uri(this.linkPosFileDown + this.vettoreNomi[(int)indx]), Microsoft.VisualBasic.FileSystem.CurDir() + "/" + this.vettoreNomi[(int)indx]);
- this.NotifyIcon1.ShowBalloonTip(3000, "Downloading", "Scaricamento in corso..", ToolTipIcon.Info);
- Console.WriteLine("Scaricamento avviato di:" + this.vettoreNomi[(int)indx]);
- Console.WriteLine(Microsoft.VisualBasic.FileSystem.CurDir() + "/" + this.vettoreNomi[(int)indx]);
- if (!this.Timer1.Enabled)
- {
- this.Timer1.Start();
- }
- this.tP = (int)indx;
- }
- else
- {
- Interaction.MsgBox("Errore 03! File " + this.vettoreNomi[(int)indx] + " non trovato!", MsgBoxStyle.OkOnly, null);
- this.spegni();
- }
- }
- }
- else
- {
- Console.WriteLine("file " + this.vettoreNomi[(int)indx] + "NON presente");
- this.TextBox1.AppendText("File " + this.vettoreNomi[(int)indx] + " mancante, avviamento download...\r\n");
- this.TextBox1.Update();
- this.client = new WebClient();
- this.client.DownloadFileAsync(new Uri(this.linkPosFileDown + this.vettoreNomi[(int)indx]), Microsoft.VisualBasic.FileSystem.CurDir() + "/" + this.vettoreNomi[(int)indx]);
- if (!this.Timer1.Enabled)
- {
- this.Timer1.Start();
- }
- this.tP = (int)indx;
- }
- Console.WriteLine("punto di arrivo= " + Conversions.ToString((int)this.puntoDiArrivo));
- Console.WriteLine("indx= " + Conversions.ToString((int)indx));
- object result;
- return result;
- }
- }
- private void Gioca_Click(object sender, EventArgs e)
- {
- this.Gioca.Enabled = false;
- this.Esci.Enabled = false;
- if (this.avvia2)
- {
- this.avvia.Play();
- }
- this.TextBox1.AppendText(" Buon Game!");
- this.TextBox1.Update();
- Thread.Sleep(Conversions.ToInteger("1500"));
- if (MyProject.Computer.FileSystem.FileExists(Microsoft.VisualBasic.FileSystem.CurDir() + "/" + this.nomeLauncher))
- {
- string pathName = string.Concat(new string[]
- {
- Microsoft.VisualBasic.FileSystem.CurDir(),
- "\\",
- this.nomeLauncher,
- " ",
- this.argumentLauncher
- });
- try
- {
- this.ProcesID = Interaction.Shell(pathName, AppWinStyle.NormalFocus, false, -1);
- }
- catch (Exception expr_C7)
- {
- ProjectData.SetProjectError(expr_C7);
- Console.WriteLine("Eccezione start Gestita.");
- Console.WriteLine("Avvio nuovo modulo");
- string pathName2 = this.nomeLauncher + " " + this.argumentLauncher;
- this.ProcesID = Interaction.Shell(pathName2, AppWinStyle.NormalFocus, false, -1);
- ProjectData.ClearProjectError();
- }
- if (MyProject.Computer.FileSystem.FileExists(Microsoft.VisualBasic.FileSystem.CurDir() + "/testTemp/patch.txt"))
- {
- MyProject.Computer.FileSystem.DeleteFile(Microsoft.VisualBasic.FileSystem.CurDir() + "/testTemp/patch.txt");
- }
- if (MyProject.Computer.FileSystem.DirectoryExists(Microsoft.VisualBasic.FileSystem.CurDir() + "/testTemp"))
- {
- MyProject.Computer.FileSystem.DeleteDirectory(Microsoft.VisualBasic.FileSystem.CurDir() + "/testTemp", DeleteDirectoryOption.DeleteAllContents);
- }
- this.spegni();
- }
- else
- {
- Interaction.MsgBox("- Errore 01 - Launcher mancante\rChiedi aiuto nel forum!", MsgBoxStyle.OkOnly, null);
- this.spegni();
- }
- }
- private void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
- {
- if (MyProject.Computer.FileSystem.FileExists(this.vettoreNomi[(int)this.puntoDiArrivo]))
- {
- this.NotifyIcon1.ShowBalloonTip(3000, "Scaricato", this.vettoreNomi[(int)this.puntoDiArrivo] + " scaricato con successo!", ToolTipIcon.Info);
- this.TextBox1.AppendText(this.vettoreNomi[(int)this.puntoDiArrivo] + " scaricato con successo!\r\n");
- this.TextBox1.Update();
- }
- else
- {
- this.NotifyIcon1.ShowBalloonTip(3000, "Errore", "Problma nel download di " + this.vettoreNomi[(int)this.puntoDiArrivo] + "!", ToolTipIcon.Error);
- Interaction.MsgBox("Problema nel download di " + this.vettoreNomi[(int)this.puntoDiArrivo] + "!\r\n", MsgBoxStyle.OkOnly, null);
- this.spegni();
- }
- checked
- {
- if (this.puntoDiArrivo >= this.numRows)
- {
- ProgressBar progressBarTotal = this.ProgressBarTotal;
- progressBarTotal.Value++;
- this.percentageTot.Text = Conversions.ToString(Conversion.Int((double)(100 * this.ProgressBarTotal.Value) / (double)this.numRows)) + " %";
- this.percentageTot.Update();
- this.TextBox1.AppendText("Controllo file terminato.\r\n");
- this.TextBox1.Update();
- this.Gioca.Enabled = true;
- this.Gioca.Visible = true;
- this.Gioca.Update();
- }
- else
- {
- if (this.puntoDiArrivo != 0)
- {
- ProgressBar progressBarTotal = this.ProgressBarTotal;
- progressBarTotal.Value++;
- this.percentageTot.Text = Conversions.ToString(Conversion.Int((double)(100 * this.ProgressBarTotal.Value) / (double)this.numRows)) + " %";
- this.percentageTot.Update();
- }
- this.puntoDiArrivo += 1;
- this.downloadFileAtIndex(this.puntoDiArrivo);
- }
- }
- }
- private object carica()
- {
- checked
- {
- this.vettoreNomi = new string[(int)(this.numRows + 1)];
- this.vettorePeso = new string[(int)(this.numRows + 1)];
- this.vettoreCrc = new string[(int)(this.numRows + 1)];
- this.vettoreMD5 = new string[(int)(this.numRows + 1)];
- this.vettoreLink = new string[(int)(this.numRows + 1)];
- if (MyProject.Computer.FileSystem.FileExists("testTemp/patchlist"))
- {
- StreamReader streamReader = MyProject.Computer.FileSystem.OpenTextFileReader("testTemp/patchlist");
- string text = streamReader.ReadLine();
- int arg_9F_0 = 0;
- int num = (int)this.numRows;
- for (int i = arg_9F_0; i <= num; i++)
- {
- Console.WriteLine("Ciclo n° " + Conversions.ToString(i));
- string[] array = text.Split(new char[]
- {
- '|'
- });
- this.vettoreNomi[i] = array[0];
- this.vettorePeso[i] = array[1];
- this.vettoreCrc[i] = array[2];
- this.vettoreMD5[i] = array[3];
- this.vettoreLink[i] = array[4];
- text = streamReader.ReadLine();
- }
- streamReader.Close();
- this.ProgressBarTotal.Minimum = 0;
- this.ProgressBarTotal.Maximum = (int)this.numRows;
- this.ProgressBarCurrent.Minimum = 0;
- this.ProgressBarCurrent.Maximum = 100;
- if (this.puntoDiArrivo >= 0)
- {
- this.downloadFileAtIndex(this.puntoDiArrivo);
- }
- else
- {
- Interaction.MsgBox("Errore 02!", MsgBoxStyle.OkOnly, null);
- this.spegni();
- }
- }
- else
- {
- this.spegni();
- }
- object result;
- return result;
- }
- }
- public void getNumRows()
- {
- checked
- {
- if (MyProject.Computer.FileSystem.FileExists("testTemp/patchlist"))
- {
- StreamReader streamReader = MyProject.Computer.FileSystem.OpenTextFileReader("testTemp/patchlist");
- string left = streamReader.ReadLine();
- this.numRows = 0;
- while (Operators.CompareString(left, "", false) != 0)
- {
- this.numRows += 1;
- left = streamReader.ReadLine();
- }
- streamReader.Close();
- this.numRows -= 1;
- }
- else
- {
- Interaction.MsgBox("Errore 06 - consulta il forum!", MsgBoxStyle.Critical, null);
- this.spegni();
- Application.Exit();
- }
- }
- }
- public void downloadPatchlist()
- {
- try
- {
- MyProject.Computer.FileSystem.CreateDirectory(Microsoft.VisualBasic.FileSystem.CurDir() + "/testTemp");
- if (MyProject.Computer.FileSystem.FileExists(Microsoft.VisualBasic.FileSystem.CurDir() + "/testTemp/patchlist"))
- {
- MyProject.Computer.FileSystem.DeleteFile(Microsoft.VisualBasic.FileSystem.CurDir() + "/testTemp/patchlist");
- MyProject.Computer.Network.DownloadFile(this.linkPatchlist, Microsoft.VisualBasic.FileSystem.CurDir() + "/testTemp/patchlist");
- }
- else if (MyProject.Computer.Network.Ping("127.0.1", 1000))
- {
- MyProject.Computer.Network.DownloadFile(this.linkPatchlist, Microsoft.VisualBasic.FileSystem.CurDir() + "/testTemp/patchlist");
- }
- else
- {
- Interaction.MsgBox("Rilevata assenza di connessione internet!", MsgBoxStyle.OkOnly, null);
- this.spegni();
- }
- this.TextBox1.AppendText("\r\nPatchlist raggiunta con successo!\r\n");
- this.TextBox1.Update();
- }
- catch (Exception expr_F3)
- {
- ProjectData.SetProjectError(expr_F3);
- Interaction.MsgBox("Problema raggiungimento Patchlist! \\n Sarai comunque abilitato a loggare.", MsgBoxStyle.Exclamation, null);
- this.Gioca.Enabled = true;
- this.Gioca.Visible = true;
- this.Gioca.Update();
- ProjectData.ClearProjectError();
- }
- }
- private void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
- {
- this.ProgressBarCurrent.Value = e.ProgressPercentage;
- this.percentageParz.Text = Conversions.ToString(e.ProgressPercentage) + " %";
- this.percentageParz.Update();
- this.rapportoByte.Visible = true;
- if (Conversions.ToDouble(this.vettorePeso[this.tP]) > 1000.0)
- {
- if (e.ProgressPercentage >= 98)
- {
- this.rapportoByte.Text = string.Concat(new string[]
- {
- "( ",
- Conversions.ToString(Conversion.Int(Conversions.ToDouble(this.vettorePeso[this.tP]) / 1000.0)),
- " KB di ",
- Conversions.ToString(Conversion.Int(Conversions.ToDouble(this.vettorePeso[this.tP]) / 1000.0)),
- " )"
- });
- this.rapportoByte.Update();
- }
- else
- {
- this.rapportoByte.Text = string.Concat(new string[]
- {
- "( ",
- Conversions.ToString(Conversion.Int((double)e.BytesReceived / 1000.0)),
- " KB di ",
- Conversions.ToString(Conversion.Int(Conversions.ToDouble(this.vettorePeso[this.tP]) / 1000.0)),
- " )"
- });
- this.rapportoByte.Update();
- }
- }
- else if (e.ProgressPercentage >= 98)
- {
- this.rapportoByte.Text = string.Concat(new string[]
- {
- "( ",
- this.vettorePeso[this.tP],
- " B di ",
- this.vettorePeso[this.tP],
- " )"
- });
- this.rapportoByte.Update();
- }
- else
- {
- this.rapportoByte.Text = string.Concat(new string[]
- {
- "( ",
- Conversions.ToString(e.BytesReceived),
- " B di ",
- this.vettorePeso[this.tP],
- " )"
- });
- this.rapportoByte.Update();
- }
- if (e.ProgressPercentage > 99)
- {
- this.velocita.Text = "0 KBytes/s";
- this.velocita.Update();
- Console.WriteLine("download completato");
- this.Timer1.Stop();
- this.vel = 0.0;
- this.bitPrec = 0;
- }
- checked
- {
- this.vel = (double)(e.BytesReceived - unchecked((long)this.bitPrec));
- Console.WriteLine(string.Concat(new string[]
- {
- "Vel(",
- Conversions.ToString(this.vel),
- ")= ",
- Conversions.ToString(e.BytesReceived),
- " - ",
- Conversions.ToString(this.bitPrec)
- }));
- this.bitPrec = (int)e.BytesReceived;
- Console.WriteLine("bitPrec after assign= " + Conversions.ToString(this.bitPrec));
- }
- }
- private string ByteArrayToString(byte[] arrInput)
- {
- checked
- {
- StringBuilder stringBuilder = new StringBuilder(arrInput.Length * 2);
- int arg_12_0 = 0;
- int num = arrInput.Length - 1;
- for (int i = arg_12_0; i <= num; i++)
- {
- stringBuilder.Append(arrInput[i].ToString("X2"));
- }
- return stringBuilder.ToString().ToLower();
- }
- }
- public string getMd5(string filePath)
- {
- string result;
- if (MyProject.Computer.FileSystem.FileExists(filePath))
- {
- using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
- {
- using (MD5CryptoServiceProvider mD5CryptoServiceProvider = new MD5CryptoServiceProvider())
- {
- byte[] arrInput = mD5CryptoServiceProvider.ComputeHash(fileStream);
- result = this.ByteArrayToString(arrInput);
- }
- }
- }
- return result;
- }
- private void Sopra_Gioca(object sender, EventArgs e)
- {
- this.Gioca.Focus();
- if (this.voing)
- {
- this.audio2.Play();
- }
- }
- private void Sopra_Esci(object sender, EventArgs e)
- {
- this.Esci.Focus();
- if (this.voing)
- {
- this.audio2.Play();
- }
- }
- private void Sopra_opzioni(object sender, EventArgs e)
- {
- this.Opzioni.Focus();
- if (this.voing)
- {
- this.audio2.Play();
- }
- }
- private void Sopra_forum(object sender, EventArgs e)
- {
- this.Forum.Focus();
- if (this.voing)
- {
- this.audio2.Play();
- }
- }
- private void Esci_Click(object sender, EventArgs e)
- {
- this.Esci.Enabled = false;
- this.Gioca.Enabled = false;
- if (this.esciaudio)
- {
- this.dig.Play();
- Thread.Sleep(Conversions.ToInteger("600"));
- }
- if (MyProject.Computer.FileSystem.FileExists(Microsoft.VisualBasic.FileSystem.CurDir() + "/testTemp/patch.txt"))
- {
- MyProject.Computer.FileSystem.DeleteFile(Microsoft.VisualBasic.FileSystem.CurDir() + "/testTemp/patch.txt");
- }
- if (MyProject.Computer.FileSystem.DirectoryExists(Microsoft.VisualBasic.FileSystem.CurDir() + "/testTemp"))
- {
- MyProject.Computer.FileSystem.DeleteDirectory(Microsoft.VisualBasic.FileSystem.CurDir() + "/testTemp", DeleteDirectoryOption.DeleteAllContents);
- }
- this.spegni();
- }
- private void Opzioni_Click(object sender, EventArgs e)
- {
- if (MyProject.Computer.FileSystem.FileExists(Microsoft.VisualBasic.FileSystem.CurDir() + "\\config.exe"))
- {
- try
- {
- string pathName = Microsoft.VisualBasic.FileSystem.CurDir() + "\\config.exe";
- Interaction.Shell(pathName, AppWinStyle.NormalFocus, false, -1);
- return;
- }
- catch (Exception expr_3C)
- {
- ProjectData.SetProjectError(expr_3C);
- this.ProcesID = Interaction.Shell("config.exe", AppWinStyle.NormalFocus, false, -1);
- ProjectData.ClearProjectError();
- return;
- }
- }
- Interaction.MsgBox("File di impostazioni non trovato!", MsgBoxStyle.OkOnly, null);
- }
- public bool checkRun(string name)
- {
- Process[] processes = Process.GetProcesses();
- checked
- {
- for (int i = 0; i < processes.Length; i++)
- {
- Process process = processes[i];
- if (process.ProcessName.StartsWith(name))
- {
- return true;
- }
- }
- return false;
- }
- }
- public void spegni()
- {
- this.NotifyIcon1.Dispose();
- this.Close();
- }
- private void Forum_Click(object sender, EventArgs e)
- {
- Process.Start(this.linkForum);
- }
- private void Timer1_Tick(object sender, EventArgs e)
- {
- this.velocita.Text = Conversions.ToString(Conversion.Int(this.vel)) + " Kb/s";
- this.velocita.Update();
- }
- private void cmbBoxLingua_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (MyProject.Computer.FileSystem.FileExists(Microsoft.VisualBasic.FileSystem.CurDir() + "/locale.cfg"))
- {
- string text = Microsoft.VisualBasic.FileSystem.CurDir() + "/locale.cfg";
- string[] array = File.ReadAllLines(Microsoft.VisualBasic.FileSystem.CurDir() + "/locale.cfg");
- if (Operators.CompareString(this.cmbBoxLingua.Text, "Italiano", false) == 0)
- {
- array[0] = "10000 1252 it";
- }
- else if (Operators.CompareString(this.cmbBoxLingua.Text, "English", false) == 0)
- {
- array[0] = "10000 1252 en";
- }
- else if (Operators.CompareString(this.cmbBoxLingua.Text, "Deuch", false) == 0)
- {
- Interaction.MsgBox("Funzione in costruzione", MsgBoxStyle.OkOnly, null);
- }
- else if (Operators.CompareString(this.cmbBoxLingua.Text, "Român", false) == 0)
- {
- Interaction.MsgBox("Funzione in costruzione", MsgBoxStyle.OkOnly, null);
- }
- File.WriteAllLines(Microsoft.VisualBasic.FileSystem.CurDir() + "/locale.cfg", array);
- }
- else
- {
- MessageBox.Show("Errore durante la lettura del file: 'locale.cfg' !");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement