Exemple #1
0
        private async void OpenFindSourceFileDialog(object sender, EventArgs e)
        {
            var sf = DebuggingService.CurrentFrame;

            if (sf == null)
            {
                LoggingService.LogWarning($"CurrentFrame was null in {nameof (OpenFindSourceFileDialog)}");
                return;
            }
            var dlg = new Ide.Gui.Dialogs.OpenFileDialog(GettextCatalog.GetString("File to Open") + " " + sf.SourceLocation.FileName, FileChooserAction.Open)
            {
                TransientFor         = IdeApp.Workbench.RootWindow,
                ShowEncodingSelector = true,
                ShowViewerSelector   = true
            };

            dlg.DirectoryChangedHandler = (s, path) => {
                return(SourceCodeLookup.TryDebugSourceFolders(sf.SourceLocation.FileName, sf.SourceLocation.FileHash, new string [] { path }));
            };
            if (!dlg.Run())
            {
                return;
            }
            var newFilePath = dlg.SelectedFile;

            try {
                if (File.Exists(newFilePath))
                {
                    var ignoreButton = new AlertButton(GettextCatalog.GetString("Ignore"));
                    if (SourceCodeLookup.CheckFileHash(newFilePath, sf.SourceLocation.FileHash) ||
                        MessageService.AskQuestion(GettextCatalog.GetString("File checksum doesn't match."), 1, ignoreButton, new AlertButton(GettextCatalog.GetString("Cancel"))) == ignoreButton)
                    {
                        SourceCodeLookup.AddLoadedFile(newFilePath, sf.SourceLocation.FileName);
                        sf.UpdateSourceFile(newFilePath);

                        var doc = await IdeApp.Workbench.OpenDocument(newFilePath, null, sf.SourceLocation.Line, 1, OpenDocumentOptions.Debugger);

                        if (doc != null)
                        {
                            await Document.Close(false);
                        }
                    }
                }
                else
                {
                    MessageService.ShowWarning(GettextCatalog.GetString("File not found."));
                }
            } catch (Exception) {
                MessageService.ShowWarning(GettextCatalog.GetString("Error opening file."));
            }
        }