11using System ;
22using System . Linq ;
33using Microsoft . UI . Input ;
4+ using Microsoft . UI . Text ;
45using Microsoft . UI . Xaml ;
56using Microsoft . UI . Xaml . Controls ;
67using Microsoft . UI . Xaml . Input ;
78using Microsoft . UI . Xaml . Markup ;
89using Windows . Storage ;
10+ using Windows . System ;
911
1012namespace WinUIGallery . ControlPages ;
1113
@@ -24,7 +26,7 @@ public ScratchPadPage()
2426 }
2527
2628 m_oldText = xamlStr ;
27- textbox . TextDocument . SetText ( Microsoft . UI . Text . TextSetOptions . None , m_oldText ) ;
29+ textbox . TextDocument . SetText ( TextSetOptions . None , m_oldText ) ;
2830 var formatter = new XamlTextFormatter ( textbox ) ;
2931 formatter . ApplyColors ( ) ;
3032
@@ -57,10 +59,10 @@ private string GetDefaultScratchXAML()
5759
5860 public string ReadScratchPadXAMLinLocalSettings ( )
5961 {
60- var appData = Windows . Storage . ApplicationData . Current ;
62+ var appData = ApplicationData . Current ;
6163 if ( appData . LocalSettings . Containers . ContainsKey ( "ScratchPad" ) )
6264 {
63- var scratchPadContainer = appData . LocalSettings . CreateContainer ( "ScratchPad" , Windows . Storage . ApplicationDataCreateDisposition . Existing ) ;
65+ var scratchPadContainer = appData . LocalSettings . CreateContainer ( "ScratchPad" , ApplicationDataCreateDisposition . Existing ) ;
6466 if ( scratchPadContainer != null && scratchPadContainer . Values . ContainsKey ( "ScratchPadXAML" ) )
6567 {
6668 // String values are limited to 4K characters. Use a composite value to support a longer string.
@@ -79,8 +81,8 @@ public string ReadScratchPadXAMLinLocalSettings()
7981
8082 public void SaveScratchPadXAMLinLocalSettings ( string xamlStr )
8183 {
82- var appData = Windows . Storage . ApplicationData . Current ;
83- var scratchPadContainer = appData . LocalSettings . CreateContainer ( "ScratchPad" , Windows . Storage . ApplicationDataCreateDisposition . Always ) ;
84+ var appData = ApplicationData . Current ;
85+ var scratchPadContainer = appData . LocalSettings . CreateContainer ( "ScratchPad" , ApplicationDataCreateDisposition . Always ) ;
8486 // String values are limited to 4K characters. Use a composite value to support a longer string.
8587 var compositeStr = new ApplicationDataCompositeValue ( ) ;
8688 int count = 0 ;
@@ -109,7 +111,7 @@ private async void ResetToDefaultClick(object sender, RoutedEventArgs e)
109111 if ( result == ContentDialogResult . Primary )
110112 {
111113 m_oldText = GetDefaultScratchXAML ( ) ;
112- textbox . TextDocument . SetText ( Microsoft . UI . Text . TextSetOptions . None , m_oldText ) ;
114+ textbox . TextDocument . SetText ( TextSetOptions . None , m_oldText ) ;
113115 var formatter = new XamlTextFormatter ( textbox ) ;
114116 formatter . ApplyColors ( ) ;
115117
@@ -136,7 +138,7 @@ private string AddXmlNamespace(string xml)
136138 private void LoadContent ( )
137139 {
138140 string newText ;
139- textbox . TextDocument . GetText ( Microsoft . UI . Text . TextGetOptions . None , out newText ) ;
141+ textbox . TextDocument . GetText ( TextGetOptions . None , out newText ) ;
140142 //System.Diagnostics.Debug.WriteLine("new text: " + newText);
141143
142144 SaveScratchPadXAMLinLocalSettings ( newText ) ;
@@ -180,7 +182,7 @@ private void InsertTextboxText(string str, bool setCursorAfterInsertedStr)
180182 private string GetTextboxTextPreviousLine ( )
181183 {
182184 string newText ;
183- textbox . TextDocument . GetText ( Microsoft . UI . Text . TextGetOptions . None , out newText ) ;
185+ textbox . TextDocument . GetText ( TextGetOptions . None , out newText ) ;
184186 var selectionIndex = textbox . TextDocument . Selection . StartPosition ;
185187 if ( selectionIndex > 0 )
186188 {
@@ -230,7 +232,7 @@ private void textbox_KeyDown(object sender, KeyRoutedEventArgs e)
230232 var isShiftKeyDown = ( ( int ) InputKeyboardSource . GetKeyStateForCurrentThread ( Windows . System . VirtualKey . Shift ) &
231233 ( int ) Windows . UI . Core . CoreVirtualKeyStates . Down ) == ( int ) Windows . UI . Core . CoreVirtualKeyStates . Down ;
232234 string text ;
233- textbox . TextDocument . GetText ( Microsoft . UI . Text . TextGetOptions . None , out text ) ;
235+ textbox . TextDocument . GetText ( TextGetOptions . None , out text ) ;
234236
235237 var selectionStart = textbox . TextDocument . Selection . StartPosition ;
236238 var selectionEnd = selectionStart + textbox . TextDocument . Selection . Length ;
@@ -246,20 +248,20 @@ private void textbox_KeyDown(object sender, KeyRoutedEventArgs e)
246248 selectionStart += 4 ;
247249 selectionEnd += 4 ;
248250
249- range . Move ( Microsoft . UI . Text . TextRangeUnit . Paragraph , 1 ) ;
251+ range . Move ( TextRangeUnit . Paragraph , 1 ) ;
250252 while ( range . StartPosition < selectionEnd )
251253 {
252254 range . Text = " " ;
253255 selectionEnd += 4 ;
254- range . Move ( Microsoft . UI . Text . TextRangeUnit . Paragraph , 1 ) ;
256+ range . Move ( TextRangeUnit . Paragraph , 1 ) ;
255257 }
256258 }
257259 else // Unindent
258260 {
259261 bool firstLine = true ;
260262 while ( range . StartPosition < selectionEnd )
261263 {
262- range . MoveEnd ( Microsoft . UI . Text . TextRangeUnit . Character , 4 ) ;
264+ range . MoveEnd ( TextRangeUnit . Character , 4 ) ;
263265 var numWhitespace = range . Text . Count ( char . IsWhiteSpace ) ;
264266 range = textbox . TextDocument . GetRange ( range . StartPosition , range . StartPosition + numWhitespace ) ;
265267 range . Text = "" ;
@@ -269,7 +271,7 @@ private void textbox_KeyDown(object sender, KeyRoutedEventArgs e)
269271 selectionStart -= numWhitespace ;
270272 }
271273 selectionEnd -= numWhitespace ;
272- range . Move ( Microsoft . UI . Text . TextRangeUnit . Paragraph , 1 ) ;
274+ range . Move ( TextRangeUnit . Paragraph , 1 ) ;
273275 }
274276 }
275277
@@ -287,11 +289,11 @@ private void textbox_PreviewKeyUp(object sender, KeyRoutedEventArgs e)
287289 m_lastChangeFromTyping = true ;
288290 switch ( e . Key )
289291 {
290- case Windows . System . VirtualKey . F5 :
292+ case VirtualKey . F5 :
291293 LoadContentAndApplyFormatting ( ) ;
292294 break ;
293295
294- case Windows . System . VirtualKey . Enter :
296+ case VirtualKey . Enter :
295297 HandleEnter ( ) ;
296298 break ;
297299 }
@@ -318,7 +320,7 @@ private void textbox_TextChanged(object sender, RoutedEventArgs e)
318320 }
319321
320322 string newText ;
321- textbox . TextDocument . GetText ( Microsoft . UI . Text . TextGetOptions . None , out newText ) ;
323+ textbox . TextDocument . GetText ( TextGetOptions . None , out newText ) ;
322324 if ( newText . Length == m_oldText . Length + 1 )
323325 {
324326 // Added just one character
@@ -367,12 +369,12 @@ private void textbox_TextChanged(object sender, RoutedEventArgs e)
367369 }
368370
369371 // Save the text so next time we can compare against the new text
370- textbox . TextDocument . GetText ( Microsoft . UI . Text . TextGetOptions . None , out m_oldText ) ;
372+ textbox . TextDocument . GetText ( TextGetOptions . None , out m_oldText ) ;
371373 }
372374
373375 private void textbox_ActualThemeChanged ( FrameworkElement sender , object args )
374376 {
375- // Updating the formating for theme change
377+ // Updating the formatting for theme change
376378 var formatter = new XamlTextFormatter ( textbox ) ;
377379 formatter . ApplyColors ( ) ;
378380 }
@@ -405,7 +407,7 @@ public void ApplyColors()
405407 doc . BeginUndoGroup ( ) ;
406408
407409 string rebText ;
408- doc . GetText ( Microsoft . UI . Text . TextGetOptions . None , out rebText ) ;
410+ doc . GetText ( TextGetOptions . None , out rebText ) ;
409411
410412 var startIndex = 0 ;
411413 var currentZoneType = ZoneType . Unknown ;
0 commit comments