// Decompiled with JetBrains decompiler
// Type: FiestaLauncher.Splash
// Assembly: FiestaOnline, Version=2019.5.22.0, Culture=neutral, PublicKeyToken=null
// MVID: 2FD5EB61-BC25-469D-997E-88998E849F6A
// Assembly location: C:\Users\marbo\Documents\Gamigo 2020 Client\FiestaOnline.exe

using FiestaLauncher.Services;
using Properties;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Threading;
using System.Windows.Forms;

namespace FiestaLauncher
{
  public class Splash : Form
  {
    private IContainer components = (IContainer) null;
    private bool _uiShown;
    private ProgressBar progressBar1;
    private PictureBox pictureBox1;

    public Splash()
    {
      this.InitializeComponent();
    }

    internal void ForceRunClient()
    {
      Process.Start(new ProcessStartInfo()
      {
        FileName = "Fiesta.bin",
        WorkingDirectory = Directory.GetCurrentDirectory(),
        UseShellExecute = false
      });
      Environment.Exit(0);
    }

    public void RunOnUiThread(Splash.RunOnUiThreadDelegate action)
    {
      try
      {
        this.Invoke((Delegate) new MethodInvoker(action.Invoke));
      }
      catch (Exception ex)
      {
        FeedbackService.Exception(ex);
      }
    }

    internal void SettingsLoadComplete()
    {
      new Thread(new ThreadStart(ExternalFileService.FileCheck)).Start();
    }

    internal void ShowUpdateUi()
    {
      if (this._uiShown)
        return;
      this._uiShown = true;
      this.pictureBox1.Visible = false;
      this.BackgroundImage = (Image) Resources.Update_launcher;
      this.progressBar1.Visible = true;
    }

    internal void UpdateComplete()
    {
      this.Hide();
      try
      {
        gFiestaLauncher.MainWindow.Init();
        gFiestaLauncher.MainWindow.PageChange(0);
        gFiestaLauncher.MainWindow.Show();
      }
      catch (Exception ex)
      {
        FeedbackService.Exception(ex);
      }
    }

    private void Splash_Load(object sender, EventArgs e)
    {
      HttpService.GetSettings();
    }

    private void Splash_FormClosed(object sender, FormClosedEventArgs e)
    {
      Environment.Exit(0);
    }

    protected override void Dispose(bool disposing)
    {
      if (disposing && this.components != null)
        this.components.Dispose();
      base.Dispose(disposing);
    }

    private void InitializeComponent()
    {
      ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (Splash));
      this.progressBar1 = new ProgressBar();
      this.pictureBox1 = new PictureBox();
      ((ISupportInitialize) this.pictureBox1).BeginInit();
      this.SuspendLayout();
      this.progressBar1.Location = new Point(53, 184);
      this.progressBar1.Name = "progressBar1";
      this.progressBar1.Size = new Size(300, 20);
      this.progressBar1.Style = ProgressBarStyle.Marquee;
      this.progressBar1.TabIndex = 1;
      this.progressBar1.Visible = false;
      this.pictureBox1.BackColor = Color.Transparent;
      this.pictureBox1.Image = (Image) Resources.Fiesta_logo2;
      this.pictureBox1.Location = new Point(52, 29);
      this.pictureBox1.Name = "pictureBox1";
      this.pictureBox1.Size = new Size(300, 168);
      this.pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
      this.pictureBox1.TabIndex = 2;
      this.pictureBox1.TabStop = false;
      this.AutoScaleMode = AutoScaleMode.None;
      this.BackgroundImage = (Image) Resources.splash_launcher;
      this.ClientSize = new Size(404, 256);
      this.Controls.Add((Control) this.progressBar1);
      this.Controls.Add((Control) this.pictureBox1);
      this.FormBorderStyle = FormBorderStyle.FixedSingle;
      this.Icon = (Icon) componentResourceManager.GetObject("$this.Icon");
      this.MaximizeBox = false;
      this.MinimizeBox = false;
      this.Name = nameof (Splash);
      this.StartPosition = FormStartPosition.CenterScreen;
      this.Text = "Fiesta Online";
      this.FormClosed += new FormClosedEventHandler(this.Splash_FormClosed);
      this.Load += new EventHandler(this.Splash_Load);
      ((ISupportInitialize) this.pictureBox1).EndInit();
      this.ResumeLayout(false);
      this.PerformLayout();
    }

    public delegate void RunOnUiThreadDelegate();
  }
}
