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.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Diagnostics;
- using System.IO;
- using System.Xml.Serialization;
- using System.Runtime.InteropServices;
- namespace tsrvtcnew
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- string fileName = "settings.txt";
- string[] loadedLines = File.ReadAllLines(fileName);
- int index = 0;
- int n = int.Parse(loadedLines[index]);
- string[] lines = new string[n];
- Array.Copy(loadedLines, index + 1, lines, 0, n);
- txtpath.Lines = lines;
- index += n + 1;
- n = int.Parse(loadedLines[index]);
- lines = new string[n];
- Array.Copy(loadedLines, index + 1, lines, 0, n);
- txtdatapath.Lines = lines;
- index += n + 1;
- n = int.Parse(loadedLines[index]);
- lines = new string[n];
- Array.Copy(loadedLines, index + 1, lines, 0, n);
- txtmessage.Lines = lines;
- }
- private void Form1_MouseDown(object sender,
- System.Windows.Forms.MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left)
- {
- ReleaseCapture();
- SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
- }
- }
- public const int WM_NCLBUTTONDOWN = 0xA1;
- public const int HT_CAPTION = 0x2;
- [DllImportAttribute("user32.dll")]
- public static extern int SendMessage(IntPtr hWnd,
- int Msg, int wParam, int lParam);
- [DllImportAttribute("user32.dll")]
- public static extern bool ReleaseCapture();
- private void btnselect_Click(object sender, EventArgs e)
- {
- FolderBrowserDialog lfpath = new FolderBrowserDialog();
- if (lfpath.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- txtpath.Text = lfpath.SelectedPath;
- }
- private void btnlaunch_Click(object sender, EventArgs e)
- {
- if (txtpath.Text == "")
- {
- MessageBox.Show("To launch Truckers MP you need to select the folder containing the launcher.exe!");
- return;
- }
- Process.Start(Path.Combine(txtpath.Text, "launcher.exe"));
- }
- private void btnselectdata_Click(object sender, EventArgs e)
- {
- FolderBrowserDialog fdb = new FolderBrowserDialog();
- if (fdb.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- txtdatapath.Text = fdb.SelectedPath;
- }
- private void btnreplace_Click(object sender, EventArgs e)
- {
- string SourcePath = (txtdatapath.Text);
- string DesPath = ("C:/ProgramData/TruckersMP");
- if (SourcePath == "")
- {
- MessageBox.Show("To replace the GUI please select the folder containg the data folder with the GUI!");
- return;
- }
- foreach (string dirPath in Directory.GetDirectories(SourcePath, "*",
- SearchOption.AllDirectories))
- Directory.CreateDirectory(DesPath + dirPath.Remove(0, SourcePath.Length));
- foreach (String newPath in Directory.GetFiles(SourcePath, "*.*",
- SearchOption.AllDirectories))
- File.Copy(newPath, DesPath + newPath.Remove(0, SourcePath.Length), true);
- }
- private void btnhelp_Click(object sender, EventArgs e)
- {
- Help hp = new tsrvtcnew.Help();
- hp.ShowDialog();
- }
- private void btnsave_Click(object sender, EventArgs e)
- {
- string fileName = "settings.txt";
- if (txtdatapath.Text == "")
- {
- MessageBox.Show("Please select gui location before saving!");
- }
- if (txtpath.Text == "")
- {
- MessageBox.Show("Please select launcher location before saving!");
- }
- List<string> linesToSave = new List<string>();
- linesToSave.Add(txtpath.Lines.Length.ToString());
- linesToSave.AddRange(txtpath.Lines);
- linesToSave.Add(txtdatapath.Lines.Length.ToString());
- linesToSave.AddRange(txtdatapath.Lines);
- linesToSave.Add(txtmessage.Lines.Length.ToString());
- linesToSave.AddRange(txtmessage.Lines);
- File.WriteAllLines(fileName, linesToSave);
- }
- private void btnwebsite_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Process.Start("www.simulatorradio.com");
- }
- private void btnfb_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Process.Start("www.facebook.com/TSRVTC/");
- }
- private void btndiscord_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Process.Start("https://discord.gg/VXzCurC");
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Application.Exit();
- }
- private void button1_Leave(object sender, EventArgs e)
- {
- this.button1.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.leave_img));
- }
- void button1_MouseMove(object sender, MouseEventArgs e)
- {
- this.button1.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.hover_img));
- }
- private void btnfb_Leave(object sender, EventArgs e)
- {
- this.btnfb.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.leave_img));
- }
- void btnfb_MouseMove(object sender, MouseEventArgs e)
- {
- this.btnfb.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.hover_img));
- }
- private void btndiscord_Leave(object sender, EventArgs e)
- {
- this.btndiscord.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.leave_img));
- }
- void btndiscord_MouseMove(object sender, MouseEventArgs e)
- {
- this.btndiscord.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.hover_img));
- }
- private void btnwebsite_Leave(object sender, EventArgs e)
- {
- this.btnwebsite.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.leave_img));
- }
- void btnwebsite_MouseMove(object sender, MouseEventArgs e)
- {
- this.btnwebsite.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.hover_img));
- }
- private void btnhelp_Leave(object sender, EventArgs e)
- {
- this.btnhelp.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.leave_img));
- }
- void btnhelp_MouseMove(object sender, MouseEventArgs e)
- {
- this.btnhelp.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.hover_img));
- }
- private void btnsave_Leave(object sender, EventArgs e)
- {
- this.btnsave.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.leave_img));
- }
- void btnsave_MouseMove(object sender, MouseEventArgs e)
- {
- this.btnsave.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.hover_img));
- }
- private void btnminimize_Click(object sender, EventArgs e)
- {
- this.WindowState = FormWindowState.Minimized;
- }
- private void btnminimize_Leave(object sender, EventArgs e)
- {
- this.btnminimize.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.leave_img));
- }
- void btnminimize_MouseMove(object sender, MouseEventArgs e)
- {
- this.btnminimize.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.hover_img));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement