Advertisement
DubStepMad

Untitled

Jun 14th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.20 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Diagnostics;
  11. using System.IO;
  12. using System.Xml.Serialization;
  13. using System.Runtime.InteropServices;
  14.  
  15. namespace tsrvtcnew
  16. {
  17. public partial class Form1 : Form
  18. {
  19. public Form1()
  20. {
  21. InitializeComponent();
  22.  
  23. string fileName = "settings.txt";
  24.  
  25. string[] loadedLines = File.ReadAllLines(fileName);
  26.  
  27. int index = 0;
  28.  
  29. int n = int.Parse(loadedLines[index]);
  30. string[] lines = new string[n];
  31. Array.Copy(loadedLines, index + 1, lines, 0, n);
  32. txtpath.Lines = lines;
  33.  
  34. index += n + 1;
  35.  
  36. n = int.Parse(loadedLines[index]);
  37. lines = new string[n];
  38. Array.Copy(loadedLines, index + 1, lines, 0, n);
  39. txtdatapath.Lines = lines;
  40.  
  41. index += n + 1;
  42.  
  43. n = int.Parse(loadedLines[index]);
  44. lines = new string[n];
  45. Array.Copy(loadedLines, index + 1, lines, 0, n);
  46. txtmessage.Lines = lines;
  47.  
  48.  
  49. }
  50.  
  51. private void Form1_MouseDown(object sender,
  52. System.Windows.Forms.MouseEventArgs e)
  53. {
  54. if (e.Button == MouseButtons.Left)
  55. {
  56. ReleaseCapture();
  57. SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
  58. }
  59. }
  60.  
  61. public const int WM_NCLBUTTONDOWN = 0xA1;
  62. public const int HT_CAPTION = 0x2;
  63.  
  64. [DllImportAttribute("user32.dll")]
  65. public static extern int SendMessage(IntPtr hWnd,
  66. int Msg, int wParam, int lParam);
  67. [DllImportAttribute("user32.dll")]
  68. public static extern bool ReleaseCapture();
  69.  
  70. private void btnselect_Click(object sender, EventArgs e)
  71. {
  72. FolderBrowserDialog lfpath = new FolderBrowserDialog();
  73. if (lfpath.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  74. txtpath.Text = lfpath.SelectedPath;
  75. }
  76.  
  77. private void btnlaunch_Click(object sender, EventArgs e)
  78. {
  79. if (txtpath.Text == "")
  80. {
  81. MessageBox.Show("To launch Truckers MP you need to select the folder containing the launcher.exe!");
  82. return;
  83. }
  84. Process.Start(Path.Combine(txtpath.Text, "launcher.exe"));
  85.  
  86. }
  87.  
  88. private void btnselectdata_Click(object sender, EventArgs e)
  89. {
  90. FolderBrowserDialog fdb = new FolderBrowserDialog();
  91. if (fdb.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  92. txtdatapath.Text = fdb.SelectedPath;
  93. }
  94.  
  95. private void btnreplace_Click(object sender, EventArgs e)
  96. {
  97.  
  98. string SourcePath = (txtdatapath.Text);
  99. string DesPath = ("C:/ProgramData/TruckersMP");
  100.  
  101. if (SourcePath == "")
  102. {
  103. MessageBox.Show("To replace the GUI please select the folder containg the data folder with the GUI!");
  104. return;
  105. }
  106.  
  107. foreach (string dirPath in Directory.GetDirectories(SourcePath, "*",
  108. SearchOption.AllDirectories))
  109. Directory.CreateDirectory(DesPath + dirPath.Remove(0, SourcePath.Length));
  110.  
  111. foreach (String newPath in Directory.GetFiles(SourcePath, "*.*",
  112. SearchOption.AllDirectories))
  113. File.Copy(newPath, DesPath + newPath.Remove(0, SourcePath.Length), true);
  114. }
  115.  
  116. private void btnhelp_Click(object sender, EventArgs e)
  117. {
  118. Help hp = new tsrvtcnew.Help();
  119. hp.ShowDialog();
  120. }
  121.  
  122. private void btnsave_Click(object sender, EventArgs e)
  123. {
  124.  
  125. string fileName = "settings.txt";
  126.  
  127. if (txtdatapath.Text == "")
  128. {
  129. MessageBox.Show("Please select gui location before saving!");
  130. }
  131.  
  132. if (txtpath.Text == "")
  133. {
  134. MessageBox.Show("Please select launcher location before saving!");
  135. }
  136.  
  137. List<string> linesToSave = new List<string>();
  138.  
  139. linesToSave.Add(txtpath.Lines.Length.ToString());
  140. linesToSave.AddRange(txtpath.Lines);
  141.  
  142. linesToSave.Add(txtdatapath.Lines.Length.ToString());
  143. linesToSave.AddRange(txtdatapath.Lines);
  144.  
  145. linesToSave.Add(txtmessage.Lines.Length.ToString());
  146. linesToSave.AddRange(txtmessage.Lines);
  147.  
  148. File.WriteAllLines(fileName, linesToSave);
  149.  
  150. }
  151.  
  152. private void btnwebsite_Click(object sender, EventArgs e)
  153. {
  154. System.Diagnostics.Process.Start("www.simulatorradio.com");
  155. }
  156.  
  157. private void btnfb_Click(object sender, EventArgs e)
  158. {
  159. System.Diagnostics.Process.Start("www.facebook.com/TSRVTC/");
  160. }
  161.  
  162. private void btndiscord_Click(object sender, EventArgs e)
  163. {
  164. System.Diagnostics.Process.Start("https://discord.gg/VXzCurC");
  165. }
  166.  
  167. private void button1_Click(object sender, EventArgs e)
  168. {
  169. Application.Exit();
  170. }
  171.  
  172. private void button1_Leave(object sender, EventArgs e)
  173. {
  174. this.button1.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.leave_img));
  175. }
  176.  
  177. void button1_MouseMove(object sender, MouseEventArgs e)
  178. {
  179. this.button1.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.hover_img));
  180. }
  181.  
  182. private void btnfb_Leave(object sender, EventArgs e)
  183. {
  184. this.btnfb.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.leave_img));
  185. }
  186.  
  187. void btnfb_MouseMove(object sender, MouseEventArgs e)
  188. {
  189. this.btnfb.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.hover_img));
  190. }
  191.  
  192. private void btndiscord_Leave(object sender, EventArgs e)
  193. {
  194. this.btndiscord.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.leave_img));
  195. }
  196.  
  197. void btndiscord_MouseMove(object sender, MouseEventArgs e)
  198. {
  199. this.btndiscord.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.hover_img));
  200. }
  201.  
  202. private void btnwebsite_Leave(object sender, EventArgs e)
  203. {
  204. this.btnwebsite.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.leave_img));
  205. }
  206.  
  207. void btnwebsite_MouseMove(object sender, MouseEventArgs e)
  208. {
  209. this.btnwebsite.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.hover_img));
  210. }
  211.  
  212. private void btnhelp_Leave(object sender, EventArgs e)
  213. {
  214. this.btnhelp.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.leave_img));
  215. }
  216.  
  217. void btnhelp_MouseMove(object sender, MouseEventArgs e)
  218. {
  219. this.btnhelp.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.hover_img));
  220. }
  221.  
  222. private void btnsave_Leave(object sender, EventArgs e)
  223. {
  224. this.btnsave.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.leave_img));
  225. }
  226.  
  227. void btnsave_MouseMove(object sender, MouseEventArgs e)
  228. {
  229. this.btnsave.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.hover_img));
  230. }
  231.  
  232. private void btnminimize_Click(object sender, EventArgs e)
  233. {
  234. this.WindowState = FormWindowState.Minimized;
  235. }
  236.  
  237. private void btnminimize_Leave(object sender, EventArgs e)
  238. {
  239. this.btnminimize.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.leave_img));
  240. }
  241.  
  242. void btnminimize_MouseMove(object sender, MouseEventArgs e)
  243. {
  244. this.btnminimize.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.hover_img));
  245. }
  246. }
  247. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement