Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.Win32;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace FSXAirplaneManager
- {
- public partial class ManagerWindow : Form
- {
- public ManagerWindow()
- {
- InitializeComponent();
- String fsxLocation = (String)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0", "AppPath", "Error");
- if (fsxLocation == "Error")
- {
- System.Environment.Exit(1);
- }
- DirectoryInfo di = new DirectoryInfo(fsxLocation + "\\SimObjects\\Airplanes\\");
- foreach (DirectoryInfo d in di.GetDirectories("*", SearchOption.TopDirectoryOnly))
- {
- folders.Add(d);
- }
- PlaneList.DataSource = folders;
- }
- static List<DirectoryInfo> folders = new List<DirectoryInfo>();
- private void PlaneList_SelectedIndexChanged(object sender, EventArgs e)
- {
- String fsxLocation = (String)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0", "AppPath", "Error") + "SimObjects\\Airplanes\\";
- String selectedItem = PlaneList.SelectedItem.ToString();
- //String[] texturesFolders;
- //texturesFolders = Directory.GetDirectories(fsxLocation + selectedItem + "\\", "texture.*");
- //AirplaneThumbnail.ImageLocation = texturesFolders[1] + "\\thumbnail.jpg";
- SelectedPlaneLabel.Text = "Selected Plane: " + selectedItem;
- if(File.Exists(fsxLocation + "\\" + selectedItem + "\\aircraft.cfg"))
- {
- PlaneStatusLabel.Text = "Plane Status: Enabled";
- EnableButton.Text = "Disable";
- }
- else
- {
- if(File.Exists(fsxLocation + "\\" + selectedItem + "\\aircraft.cfg.disabled"))
- {
- PlaneStatusLabel.Text = "Plane Status: Disabled";
- EnableButton.Text = "Enable";
- }
- else
- {
- PlaneStatusLabel.Text = "Plane Status: Does Not Exist";
- EnableButton.Text = "N/A";
- }
- }
- }
- private void EnableButton_Click(object sender, EventArgs e)
- {
- if(EnableButton.Text == "Enable")
- {
- String fsxLocation = (String)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0", "AppPath", "Error") + "SimObjects\\Airplanes\\";
- String selectedItem = PlaneList.SelectedItem.ToString();
- File.Move(fsxLocation + "\\" + selectedItem + "\\aircraft.cfg.disabled", fsxLocation + "\\" + selectedItem + "\\aircraft.cfg");
- EnableButton.Text = "Disable";
- PlaneStatusLabel.Text = "Plane Status: Enabled";
- }
- else
- {
- if(EnableButton.Text == "Disable")
- {
- String fsxLocation = (String)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0", "AppPath", "Error") + "SimObjects\\Airplanes\\";
- String selectedItem = PlaneList.SelectedItem.ToString();
- File.Move(fsxLocation + "\\" + selectedItem + "\\aircraft.cfg", fsxLocation + "\\" + selectedItem + "\\aircraft.cfg.disabled");
- EnableButton.Text = "Enable";
- PlaneStatusLabel.Text = "Plane Status: Disabled";
- }
- else
- {
- }
- }
- }
- private void ExitButton_Click(object sender, EventArgs e)
- {
- System.Environment.Exit(0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment