Пример #1
0
        public void Init(MainWindow mainWindow, string version)
        {
            this.mainWindow = mainWindow;

            switch (version)
            {
            case "Falcon BMS 4.37 (Internal)":
                bms_Version     = BMS_Version.BMS437I;
                keyFileName     = "BMS - Full.key";
                overRideSetting = new OverrideSettingFor437(this.mainWindow, this);
                starter         = new Starter437Internal(this, this.mainWindow);
                break;

            case "Falcon BMS 4.36 (Internal)":
                bms_Version     = BMS_Version.BMS436I;
                keyFileName     = "BMS - Full.key";
                overRideSetting = new OverrideSettingFor436(this.mainWindow, this);
                starter         = new Starter436Internal(this, this.mainWindow);
                break;

            case "Falcon BMS 4.37":
                bms_Version     = BMS_Version.BMS437;
                keyFileName     = "BMS - Full.key";
                overRideSetting = new OverrideSettingFor437(this.mainWindow, this);
                starter         = new Starter437(this, this.mainWindow);
                break;

            case "Falcon BMS 4.36":
                bms_Version     = BMS_Version.BMS436;
                keyFileName     = "BMS - Full.key";
                overRideSetting = new OverrideSettingFor436(this.mainWindow, this);
                starter         = new Starter436(this, this.mainWindow);
                break;

            case "Falcon BMS 4.35":
                bms_Version     = BMS_Version.BMS435;
                keyFileName     = "BMS - Full.key";
                overRideSetting = new OverrideSettingFor435(this.mainWindow, this);
                starter         = new Starter435(this, this.mainWindow);
                break;

            case "Falcon BMS 4.34":
                bms_Version     = BMS_Version.BMS434U1;
                keyFileName     = "BMS - Full.key";
                overRideSetting = new OverrideSettingFor434U1(this.mainWindow, this);
                starter         = new Starter434(this, this.mainWindow);
                break;

            case "Falcon BMS 4.33 U1":
                bms_Version     = BMS_Version.BMS433U1;
                keyFileName     = "BMS - Full.key";
                overRideSetting = new OverrideSettingFor433(this.mainWindow, this);
                starter         = new Starter433(this, this.mainWindow);
                break;

            case "Falcon BMS 4.33":
                bms_Version     = BMS_Version.BMS433;
                keyFileName     = "BMS - Full.key";
                overRideSetting = new OverrideSettingFor433(this.mainWindow, this);
                starter         = new Starter433(this, this.mainWindow);
                break;

            case "Falcon BMS 4.32":
                bms_Version     = BMS_Version.BMS432;
                keyFileName     = "BMS.key";
                overRideSetting = new OverrideSettingFor432(this.mainWindow, this);
                starter         = new Starter432(this, this.mainWindow);
                break;

            default:
                bms_Version = BMS_Version.UNDEFINED;
                Properties.Settings.Default.BMS_Version = "Falcon4.0";
                throw new ArgumentOutOfRangeException();     // Just to be explicit.
                break;
            }

            string regName64 = "SOFTWARE\\Wow6432Node\\Benchmark Sims\\" + version;
            string regName32 = "SOFTWARE\\Benchmark Sims\\" + version;

            RegistryKey regkey64 = Registry.LocalMachine.OpenSubKey(regName64, true);
            RegistryKey regkey32 = Registry.LocalMachine.OpenSubKey(regName32, true);

            // Read Registry
            if (regkey64 == null)
            {
                if (regkey32 == null)
                {
                    Properties.Settings.Default.BMS_Version = "Falcon4.0";
                    MessageBox.Show("Could not find FalconBMS Installed.");
                    mainWindow.Close();
                    return;
                }

                platform = Platform.OS_32bit;
                mainWindow.Misc_Platform.IsChecked = false;
                mainWindow.Misc_Platform.IsEnabled = false;

                regName = regName32;
                regkey  = regkey32;
            }
            else
            {
                regName = regName64;
                regkey  = regkey64;
            }

            byte[] bs;

            if (regkey.GetValue("PilotName") == null)
            {
                bs = Encoding.ASCII.GetBytes("Joe Pilot\0\0\0\0\0\0\0\0\0\0\0");
                regkey.SetValue("PilotName", bs);
            }
            if (regkey.GetValue("PilotCallsign") == null)
            {
                bs = Encoding.ASCII.GetBytes("Viper\0\0\0\0\0\0\0");
                regkey.SetValue("PilotCallsign", bs);
            }
            if (regkey.GetValue("curTheater") == null)
            {
                regkey.SetValue("curTheater", "Korea KTO");
            }

            installDir     = (string)regkey.GetValue("baseDir");
            currentTheater = (string)regkey.GetValue("curTheater");

            pilotCallsign = ReadPilotCallsign((byte[])regkey.GetValue("PilotCallsign"));

            if (platform == Platform.OS_64bit)
            {
                exeDir = installDir + "\\bin\\x64\\Falcon BMS.exe";
            }
            if (platform == Platform.OS_32bit)
            {
                exeDir = installDir + "\\bin\\x86\\Falcon BMS.exe";
            }

            updateVersion = CheckUpdateVersion();

            regkey.Close();
        }
        public AppRegInfo(MainWindow mainWindow)
        {
            this.mainWindow = mainWindow;

            // Read Current Directory
            int    versionNum = 0;
            int    updateNum  = 0;
            string exeName    = System.IO.Directory.GetCurrentDirectory() + "/Falcon BMS.exe";

            if (!System.IO.File.Exists(exeName))
            {
                exeName = System.IO.Directory.GetCurrentDirectory() + "/../x64/Falcon BMS.exe";
            }
            if (System.IO.File.Exists(exeName))
            {
                System.Diagnostics.FileVersionInfo exeVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(exeName);
                versionNum = exeVersion.ProductMinorPart;
                updateNum  = exeVersion.ProductBuildPart;
            }

            if (versionNum == 32)
            {
                bms_Version = BMS_Version.BMS432;
            }
            else if (versionNum == 33 && updateNum == 0)
            {
                bms_Version = BMS_Version.BMS433;
            }
            else if (versionNum == 33 && updateNum > 0)
            {
                bms_Version = BMS_Version.BMS433U1;
            }
            else if (versionNum == 34 && updateNum == 0)
            {
                bms_Version = BMS_Version.BMS434;
            }
            else if (versionNum == 34 && updateNum > 0)
            {
                bms_Version = BMS_Version.BMS434U1;
            }
            else if (versionNum == 35)
            {
                bms_Version = BMS_Version.BMS435;
            }
            else
            {
                bms_Version = BMS_Version.BMS435;
            }

            // load command line.
            string[] args = Environment.GetCommandLineArgs();
            Dictionary <string, string> option = new Dictionary <string, string>();

            if (args.Length % 2 == 1)
            {
                for (int index = 1; index < args.Length; index += 2)
                {
                    option.Add(args[index], args[index + 1]);
                }
            }

            // User defined BMS version
            if (option.ContainsKey("/bms"))
            {
                switch (option["/bms"])
                {
                case "4.32":
                    bms_Version = BMS_Version.BMS432;
                    break;

                case "4.33":
                    bms_Version = BMS_Version.BMS433;
                    break;

                case "4.33.1":
                    bms_Version = BMS_Version.BMS433U1;
                    break;

                case "4.34":
                    bms_Version = BMS_Version.BMS434;
                    break;

                case "4.34.1":
                    bms_Version = BMS_Version.BMS434U1;
                    break;

                case "4.35":
                    bms_Version = BMS_Version.BMS435;
                    break;

                default:
                    bms_Version = BMS_Version.BMS435;
                    break;
                }
            }

            // BMS version
            switch (bms_Version)
            {
            case BMS_Version.BMS432:
                regName         = "SOFTWARE\\Wow6432Node\\Benchmark Sims\\Falcon BMS 4.32";
                keyFileName     = "BMS.key";
                overRideSetting = new OverrideSettingFor432(this.mainWindow, this);
                launcher        = new Launcher432(this, this.mainWindow);
                mainWindow.LOGO432.Visibility = Visibility.Visible;
                break;

            case BMS_Version.BMS433:
                regName         = "SOFTWARE\\Wow6432Node\\Benchmark Sims\\Falcon BMS 4.33";
                keyFileName     = "BMS - Full.key";
                overRideSetting = new OverrideSettingFor433(this.mainWindow, this);
                launcher        = new Launcher433(this, this.mainWindow);
                mainWindow.LOGO433.Visibility = Visibility.Visible;
                break;

            case BMS_Version.BMS433U1:
                regName         = "SOFTWARE\\Wow6432Node\\Benchmark Sims\\Falcon BMS 4.33 U1";
                keyFileName     = "BMS - Full.key";
                overRideSetting = new OverrideSettingFor433(this.mainWindow, this);
                launcher        = new Launcher433(this, this.mainWindow);
                mainWindow.LOGO433.Visibility = Visibility.Visible;
                break;

            case BMS_Version.BMS434:
                regName         = "SOFTWARE\\Wow6432Node\\Benchmark Sims\\Falcon BMS 4.34";
                keyFileName     = "BMS - Full.key";
                overRideSetting = new OverrideSettingFor434(this.mainWindow, this);
                launcher        = new Launcher434(this, this.mainWindow);
                mainWindow.LOGO434.Visibility = Visibility.Visible;
                break;

            case BMS_Version.BMS434U1:
                regName         = "SOFTWARE\\Wow6432Node\\Benchmark Sims\\Falcon BMS 4.34";
                keyFileName     = "BMS - Full.key";
                overRideSetting = new OverrideSettingFor434U1(this.mainWindow, this);
                launcher        = new Launcher434(this, this.mainWindow);
                mainWindow.LOGO434.Visibility = Visibility.Visible;
                break;

            case BMS_Version.BMS435:
                regName         = "SOFTWARE\\Wow6432Node\\Benchmark Sims\\Falcon BMS 4.35";
                keyFileName     = "BMS - Full.key";
                overRideSetting = new OverrideSettingFor435(this.mainWindow, this);
                launcher        = new Launcher435(this, this.mainWindow);
                mainWindow.LOGO435.Visibility = Visibility.Visible;
                break;

            case BMS_Version.UNDEFINED:
                throw new ArgumentOutOfRangeException();     // Just to be explicit.

            default:
                throw new ArgumentOutOfRangeException();
            }

            // User defined registry
            if (option.ContainsKey("/reg"))
            {
                regName = "SOFTWARE\\Wow6432Node\\Benchmark Sims\\" + option["/reg"];
            }

            // User defined key file
            if (option.ContainsKey("/key"))
            {
                keyFileName = option["/key"];
            }

            // Read Registry
            regkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(regName, false);
            if (regkey == null)
            {
                regName  = regName.Replace("SOFTWARE\\Wow6432Node\\", "SOFTWARE\\");
                regkey   = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(regName, false);
                platform = Platform.OS_32bit;
                mainWindow.Misc_Platform.IsChecked = false;
                mainWindow.Misc_Platform.IsEnabled = false;
            }
            if (regkey == null)
            {
                MessageBox.Show("Could not find FalconBMS Installed.");
                mainWindow.Close();
                return;
            }

            byte[] bs;
            if (regkey.GetValue("PilotName") == null)
            {
                regkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(regName, true);
                bs     = new byte[] { 0x4a, 0x6f, 0x65, 0x20, 0x50, 0x69, 0x6c, 0x6f, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
                regkey.SetValue("PilotName", bs);
            }
            if (regkey.GetValue("PilotCallsign") == null)
            {
                regkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(regName, true);
                bs     = new byte[] { 0x56, 0x69, 0x70, 0x65, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
                regkey.SetValue("PilotCallsign", bs);
            }
            if (regkey.GetValue("curTheater") == null)
            {
                regkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(regName, true);
                regkey.SetValue("curTheater", "Korea KTO");
            }

            installDir     = (string)regkey.GetValue("baseDir");
            currentTheater = (string)regkey.GetValue("curTheater");
            pilotCallsign  = Encoding.UTF8.GetString((byte[])regkey.GetValue("PilotCallsign")).Replace("\0", "");

            regkey.Close();
        }
        public AppRegInfo(MainWindow mainWindow)
        {
            this.mainWindow = mainWindow;

            // Read Current Directry
            string stCurrentDir = System.IO.Directory.GetCurrentDirectory();

            if (stCurrentDir.Contains("Falcon BMS 4.32"))
            {
                this.regName     = "SOFTWARE\\Wow6432Node\\Benchmark Sims\\Falcon BMS 4.32";
                this.bms_Version = BMS_Version.BMS432;
                this.platform    = Platform.OS_32bit;
                this.keyFileName = "BMS.key";
                mainWindow.Misc_Platform.IsChecked = false;
                mainWindow.Misc_Platform.IsEnabled = false;
                mainWindow.LOGO432.Visibility      = System.Windows.Visibility.Visible;
            }
            else if (stCurrentDir.Contains("Falcon BMS 4.33") && !stCurrentDir.Contains("Falcon BMS 4.33 U1"))
            {
                this.regName     = "SOFTWARE\\Wow6432Node\\Benchmark Sims\\Falcon BMS 4.33";
                this.bms_Version = BMS_Version.BMS433;
                this.platform    = Platform.OS_64bit;
                this.keyFileName = "BMS - FULL.key";
                mainWindow.LOGO433.Visibility = System.Windows.Visibility.Visible;
            }
            else if (stCurrentDir.Contains("Falcon BMS 4.33 U1"))
            {
                this.regName     = "SOFTWARE\\Wow6432Node\\Benchmark Sims\\Falcon BMS 4.33 U1";
                this.bms_Version = BMS_Version.BMS433U1;
                this.platform    = Platform.OS_64bit;
                this.keyFileName = "BMS - FULL.key";
                mainWindow.LOGO433.Visibility = System.Windows.Visibility.Visible;
            }
            else if (stCurrentDir.Contains("Falcon BMS 4.34"))
            {
                this.regName     = "SOFTWARE\\Wow6432Node\\Benchmark Sims\\Falcon BMS 4.34";
                this.bms_Version = BMS_Version.BMS434;
                this.platform    = Platform.OS_64bit;
                this.keyFileName = "BMS - FULL.key";
                mainWindow.LOGO434.Visibility = System.Windows.Visibility.Visible;
            }
            else if (stCurrentDir.Contains("Falcon BMS 4.35"))
            {
                this.regName     = "SOFTWARE\\Wow6432Node\\Benchmark Sims\\Falcon BMS 4.35";
                this.bms_Version = BMS_Version.BMS435;
                this.platform    = Platform.OS_64bit;
                this.keyFileName = "BMS - FULL.key";
                mainWindow.LOGO435.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                this.regName     = "SOFTWARE\\Wow6432Node\\Benchmark Sims\\Falcon BMS 4.33 U1";
                this.bms_Version = BMS_Version.BMS433U1;
                this.platform    = Platform.OS_64bit;
                this.keyFileName = "BMS - FULL.key";
                mainWindow.LOGO433.Visibility = System.Windows.Visibility.Visible;
            }

            // Read Registry
            this.regkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(regName, false);

            if (regkey == null)
            {
                this.regName  = this.regName.Replace("SOFTWARE\\Wow6432Node\\", "SOFTWARE\\");
                this.regkey   = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(regName, false);
                this.platform = Platform.OS_32bit;
                mainWindow.Misc_Platform.IsChecked = false;
                mainWindow.Misc_Platform.IsEnabled = false;
            }
            if (regkey == null)
            {
                System.Windows.MessageBox.Show("There is no FalconBMS 4.33 U1 Installed.");
                mainWindow.Close();
                return;
            }

            this.installDir     = (string)regkey.GetValue("baseDir");
            this.currentTheater = (string)regkey.GetValue("curTheater");
            this.pilotCallsign  = (Encoding.UTF8.GetString((byte[])regkey.GetValue("PilotCallsign"))).Replace("\0", "");

            this.regkey.Close();
        }