Skip to content

Commit 00167ba

Browse files
committed
Change ctrl to star to rotate object.
Add option to open transparent none-styled window to force DirectX hw acceleration
1 parent a0ad074 commit 00167ba

File tree

4 files changed

+787
-10
lines changed

4 files changed

+787
-10
lines changed

QuickViewFile/Controls/VideoPlayerControl.xaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
</Grid.RowDefinitions>
1919

2020
<Grid Grid.Row="0">
21-
<local:ZoomableMediaElement x:Name="videoInWindowPlayer" LoadedBehavior="Manual" RenderOptions.BitmapScalingMode="{Binding videoQuality}"/>
21+
<local:ZoomableMediaElement x:Name="videoInWindowPlayer"
22+
LoadedBehavior="Manual"
23+
RenderOptions.BitmapScalingMode="{Binding videoQuality}"
24+
CacheMode="BitmapCache" UnloadedBehavior="Manual"
25+
/>
2226
</Grid>
2327

2428
<StatusBar Grid.Row="1">

QuickViewFile/MainWindow.xaml.cs

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,57 @@ public MainWindow()
8585
}
8686
}
8787

88+
public MainWindow(string pathNoBorder)
89+
{
90+
try
91+
{
92+
RenderOptions.SetCachingHint(this, CachingHint.Cache);
93+
this.UseLayoutRounding = true;
94+
_config = ConfigHelper.loadedConfig;
95+
RenderOptions.ProcessRenderMode = _config.RenderMode == 0 ? System.Windows.Interop.RenderMode.Default : System.Windows.Interop.RenderMode.SoftwareOnly;
96+
RenderOptions.SetEdgeMode(this, _config.EdgeMode == 1 ? EdgeMode.Aliased : EdgeMode.Unspecified);
97+
if (_config.ShadowEffect == 1)
98+
{
99+
System.Windows.Media.Effects.DropShadowEffect dropShadow = new System.Windows.Media.Effects.DropShadowEffect
100+
{
101+
ShadowDepth = _config.ShadowDepth,
102+
Opacity = _config.ShadowOpacity,
103+
BlurRadius = _config.ShadowBlur,
104+
RenderingBias = _config.ShadowQuality == 1 ? System.Windows.Media.Effects.RenderingBias.Quality : System.Windows.Media.Effects.RenderingBias.Performance,
105+
};
106+
Effect = dropShadow;
107+
}
108+
if (_config.ThemeMode == 2)
109+
{
110+
#pragma warning disable WPF0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
111+
Application.Current.ThemeMode = ThemeMode.Dark;
112+
#pragma warning restore WPF0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
113+
}
114+
else if (_config.ThemeMode == 1)
115+
{
116+
#pragma warning disable WPF0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
117+
Application.Current.ThemeMode = ThemeMode.Light;
118+
#pragma warning restore WPF0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
119+
}
120+
InitializeComponent();
121+
FilesListView.Focus();
122+
123+
string fileToSelectFullPath = pathNoBorder;
124+
125+
vm = new FilesListViewModel(fileToSelectFullPath);
126+
DataContext = vm;
127+
}
128+
catch
129+
{
130+
FilesListViewModel vm = new FilesListViewModel(Directory.GetCurrentDirectory());
131+
DataContext = vm;
132+
}
133+
finally
134+
{
135+
FilesListView.IsSynchronizedWithCurrentItem = true;
136+
FilesListView.ScrollIntoView(FilesListView.SelectedItem);
137+
}
138+
}
88139
private void FilesListView_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) //Change directory or force load file (using double click)
89140
{
90141
if (DataContext is FilesListViewModel vm)
@@ -189,15 +240,11 @@ private void AppWindow_KeyDown(object sender, KeyEventArgs e)
189240
}
190241
}
191242

192-
if (vm.SelectedItem?.FileContentModel?.VideoMedia is not null)
243+
if (e.Key == Key.F4 && vm.SelectedItem?.FullPath is not null)
193244
{
194-
if (e.Key == Key.F4)
195-
{
196-
TimeSpan currentVideoPosition = VideoMedia.GetCurrentVideoPosition();
197-
VideoPlayerFullScreen fullScreenVideo = new VideoPlayerFullScreen(vm.SelectedItem.FullPath, _config.BitmapScalingMode, currentVideoPosition);
198-
vm.SelectedItem = null;
199-
fullScreenVideo.Show();
200-
}
245+
MainWindowNoBorder fullScreen = new MainWindowNoBorder(vm.SelectedItem.FullPath);
246+
fullScreen.Show();
247+
this.Close();
201248
}
202249

203250
if (vm.SelectedItem?.FileContentModel.TextContent is not null)
@@ -212,7 +259,7 @@ private void AppWindow_KeyDown(object sender, KeyEventArgs e)
212259
}
213260
}
214261

