Наследование: System.Windows.Forms.Form
Пример #1
0
 private void Close_internal()
 {
     _CloseTimer.Dispose();
     _Logger      = null;
     SplashObject = null;
     this.Close();
 }
Пример #2
0
 public SplashScreenForm()
 {
     InitializeComponent();
     SplashInfo.Items.Clear();
     SplashObject = this;
     lblVersion.Text = "v" + VersionHelper.Parts(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version, 3);
 }
Пример #3
0
        public void ShowDialog(Exception ex, string infotext, Boolean ignoreAllowed)
        {
            string Info;

            _LogPath = Program.GetDataPath("Logs");
            SingleThreadLogger _logger          = new SingleThreadLogger(ThreadLoggerType.Exception, _LogPath, true);
            Exception          currentException = ex;

            String errorMessage = GetErrorMessage(ref infotext, currentException);

            _logger.Log(errorMessage);

            cmdIgnore.Visible = ignoreAllowed;

            txtErrorDetail.Text            = errorMessage;
            lblErrorInfo.Text              = infotext;
            lblLogDestination.Text         = string.Format("(Logfile : {0})", _logger.logPathName);
            txtErrorDetail.SelectionStart  = 0;
            txtErrorDetail.SelectionLength = 0;


            SplashScreenForm.SetTopmost(false);
            if (SplashScreenForm.GetPrimaryGUI(Program.MainForm).InvokeRequired)
            {
                SplashScreenForm.GetPrimaryGUI(Program.MainForm).Invoke(new ShowDialogInvokedDelegate(ShowDialogInvoked), ex, infotext);
            }
            else
            {
                ShowDialogInvoked(ex, infotext);
            }


            SplashScreenForm.SetTopmost(true);
        }
Пример #4
0
        public SplashScreenForm()
        {
            InitializeComponent();

            ThreadSynchronizationContext = System.Threading.SynchronizationContext.Current;

            //_MinimizeTimer = new System.Windows.Forms.Timer(this.components);
            InfoTarget.Items.Clear();
            SplashObject    = this;
            lblVersion.Text = "v" + VersionHelper.Parts(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version, 3);
        }
Пример #5
0
        private static void HandleException(Exception ex)
        {
            String FileName = String.Format("ed-ibe-dump-v{0}.dmp", VersionHelper.Parts(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version, 3).Replace(".", "_"));

            if (ex == null)
            {
                return;
            }

            SplashScreenForm.SetTopmost(false);

            CErr.processError(ex, "Unhandled Exception");
            // ExceptionPolicy.HandleException(ex, "Default Policy");
            //CreateMiniDump(FileName);
            //MessageBox.Show("Fatal error.\r\n\r\nA dump file (\"" + FileName + "\" has been created in your data directory.  \r\n\r\nPlease place this in a file-sharing service such as SendSpace, Google Drive or Dropbox, then link to the file in the Frontier forums or on the GitHub archive or send e mail to [email protected].  This will allow the developers to fix this problem.  \r\n\r\nThanks, and sorry about the crash...");
            //Application.Exit();
        }
