Advertisement
Guest User

Form1.cs

a guest
May 11th, 2014
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.29 KB | None | 0 0
  1. using System;
  2. using System.Diagnostics;
  3. using System.IO;
  4. using System.Reflection;
  5. using System.Windows.Forms;
  6. using System.Xml.Serialization;
  7. using HL2_Cinematic_Mod_Launcher.Properties;
  8.  
  9. namespace HL2_Cinematic_Mod_Launcher
  10. {
  11.     public partial class Form1 : Form
  12.     {
  13.         private ToolStripMenuItem _fileToolStripMenuItem;
  14.  
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         public void Form1_Load(object sender, EventArgs e)
  21.         {
  22.         }
  23.  
  24.         private void button1_Click(object sender, EventArgs e)
  25.         {
  26.             var myDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
  27.             if (myDir == null) return;
  28.             var gameDir = Path.Combine(myDir, "E:\\Steam Games\\SteamApps\\common\\CM2013");
  29.             var gameExe = Path.Combine(gameDir, "Configurator.EXE");
  30.             var proc1 = new Process
  31.             {
  32.                 StartInfo = {FileName = gameExe, WorkingDirectory = gameDir},
  33.                 SynchronizingObject = this,
  34.                 EnableRaisingEvents = true
  35.             };
  36.             proc1.Start();
  37.         }
  38.  
  39.         private void button2_Click(object sender, EventArgs e)
  40.         {
  41.             var myDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
  42.             if (myDir == null) return;
  43.             var gameDir = Path.Combine(myDir, "E:\\Steam Games\\SteamApps\\common\\CM2013");
  44.             var gameExe = Path.Combine(gameDir, "Launcher_EP0.exe");
  45.             var proc2 = new Process
  46.             {
  47.                 StartInfo = {FileName = gameExe, WorkingDirectory = gameDir},
  48.                 SynchronizingObject = this,
  49.                 EnableRaisingEvents = true
  50.             };
  51.             proc2.Start();
  52.         }
  53.  
  54.         private void button3_Click(object sender, EventArgs e)
  55.         {
  56.             var myDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
  57.             if (myDir == null) return;
  58.             var gameDir = Path.Combine(myDir, "E:\\Steam Games\\SteamApps\\common\\CM2013");
  59.             var gameExe = Path.Combine(gameDir, "launcher_EP1.exe");
  60.             var proc3 = new Process
  61.             {
  62.                 StartInfo = {FileName = gameExe, WorkingDirectory = gameDir},
  63.                 SynchronizingObject = this,
  64.                 EnableRaisingEvents = true
  65.             };
  66.             proc3.Start();
  67.         }
  68.  
  69.         private void button4_Click(object sender, EventArgs e)
  70.         {
  71.             var myDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
  72.             if (myDir == null) return;
  73.             var gameDir = Path.Combine(myDir, "E:\\Steam Games\\SteamApps\\common\\CM2013");
  74.             var gameExe = Path.Combine(gameDir, "Launcher_EP2.exe");
  75.             var proc4 = new Process
  76.             {
  77.                 StartInfo = {FileName = gameExe, WorkingDirectory = gameDir},
  78.                 SynchronizingObject = this,
  79.                 EnableRaisingEvents = true
  80.             };
  81.             proc4.Start();
  82.         }
  83.  
  84.         private void exitToolStripMenuItem_Click(object sender, EventArgs e)
  85.         {
  86.             Close();
  87.         }
  88.  
  89.         private void button5_Click(object sender, EventArgs e)
  90.         {
  91.             Settings.Default.Reload();
  92.             var folderBrowserDialog = new FolderBrowserDialog();
  93.             var fbd = folderBrowserDialog;
  94.             fbd.Description = @"Please select the HL2 Cinematic Mod installation directory.";
  95.             if (fbd.ShowDialog() == DialogResult.OK)
  96.                 MessageBox.Show(fbd.SelectedPath);
  97.         }
  98.  
  99.         public class Config
  100.         {
  101.             private const string ConfigPath = @"%USERPROFILE%\\HL2 CM Launcher\\config\\config.xml";
  102.  
  103.             public string ModDirectory { get; set; }
  104.  
  105.             public static Config Load()
  106.             {
  107.                 var serializer = new XmlSerializer(typeof (Config));
  108.                 using (var reader = new StreamReader(ConfigPath))
  109.                     return (Config) serializer.Deserialize(reader);
  110.             }
  111.  
  112.             public void Save()
  113.             {
  114.                 var serializer = new XmlSerializer(typeof (Config));
  115.                 using (var writer = new StreamWriter(ConfigPath))
  116.                     serializer.Serialize(writer, this);
  117.             }
  118.         }
  119.     }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement