/// <summary> /// PropertyChangedCallback for Text /// </summary> private static void TextPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { if (obj is KaxamlTextEditor) { KaxamlTextEditor owner = (KaxamlTextEditor)obj; string newValue = " "; if (!String.IsNullOrEmpty((string)args.NewValue)) { newValue = (string)args.NewValue; } if (!owner._SetTextInternal) { owner._ResetTextInternal = true; owner.TextEditor.ResetText(); owner.TextEditor.Refresh(); owner.TextEditor.Text = newValue; owner._ResetTextInternal = false; } if (!owner._ResetTextInternal) { owner.RaiseTextChangedEvent(newValue); } } }
/// <summary> /// PropertyChangedCallback for EnableXmlFolding /// </summary> private static void EnableXmlFoldingChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { if (obj is KaxamlTextEditor) { KaxamlTextEditor owner = (KaxamlTextEditor)obj; if ((bool)args.NewValue) { // set the folding strategy if (owner.TextEditor.Document.FoldingManager.FoldingStrategy == null) { owner.TextEditor.Document.FoldingManager.FoldingStrategy = new XmlFoldingStrategy(); } // create a timer to update the folding every second if (owner.FoldingTimer == null) { owner.FoldingTimer = new DispatcherTimer(); owner.FoldingTimer.Interval = TimeSpan.FromMilliseconds(1000); owner.FoldingTimer.Tick += new EventHandler(owner.FoldingTimerTick); } // enable folding and start the timer owner.TextEditor.EnableFolding = true; owner.FoldingTimer.Start(); } else { // disable folding and start the timer owner.TextEditor.EnableFolding = false; owner.FoldingTimer.Stop(); } } }
/// <summary> /// PropertyChangedCallback for ConvertTabs /// </summary> private static void ConvertTabsChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { if (obj is KaxamlTextEditor) { KaxamlTextEditor owner = (KaxamlTextEditor)obj; owner.TextEditor.ConvertTabsToSpaces = (bool)args.NewValue; } }
/// <summary> /// PropertyChangedCallback for FontSize /// </summary> private static void FontSizeChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { if (obj is KaxamlTextEditor) { KaxamlTextEditor owner = (KaxamlTextEditor)obj; owner.TextEditor.Font = new System.Drawing.Font(owner.FontFamily, (float)args.NewValue); } }
/// <summary> /// PropertyChangedCallback for ShowLineNumbers /// </summary> private static void ShowLineNumbersChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { if (obj is KaxamlTextEditor) { KaxamlTextEditor owner = (KaxamlTextEditor)obj; owner.TextEditor.ShowLineNumbers = (bool)args.NewValue; } }
/// <summary> /// PropertyChangedCallback for LinePosition /// </summary> private static void LinePositionChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { if (obj is KaxamlTextEditor) { KaxamlTextEditor owner = (KaxamlTextEditor)obj; owner.TextEditor.ActiveTextAreaControl.Caret.Position = new System.Drawing.Point((int)args.NewValue, owner.TextEditor.ActiveTextAreaControl.Caret.Position.Y); } }
/// <summary> /// PropertyChangedCallback for LineNumber /// </summary> private static void LineNumberChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { if (obj is KaxamlTextEditor) { KaxamlTextEditor owner = (KaxamlTextEditor)obj; owner.TextEditor.ActiveTextAreaControl.Caret.Line = (int)args.NewValue; } }
/// <summary> /// PropertyChangedCallback for ConvertTabsCount /// </summary> private static void ConvertTabsCountChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { if (obj is KaxamlTextEditor) { KaxamlTextEditor owner = (KaxamlTextEditor)obj; owner.TextEditor.TabIndent = (int)args.NewValue; owner.TextEditor.TextEditorProperties.IndentationSize = (int)args.NewValue;; } }
/// <summary> /// PropertyChangedCallback for EnableSyntaxHighlighting /// </summary> private static void EnableSyntaxHighlightingChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { if (obj is KaxamlTextEditor) { KaxamlTextEditor owner = (KaxamlTextEditor)obj; if ((bool)args.NewValue) { // set the highlighting strategy owner.TextEditor.Document.HighlightingStrategy = HighlightingManager.Manager.FindHighlighter("XML"); } else { owner.TextEditor.Document.HighlightingStrategy = HighlightingManager.Manager.FindHighlighter("None"); } } }