Esempio n. 1
0
 private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (e.NewValue is FileEditorViewModel viewModel && viewModel.FileInEdit != null)
     {
         SyntaxDefinitions.SelectedItem = SyntaxHighlightingHelper.GuessHighligtingDefinition(viewModel.FileInEdit.Path);
         Editor.Load(viewModel.FileInEdit.GetStream());
     }
 }
Esempio n. 2
0
        private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            var info = (FileContentInfo)DataContext;

            if (info != null && info.IsTextFile)
            {
                LanguageBox.SelectedItem = SyntaxHighlightingHelper.GuessHighligtingDefinition(info.File.Name);
                contentBox.ScrollToHome();
                contentBox.Load(StreamUtility.ToStream((string)info.Content));
            }
            else
            {
                contentBox.Clear();
            }
        }
Esempio n. 3
0
 private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (e.NewValue is FileEditorViewModel viewModel && viewModel.FileInEdit != null)
     {
         SyntaxDefinitions.SelectedItem = SyntaxHighlightingHelper.GuessHighligtingDefinition(viewModel.FileInEdit.Path);
         try
         {
             var stream = viewModel.FileInEdit.GetStream();
             stream = StreamUtility.MakeSeekable(stream);
             Editor.Load(stream);
         }
         catch (Exception ex)
         {
             _uIServices.Show(ex.Message, MessageLevel.Error);
         }
     }
 }
 private async void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (e.NewValue is FileEditorViewModel viewModel && viewModel.FileInEdit != null)
     {
         SyntaxDefinitions.SelectedItem = SyntaxHighlightingHelper.GuessHighligtingDefinition(viewModel.FileInEdit.Path);
         var stream = viewModel.FileInEdit.GetStream();
         if (!stream.CanSeek)
         {
             var memoryStream = new MemoryStream();
             using (stream)
             {
                 await stream.CopyToAsync(memoryStream);
             }
             memoryStream.Position = 0;
             stream = memoryStream;
         }
         Editor.Load(stream);
     }
 }