215-
if (e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl)
262+
if (e.Key == Key.Multiply)
216263
{
217264
degreesRotation += 90;
218265
if (degreesRotation < 360)
Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
<Window x:Class="QuickViewFile.MainWindowNoBorder"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:QuickViewFile.Controls"
7+
xmlns:helpers="clr-namespace:QuickViewFile.Helpers"
8+
xmlns:viewmodel="clr-namespace:QuickViewFile.ViewModel"
9+
d:DataContext="{d:DesignInstance Type=viewmodel:FilesListViewModel}"
10+
mc:Ignorable="d"
11+
WindowState="Maximized"
12+
WindowStyle="None"
13+
Background="Transparent"
14+
AllowsTransparency="True"
15+
WindowStartupLocation="CenterScreen"
16+
KeyDown="AppWindow_KeyDown"
17+
MouseLeftButtonDown="Window_MouseLeftButtonDown"
18+
ResizeMode="CanResize"
19+
Title="QuickViewFile" Height="720" Width="1280">
20+
<Window.Resources>
21+
<BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
22+
<helpers:NullToVisibilityConverter x:Key="NullToVisibilityConverter"/>
23+
<helpers:NullToCollapsedConverter x:Key="NullToCollapsedConverter"/>
24+
<helpers:ScrollBarsVisibilityConverter x:Key="ScrollBarsVisibilityConverter"/>
25+
<Style TargetType="ListViewItem">
26+
<Setter Property="MinHeight" Value="40"/>
27+
</Style>
28+
</Window.Resources>
29+
<Grid Name="MainGrid" Focusable="False">
30+
<Grid.RowDefinitions>
31+
<RowDefinition Height="Auto"/>
32+
<RowDefinition Height="*"/>
33+
<RowDefinition Height="Auto"/>
34+
</Grid.RowDefinitions>
35+
36+
<Grid Grid.Row="0" x:Name="TopInfoPanel">
37+
<Grid.ColumnDefinitions>
38+
<ColumnDefinition Width="*"/>
39+
<ColumnDefinition Width="Auto"/>
40+
</Grid.ColumnDefinitions>
41+
42+
<TextBlock
43+
Grid.Column="0"
44+
Text="{Binding SelectedItem.FullPath}"
45+
FontWeight="Bold"
46+
Foreground="{DynamicResource {x:Static SystemColors.AccentColorBrushKey}}"
47+
Name="FileFullPathTextBlock"
48+
FontSize="13"
49+
Margin="0,0,0,0"
50+
Padding="10,10,10,10"
51+
TextWrapping="NoWrap" />
52+
53+
<Button
54+
Grid.Column="1"
55+
Content="Save"
56+
Name="SaveButton"
57+
Height="24"
58+
Margin="0,8,10,8"
59+
Padding="15,0"
60+
Click="SaveButton_Click"
61+
Visibility="{Binding SelectedItem.FileContentModel.ShowTextBox, Converter={StaticResource BoolToVisibilityConverter}}"/>
62+
</Grid>
63+
64+
<Grid Grid.Row="1" Focusable="False">
65+
<Grid.ColumnDefinitions>
66+
<ColumnDefinition x:Name="FilesListColumn" Width="Auto"/>
67+
<ColumnDefinition Width="Auto" />
68+
<ColumnDefinition Width="*" />
69+
</Grid.ColumnDefinitions>
70+
<ListView Grid.Column="0"
71+
x:Name="FilesListView"
72+
Focusable="False"
73+
IsTabStop="False"
74+
SelectionMode="Single"
75+
ItemsSource="{Binding ActiveListItems}"
76+
SelectedItem="{Binding SelectedItem}"
77+
MouseDoubleClick="FilesListView_MouseDoubleClick"
78+
Margin="10"
79+
KeyDown="FilesListView_KeyDown"
80+
ClipToBounds="True"
81+
Width="Auto"
82+
FocusManager.IsFocusScope="False"
83+
ScrollViewer.PanningMode="VerticalFirst"
84+
SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
85+
IsManipulationEnabled="True"
86+
ScrollViewer.HorizontalScrollBarVisibility="Auto"
87+
ScrollViewer.CanContentScroll="True" >
88+
<ListView.View>
89+
<GridView>
90+
<GridViewColumn Header="Name" Width="Auto" FocusManager.IsFocusScope="False">
91+
<GridViewColumn.CellTemplate>
92+
<DataTemplate>
93+
<TextBlock Text="{Binding Name}"
94+
FontSize="13"
95+
Focusable="False"
96+
VerticalAlignment="Center"
97+
FontWeight="Normal"/>
98+
</DataTemplate>
99+
</GridViewColumn.CellTemplate>
100+
</GridViewColumn>
101+
<GridViewColumn Header="Size (KB)" Width="80" FocusManager.IsFocusScope="False">
102+
<GridViewColumn.CellTemplate>
103+
<DataTemplate>
104+
<TextBlock Text="{Binding Size}"
105+
FontSize="13"
106+
Focusable="False"
107+
VerticalAlignment="Center"
108+
FontWeight="Normal"/>
109+
</DataTemplate>
110+
</GridViewColumn.CellTemplate>
111+
</GridViewColumn>
112+
</GridView>
113+
</ListView.View>
114+
</ListView>
115+
<GridSplitter Grid.Column="1"
116+
Width="1"
117+
UseLayoutRounding="True"
118+
Margin="5,5,5,5"
119+
x:Name="MainWindowGridSplitter"
120+
Background="{DynamicResource {x:Static SystemColors.AccentColorBrushKey}}"
121+
HorizontalContentAlignment="Center" Focusable="False"/>
122+
<Border x:Name="ContentBorder"
123+
Grid.Column="2"
124+
BorderThickness="1"
125+
Margin="1">
126+
<Grid
127+
MouseRightButtonDown="Grid_MouseRightButtonDown"
128+
Height="Auto"
129+
HorizontalAlignment="Stretch"
130+
Width="Auto">
131+
<Grid.RowDefinitions>
132+
<RowDefinition Height="*"/>
133+
</Grid.RowDefinitions>
134+
135+
<!-- File content: Image, Video or Text-->
136+
<Grid MouseRightButtonDown="FileContentGrid_MouseRightButtonDown"
137+
Grid.Row="0"
138+
Name="GridFileContent" ClipToBounds="True" Grid.IsSharedSizeScope="True" IsManipulationEnabled="True" SnapsToDevicePixels="True">
139+
140+
<local:VideoPlayerControl
141+
x:Name="VideoMedia"
142+
Content="{Binding SelectedItem.FileContentModel.VideoMedia}"
143+
Visibility="{Binding SelectedItem.FileContentModel.VideoMedia, Converter={StaticResource NullToCollapsedConverter}}" />
144+
145+
146+
<Grid
147+
Height="Auto"
148+
Width="Auto"
149+
Visibility="{Binding SelectedItem.FileContentModel.ImageSource, Converter={StaticResource NullToCollapsedConverter}}"
150+
ClipToBounds="True">
151+
<local:ZoomableImage
152+
Source="{Binding SelectedItem.FileContentModel.ImageSource}"
153+
VerticalAlignment="Center"
154+
Stretch="Uniform"
155+
x:Name="ZoomableImageElement"
156+
HorizontalAlignment="Center"
157+
RenderOptions.BitmapScalingMode="{Binding Config.BitmapScalingMode}"
158+
Visibility="{Binding SelectedItem.FileContentModel.ImageSource, Converter={StaticResource NullToCollapsedConverter}}"
159+
/>
160+
</Grid>
161+
162+
163+
<Grid Visibility="{Binding SelectedItem.FileContentModel.ShowTextBox, Converter={StaticResource BoolToVisibilityConverter}}" x:Name="GridSearchBox">
164+
<Grid.RowDefinitions>
165+
<RowDefinition Height="Auto"/>
166+
<RowDefinition Height="*"/>
167+
</Grid.RowDefinitions>
168+
169+
<!-- Search Panel -->
170+
<StackPanel Grid.Row="0"
171+
Orientation="Horizontal"
172+
Margin="10,5,10,5">
173+
<TextBox x:Name="SearchTextBox"
174+
Width="200"
175+
Margin="5,0,5,0"
176+
VerticalContentAlignment="Center"
177+
KeyDown="SearchTextBox_KeyDown"/>
178+
<Button Content="Find Next"
179+
Height="24"
180+
Padding="10,0"
181+
Click="FindNext_Click"
182+
Margin="0,0,5,0"/>
183+
<Button Content="Find Previous"
184+
Height="24"
185+
Padding="10,0"
186+
Click="FindPrevious_Click"
187+
Margin="0,0,5,0"/>
188+
<TextBlock x:Name="SearchResultsCount"
189+
VerticalAlignment="Center"
190+
Margin="5,0"/>
191+
</StackPanel>
192+
193+
<TextBox Grid.Row="1"
194+
FontFamily="Consolas"
195+
SpellCheck.IsEnabled="False"
196+
Name="TextBoxTextContent"
197+
HorizontalScrollBarVisibility="Auto"
198+
VerticalScrollBarVisibility="Auto"
199+
Margin="10"
200+
ClipToBounds="True"
201+
Visibility="{Binding SelectedItem.FileContentModel.ShowTextBox, Converter={StaticResource BoolToVisibilityConverter}}"
202+
FontSize="{Binding Config.FontSize}"
203+
Text="{Binding SelectedItem.FileContentModel.TextContent, Mode=TwoWay}"
204+
TextWrapping="{Binding Config.TextPreviewWordWrap}"/>
205+
</Grid>
206+
</Grid>
207+
</Grid>
208+
</Border>
209+
</Grid>
210+
<Grid Grid.Row="2" x:Name="StatusBar">
211+
<TextBlock x:Name="StatusBarTextBlock"
212+
FontSize="9"
213+
VerticalAlignment="Bottom"
214+
HorizontalAlignment="Left"
215+
Margin="0,0,0,0"
216+
MouseDown="StatusBarTextBlock_MouseDown"
217+
Foreground="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"
218+
Text="{Binding StatusBarText}"/>
219+
</Grid>
220+
</Grid>
221+
</Window>

0 commit comments

Comments
 (0)