void AddColorScheme(object sender, EventArgs args) { var dialog = new SelectFileDialog(GettextCatalog.GetString("Highlighting Scheme"), Gtk.FileChooserAction.Open) { TransientFor = this.Toplevel as Gtk.Window, }; dialog.AddFilter(GettextCatalog.GetString("Color schemes"), "*.json"); dialog.AddFilter(GettextCatalog.GetString("Visual Studio .NET settings"), "*.vssettings"); if (!dialog.Run()) { return; } string newFileName = SourceEditorDisplayBinding.SyntaxModePath.Combine(dialog.SelectedFile.FileName); bool success = true; try { File.Copy(dialog.SelectedFile.FullPath, newFileName); } catch (Exception e) { success = false; LoggingService.LogError("Can't copy syntax mode file.", e); } if (success) { SourceEditorDisplayBinding.LoadCustomStylesAndModes(); ShowStyles(); } }
void AddColorScheme(object sender, EventArgs args) { var dialog = new SelectFileDialog(GettextCatalog.GetString("Highlighting Scheme"), Gtk.FileChooserAction.Open) { TransientFor = this.Toplevel as Gtk.Window, }; dialog.AddFilter(null, "*.xml"); if (!dialog.Run()) { return; } System.Collections.Generic.List <System.Xml.Schema.ValidationEventArgs> validationResult; try { validationResult = Mono.TextEditor.Highlighting.SyntaxModeService.ValidateStyleFile(dialog.SelectedFile); } catch (Exception) { MessageService.ShowError(GettextCatalog.GetString("Validation of style file failed.")); return; } if (validationResult.Count == 0) { string newFileName = SourceEditorDisplayBinding.SyntaxModePath.Combine(dialog.SelectedFile.FileName); if (!newFileName.EndsWith("Style.xml")) { newFileName = SourceEditorDisplayBinding.SyntaxModePath.Combine(dialog.SelectedFile.FileNameWithoutExtension + "Style.xml"); } bool success = true; try { File.Copy(dialog.SelectedFile, newFileName); } catch (Exception e) { success = false; LoggingService.LogError("Can't copy syntax mode file.", e); } if (success) { SourceEditorDisplayBinding.LoadCustomStylesAndModes(); ShowStyles(); } } else { StringBuilder errorMessage = new StringBuilder(); errorMessage.AppendLine(GettextCatalog.GetString("Validation of style file failed.")); int count = 0; foreach (System.Xml.Schema.ValidationEventArgs vArg in validationResult) { errorMessage.AppendLine(vArg.Message); if (count++ > 5) { errorMessage.AppendLine("..."); break; } } MessageService.ShowError(errorMessage.ToString()); } }
void RemoveColorScheme(object sender, EventArgs args) { string styleName = null; TreeIter selectedIter; if (styleTreeview.Selection.GetSelected(out selectedIter)) { styleName = (string)this.styleStore.GetValue(selectedIter, 1); } var style = LoadStyle(styleName, false); UrlXmlProvider provider = Mono.TextEditor.Highlighting.SyntaxModeService.GetProvider(style) as UrlXmlProvider; if (provider != null) { if (provider.Url.StartsWith(SourceEditorDisplayBinding.SyntaxModePath)) { Mono.TextEditor.Highlighting.SyntaxModeService.Remove(style); File.Delete(provider.Url); SourceEditorDisplayBinding.LoadCustomStylesAndModes(); ShowStyles(); } } }