コード例 #1
0
ファイル: App.xaml.cs プロジェクト: tmedwards/CoCEd
        void Initialize()
        {
            ExceptionBox box;

            foreach (string xmlFile in XmlData.Files.All)
            {
                var xmlResult = XmlData.LoadXml(xmlFile);
                switch (xmlResult)
                {
                    case XmlLoadingResult.Success:
                        break;

                    case XmlLoadingResult.InvalidFile:
                        box = new ExceptionBox();
                        box.Title = "Fatal error";
                        box.Message = "The " + xmlFile + " file is out of date. Did you replace the bundled XML?";
                        box.Path = Environment.CurrentDirectory;
                        box.ShowDialog(ExceptionBoxButtons.Quit);
                        Shutdown();
                        return;

                    case XmlLoadingResult.MissingFile:
                        box = new ExceptionBox();
                        box.Title = "Fatal error";
                        box.Message = "The " + xmlFile + " file could not be found. Did you try to run the program from the archive without extracting all the files first?";
                        box.Path = Environment.CurrentDirectory;
                        box.ShowDialog(ExceptionBoxButtons.Quit);
                        Shutdown();
                        return;

                    case XmlLoadingResult.NoPermission:
                        box = new ExceptionBox();
                        box.Title = "Fatal error";
                        box.Message = "The " + xmlFile + " file was already in use or this application does not have permission to read from the folder where it is located.";
                        box.Path = Environment.CurrentDirectory;
                        box.ShowDialog(ExceptionBoxButtons.Quit);
                        Shutdown();
                        return;

                    default:
                        throw new NotImplementedException();
                }
            }

            VM.Create();

            FileManager.BuildPaths();
            var directories = FileManager.GetDirectories().ToArray(); // Load all on startup to check for errors
            var result = ExceptionBoxResult.Continue;
            switch (FileManager.Result)
            {
                case FileEnumerationResult.NoPermission:
                    box = new ExceptionBox();
                    box.Title = "Could not scan some folders.";
                    box.Message = "CoCEd did not get permission to read a folder or file.\nSome files will not be displayed in the Open/Save menus.";
                    box.Path = FileManager.ResultPath;
                    box.IsWarning = true;
                    result = box.ShowDialog(ExceptionBoxButtons.Quit, ExceptionBoxButtons.Continue);
                    break;

                case FileEnumerationResult.Unreadable:
                    box = new ExceptionBox();
                    box.Title = "Could not read some folders.";
                    box.Message = "CoCEd could not read a folder or file.\nSome files will not be displayed in the Open/Save menus.";
                    box.Path = FileManager.ResultPath;
                    box.IsWarning = true;
                    result = box.ShowDialog(ExceptionBoxButtons.Quit, ExceptionBoxButtons.Continue);
                    break;
            }
            if (result == ExceptionBoxResult.Quit)
            {
                Shutdown();
                return;
            }

            #if DEBUG
            var file = AutoLoad(directories);
            //new AmfFile("e:\\plainObject.sol").TestSerialization();
            //new AmfFile("e:\\unicode.sol").TestSerialization();
            //DebugStatuses(file);
            //RunSerializationTest(set);
            //ParsePerks();
            //ImportStatuses();
            //ImportFlags();
            #endif
        }
コード例 #2
0
ファイル: App.xaml.cs プロジェクト: tmedwards/CoCEd
        void SetError(ExceptionBox box, Exception exception)
        {
            var msg = exception.ToString();
            box.ExceptionMessage = msg;

            // Special case for image codec problem
            if (msg.Contains("0x88982F04"))
            {
                box.Title = "Bad image codec";
                box.Message = "You use a non-standard image codec that does not properly handle some PNG files. It's not only CoCEd, other programs may also be affected.\n\nCheck for FastPictureViewer's or Canon's codec packs and try to update or uninstall them.";
            }
            else
            {
                box.Title = "Unexpected error";
                box.Message = "An unexpected error occured and the application is going to exit.";
                box.ShowReportInstructions = true;
            }
        }
コード例 #3
0
        public static new ExceptionBoxResult Show()
        {
            var box = new ExceptionBox();

            return(box.ShowDialog());
        }
コード例 #4
0
ファイル: App.xaml.cs プロジェクト: tmedwards/CoCEd
        void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            e.Handled = true;
            DispatcherUnhandledException -= OnDispatcherUnhandledException;

            try
            {
                ExceptionBox box = new ExceptionBox();
                SetError(box, e.Exception);
                box.ShowDialog(ExceptionBoxButtons.Quit);
            }
            catch(Exception e2)
            {
                MessageBox.Show(e2.ToString(), "Error in error box ?!", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            Logger.Error(e.Exception);
            Shutdown();
        }
コード例 #5
0
ファイル: ExceptionBox.xaml.cs プロジェクト: Belgrath/CoCEd
 public static new ExceptionBoxResult Show()
 {
     var box = new ExceptionBox();
     return box.ShowDialog();
 }