|
9 | 9 | xmlns:behaviors="clr-namespace:Diffusion.Toolkit.Behaviors" |
10 | 10 | xmlns:converters="clr-namespace:Diffusion.Toolkit.Converters" |
11 | 11 | xmlns:lex="http://wpflocalizeextension.codeplex.com" |
| 12 | + xmlns:models="clr-namespace:Diffusion.Toolkit.Models" |
| 13 | + xmlns:common="clr-namespace:Diffusion.Common;assembly=Diffusion.Common" |
12 | 14 | mc:Ignorable="d" |
13 | 15 | d:DesignHeight="600" d:DesignWidth="800"> |
14 | 16 | <UserControl.Resources> |
|
23 | 25 | <converters:IntToVisibilityConverter x:Key="intToVis"></converters:IntToVisibilityConverter> |
24 | 26 | <converters:IfLessThanConverter x:Key="iflessThan"></converters:IfLessThanConverter> |
25 | 27 | <converters:IfGreaterThanConverter x:Key="ifGreaterThan"></converters:IfGreaterThanConverter> |
| 28 | + |
| 29 | + <DataTemplate x:Key="ImageDataTemplate"> |
| 30 | + <ScrollViewer Grid.Row="0" Grid.RowSpan="3" |
| 31 | + Loaded="ScrollViewer_OnLoaded" |
| 32 | + HorizontalScrollBarVisibility="{Binding MainModel.FitToPreview, Converter={StaticResource scrollBarVisibility}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" |
| 33 | + VerticalScrollBarVisibility="{Binding MainModel.FitToPreview, Converter={StaticResource scrollBarVisibility}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" |
| 34 | + > |
| 35 | + |
| 36 | + <Image |
| 37 | + DataContext="{Binding Image, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" |
| 38 | + Stretch="None" |
| 39 | + Opacity="{Binding ForDeletion, Converter={StaticResource BoolToOpacity}}" |
| 40 | + RenderOptions.BitmapScalingMode="Fant" |
| 41 | + Source="{Binding Image}" > |
| 42 | + <Image.Visibility> |
| 43 | + <MultiBinding Converter="{StaticResource invBoolToVisMulti}" ConverterParameter="20"> |
| 44 | + <Binding Path="NSFW"></Binding> |
| 45 | + <Binding Path="MainModel.NSFWBlur" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" ></Binding> |
| 46 | + </MultiBinding> |
| 47 | + </Image.Visibility> |
| 48 | + <Image.Effect> |
| 49 | + <BlurEffect KernelType="Gaussian"> |
| 50 | + <BlurEffect.Radius> |
| 51 | + <MultiBinding Converter="{StaticResource boolToBlurMulti}" ConverterParameter="20"> |
| 52 | + <Binding Path="NSFW"></Binding> |
| 53 | + <Binding Path="MainModel.NSFWBlur" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}"></Binding> |
| 54 | + </MultiBinding> |
| 55 | + </BlurEffect.Radius> |
| 56 | + </BlurEffect> |
| 57 | + </Image.Effect> |
| 58 | + </Image> |
| 59 | + |
| 60 | + </ScrollViewer> |
| 61 | + </DataTemplate> |
| 62 | + <DataTemplate x:Key="VideoDataTemplate" DataType="{x:Type models:ImageViewModel}"> |
| 63 | + <MediaElement |
| 64 | + DataContext="{Binding Image, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" |
| 65 | + Source="{Binding Path}" |
| 66 | + LoadedBehavior="Play" |
| 67 | + Loaded="Player_OnLoaded" |
| 68 | + MediaEnded="Player_OnMediaEnded" |
| 69 | + SpeedRatio="1" |
| 70 | + ></MediaElement> |
| 71 | + </DataTemplate> |
26 | 72 | </ResourceDictionary> |
27 | 73 | </UserControl.Resources> |
28 | 74 | <Grid x:Name="PreviewGrid" DataContext="{Binding ., RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" Background="Transparent"> |
|
44 | 90 | <RowDefinition Height="Auto" /> |
45 | 91 | <RowDefinition/> |
46 | 92 | </Grid.RowDefinitions>--> |
47 | | - <Grid Style="{StaticResource Preview}" Background="{x:Null}"> |
| 93 | + <!--<Grid Style="{StaticResource Preview}" Background="{x:Null}" |
| 94 | + x:Name="Grid" |
| 95 | + MouseMove="Grid_OnMouseMove" |
| 96 | + PreviewMouseWheel="UIElement_OnMouseWheel" |
| 97 | + PreviewKeyDown="Grid_OnPreviewKeyDown" |
| 98 | + PreviewKeyUp="Grid_OnPreviewKeyUp" |
| 99 | + KeyDown="Grid_OnKeyDown" |
| 100 | + >--> |
| 101 | + |
| 102 | + <Grid Style="{StaticResource Preview}" Background="{x:Null}" |
| 103 | + x:Name="Grid" |
| 104 | + MouseMove="Grid_OnMouseMove" |
| 105 | + PreviewMouseWheel="UIElement_OnMouseWheel" |
| 106 | + PreviewKeyDown="Grid_OnPreviewKeyDown" |
| 107 | + PreviewKeyUp="Grid_OnPreviewKeyUp" |
| 108 | + KeyDown="Grid_OnKeyDown" |
| 109 | + Focusable="True" |
| 110 | + > |
| 111 | + <Grid.ContextMenu> |
| 112 | + <ContextMenu> |
| 113 | + <MenuItem x:Name="AlbumMenu" ItemsSource="{Binding MainModel.AlbumMenuItems}" Header="{lex:Loc Thumbnail.ContextMenu.AddToAlbum}" > |
| 114 | + </MenuItem> |
| 115 | + <MenuItem x:Name="SelectionAlbumMenu" ItemsSource="{Binding MainModel.SelectionAlbumMenuItems}" Header="{lex:Loc Thumbnail.ContextMenu.RemoveFromAlbum}"></MenuItem> |
| 116 | + <Separator /> |
| 117 | + <MenuItem ItemsSource="{Binding MainModel.OpenWithMenuItems}" Header="{lex:Loc Thumbnail.ContextMenu.OpenWith}"></MenuItem> |
| 118 | + <Separator></Separator> |
| 119 | + <MenuItem Header="Fit to Preview" InputGestureText="CTRL+Shift+F" Command="{Binding MainModel.ToggleFitToPreview}" IsChecked="{Binding MainModel.FitToPreview}"></MenuItem> |
| 120 | + <MenuItem Header="Actual Size" InputGestureText="CTRL+Shift+A" Command="{Binding MainModel.ToggleActualSize}" IsChecked="{Binding MainModel.ActualSize}"></MenuItem> |
| 121 | + <Separator></Separator> |
| 122 | + <MenuItem Header="Copy Path" Command="{Binding CopyPathCommand}"></MenuItem> |
| 123 | + </ContextMenu> |
| 124 | + |
| 125 | + <!--Stretch="{Binding MainModel.FitToPreview, Converter={StaticResource stretch}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"--> |
| 126 | + |
| 127 | + </Grid.ContextMenu> |
48 | 128 | <Grid.RowDefinitions> |
49 | 129 | <RowDefinition Height="42"/> |
50 | 130 | <RowDefinition Height="*" /> |
|
57 | 137 | <!--HorizontalScrollBarVisibility="Hidden" |
58 | 138 | VerticalScrollBarVisibility="Hidden"--> |
59 | 139 |
|
| 140 | + <Grid Background="Transparent" Grid.Row="0" Grid.RowSpan="3"> |
| 141 | + <ContentControl x:Name="Content" DataContext="{Binding Path=Image}"> |
| 142 | + <ContentControl.Style> |
| 143 | + <Style TargetType="ContentControl"> |
| 144 | + <Setter Property="ContentTemplate" Value="{StaticResource ImageDataTemplate}" /> |
| 145 | + <Style.Triggers> |
| 146 | + <DataTrigger Binding="{Binding Type}" Value="{x:Static common:ImageType.Image}"> |
| 147 | + <Setter Property="ContentTemplate" Value="{StaticResource ImageDataTemplate}" /> |
| 148 | + </DataTrigger> |
| 149 | + <DataTrigger Binding="{Binding Type}" Value="{x:Static common:ImageType.Video}"> |
| 150 | + <Setter Property="ContentTemplate" Value="{StaticResource VideoDataTemplate}" /> |
| 151 | + </DataTrigger> |
| 152 | + </Style.Triggers> |
| 153 | + </Style> |
| 154 | + </ContentControl.Style> |
| 155 | + </ContentControl> |
| 156 | + </Grid> |
| 157 | + |
| 158 | + |
60 | 159 |
|
61 | | - <ScrollViewer x:Name="ScrollViewer" Grid.Row="0" Grid.RowSpan="3" |
62 | | - HorizontalScrollBarVisibility="{Binding MainModel.FitToPreview, Converter={StaticResource scrollBarVisibility}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" |
63 | | - VerticalScrollBarVisibility="{Binding MainModel.FitToPreview, Converter={StaticResource scrollBarVisibility}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" |
64 | | - MouseMove="ScrollViewer_OnMouseMove" |
65 | | - PreviewKeyDown="ScrollViewer_OnPreviewKeyDown" |
66 | | - PreviewMouseWheel="UIElement_OnMouseWheel" |
67 | | - PreviewKeyUp="ScrollViewer_OnPreviewKeyUp" |
68 | | - KeyDown="ScrollViewer_OnKeyDown" |
69 | | - > |
70 | | - <ScrollViewer.ContextMenu> |
71 | | - <ContextMenu> |
72 | | - <MenuItem x:Name="AlbumMenu" ItemsSource="{Binding MainModel.AlbumMenuItems}" Header="{lex:Loc Thumbnail.ContextMenu.AddToAlbum}" > |
73 | | - </MenuItem> |
74 | | - <MenuItem x:Name="SelectionAlbumMenu" ItemsSource="{Binding MainModel.SelectionAlbumMenuItems}" Header="{lex:Loc Thumbnail.ContextMenu.RemoveFromAlbum}"></MenuItem> |
75 | | - <Separator /> |
76 | | - <MenuItem ItemsSource="{Binding MainModel.OpenWithMenuItems}" Header="{lex:Loc Thumbnail.ContextMenu.OpenWith}"></MenuItem> |
77 | | - <Separator></Separator> |
78 | | - <MenuItem Header="Fit to Preview" InputGestureText="CTRL+Shift+F" Command="{Binding MainModel.ToggleFitToPreview}" IsChecked="{Binding MainModel.FitToPreview}"></MenuItem> |
79 | | - <MenuItem Header="Actual Size" InputGestureText="CTRL+Shift+A" Command="{Binding MainModel.ToggleActualSize}" IsChecked="{Binding MainModel.ActualSize}"></MenuItem> |
80 | | - <Separator></Separator> |
81 | | - <MenuItem Header="Copy Path" Command="{Binding CopyPathCommand}"></MenuItem> |
82 | | - </ContextMenu> |
83 | | - |
84 | | - <!--Stretch="{Binding MainModel.FitToPreview, Converter={StaticResource stretch}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"--> |
85 | | - |
86 | | - </ScrollViewer.ContextMenu> |
87 | | - <Image x:Name="Preview" |
88 | | - DataContext="{Binding Image, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" |
89 | | - Stretch="None" |
90 | | - Opacity="{Binding ForDeletion, Converter={StaticResource BoolToOpacity}}" |
91 | | - RenderOptions.BitmapScalingMode="Fant" |
92 | | - Source="{Binding Image}" > |
93 | | - <Image.Visibility> |
94 | | - <MultiBinding Converter="{StaticResource invBoolToVisMulti}" ConverterParameter="20"> |
95 | | - <Binding Path="NSFW"></Binding> |
96 | | - <Binding Path="MainModel.NSFWBlur" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" ></Binding> |
97 | | - </MultiBinding> |
98 | | - </Image.Visibility> |
99 | | - <Image.Effect> |
100 | | - <BlurEffect KernelType="Gaussian"> |
101 | | - <BlurEffect.Radius> |
102 | | - <MultiBinding Converter="{StaticResource boolToBlurMulti}" ConverterParameter="20"> |
103 | | - <Binding Path="NSFW"></Binding> |
104 | | - <Binding Path="MainModel.NSFWBlur" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}"></Binding> |
105 | | - </MultiBinding> |
106 | | - </BlurEffect.Radius> |
107 | | - </BlurEffect> |
108 | | - </Image.Effect> |
109 | | - </Image> |
110 | | - |
111 | | - </ScrollViewer> |
112 | | - |
113 | | - <MediaElement x:Name="Player" Grid.Row="0" Grid.RowSpan="3" |
114 | | - MouseMove="ScrollViewer_OnMouseMove" |
115 | | - PreviewKeyDown="ScrollViewer_OnPreviewKeyDown" |
116 | | - PreviewMouseWheel="UIElement_OnMouseWheel" |
117 | | - PreviewKeyUp="ScrollViewer_OnPreviewKeyUp" |
118 | | - KeyDown="ScrollViewer_OnKeyDown" |
119 | | - LoadedBehavior="Manual" |
120 | | - Loaded="Player_OnLoaded" |
121 | | - MediaEnded="Player_OnMediaEnded" |
122 | | - ></MediaElement> |
123 | 160 |
|
124 | 161 | <Grid Grid.Row="0" RowSpan="3" Background="Transparent" IsHitTestVisible="False" |
125 | 162 | DataContext="{Binding Image, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" |
|
0 commit comments