Пример #6
0
        /// <summary>
        /// starts the initialization of the global objects
        /// </summary>
        public static void Init()
        {
            try
            {
                if(!m_initDone)
                {
                    Program.SplashScreen = new SplashScreenForm();
                    Program.SplashScreen.Show();

                    Program.SplashScreen.InfoAdd("initializing logger...");
                    Program.Logger = new SingleThreadLogger(ThreadLoggerType.Form);
                    Program.Logger.Log("Initialising...\n");
                    Program.SplashScreen.InfoAppendLast("<OK>");

                    Program.SplashScreen.InfoAdd("starting sql server...");

                    // load settings from file
                    IniFile = new STA.Settings.INIFile(GetDataPath("ED-IBE.ini"), false, true);

                    // starT database process (if not running)
                    DBProcess.DBProcessParams newProcessParams  = new DBProcess.DBProcessParams() { };
                    newProcessParams.Commandline                = IniFile.GetValue("DB_Server",        "Commandline",      @"bin\mysqld.exe");
                    newProcessParams.Commandargs                = IniFile.GetValue("DB_Server",        "CommandArgs",      @"--defaults-file=Elite.ini --console");
                    newProcessParams.Workingdirectory           = IniFile.GetValue("DB_Server",        "WorkingDirectory", @"..\..\..\RNDatabase\Database");
                    newProcessParams.Port                       = IniFile.GetValue<Int16>("DB_Server", "Port",             "3306");
                    newProcessParams.DBStartTimeout             = IniFile.GetValue<Int16>("DB_Server", "DBStartTimeout",   "60");

                    EliteDBProcess                              = new DBProcess(newProcessParams);

                    if (EliteDBProcess.WasRunning)
                        Program.SplashScreen.InfoAppendLast("already running...<OK>");
                    else
                        Program.SplashScreen.InfoAppendLast("<OK>");

                    // connecT to the database
                    Program.SplashScreen.InfoAdd("connect to sql server...");

                    DBConnector.ConnectionParams newConnectionParams = new DBConnector.ConnectionParams() { };

                    newConnectionParams.Name                    = IniFile.GetValue("DB_Connection",          "Name",           "master");
                    newConnectionParams.Server                  = IniFile.GetValue("DB_Connection",          "Server",         "localhost");
                    newConnectionParams.Database                = IniFile.GetValue("DB_Connection",          "Database",       "Elite_DB");
                    newConnectionParams.User                    = IniFile.GetValue("DB_Connection",          "User",           "RN_User");
                    newConnectionParams.Pass                    = IniFile.GetValue("DB_Connection",          "Pass",           "Elite");
                    newConnectionParams.ConnectTimeout          = IniFile.GetValue<Int16>("DB_Connection",   "ConnectTimeout", "60");
                    newConnectionParams.StayAlive               = IniFile.GetValue<Boolean>("DB_Connection", "StayAlive",      "false");
                    newConnectionParams.TimeOut                 = IniFile.GetValue<Int16>("DB_Connection",   "TimeOut",        "60");

                    DBCon                                       = new DBConnector(newConnectionParams);

                    DBCon.Connect();

                    Program.SplashScreen.InfoAppendLast("<OK>");

                    /* **************** database is running ********************** */

                    Program.SplashScreen.InfoAdd("preparing global objects...");

                    // prepare colors-object
                    Colors                                      = new GUIColors();

                    // preprare main data object
                    Data                                        = new IBE.SQL.EliteDBIO();
                    Data.PrepareBaseTables();

                    // create global paths-object
                    //Paths                                       = new ProgramPaths();

                    // prepare settings
                    Settings                                    = new Settings();
                    Settings.BaseData                           = Data.BaseData;

                    // prepare commanders log
                    CommandersLog                               = new CommandersLog();
                    CommandersLog.BaseData                      = Data.BaseData;

                    // prepare price analysis
                    PriceAnalysis                               = new PriceAnalysis(new DBConnector(DBCon.ConfigData, true));
                    PriceAnalysis.BaseData                      = Data.BaseData;

                    // starting the external data interface
                    ExternalData                                = new ExternalDataInterface();

                    // initializing the object for the actual condition
                    actualCondition                             = new Condition();

                    // initializing the LogfileScanner
                    LogfileScanner                              = new EDLogfileScanner();

                    // forwards a potentially new system or station information to database
                    Program.LogfileScanner.LocationInfo += LogfileScanner_LocationInfo;
                    Program.ExternalData.LocationInfo   += ExternalData_LocationInfo;

                    // register the LogfileScanner in the CommandersLog for the ExternalDataEvent-event
                    CommandersLog.registerLogFileScanner(LogfileScanner);
                    CommandersLog.registerExternalTool(ExternalData);

                    PriceAnalysis.registerLogFileScanner(LogfileScanner);
                    PriceAnalysis.registerExternalTool(ExternalData);

                    Program.SplashScreen.InfoAppendLast("<OK>");

                    m_initDone = true;

                }
            }
            catch (Exception ex)
            {
                cErr.processError(ex, "Error while initializing the program object", true);
            }
        }
