Skip to content

Commit

Permalink
add volume slider
Browse files Browse the repository at this point in the history
  • Loading branch information
xupefei committed Aug 13, 2017
1 parent 11ab3d7 commit b4ed9b4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 40 deletions.
20 changes: 10 additions & 10 deletions QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Styles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<!-- Custom Slider Control -->
<ControlTemplate x:Key="CustomSliderThumbTemplate" TargetType="{x:Type Thumb}">
<Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
<Rectangle x:Name="grip" Fill="{DynamicResource WindowTextForeground}" Width="8"
<Rectangle x:Name="grip" Fill="{DynamicResource WindowTextForeground}" Width="5"
Height="{Binding Path=Height, RelativeSource={RelativeSource TemplatedParent}}"
StrokeThickness="0"
UseLayoutRounding="True" Stretch="Fill" RadiusX="3" RadiusY="3" />
Expand All @@ -101,18 +101,18 @@
<RowDefinition Height="{TemplateBinding MinHeight}" />
</Grid.RowDefinitions>
<DockPanel LastChildFill="True">
<Border ClipToBounds="True" x:Name="PART_SelectionRange" Height="3" Visibility="Visible">
<Rectangle RadiusX="1" RadiusY="1" Margin="4,0,-4,0"
<Border ClipToBounds="True" x:Name="PART_SelectionRange" Height="1" Visibility="Visible">
<Rectangle RadiusX="1" RadiusY="1" Margin="4,0,-2,0"
Fill="{DynamicResource WindowTextForeground}" />
</Border>
<Border ClipToBounds="True" Height="3" Visibility="Visible">
<Rectangle x:Name="PART_NegativeSelection" RadiusX="1" RadiusY="1" Margin="8,0,4,0"
Fill="{DynamicResource MainWindowBackground}" />
<Border ClipToBounds="True" Height="1" Visibility="Visible">
<Rectangle x:Name="PART_NegativeSelection" RadiusX="1" RadiusY="1" Margin="-2,0,4,0"
Fill="{DynamicResource WindowTextForegroundAlternative}" />
</Border>
</DockPanel>
<Track x:Name="PART_Track">
<Track.Thumb>
<Thumb x:Name="Thumb" Focusable="False" Width="8" Height="{TemplateBinding MinHeight}"
<Thumb x:Name="Thumb" Focusable="False" Width="5" Height="{TemplateBinding MinHeight}"
OverridesDefaultStyle="True" Template="{StaticResource CustomSliderThumbTemplate}"
VerticalAlignment="Center" />
</Track.Thumb>
Expand All @@ -124,9 +124,9 @@
<Setter Property="Stylus.IsPressAndHoldEnabled" Value="false" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="MinHeight" Value="16" />
<Setter Property="MaxHeight" Value="16" />
<Setter Property="Height" Value="16" />
<Setter Property="MinHeight" Value="14" />
<Setter Property="MaxHeight" Value="14" />
<Setter Property="Height" Value="14" />
<Setter Property="Minimum" Value="0" />
<Setter Property="IsSnapToTickEnabled" Value="True" />
<Setter Property="SmallChange" Value="0.01" />
Expand Down
39 changes: 10 additions & 29 deletions QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@
</Style>
</Button.Style>
</Button>
<Button x:Name="buttonTime" Width="37" Style="{StaticResource ControlButtonStyle}" DockPanel.Dock="Right" Tag="Time">
<Button x:Name="buttonTime" Width="37" Style="{StaticResource ControlButtonStyle}"
DockPanel.Dock="Right" Tag="Time">
<TextBlock VerticalAlignment="Center" FontSize="11"
FontFamily="{Binding ElementName=viewerPanel, Path=FontFamily}"
Foreground="{DynamicResource CaptionButtonIconForeground}">
Expand All @@ -174,39 +175,19 @@
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</TextBlock>
</Button>
<Slider x:Name="sliderProgress" Style="{StaticResource PositionSliderStyle}"
SmallChange="0.00001" LargeChange="0.01" Maximum="1"
Value="{Binding Position, ElementName=mediaElement}" />
</DockPanel>
</Grid>
<!--<Grid Height="32" Width="100" HorizontalAlignment="Right" VerticalAlignment="Bottom"
Background="{DynamicResource CaptionBackground}" Margin="0,0,0,32">
<Grid.Style>
<Style TargetType="Grid">
<Setter Property="Opacity" Value="0" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=buttonMute, Path=IsMouseOver}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard TargetProperty="Opacity">
<DoubleAnimation To="1" Duration="0:0:0.1" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard TargetProperty="Opacity">
<DoubleAnimation To="0" Duration="0:0:0.1" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<Slider Style="{StaticResource CustomSliderStyle}" Width="100" Maximum="100" Value="{Binding ElementName=mediaElement, Path=Volume}" />
</Grid>-->
<Grid x:Name="volumeSliderLayer" Background="Transparent" Visibility="Collapsed">
<Grid Height="32" Width="130" HorizontalAlignment="Right" VerticalAlignment="Bottom"
Background="{DynamicResource CaptionButtonHoverBackground}" Margin="0,0,0,32">
<Slider Style="{StaticResource CustomSliderStyle}" Width="110" Maximum="100"
Value="{Binding ElementName=mediaElement, Path=Volume}" />
</Grid>
</Grid>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public ViewerPanel(ContextObject context)

buttonPlayPause.Click += TogglePlayPause;
buttonTime.Click += (sender, e) => buttonTime.Tag = (string) buttonTime.Tag == "Time" ? "Length" : "Time";
buttonMute.Click += (sender, e) => IsMuted = !IsMuted;
buttonMute.Click += (sender, e) => volumeSliderLayer.Visibility = Visibility.Visible;
volumeSliderLayer.MouseDown += (sender, e) => volumeSliderLayer.Visibility = Visibility.Collapsed;

sliderProgress.PreviewMouseDown += (sender, e) =>
{
Expand Down

0 comments on commit b4ed9b4

Please sign in to comment.