Guest User

Airplane Manager

a guest
Nov 28th, 2015
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.98 KB | None | 0 0
  1. using Microsoft.Win32;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12.  
  13. namespace FSXAirplaneManager
  14. {
  15.     public partial class ManagerWindow : Form
  16.     {
  17.         public ManagerWindow()
  18.         {
  19.             InitializeComponent();
  20.             String fsxLocation = (String)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0", "AppPath", "Error");
  21.             if (fsxLocation == "Error")
  22.             {
  23.                 System.Environment.Exit(1);
  24.             }
  25.             DirectoryInfo di = new DirectoryInfo(fsxLocation + "\\SimObjects\\Airplanes\\");
  26.             foreach (DirectoryInfo d in di.GetDirectories("*", SearchOption.TopDirectoryOnly))
  27.             {
  28.                 folders.Add(d);
  29.             }
  30.             PlaneList.DataSource = folders;
  31.         }
  32.         static List<DirectoryInfo> folders = new List<DirectoryInfo>();
  33.  
  34.         private void PlaneList_SelectedIndexChanged(object sender, EventArgs e)
  35.         {
  36.             String fsxLocation = (String)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0", "AppPath", "Error") + "SimObjects\\Airplanes\\";
  37.             String selectedItem = PlaneList.SelectedItem.ToString();
  38.             //String[] texturesFolders;
  39.             //texturesFolders = Directory.GetDirectories(fsxLocation + selectedItem + "\\", "texture.*");
  40.             //AirplaneThumbnail.ImageLocation = texturesFolders[1] + "\\thumbnail.jpg";
  41.             SelectedPlaneLabel.Text = "Selected Plane: " + selectedItem;
  42.             if(File.Exists(fsxLocation + "\\" + selectedItem + "\\aircraft.cfg"))
  43.             {
  44.                 PlaneStatusLabel.Text = "Plane Status: Enabled";
  45.                 EnableButton.Text = "Disable";
  46.             }
  47.             else
  48.             {
  49.                 if(File.Exists(fsxLocation + "\\" + selectedItem + "\\aircraft.cfg.disabled"))
  50.                 {
  51.                     PlaneStatusLabel.Text = "Plane Status: Disabled";
  52.                     EnableButton.Text = "Enable";
  53.                 }
  54.                 else
  55.                 {
  56.                     PlaneStatusLabel.Text = "Plane Status: Does Not Exist";
  57.                     EnableButton.Text = "N/A";
  58.                 }
  59.             }
  60.         }
  61.  
  62.         private void EnableButton_Click(object sender, EventArgs e)
  63.         {
  64.             if(EnableButton.Text == "Enable")
  65.             {
  66.                 String fsxLocation = (String)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0", "AppPath", "Error") + "SimObjects\\Airplanes\\";
  67.                 String selectedItem = PlaneList.SelectedItem.ToString();
  68.                 File.Move(fsxLocation + "\\" + selectedItem + "\\aircraft.cfg.disabled", fsxLocation + "\\" + selectedItem + "\\aircraft.cfg");
  69.                 EnableButton.Text = "Disable";
  70.                 PlaneStatusLabel.Text = "Plane Status: Enabled";
  71.             }
  72.             else
  73.             {
  74.                 if(EnableButton.Text == "Disable")
  75.                 {
  76.                     String fsxLocation = (String)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0", "AppPath", "Error") + "SimObjects\\Airplanes\\";
  77.                     String selectedItem = PlaneList.SelectedItem.ToString();
  78.                     File.Move(fsxLocation + "\\" + selectedItem + "\\aircraft.cfg", fsxLocation + "\\" + selectedItem + "\\aircraft.cfg.disabled");
  79.                     EnableButton.Text = "Enable";
  80.                     PlaneStatusLabel.Text = "Plane Status: Disabled";
  81.                 }
  82.                 else
  83.                 {
  84.  
  85.                 }
  86.             }
  87.         }
  88.  
  89.         private void ExitButton_Click(object sender, EventArgs e)
  90.         {
  91.             System.Environment.Exit(0);
  92.         }
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment