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()); } }
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(); } }
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); } }