public DefaultSettingsPage(SettingsFile settingsFile) { InitializeComponent(); SettingsFile = settingsFile; text.Text = settingsFile.Text; text.TextArea.TextView.LineSpacing = 1.45d; using (Stream s = new MemoryStream(Properties.Resources.YAML)) { using (XmlTextReader reader = new XmlTextReader(s)) { text.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance); } } text.Options.IndentationSize = 2; //text.Options.ShowSpaces = true; //text.Options.ShowColumnRuler = true; //text.Options.ColumnRulerPosition = 1; text.TextArea.TextView.LinkTextForegroundBrush = (SolidColorBrush) new BrushConverter().ConvertFrom("#79CF93"); foldingManager = FoldingManager.Install(text.TextArea); tabFoldingStrategy = new TabFoldingStrategy(); UpdateFoldings(foldingManager, tabFoldingStrategy); text.TextChanged += TextChanged; settingsFile.TextReadUpdateEvent += HandleTextReadUpdate; }
void editSetup() { UpdateEditView(); this.FontFamily = new FontFamily("Consolas"); this.FontWeight = FontWeight.FromOpenTypeWeight(1); Foreground = new SolidColorBrush(Color.FromRgb(0X2B, 0X91, 0XAF)); foldingManager = FoldingManager.Install(TextArea); foldingStrategy = new TabFoldingStrategy(); foldingStrategy.UpdateFoldings(foldingManager, Document); DispatcherTimer foldingUpdateTimer = new DispatcherTimer(); foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2); foldingUpdateTimer.Tick += delegate { UpdateFoldings(); }; foldingUpdateTimer.Start(); IHighlightingDefinition customHighlighting; using (Stream s = typeof(m0.MinusZero).Assembly.GetManifestResourceStream("m0.ZeroCodeHighlighting.xshd")) { if (s == null) { throw new InvalidOperationException("Could not find embedded resource"); } using (XmlReader reader = new XmlTextReader(s)) { customHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd. HighlightingLoader.Load(reader, HighlightingManager.Instance); } } SyntaxHighlighting = customHighlighting; }
private void UpdateFoldings(FoldingManager foldingManager, TabFoldingStrategy tabFoldingStrategy) { tabFoldingStrategy.UpdateFoldings(foldingManager, text.TextArea.Document); }