예제 #1
0
파일: ErrorViewer.cs 프로젝트: mlof/ED-IBE
        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);
        }
예제 #2
0
파일: Program.cs 프로젝트: mlof/ED-IBE
        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();
        }
예제 #3
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);
            }
        }
예제 #4
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);
            }
        }