Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions QuickViewFile/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
xmlns:local="clr-namespace:QuickViewFile.Controls"
xmlns:helpers="clr-namespace:QuickViewFile.Helpers"
xmlns:viewmodel="clr-namespace:QuickViewFile.ViewModel"
xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
d:DataContext="{d:DesignInstance Type=viewmodel:FilesListViewModel}"
mc:Ignorable="d"
WindowState="Maximized"
Expand Down Expand Up @@ -252,6 +254,20 @@
/>
</Grid>

<wv2:WebView2 x:Name="WebViewElement"
Visibility="{Binding SelectedItem.FileContentModel.ShowWebView, Converter={StaticResource BoolToVisibilityConverter}}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" />

<avalonEdit:TextEditor x:Name="CodeEditorElement"
Visibility="{Binding SelectedItem.FileContentModel.ShowCodeEditor, Converter={StaticResource BoolToVisibilityConverter}}"
FontFamily="Consolas"
FontSize="{Binding Config.FontSize}"
IsReadOnly="True"
ShowLineNumbers="True"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto"
Margin="10" />

<Grid Visibility="{Binding SelectedItem.FileContentModel.ShowTextBox, Converter={StaticResource BoolToVisibilityConverter}}" x:Name="GridSearchBox">
<Grid.RowDefinitions>
Expand Down
16 changes: 16 additions & 0 deletions QuickViewFile/MainWindowNoBorder.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
xmlns:local="clr-namespace:QuickViewFile.Controls"
xmlns:helpers="clr-namespace:QuickViewFile.Helpers"
xmlns:viewmodel="clr-namespace:QuickViewFile.ViewModel"
xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
d:DataContext="{d:DesignInstance Type=viewmodel:FilesListViewModel}"
mc:Ignorable="d"
WindowState="Maximized"
Expand Down Expand Up @@ -244,6 +246,20 @@
/>
</Grid>

<wv2:WebView2 x:Name="WebViewElementNoBorder"
Visibility="{Binding SelectedItem.FileContentModel.ShowWebView, Converter={StaticResource BoolToVisibilityConverter}}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" />

<avalonEdit:TextEditor x:Name="CodeEditorElementNoBorder"
Visibility="{Binding SelectedItem.FileContentModel.ShowCodeEditor, Converter={StaticResource BoolToVisibilityConverter}}"
FontFamily="Consolas"
FontSize="{Binding Config.FontSize}"
IsReadOnly="True"
ShowLineNumbers="True"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto"
Margin="10" />

<Grid Visibility="{Binding SelectedItem.FileContentModel.ShowTextBox, Converter={StaticResource BoolToVisibilityConverter}}" x:Name="GridSearchBox">
<Grid.RowDefinitions>
Expand Down
24 changes: 22 additions & 2 deletions QuickViewFile/Models/FileContentModel.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
using QuickViewFile.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace QuickViewFile.Models
{
public class FileContentModel : IDisposable
public class FileContentModel : IDisposable, INotifyPropertyChanged
{
public string? TextContent { get; set; } = null;
public event PropertyChangedEventHandler? PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string name = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}

private string? _textContent = null;
public string? TextContent { get => _textContent; set { _textContent = value; OnPropertyChanged(); } }

public ImageSource? ImageSource { get; set; } = null;

Expand All @@ -15,6 +24,14 @@ public class FileContentModel : IDisposable
public bool IsLoaded { get; set; } = false;
public bool ShowTextBox { get; set; } = false;

private bool _showWebView = false;
public bool ShowWebView { get => _showWebView; set { _showWebView = value; OnPropertyChanged(); } }

public bool ShowCodeEditor { get; set; } = false;

private string? _webViewSource = null;
public string? WebViewSource { get => _webViewSource; set { _webViewSource = value; OnPropertyChanged(); } }

public void Dispose()
{
// Dispose of managed resources.
Expand All @@ -31,6 +48,9 @@ public void Dispose()

IsLoaded = false;
ShowTextBox = false;
ShowWebView = false;
ShowCodeEditor = false;
WebViewSource = null;

// Suppress finalization to prevent GC from calling finalizer on disposed object.
GC.SuppressFinalize(this);
Expand Down
6 changes: 6 additions & 0 deletions QuickViewFile/QuickViewFile.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,10 @@
<RuntimeHostConfigurationOption Include="Switch.System.Windows.Media.EnableHardwareAccelerationInRdp" Value="true" />
</ItemGroup>


<ItemGroup>
<PackageReference Include="AvalonEdit" Version="6.3.1.120" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.4078.44" />
</ItemGroup>

</Project>