Пример #7
0
        AppConfig CheckAndRequestVerboseLogging(String fileName, AppConfig configuration)
        {
            try
            {
                if ((configuration == null) || (configuration.Network.VerboseLogging != 1))
                {
                    SplashScreenForm.SetTopmost(false);

                    var setLog =
                        MessageBox.Show(SplashScreenForm.GetPrimaryGUI(Program.MainForm),
                                        "Verbose logging isn't set in your Elite Dangerous AppConfig.xml, so I can't read system names. Would you like me to set it for you?",
                                        "Set verbose logging?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    SplashScreenForm.SetTopmost(true);

                    if (setLog == DialogResult.Yes)
                    {
                        var appConfigFilePath = Path.Combine(m_lDBCon.getIniValue <String>(IBE.IBESettingsView.DB_GROUPNAME, "GamePath"), fileName);
                        var doc = new XmlDocument();

                        //Make backup
                        if (File.Exists(appConfigFilePath))
                        {
                            File.Copy(appConfigFilePath, appConfigFilePath + ".bak", true);
                            doc.Load(appConfigFilePath);
                        }
                        else
                        {
                            doc.LoadXml("<AppConfig><Network></Network></AppConfig>");
                        }

                        var ie = doc.SelectNodes("/AppConfig/Network").GetEnumerator();

                        while (ie.MoveNext())
                        {
                            if ((ie.Current as XmlNode).Attributes["VerboseLogging"] != null)
                            {
                                (ie.Current as XmlNode).Attributes["VerboseLogging"].Value = "1";
                            }
                            else
                            {
                                var verb = doc.CreateAttribute("VerboseLogging");
                                verb.Value = "1";

                                (ie.Current as XmlNode).Attributes.Append(verb);
                            }
                        }

                        try
                        {
                            doc.Save(appConfigFilePath);

                            SplashScreenForm.SetTopmost(false);

                            MessageBox.Show(SplashScreenForm.GetPrimaryGUI(Program.MainForm),
                                            fileName + " updated.  You'll need to restart Elite Dangerous if it's already running.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            SplashScreenForm.SetTopmost(true);
                        }
                        catch (Exception ex)
                        {
                            SplashScreenForm.SetTopmost(false);

                            MessageBox.Show(SplashScreenForm.GetPrimaryGUI(Program.MainForm),
                                            "I can't save the file (no permission). Please set the 'VorboseLogging' manually.", "Can't write", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                            SplashScreenForm.SetTopmost(true);
                        }
                    }

                    //Update config
                    configuration = LoadAppConfig(fileName, false);
                }

                return(configuration);
            }
            catch (Exception ex)
            {
                throw new Exception("Error while checking VerboseLogging", ex);
            }
        }
Пример #8
0
        void LoadDisplaySettings()
        {
            try
            {
                TimeSpan        delta;
                DialogResult    MBResult = DialogResult.Ignore;
                EdDisplayConfig locDisplay;

                var configFile = Path.Combine(m_lDBCon.getIniValue <String>(IBE.IBESettingsView.DB_GROUPNAME, "ProductAppData"), "Graphics", "DisplaySettings.xml");
                if (!File.Exists(configFile))
                {
                    return;
                }
                var serializer = new XmlSerializer(typeof(EdDisplayConfig));


                do
                {
                    try
                    {
                        using (var myFileStream = new FileStream(configFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                        {
                            locDisplay = (EdDisplayConfig)serializer.Deserialize(myFileStream);
                            m_Display  = locDisplay;
                        }
                    }
                    catch (Exception ex)
                    {
                        if (m_Display == null)
                        {
                            // ignore this if it was loaded short before
                            delta = DateTime.UtcNow - lastTry_Displaydata;
                            if (delta.TotalMilliseconds > 1000)
                            {
                                SplashScreenForm.SetTopmost(false);

                                // ignore this if it was asked before
                                MBResult = MessageBox.Show(SplashScreenForm.GetPrimaryGUI(Program.MainForm),
                                                           String.Format("Error while loading ED-Displaysettings from file <{0}>", configFile), "Problem while loading data...", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button3);

                                SplashScreenForm.SetTopmost(true);

                                if (MBResult == DialogResult.Abort)
                                {
                                    CErr.processError(ex, "Error in AppData_Changed()");
                                }
                                lastTry_Displaydata = DateTime.UtcNow;
                            }
                        }
                    }
                } while (MBResult == DialogResult.Retry);

                // this makes problems -> another solution is needed
                //if (_parent != null)
                //{
                //    _parent.setOCRTabsVisibility();
                //}
            }
            catch (Exception ex)
            {
                throw new Exception("Error while loading display settings", ex);
            }
        }
Пример #9
0
        /// <summary>
        /// starts the initialization of the global objects
        /// </summary>
        public static void Init()
        {

            try
            {
                if(!m_initDone)
                { 
                    Program.SplashScreen = new SplashScreenForm();
                    Program.SplashScreen.Show();

                    Program.SplashScreen.Logger = MainLog;

                    Program.SplashScreen.InfoAdd("initializing logger...");
                    Program.MainLog.Log("Initialising...\n");
                    Program.SplashScreen.InfoAppendLast("<OK>");

                    Program.SplashScreen.InfoAdd("starting sql server...");

                    // load settings from file
                    IniFile = new STA.Settings.INIFile(GetDataPath("ED-IBE.ini"), false, true);


                    // prepare architecture-dependend files
                    PrepareDepFiles();

                    // start database process (if not running)
                    DBProcess.DBProcessParams newProcessParams  = new DBProcess.DBProcessParams() { };
                    newProcessParams.Commandline                = IniFile.GetValue("DB_Server",         "Commandline",      @"bin\mysqld.exe");    
                    newProcessParams.Commandargs                = IniFile.GetValue("DB_Server",         "CommandArgs",      @"--defaults-file=Elite.ini --console");
                    newProcessParams.Workingdirectory           = IniFile.GetValue("DB_Server",         "WorkingDirectory", @"..\..\..\RNDatabase\Database");
                    newProcessParams.Port                       = IniFile.GetValue<UInt16>("DB_Server", "Port",             "3306");
                    newProcessParams.DBStartTimeout             = IniFile.GetValue<Int16>("DB_Server",  "DBStartTimeout",   "60");

                    Program.SplashScreen.InfoAppendLast("on port " + newProcessParams.Port + "...");

                    EliteDBProcess                              = new DBProcess(newProcessParams);

                    if (EliteDBProcess.WasRunning)
                        Program.SplashScreen.InfoAppendLast("already running...<OK>"); 
                    else
                        Program.SplashScreen.InfoAppendLast("<OK>");
                        


                    // connecT to the database
                    Program.SplashScreen.InfoAdd("connect to sql server...");

                    DBConnector.ConnectionParams newConnectionParams = new DBConnector.ConnectionParams() { };

                    newConnectionParams.Name                    = IniFile.GetValue("DB_Connection",          "Name",           "master");   
                    newConnectionParams.Server                  = IniFile.GetValue("DB_Connection",          "Server",         "localhost");
                    newConnectionParams.Port                    = IniFile.GetValue<UInt16>("DB_Server",      "Port",           "3306");
                    newConnectionParams.Database                = IniFile.GetValue("DB_Connection",          "Database",       "Elite_DB"); 
                    newConnectionParams.User                    = IniFile.GetValue("DB_Connection",          "User",           "RN_User");  
                    newConnectionParams.Pass                    = IniFile.GetValue("DB_Connection",          "Pass",           "Elite");    
                    newConnectionParams.ConnectTimeout          = IniFile.GetValue<Int16>("DB_Connection",   "ConnectTimeout", "60");   
                    newConnectionParams.StayAlive               = IniFile.GetValue<Boolean>("DB_Connection", "StayAlive",      "false");    
                    newConnectionParams.TimeOut                 = IniFile.GetValue<Int16>("DB_Connection",   "TimeOut",        "10000");

                    DBCon                                       = new DBConnector(newConnectionParams);

                    DBCon.Connect();

                    Program.SplashScreen.InfoAppendLast("<OK>");

                    /* **************** database is running ********************** */
                    
                    /* perform updates */
                    Updater.DBUpdate();

                    Program.SplashScreen.InfoAdd("preparing global objects...");

                    // prepare colors-object
                    Colors                                      = new GUIColors();

                    // preprare main data object
                    Data                                        = new IBE.SQL.EliteDBIO();
                    Data.PrepareBaseTables();

                    // create global paths-object
                    //Paths                                       = new ProgramPaths();

                    // prepare settings
//                    Settings                                    = new Settings();
//                    Settings.BaseData                           = Data.BaseData;

                    // prepare commanders log 
                    CommandersLog                               = new CommandersLog();
                    CommandersLog.BaseData                      = Data.BaseData;

                    // prepare price analysis 
                    PriceAnalysis                               = new PriceAnalysis(new DBConnector(DBCon.ConfigData, true));
                    PriceAnalysis.BaseData                      = Data.BaseData;

                    //// starting the external data interface
                    //ExternalData                                = new ExternalDataInterface();

                    // Companion IO
                    CompanionIO = new IBECompanion.CompanionData(Program.GetDataPath());
                    if(CompanionIO.ConditionalLogIn())
                        CompanionIO.GetProfileDataAsync();

                    // initializing the object for the actual condition
                    actualCondition                             = new Condition();

                    // initializing the LogfileScanner
                    //LogfileScanner                              = new EDLogfileScanner();
                    JournalScanner                              = new EDJournalScanner();

                    // EDDN Interface
                    EDDNComm = new IBE.EDDN.EDDNCommunicator();

                    // EDSMComm Interface
                    EDSMComm = new IBE.EDSM.EDStarmapInterface(Program.DBCon);

                    CommandersLog.registerJournalScanner(JournalScanner);
                    CommandersLog.registerExternalTool(CompanionIO);

                    CompanionIO.registerJournalScanner(JournalScanner);
                    
                    PriceAnalysis.registerJournalScanner(JournalScanner);
                    PriceAnalysis.registerExternalTool(CompanionIO);

                    EDSMComm.registerJournalScanner(JournalScanner);

                    actualCondition.RegisterJournalScanner(JournalScanner);
                    EDDNComm.RegisterJournalScanner(JournalScanner);
                    

                    // Plausibility-Checker
                    PlausibiltyCheck = new PlausibiltyChecker();

                    /// early variant of DoSpecial();
                    Updater.DoSpecial_Early();

                    Program.SplashScreen.InfoAppendLast("<OK>");

                    m_initDone = true;

                }
            }
            catch (Exception ex)
            {
                CErr.processError(ex, "Error while initializing the program object");
            }

        }
Пример #10
0
 public void ShowDialogInvoked(Exception ex, string infotext)
 {
     this.ShowDialog(SplashScreenForm.GetPrimaryGUI(Program.MainForm));
 }