示例#1
0
        private bool LaunchClick(GUIButton button, object obj)
        {
            if (!TrySaveSettings())
            {
                return(false);
            }

            var executables = ContentPackage.GetFilesOfType(settings.SelectedContentPackages, ContentType.Executable);

            if (!executables.Any())
            {
                ShowError("Error", "The game executable isn't configured in the selected content package.");
                return(false);
            }

            string exePath = Path.Combine(Directory.GetCurrentDirectory(), executables.First());

            if (!File.Exists(exePath))
            {
                ShowError("Error", "Couldn't find the executable \"" + exePath + "\"!");
                return(false);
            }

            try
            {
                Process.Start(new ProcessStartInfo(exePath));
            }
            catch (Exception exception)
            {
                ShowError("Error while opening executable \"" + exePath + "\"", exception.Message);
                return(false);
            }

            Exit();

            return(true);
        }