void AddLanguageBundle(object sender, EventArgs e) { var dialog = new SelectFileDialog(GettextCatalog.GetString("Language Bundles"), MonoDevelop.Components.FileChooserAction.Open) { TransientFor = this.Toplevel as Gtk.Window, }; dialog.AddFilter(GettextCatalog.GetString("Bundles"), "*.tmBundle", "*.sublime-package", "*.tmbundle"); if (!dialog.Run()) { return; } string newFileName = SyntaxHighlightingService.LanguageBundlePath.Combine(dialog.SelectedFile.FileName); bool success = true; try { if (File.Exists(newFileName)) { MessageService.ShowError(string.Format(GettextCatalog.GetString("Bundle with the same name already exists. Remove {0} first."), System.IO.Path.GetFileNameWithoutExtension(newFileName))); return; } File.Copy(dialog.SelectedFile.FullPath, newFileName); } catch (Exception ex) { success = false; LoggingService.LogError("Can't copy syntax mode file.", ex); } if (success) { var bundle = SyntaxHighlightingService.LoadStyleOrMode(SyntaxHighlightingService.userThemeBundle, newFileName) as LanguageBundle; if (bundle != null) { #pragma warning disable CS0618 // Type or member is obsolete foreach (var h in bundle.Highlightings) { var def = h as SyntaxHighlightingDefinition; def?.PrepareMatches(); } #pragma warning restore CS0618 // Type or member is obsolete FillBundles(); } else { MessageService.ShowError(GettextCatalog.GetString("Invalid bundle: {0}", dialog.SelectedFile.FileName)); try { File.Delete(newFileName); } catch (Exception) {} } } }