Пример #1
0
        static void Main()
        {
#if !DEBUG
            GitHubUpdateTask update = new GitHubUpdateTask("BigETI", "SAMPLauncherNET");
            if (update.IsUpdateAvailable)
            {
                if (Utils.ExportResource("SAMPLauncherNET.PreBuilds.SAMPLauncherNETUpdater.exe", Path.Combine(Environment.CurrentDirectory, "SAMPLauncherNETUpdater.exe")))
                {
                    try
                    {
                        Process.Start("SAMPLauncherNETUpdater.exe");
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message, "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
#endif
            try
            {
                Translator.TranslatorInterface = new TranslatorInterface();
                if (IsSAMPInstalled)
                {
                    if (!Directory.Exists(ConfigPath + "\\screens"))
                    {
                        Directory.CreateDirectory(ConfigPath + "\\screens");
                    }
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new MainForm());
                }
                else
                {
                    LaunchLatestSAMPInstaller();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("A fatal error has occured:\r\n\r\n" + e.Message, "Fatal error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
#if !DEBUG
        }

        if (installerPath != null)
        {
            while (isDownloading)
            {
                Thread.Sleep(200);
            }
        }
#endif
            Application.Exit();
        }
Пример #2
0
        /// <summary>
        /// Main form load event
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">Event arguments</param>
        private void MainForm_Load(object sender, EventArgs e)
        {
            GitHubUpdateTask update = new GitHubUpdateTask("BigETI", "SAMPLauncherNET", @".*\.exe", RegexOptions.IgnoreCase);

            update.DownloadProgressChanged += OnDownloadProgressChanged;
            update.UpdateTaskFinished      += OnUpdateTaskFinished;
            if (update.IsUpdateAvailable)
            {
                update.InstallUpdates();
            }
            else
            {
                CloseApp();
            }
        }
Пример #3
0
 static void Main()
 {
     try
     {
         try
         {
             if (!(Directory.Exists(languagesDirectory)))
             {
                 Directory.CreateDirectory(languagesDirectory);
                 string[] resources = Assembly.GetExecutingAssembly().GetManifestResourceNames();
                 if (resources != null)
                 {
                     Regex regex      = new Regex(Assembly.GetExecutingAssembly().GetName().Name + @"\.languages\..*\.json", RegexOptions.IgnoreCase);
                     int   prefix_len = (Assembly.GetExecutingAssembly().GetName().Name + ".languages.").Length;
                     foreach (string resource in resources)
                     {
                         if (resource != null)
                         {
                             if (regex.IsMatch(resource))
                             {
                                 using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource))
                                 {
                                     if (stream != null)
                                     {
                                         using (FileStream file_stream = File.Open(Path.Combine(languagesDirectory, resource.Substring(prefix_len)), FileMode.Create, FileAccess.Write))
                                         {
                                             stream.CopyTo(file_stream);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         catch (Exception e)
         {
             Console.Error.WriteLine(e);
         }
         if (IsSAMPInstalled)
         {
             Application.EnableVisualStyles();
             Application.SetCompatibleTextRenderingDefault(false);
             if (!Directory.Exists(configPath + "\\screens"))
             {
                 Directory.CreateDirectory(configPath + "\\screens");
             }
             bool init = true;
             if (!(SAMP.LauncherConfigIO.DoNotCheckForUpdates))
             {
                 GitHubUpdateTask update = new GitHubUpdateTask("BigETI", "SAMPLauncherNET");
                 if (update.Version != Assembly.GetExecutingAssembly().GetName().Version.ToString())
                 {
                     UpdateNotificationForm update_notification_form = new UpdateNotificationForm(update.Version);
                     if (update_notification_form.ShowDialog() == DialogResult.Yes)
                     {
                         init = false;
                         try
                         {
                             Process.Start("https://github.com/BigETI/SAMPLauncherNET/releases/tag/" + update.Version);
                         }
                         catch (Exception e)
                         {
                             Console.Error.WriteLine(e);
                         }
                     }
                 }
             }
             if (init)
             {
                 Application.Run(new MainForm());
             }
         }
         else
         {
             LaunchLatestSAMPInstaller();
         }
     }
     catch (Exception e)
     {
         Console.Error.WriteLine(e);
         MessageBox.Show("A fatal error has occured:" + Environment.NewLine + Environment.NewLine + e, "Fatal error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     if (installerPath != null)
     {
         while (isDownloading)
         {
             Thread.Sleep(200);
         }
     }
     Application.Exit();
 }