WPF 豆瓣电台 (Skin)
12 Apr 2012用WPF做一个豆瓣电台,提取歌曲的方法我找到了,晒一下新写的皮肤。

Window.xaml
<Window x:Class="WPF_title.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="夜阑听音" Height="200" Width="400" WindowStyle="None" AllowsTransparency="True" MouseDown="Window_MouseDown" Background="#FF030303" Opacity="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0">
<Rectangle.Fill>
<ImageBrush ImageSource="Resources/Img/maximilian.jpg"/>
</Rectangle.Fill>
</Rectangle>
<StackPanel x:Name="Top" Grid.Column="1">
<Grid x:Name="Control" Height="20">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Name="Genre" Text="Indie" Grid.Column="0"/>
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
<Button x:Name="Minizise" Width="15" Style="{DynamicResource MinimizeStyle}" Click="Min"/>
<Button x:Name="DockToBottom" Width="15" Style="{DynamicResource ToNotifyIconStyle}" Click="Dock"/>
<Button x:Name="Close" Width="15" Style="{DynamicResource ExitStyle}" Click="Exit"/>
</StackPanel>
</Grid>
<Grid x:Name="SongMeta">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="153*" />
<ColumnDefinition Width="25*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
</Grid>
<TextBlock Name="Title" Text="The days are long and filled with pain" Grid.Row="1" FontSize="15"/>
<TextBlock Name="Album" Text="I Am Falling Now" Grid.Row="2"/>
<TextBlock Name="Singer" Text="Maximilian Hecker" Grid.Row="3"/>
</StackPanel>
<!--<Grid x:Name="Time" Grid.Column="1" VerticalAlignment="Bottom" Margin="0 0 0 60">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="CurrentTime" FontSize="11" Foreground="White" Text="00:00" Grid.Column="0"/>
<TextBlock x:Name="TotalTime" FontSize="11" HorizontalAlignment="Right" Foreground="White" Text="00:00" Grid.Column="1" />
</Grid>
<Grid Margin="0 0 0 40" VerticalAlignment="Bottom" Grid.Column="1">
<Slider x:Name="slidebar" Width="200" Style="{DynamicResource SliderStyleForProgress}" />
</Grid>-->
<Grid x:Name="Bottom" Margin="0 130 0 0" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<CheckBox Grid.Column="0" x:Name="CheckBoxLike" Style="{DynamicResource LikeStyle}" Margin="13" />
<Button Grid.Column="1" x:Name="ButtonNever" Style="{DynamicResource NeverStyle}" Margin="13"/>
<CheckBox Grid.Column="2" x:Name="CheckBoxPause" Style="{DynamicResource PauseStyle}" Margin="13"/>
<Button Grid.Column="3" x:Name="ButtonNext" Style="{DynamicResource NextStyle}" Margin="13"/>
</Grid>
</Grid>
</Window>
Style.xaml
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="TextBlock">
<Style.Setters>
<Setter Property="Foreground" Value="#fff"/>
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="Margin" Value="5 5 5 0"/>
</Style.Setters>
</Style>
<Style x:Key="Top" TargetType="{x:Type StackPanel}">
<Setter Property="MaxHeight" Value="110"/>
</Style>
<Style x:Key="CustomButtonBaseStyle" TargetType="{x:Type ButtonBase}">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="#ff4040"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Foreground" Value="#bb3355"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="#fff"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="CustomButtonStyle" BasedOn="{StaticResource CustomButtonBaseStyle}" TargetType="{x:Type Button}">
</Style>
<Style x:Key="CustomCheckBoxStyle" BasedOn="{StaticResource CustomButtonBaseStyle}" TargetType="{x:Type CheckBox}">
</Style>
<Style x:Key="MinimizeStyle" BasedOn="{StaticResource CustomButtonStyle}" TargetType="{x:Type Button}">
<Setter Property="ToolTip" Value="最小化"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Viewbox>
<Canvas Width="256" Height="256" Clip="F1 M 0,0L 256,0L 256,256L 0,256L 0,0" Background="{TemplateBinding Background}">
<Rectangle Width="192" Height="32" Canvas.Left="32" Canvas.Top="192" Stretch="Fill" Fill="{TemplateBinding Foreground}"/>
</Canvas>
</Viewbox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ToNotifyIconStyle" BasedOn="{StaticResource CustomButtonStyle}" TargetType="{x:Type Button}">
<Setter Property="ToolTip" Value="最小化到托盘"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Viewbox>
<Canvas Width="256" Height="256" Clip="F1 M 0,0L 256,0L 256,256L 0,256L 0,0" Background="{TemplateBinding Background}">
<Path Width="224" Height="224" Canvas.Left="16" Canvas.Top="16" Stretch="Fill" StrokeThickness="32" StrokeLineJoin="Round" Stroke="{TemplateBinding Foreground}" Data="M 32,32L 224,224"/>
<Path Width="127.5" Height="128.25" Canvas.Left="112.5" Canvas.Top="112" Stretch="Fill" StrokeThickness="32" StrokeLineJoin="Round" Stroke="{TemplateBinding Foreground}" Data="M 128.5,224.25L 224,224L 224,128"/>
</Canvas>
</Viewbox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ExitStyle" BasedOn="{StaticResource CustomButtonStyle}" TargetType="{x:Type Button}">
<Setter Property="ToolTip" Value="退出"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Viewbox>
<Canvas Width="256" Height="256" Clip="F1 M 0,0L 256,0L 256,256L 0,256L 0,0" Background="{TemplateBinding Background}">
<Path Width="214.627" Height="214.627" Canvas.Left="20.6863" Canvas.Top="20.6863" Stretch="Fill" Fill="{TemplateBinding Foreground}" Data="M 20.6863,212.686L 105.373,128L 20.6863,43.3137L 43.3137,20.6863L 128,105.373L 212.686,20.6863L 235.314,43.3137L 150.627,128L 235.314,212.686L 212.686,235.314L 128,150.627L 43.3137,235.314L 20.6863,212.686 Z "/>
</Canvas>
</Viewbox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--<Style x:Key="SliderStyleForProgress" TargetType="{x:Type Slider}">
<Setter Property="Height" Value="5"/>
<Setter Property="Background" Value="Dodgerblue"/>
<Setter Property="Foreground" Value="Yellow"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Slider}">
<Grid>
<Rectangle x:Name="Track" Fill="{TemplateBinding Background}"/>
<Rectangle x:Name="Thumb" Fill="{TemplateBinding Foreground}">
<Rectangle.RenderTransform>
<ScaleTransform>
<ScaleTransform.ScaleX>
<MultiBinding Converter="{StaticResource converter1}">
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Value"/>
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Minimum"/>
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Maximum"/>
</MultiBinding>
</ScaleTransform.ScaleX>
</ScaleTransform>
</Rectangle.RenderTransform>
</Rectangle>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>-->
<Style x:Key="LikeStyle" BasedOn="{StaticResource CustomCheckBoxStyle}" TargetType="{x:Type CheckBox}">
<Setter Property="BorderBrush" Value="White"/>
<Setter Property="ToolTip" Value="喜欢"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CheckBox}">
<Viewbox>
<Canvas Width="256" Height="220" Clip="F1 M 0,0L 256,0L 256,220L 0,220L 0,0" Background="{TemplateBinding Background}">
<Path x:Name="path" Width="256" Height="216.961" Canvas.Left="1.67144e-005" Canvas.Top="5.03886" Stretch="Fill" Fill="{TemplateBinding Foreground}" Data="F1 M 128,220C 154.667,200.333 186,172 202,156C 218,140 256,94 256,69C 256,-1.99995 194.288,0.999451 176,5C 144,12 135.016,36.0526 128,44C 120.984,36.0526 112,13 80,6C 61.7118,1.99945 2.61674e-005,-0.999954 5.82235e-006,70C 2.61674e-005,95 38,140 54,156C 70,172 101.333,200.333 128,220" Stroke="{TemplateBinding BorderBrush}" StrokeStartLineCap="Round" StrokeThickness="0"/>
</Canvas>
</Viewbox>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="StrokeThickness" TargetName="path" Value="10"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="NeverStyle" BasedOn="{StaticResource CustomButtonStyle}" TargetType="{x:Type Button}">
<Setter Property="ToolTip" Value="不再播放"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Viewbox>
<Canvas Width="256" Height="256" Clip="F1 M 0,0L 256,0L 256,256L 0,256L 0,0" Background="{TemplateBinding Background}">
<Path Width="185" Height="256" Canvas.Left="35.5" Canvas.Top="4.57764e-005" Stretch="Fill" Fill="{TemplateBinding Foreground}" Data="M 198.667,84L 198.667,236C 198.667,247.046 189.712,256 178.667,256L 77.3332,256C 66.2875,256 57.3332,247.046 57.3332,236L 57.3332,84C 57.3332,82.6301 57.471,81.2925 57.7333,80L 198.267,80C 198.529,81.2925 198.667,82.6301 198.667,84 Z M 91.2256,108.496L 91.2256,227.504L 108.774,227.504L 108.774,108.496L 91.2256,108.496 Z M 147.226,108.496L 147.226,227.504L 164.774,227.504L 164.774,108.496L 147.226,108.496 Z M 85,4.57764e-005L 171,4.57764e-005C 173.761,4.57764e-005 176,2.2386 176,5.00005L 176,32L 220.5,32L 220.5,64L 35.5,64L 35.5,32L 80,32L 80,5.00005C 80,2.2386 82.2386,4.57764e-005 85,4.57764e-005 Z M 101,16.0001C 98.2385,16.0001 95.9999,18.2387 95.9999,21.0001L 95.9999,32L 160,32L 160,21.0001C 160,18.2387 157.761,16.0001 155,16.0001L 101,16.0001 Z "/>
</Canvas>
</Viewbox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="PauseStyle" BasedOn="{StaticResource CustomCheckBoxStyle}" TargetType="{x:Type CheckBox}">
<Setter Property="ToolTip" Value="暂停"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CheckBox}">
<Viewbox>
<Canvas Width="30" Height="30" Background="{TemplateBinding Background}">
<Rectangle x:Name="Rectangle" Width="10" Height="30" Canvas.Left="20" Canvas.Top="0" Stretch="Fill" Fill="{TemplateBinding Foreground}"/>
<Rectangle x:Name="Rectangle_0" Width="10" Height="30" Canvas.Left="0" Canvas.Top="0" Stretch="Fill" Fill="{TemplateBinding Foreground}"/>
</Canvas>
</Viewbox>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="ToolTip" Value="播放"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CheckBox}">
<Viewbox>
<Canvas Width="26" Height="30" Background="{TemplateBinding Background}">
<Path x:Name="Path" Width="25.981" Height="30.0003" Canvas.Left="2.87779e-007" Canvas.Top="-6.35788e-007" Stretch="Fill" Fill="{TemplateBinding Foreground}" Data="F1 M 25.981,15.0001L 2.87779e-007,-6.35788e-007L 2.87779e-007,30.0003L 25.981,15.0001 Z "/>
</Canvas>
</Viewbox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="NextStyle" BasedOn="{StaticResource CustomButtonStyle}" TargetType="{x:Type Button}">
<Setter Property="ToolTip" Value="下一首"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Viewbox>
<Canvas x:Name="Document" Width="30" Height="20" Clip="F1 M 0,0L 30,0L 30,20L 0,20L 0,0" Background="Transparent">
<Canvas Width="30" Height="30" Canvas.Left="0" Canvas.Top="0">
<Path x:Name="Path" Width="30" Height="20" Canvas.Left="-1.98682e-008" Canvas.Top="-9.53674e-007" Stretch="Fill" Data="M 30,-9.53674e-007L 26,-9.53674e-007L 26,8L 13,-9.53674e-007L 13,8L -1.98682e-008,-9.53674e-007L -1.98682e-008,20L 13,12L 13,20L 26,12L 26,20L 30,20L 30,-9.53674e-007 Z " Fill="{TemplateBinding Foreground}"/>
</Canvas>
</Canvas>
</Viewbox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
转载请注明:于哲的博客 » WPF 豆瓣电台 (Skin)