using ClientSupport; using FORCServerSupport; using FrontierSupport; using System; using System.Windows.Forms; namespace EliteLauncher { public partial class Form1 : Form { public Form1() { InitializeComponent(); } FORCManager m_manager = new FORCManager(); string m_actualVersion; string CobraBayVersion; ServerInterface.VersionStatus m_versionStatus; string m_serverClientVersion; bool m_wasAuthorised; NewsFeed m_newsfeed; string m_productDirectoryRoot; public NewsFeed News { get { return this.m_newsfeed; } set { if (value != this.m_newsfeed) { this.m_newsfeed = value; //this.RaisePropertyChanged("Newsfeed"); } } } public string ProductDirectoryRoot { get { return this.m_productDirectoryRoot; } set { if (this.m_productDirectoryRoot != value) { this.m_productDirectoryRoot = value; //this.RaisePropertyChanged("ProductDirectoryRoot"); } } } private void Form1_Load(object sender, EventArgs e) { try { m_manager.Initialise(new FormsDirectorySelector()); if (m_manager.ServerConnection == null) { FORCServerConnection fORCServerConnection = new FORCServerConnection(m_manager); m_manager.ServerConnection = fORCServerConnection; if (!this.m_manager.HasServer) { return; } } if (m_manager.MachineIdentifier == null) { m_manager.MachineIdentifier = new FrontierMachineIdentifier(); } m_actualVersion = m_manager.ActualVersion; CobraBayVersion = m_manager.ApplicationVersion; LogEntry logEntry = new LogEntry("ClientVersion"); logEntry.AddValue("application", CobraBayVersion); if (CobraBayVersion != m_actualVersion) { logEntry.AddValue("actual", m_actualVersion); } m_manager.ServerConnection.LogValues(m_manager.UserDetails, logEntry); JSONWebQuery.SetUserAgent("EDLaunch", CobraBayVersion, null); m_versionStatus = m_manager.ServerConnection.CheckClientVersion(CobraBayVersion, out m_serverClientVersion); // m_manager.UpdateProjectList(); Update(); //this.TidyOldConfigurations(); } catch (Exception crap) { return; } } private Project GetSelectedProject() { Project[] projectArray = this.m_manager.AvailableProjects.GetProjectArray(); string[] strArrays = new string[] { "FORC_FDEV_D_VIP_1001", "FORC_FDEV_D_PRESS_1001", "FORC-FDEV-D-1000", "FORC-FDEV-D-1001", "FORC-FDEV-D-1002" }; string[] strArrays1 = strArrays; for (int i = 0; i < (int)strArrays1.Length; i++) { string str = strArrays1[i]; Project[] projectArray1 = projectArray; for (int j = 0; j < (int)projectArray1.Length; j++) { Project project = projectArray1[j]; if (project.Name == str) { return project; } } } if ((int)projectArray.Length != 1) { return null; } return projectArray[0]; } private void btnLogin_Click(object sender, EventArgs e) { m_manager.ResetLogin(true, true); m_manager.UserDetails.EmailAddress = ""; m_manager.UserDetails.Password = ""; //m_manager.UserDetails.TwoFactor = null; m_manager.Authenticate(); return; } public void Debug(string text, params string[] reps) { for (int i = 0; i < reps.Length; i++) { text = text.Replace("{" + i + "}", reps[i]); } this.UIThread(() => { //debugbox.Text += DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " - " + text + Environment.NewLine; txtDebug.Text += text + Environment.NewLine; txtDebug.SelectionStart = txtDebug.Text.Length; txtDebug.ScrollToCaret(); txtDebug.Refresh(); }); } private void Update() { LogEntry logEntry; //this.HideUnusedSeparators(); if (this.News == null) { this.News = new NewsFeed(this.m_manager); } this.News.Update(); this.ProductDirectoryRoot = this.m_manager.RootDirectory; } } public static class ControlExtensions { public static void UIThread(this Control @this, Action code) { if (null != @this && (!@this.Disposing || !@this.IsDisposed)) { if (@this.InvokeRequired) { @this.BeginInvoke(code); } else { code.Invoke(); } } } } }