11using DiffPlex ;
22using DiffPlex . DiffBuilder ;
33using DiffPlex . DiffBuilder . Model ;
4+ using ICSharpCode . AvalonEdit ;
45using StructuredXmlEditor . Data ;
56using StructuredXmlEditor . View ;
67using System ;
78using System . Collections . Generic ;
89using System . IO ;
910using System . Linq ;
11+ using System . Reflection ;
1012using System . Text ;
1113using System . Threading . Tasks ;
14+ using System . Windows . Media ;
1215using System . Xml ;
1316using System . Xml . Linq ;
1417
@@ -32,18 +35,7 @@ public string ElementPath
3235 private string m_elementPath = "Example.Data" ;
3336
3437 //-----------------------------------------------------------------------
35- public string OutputTemplate
36- {
37- get { return m_outputTemplate ; }
38- set
39- {
40- m_outputTemplate = value ;
41- RaisePropertyChangedEvent ( ) ;
42-
43- UpdatePreview ( ) ;
44- }
45- }
46- private string m_outputTemplate = "{el||}" ;
38+ public TextEditor TextEditor { get ; set ; }
4739
4840 //-----------------------------------------------------------------------
4941 private DataTransformer DataTransformer { get ; } = new DataTransformer ( ) ;
@@ -88,6 +80,24 @@ public string ExampleDocument
8880 //-----------------------------------------------------------------------
8981 public DataTransformerTool ( Workspace workspace ) : base ( workspace , "Data Transformer Tool" )
9082 {
83+ TextEditor = new TextEditor ( ) ;
84+
85+ var assembly = Assembly . GetExecutingAssembly ( ) ;
86+ var resourceName = ( "StructuredXmlEditor.Resources.DataTransformerSyntax.xshd" ) ;
87+ using ( Stream stream = assembly . GetManifestResourceStream ( resourceName ) )
88+ using ( XmlTextReader reader = new XmlTextReader ( stream ) )
89+ {
90+ TextEditor . SyntaxHighlighting = ICSharpCode . AvalonEdit . Highlighting . Xshd . HighlightingLoader . Load ( reader , ICSharpCode . AvalonEdit . Highlighting . HighlightingManager . Instance ) ;
91+ }
92+
93+ TextEditor . Text = "{el||}" ;
94+ TextEditor . Foreground = new SolidColorBrush ( Color . FromRgb ( 255 , 255 , 255 ) ) ;
95+ TextEditor . Background = Brushes . Transparent ;
96+ TextEditor . Document . TextChanged += ( e , args ) =>
97+ {
98+ UpdatePreview ( ) ;
99+ } ;
100+
91101 ExampleDocument = "<Example><Data /></Example>" ;
92102
93103 VisibleByDefault = false ;
@@ -99,7 +109,7 @@ public DataTransformerTool(Workspace workspace) : base(workspace, "Data Transfor
99109 public void UpdatePreview ( )
100110 {
101111 DataTransformer . ElementPaths = ElementPath . Split ( '\n ' ) . Select ( e => e . Trim ( ) ) . ToList ( ) ;
102- DataTransformer . OutputTemplate = OutputTemplate ;
112+ DataTransformer . OutputTemplate = TextEditor . Text ;
103113
104114 TransformError = null ;
105115
0 commit comments