http://www.cnblogs.com/wxdtk1989/archive/2011/08/10/2133627.html
软件介绍:本软件使用虾米网的资源,真正下载虾米网的音乐要用积分,所以在这不添加下载功能。代码也只贴部分。我用的NetFramework4.0 不知道在别的电脑上能不能支持。
api是怎么得到的,就是下载它的swf文件,然后反编译,分析代码找到xml地址,MP3地址是加密的,解密算法也是在swf文件里,有兴趣的同学可以研究一下。还有个budge ,mediaElement不在咋了,pause不好使,就是停不下,所以改成了静音效果,伪装成暂停。
下载地址(非源码):https://files.cnblogs.com/wxdtk1989/SkyMusic.zip 不足之处请谅解。
图:



部分代码:
xaml:
004 |
xmlns:SkyMuisc_Properties="clr-namespace:SkyMuisc.Properties" |
008 |
x:Class="SkyMuisc.MainWindow" |
009 |
Title="天空的声音" Height="550" Width="280" WindowStartupLocation="CenterScreen" MaxWidth="280" MaxHeight="550" WindowStyle="SingleBorderWindow" MinWidth="280" MinHeight="550" FontSize="16" Icon="/SkyMuisc;component/20100829224935145.ico" Loaded="Window_Loaded" MouseDown="Window_MouseDown"> |
011 |
<ContextMenu Name="contextmenu1"> |
012 |
<MenuItem Header="关于我" Name="MenuItem1" Click="MenuItem1_Click" /> |
013 |
<MenuItem Header="退出" Name="MenuItem2" Click="MenuItem2_Click"/> |
015 |
</Window.ContextMenu> |
017 |
<Style x:Key="ButtonStyle1" TargetType="{x:Type Button}"> |
018 |
<Setter Property="Template"> |
020 |
<ControlTemplate TargetType="{x:Type Button}"> |
022 |
<VisualStateManager.CustomVisualStateManager> |
023 |
<ei:ExtendedVisualStateManager/> |
024 |
</VisualStateManager.CustomVisualStateManager> |
025 |
<VisualStateManager.VisualStateGroups> |
026 |
<VisualStateGroup x:Name="CommonStates" ei:ExtendedVisualStateManager.UseFluidLayout="True"> |
027 |
<VisualState x:Name="Normal"/> |
028 |
<VisualState x:Name="MouseOver"> |
030 |
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ellipse"> |
031 |
<EasingDoubleKeyFrame KeyTime="0" Value="0.56"/> |
032 |
</DoubleAnimationUsingKeyFrames> |
035 |
<VisualState x:Name="Pressed"> |
037 |
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="ellipse"> |
038 |
<DiscreteObjectKeyFrame KeyTime="0"> |
039 |
<DiscreteObjectKeyFrame.Value> |
040 |
<System:Double>35</System:Double> |
041 |
</DiscreteObjectKeyFrame.Value> |
042 |
</DiscreteObjectKeyFrame> |
043 |
</ObjectAnimationUsingKeyFrames> |
044 |
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="ellipse"> |
045 |
<DiscreteObjectKeyFrame KeyTime="0"> |
046 |
<DiscreteObjectKeyFrame.Value> |
047 |
<System:Double>35</System:Double> |
048 |
</DiscreteObjectKeyFrame.Value> |
049 |
</DiscreteObjectKeyFrame> |
050 |
</ObjectAnimationUsingKeyFrames> |
053 |
<VisualState x:Name="Disabled"/> |
055 |
</VisualStateManager.VisualStateGroups> |
056 |
<Ellipse x:Name="ellipse" Stroke="Black" StrokeThickness="3"> |
058 |
<ImageBrush ImageSource="appbar.transport.play.rest.png"/> |
061 |
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content=""/> |
063 |
<ControlTemplate.Triggers> |
064 |
<Trigger Property="IsFocused" Value="True"/> |
065 |
<Trigger Property="IsDefaulted" Value="True"/> |
066 |
<Trigger Property="IsMouseOver" Value="True"/> |
067 |
<Trigger Property="IsPressed" Value="True"/> |
068 |
<Trigger Property="IsEnabled" Value="False"/> |
069 |
</ControlTemplate.Triggers> |
074 |
<Style x:Key="ButtonStyle2" TargetType="{x:Type Button}"> |
075 |
<Setter Property="Template"> |
077 |
<ControlTemplate TargetType="{x:Type Button}"> |
079 |
<VisualStateManager.CustomVisualStateManager> |
080 |
<ei:ExtendedVisualStateManager/> |
081 |
</VisualStateManager.CustomVisualStateManager> |
082 |
<VisualStateManager.VisualStateGroups> |
083 |
<VisualStateGroup x:Name="CommonStates" ei:ExtendedVisualStateManager.UseFluidLayout="True"> |
084 |
<VisualState x:Name="Normal"/> |
085 |
<VisualState x:Name="MouseOver"> |
087 |
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ellipse"> |
088 |
<EasingDoubleKeyFrame KeyTime="0" Value="0.56"/> |
089 |
</DoubleAnimationUsingKeyFrames> |
092 |
<VisualState x:Name="Pressed"> |
094 |
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="ellipse"> |
095 |
<DiscreteObjectKeyFrame KeyTime="0"> |
096 |
<DiscreteObjectKeyFrame.Value> |
097 |
<System:Double>35</System:Double> |
098 |
</DiscreteObjectKeyFrame.Value> |
099 |
</DiscreteObjectKeyFrame> |
100 |
</ObjectAnimationUsingKeyFrames> |
101 |
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="ellipse"> |
102 |
<DiscreteObjectKeyFrame KeyTime="0"> |
103 |
<DiscreteObjectKeyFrame.Value> |
104 |
<System:Double>35</System:Double> |
105 |
</DiscreteObjectKeyFrame.Value> |
106 |
</DiscreteObjectKeyFrame> |
107 |
</ObjectAnimationUsingKeyFrames> |
110 |
<VisualState x:Name="Disabled"/> |
112 |
</VisualStateManager.VisualStateGroups> |
113 |
<Ellipse x:Name="ellipse" Stroke="Black" StrokeThickness="3"> |
115 |
<ImageBrush ImageSource="appbar.transport.pause.rest.png"/> |
118 |
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content=""/> |
120 |
<ControlTemplate.Triggers> |
121 |
<Trigger Property="IsFocused" Value="True"/> |
122 |
<Trigger Property="IsDefaulted" Value="True"/> |
123 |
<Trigger Property="IsMouseOver" Value="True"/> |
124 |
<Trigger Property="IsPressed" Value="True"/> |
125 |
<Trigger Property="IsEnabled" Value="False"/> |
126 |
</ControlTemplate.Triggers> |
131 |
<Style x:Key="ButtonStyle3" TargetType="{x:Type Button}"> |
132 |
<Setter Property="Template"> |
134 |
<ControlTemplate TargetType="{x:Type Button}"> |
136 |
<VisualStateManager.CustomVisualStateManager> |
137 |
<ei:ExtendedVisualStateManager/> |
138 |
</VisualStateManager.CustomVisualStateManager> |
139 |
<VisualStateManager.VisualStateGroups> |
140 |
<VisualStateGroup x:Name="CommonStates" ei:ExtendedVisualStateManager.UseFluidLayout="True"> |
141 |
<VisualState x:Name="Normal"/> |
142 |
<VisualState x:Name="MouseOver"> |
144 |
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ellipse"> |
145 |
<EasingDoubleKeyFrame KeyTime="0" Value="0.56"/> |
146 |
</DoubleAnimationUsingKeyFrames> |
149 |
<VisualState x:Name="Pressed"> |
151 |
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="ellipse"> |
152 |
<DiscreteObjectKeyFrame KeyTime="0"> |
153 |
<DiscreteObjectKeyFrame.Value> |
154 |
<System:Double>35</System:Double> |
155 |
</DiscreteObjectKeyFrame.Value> |
156 |
</DiscreteObjectKeyFrame> |
157 |
</ObjectAnimationUsingKeyFrames> |
158 |
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="ellipse"> |
159 |
<DiscreteObjectKeyFrame KeyTime="0"> |
160 |
<DiscreteObjectKeyFrame.Value> |
161 |
<System:Double>35</System:Double> |
162 |
</DiscreteObjectKeyFrame.Value> |
163 |
</DiscreteObjectKeyFrame> |
164 |
</ObjectAnimationUsingKeyFrames> |
167 |
<VisualState x:Name="Disabled"/> |
169 |
</VisualStateManager.VisualStateGroups> |
170 |
<Ellipse x:Name="ellipse" Stroke="Black" StrokeThickness="3"> |
172 |
<ImageBrush ImageSource="appbar.transport.ff.rest.png"/> |
175 |
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content=""/> |
177 |
<ControlTemplate.Triggers> |
178 |
<Trigger Property="IsFocused" Value="True"/> |
179 |
<Trigger Property="IsDefaulted" Value="True"/> |
180 |
<Trigger Property="IsMouseOver" Value="True"/> |
181 |
<Trigger Property="IsPressed" Value="True"/> |
182 |
<Trigger Property="IsEnabled" Value="False"/> |
183 |
</ControlTemplate.Triggers> |
188 |
<Style x:Key="ButtonStyle4" TargetType="{x:Type Button}"> |
189 |
<Setter Property="Template"> |
191 |
<ControlTemplate TargetType="{x:Type Button}"> |
193 |
<VisualStateManager.CustomVisualStateManager> |
194 |
<ei:ExtendedVisualStateManager/> |
195 |
</VisualStateManager.CustomVisualStateManager> |
196 |
<VisualStateManager.VisualStateGroups> |
197 |
<VisualStateGroup x:Name="CommonStates" ei:ExtendedVisualStateManager.UseFluidLayout="True"> |
198 |
<VisualState x:Name="Normal"/> |
199 |
<VisualState x:Name="MouseOver"> |
201 |
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ellipse"> |
202 |
<EasingDoubleKeyFrame KeyTime="0" Value="0.56"/> |
203 |
</DoubleAnimationUsingKeyFrames> |
206 |
<VisualState x:Name="Pressed"> |
208 |
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="ellipse"> |
209 |
<DiscreteObjectKeyFrame KeyTime="0"> |
210 |
<DiscreteObjectKeyFrame.Value> |
211 |
<System:Double>35</System:Double> |
212 |
</DiscreteObjectKeyFrame.Value> |
213 |
</DiscreteObjectKeyFrame> |
214 |
</ObjectAnimationUsingKeyFrames> |
215 |
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="ellipse"> |
216 |
<DiscreteObjectKeyFrame KeyTime="0"> |
217 |
<DiscreteObjectKeyFrame.Value> |
218 |
<System:Double>35</System:Double> |
219 |
</DiscreteObjectKeyFrame.Value> |
220 |
</DiscreteObjectKeyFrame> |
221 |
</ObjectAnimationUsingKeyFrames> |
224 |
<VisualState x:Name="Disabled"/> |
226 |
</VisualStateManager.VisualStateGroups> |
227 |
<Ellipse x:Name="ellipse" Stroke="Black" StrokeThickness="3"> |
229 |
<ImageBrush ImageSource="appbar.download.rest.png"/> |
232 |
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content=""/> |
234 |
<ControlTemplate.Triggers> |
235 |
<Trigger Property="IsFocused" Value="True"/> |
236 |
<Trigger Property="IsDefaulted" Value="True"/> |
237 |
<Trigger Property="IsMouseOver" Value="True"/> |
238 |
<Trigger Property="IsPressed" Value="True"/> |
239 |
<Trigger Property="IsEnabled" Value="False"/> |
240 |
</ControlTemplate.Triggers> |
247 |
<Grid.RowDefinitions> |
248 |
<RowDefinition Height="148*" /> |
249 |
<RowDefinition Height="200" /> |
250 |
<RowDefinition Height="30*" /> |
251 |
<RowDefinition Height="133*" /> |
252 |
</Grid.RowDefinitions> |
253 |
<Expander Height="58" HorizontalAlignment="Left" x:Name="expander1" VerticalAlignment="Top" Width="254" Header="频道选择" Margin="1,73,0,0" RenderTransformOrigin="0.5,0.5" Grid.Row="3"> |
254 |
<Expander.RenderTransform> |
259 |
<TranslateTransform/> |
261 |
</Expander.RenderTransform> |
262 |
<WrapPanel Height="24" Name="wrapPanel1" Width="244" > |
263 |
<RadioButton Content="动漫" Height="26" Name="radioButton1" IsChecked="False" Checked="radioButton1_Checked" /> |
264 |
<RadioButton Content="华语" Height="26" Name="radioButton2" Checked="radioButton2_Checked" /> |
265 |
<RadioButton Content="欧美" Height="26" Name="radioButton3" Checked="radioButton3_Checked" /> |
266 |
<RadioButton Content="日语" Height="26" Name="radioButton4" Checked="radioButton4_Checked" /> |
267 |
<RadioButton Content="韩语" Height="26" Name="radioButton5" Checked="radioButton5_Checked" /> |
270 |
<Rectangle Height="15" HorizontalAlignment="Left" Margin="35,146,0,0" x:Name="rectangle1" Stroke="Black" VerticalAlignment="Top" Width="185" StrokeThickness="0" Grid.RowSpan="2"> |
272 |
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> |
273 |
<GradientStop Color="Black" Offset="1" /> |
274 |
<GradientStop Color="Transparent" Offset="0.099" /> |
275 |
</LinearGradientBrush> |
278 |
<Rectangle Height="185" HorizontalAlignment="Left" Margin="218,10,0,0" x:Name="rectangle2" Stroke="Black" VerticalAlignment="Top" Width="15" StrokeThickness="0" Grid.Row="1"> |
280 |
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5"> |
281 |
<GradientStop Color="Black" Offset="0" /> |
282 |
<GradientStop Color="Transparent" Offset="0.814" /> |
283 |
</LinearGradientBrush> |
286 |
<Rectangle Height="20" HorizontalAlignment="Left" Margin="35,190,0,0" x:Name="rectangle4" Stroke="Black" VerticalAlignment="Top" Width="185" StrokeThickness="0" Grid.Row="1" Grid.RowSpan="2"> |
288 |
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> |
289 |
<GradientStop Color="Black" Offset="0" /> |
290 |
<GradientStop Color="Transparent" Offset="0.872" /> |
291 |
</LinearGradientBrush> |
294 |
<Rectangle Height="185" HorizontalAlignment="Left" Margin="23,10,0,0" x:Name="rectangle3" Stroke="Black" VerticalAlignment="Top" Width="15" StrokeThickness="0" Grid.Row="1"> |
296 |
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5"> |
297 |
<GradientStop Color="Black" Offset="1" /> |
298 |
<GradientStop Color="Transparent" Offset="0.099" /> |
299 |
</LinearGradientBrush> |
302 |
<Image Grid.Row="1" Height="185" HorizontalAlignment="Left" Margin="35,10,0,0" Name="image2" Stretch="UniformToFill" VerticalAlignment="Top" Width="185" Source="/SkyMuisc;component/Images/20100829224935145.png" /> |
303 |
<Image Height="185" HorizontalAlignment="Left" Margin="35,10,0,0" x:Name="image1" Stretch="UniformToFill" VerticalAlignment="Top" Width="185" Source="{Binding ElementName=textBox1,Path=Text}" Grid.Row="1" ToolTip="专辑图片" /> |
304 |
<Rectangle Height="28" HorizontalAlignment="Left" Margin="35,197,0,0" x:Name="rectangle5" Stroke="Black" VerticalAlignment="Top" Width="185" Stretch="UniformToFill" StrokeThickness="0" Grid.Row="1" Grid.RowSpan="2" > |
306 |
<VisualBrush Visual="{Binding ElementName=image1}"> |
307 |
<VisualBrush.RelativeTransform > |
309 |
<ScaleTransform ScaleX="1" ScaleY="-1"/> |
310 |
<TranslateTransform Y="1"/> |
312 |
</VisualBrush.RelativeTransform> |
315 |
<Rectangle.OpacityMask> |
316 |
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> |
317 |
<GradientStop Color="Black" Offset="0" /> |
318 |
<GradientStop Color="#2DFFFFFF" Offset="0.081" /> |
319 |
</LinearGradientBrush> |
320 |
</Rectangle.OpacityMask> |
322 |
<TextBlock Height="23" HorizontalAlignment="Left" Margin="31,31,0,0" x:Name="textBlock1" Text="歌曲:" VerticalAlignment="Top" /> |
323 |
<TextBlock Height="23" HorizontalAlignment="Left" Margin="31,69,0,0" x:Name="textBlock2" Text="演唱:" VerticalAlignment="Top" /> |
324 |
<TextBlock Height="23" HorizontalAlignment="Left" Margin="31,106,0,0" x:Name="textBlock3" Text="专辑:" VerticalAlignment="Top" /> |
325 |
<TextBlock Height="40" HorizontalAlignment="Left" Margin="85,31,0,0" x:Name="textBlocksong" Text="无" VerticalAlignment="Top" Width="163" TextWrapping="Wrap" /> |
326 |
<TextBlock Height="23" HorizontalAlignment="Left" Margin="85,69,0,0" x:Name="textBlocksing" Text="无" VerticalAlignment="Top" Width="163" /> |
327 |
<TextBlock Height="42" HorizontalAlignment="Left" Margin="85,106,0,0" x:Name="textBlockalbum" Text="无" VerticalAlignment="Top" Width="163" TextWrapping="Wrap" /> |
328 |
<MediaElement Grid.Row="1" Height="42" HorizontalAlignment="Left" Margin="5,38,0,0" Name="mediaElementsong" VerticalAlignment="Top" Width="26" UnloadedBehavior="Manual" MediaEnded="mediaElementsong_MediaEnded" MediaFailed="mediaElementsong_MediaFailed" /> |
329 |
<TextBox Grid.RowSpan="2" Height="243" HorizontalAlignment="Left" Margin="12,20,0,0" Name="textBox1" VerticalAlignment="Top" Width="246" TextWrapping="Wrap" FontSize="12" Visibility="Hidden" /> |
330 |
<Button Content="Button" HorizontalAlignment="Left" Margin="69,0,0,66" Style="{DynamicResource ButtonStyle1}" Width="40" Height="40" VerticalAlignment="Bottom" Grid.Row="3" Name="buttonstart" Click="buttonstart_Click" ToolTip="播放" IsEnabled="False" /> |
331 |
<Button Content="Button" HorizontalAlignment="Left" Margin="70,0,0,66" Style="{DynamicResource ButtonStyle2}" Width="40" Height="40" VerticalAlignment="Bottom" Grid.Row="3" Name="buttonpause" Visibility="Collapsed" Click="buttonpause_Click" ToolTip="暂停" /> |
332 |
<Button Content="Button" HorizontalAlignment="Left" Margin="115,0,0,66" Style="{DynamicResource ButtonStyle3}" Width="40" Height="40" VerticalAlignment="Bottom" Grid.Row="3" Name="buttonnext" Click="buttonnext_Click" Visibility="Visible" IsEnabled="False" ToolTip="下一首" /> |
333 |
<Button Content="Button" HorizontalAlignment="Left" Margin="161,0,0,66" Style="{DynamicResource ButtonStyle4}" Width="40" Height="40" VerticalAlignment="Bottom" Grid.Row="3" Name="buttondown" Click="buttondown_Click" ToolTip="下载到桌面" IsEnabled="False" /> |
334 |
<CheckBox Content="玻璃效果" Height="22" HorizontalAlignment="Left" Margin="25,5,0,0" Name="checkBox1" VerticalAlignment="Top" IsChecked="True" Unchecked="checkBox1_Unchecked" Checked="checkBox1_Checked" /> |
335 |
<TextBlock Height="31" HorizontalAlignment="Left" Margin="70,127,0,0" Name="textBlock4" Text="正在初始化......" VerticalAlignment="Top" Foreground="#FFEB1B1B" Grid.RowSpan="2" FontSize="18" /> |
336 |
<ProgressBar Grid.Row="3" Height="10" HorizontalAlignment="Left" Margin="47,6,0,0" Name="progressBar1" VerticalAlignment="Top" Width="168" Panel.ZIndex="1" ToolTip="进度" IsEnabled="True" Background="#78DECACA"> |
337 |
<ProgressBar.Foreground> |
338 |
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> |
339 |
<GradientStop Color="#FF0A0705" Offset="1" /> |
340 |
<GradientStop Color="#FF56585C" Offset="0" /> |
341 |
<GradientStop Color="Black" Offset="0.459" /> |
342 |
</LinearGradientBrush> |
343 |
</ProgressBar.Foreground> |
345 |
<TextBlock Grid.Row="3" Height="19" HorizontalAlignment="Left" Margin="219,2,0,0" Name="textBlock5" Text="00:00" VerticalAlignment="Top" FontSize="14" Width="37" /> |
346 |
<TextBlock FontSize="14" Height="19" HorizontalAlignment="Left" Margin="7,2,0,0" Name="textBlock6" Text="00:00" VerticalAlignment="Top" Width="37" Grid.Row="3" /> |
347 |
<Label Content="{x:Static System:Environment.UserName}" Height="38" HorizontalAlignment="Left" Margin="115,-1,0,0" Name="label1" VerticalAlignment="Top" Width="59" Visibility="Collapsed" /> |
348 |
<Expander Header="定时关机" Height="100" HorizontalAlignment="Left" Margin="124,7,0,0" Name="expander2" VerticalAlignment="Top" Width="132" BorderThickness="3"> |
350 |
<TextBox Height="23" HorizontalAlignment="Left" Margin="8,6,0,0" Name="textBox2" VerticalAlignment="Top" Width="46" BorderThickness="2" BorderBrush="#E6000000" Background="#00000000" FontSize="14" HorizontalContentAlignment="Center" TextAlignment="Center" Text="" /> |
351 |
<TextBlock Height="23" HorizontalAlignment="Left" Margin="59,6,0,0" Name="textBlock7" Text="分钟关机" VerticalAlignment="Top" Width="66" /> |
352 |
<CheckBox Content="确定" Height="25" HorizontalAlignment="Left" Margin="37,36,0,0" Name="checkBox2" VerticalAlignment="Top" Width="56" Checked="checkBox2_Checked" Unchecked="checkBox2_Unchecked" /> |
C#:
002 |
using System.Collections.Generic; |
005 |
using System.Windows; |
006 |
using System.Windows.Controls; |
007 |
using System.Windows.Data; |
008 |
using System.Windows.Documents; |
009 |
using System.Windows.Input; |
010 |
using System.Windows.Media; |
011 |
using System.Windows.Media.Imaging; |
012 |
using System.Windows.Navigation; |
013 |
using System.Windows.Shapes; |
014 |
using System.Windows.Interop; |
015 |
using System.Runtime.InteropServices; |
017 |
using System.Xml.Linq; |
019 |
using System.Windows.Threading; |
023 |
/// MainWindow.xaml 的交互逻辑 |
025 |
public partial class MainWindow : Window |
027 |
public string albumurl; |
028 |
public string[] title1 = new string[80]; |
029 |
public string[] album_name1 = new string[80]; |
030 |
public string[] artist1 = new string[80]; |
031 |
public string[] pic1 = new string[80]; |
032 |
public string[] location1 = new string[80]; |
033 |
public int x = 0,y=0,z=0,w=0; |
034 |
DispatcherTimer t = new DispatcherTimer(); |
035 |
DispatcherTimer t1 = new DispatcherTimer(); |
038 |
InitializeComponent(); |
041 |
[StructLayout(LayoutKind.Sequential)] |
042 |
public struct MARGINS |
044 |
public int cxLeftWidth; |
045 |
public int cxRightWidth; |
046 |
public int cyTopHeight; |
047 |
public int cyBottomHeight; |
050 |
[DllImport("DwmApi.dll")] |
051 |
public static extern int DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS pMarInset); |
052 |
[DllImport("user32.dll", EntryPoint = "SendMessage")] |
053 |
public static extern int SendMessage(int hWnd, int wMsg, int wParam, int lParam); |
054 |
[DllImport("user32.dll", EntryPoint = "ReleaseCapture")] |
055 |
public static extern int ReleaseCapture(); |
056 |
public const int WM_SysCommand = 0x0112; |
057 |
public const int SC_MOVE = 0xF012; |
058 |
[DllImport ("e_xitong.dll")] |
059 |
public static extern void guanji(); |
062 |
private void Window_Loaded(object sender, RoutedEventArgs e) |
066 |
StreamReader r = new StreamReader("stye.txt"); |
067 |
string radioche = r.ReadToEnd(); |
071 |
radioButton1.IsChecked = true; |
073 |
if (radioche == "华语") |
075 |
radioButton2.IsChecked = true; |
077 |
if (radioche == "欧美") |
079 |
radioButton3.IsChecked = true; |
081 |
if (radioche == "日语") |
083 |
radioButton4.IsChecked = true; |
085 |
if (radioche == "韩语") |
087 |
radioButton5.IsChecked = true; |
092 |
albumurl = albumid("动漫"); |
093 |
radioButton1.IsChecked = true; |
096 |
this.Background = Brushes.Transparent; |
097 |
ExtendAeroGlass(this); |
100 |
private void ExtendAeroGlass(Window window) |
105 |
IntPtr mainWindowPtr = new WindowInteropHelper(window).Handle; |
106 |
HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr); |
107 |
mainWindowSrc.CompositionTarget.BackgroundColor = Colors.Transparent; |
109 |
MARGINS margins = new MARGINS(); |
112 |
margins.cxLeftWidth = -1; |
113 |
margins.cxRightWidth = -1; |
114 |
margins.cyTopHeight = -1; |
115 |
margins.cyBottomHeight = -1; |
117 |
int hr = DwmExtendFrameIntoClientArea(mainWindowSrc.Handle, ref margins); |
120 |
checkBox1.IsChecked = false; |
121 |
MessageBox.Show("玻璃效果加载失败!"); |
124 |
catch (DllNotFoundException) |
126 |
Application.Current.MainWindow.Background = Brushes.White; |
129 |
private void Window_MouseDown(object sender, MouseButtonEventArgs e) |
131 |
IntPtr mainWindowPtr = new WindowInteropHelper(this).Handle; |
132 |
HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr); |
134 |
SendMessage(mainWindowSrc.Handle.ToInt32(), WM_SysCommand, SC_MOVE, 0); |
137 |
private void buttonstart_Click(object sender, RoutedEventArgs e) |
140 |
buttonnext.IsEnabled = true; |
141 |
buttonstart.Visibility = Visibility.Collapsed; |
142 |
buttonpause.Visibility = Visibility.Visible; |
143 |
textBlock4.Visibility = Visibility.Collapsed; |
148 |
mediaElementsong.Volume = 1; |
149 |
t.Interval = new TimeSpan(0,0,1); |
151 |
t.Tick += new EventHandler(t_Tick); |
155 |
void t_Tick(object sender, EventArgs e) |
159 |
textBlock5.Text = (mediaElementsong.NaturalDuration).ToString().Substring(3, 5); |
160 |
textBlock6.Text = (mediaElementsong.Position).ToString().Substring(3, 5); |
161 |
progressBar1.Value =(int)(((double.Parse(textBlock6.Text.Substring(0, 2)) * 60 + double.Parse(textBlock6.Text.Substring(3, 2))) |
162 |
/ (double.Parse(textBlock5.Text.Substring(0, 2)) * 60 + double.Parse(textBlock5.Text.Substring(3, 2)))) * 100); |
168 |
private void buttonpause_Click(object sender, RoutedEventArgs e) |
171 |
buttonstart.Visibility = Visibility.Visible; |
172 |
buttonpause.Visibility = Visibility.Collapsed; |
173 |
mediaElementsong.Volume = 0; |
179 |
private void buttonnext_Click(object sender, RoutedEventArgs e) |
181 |
buttonstart.Visibility = Visibility.Collapsed; |
182 |
buttonpause.Visibility = Visibility.Visible; |
185 |
progressBar1.Value = 0; |
186 |
t.Interval = new TimeSpan(0, 0, 1); |
188 |
t.Tick += new EventHandler(t_Tick); |
191 |
private void nextSong() |
199 |
textBlock4.Visibility = Visibility.Collapsed; |
203 |
textBlock4.Visibility = Visibility.Visible; |
204 |
textBlock4.Text = "加载下一专辑中..."; |
208 |
textBlock4.Visibility = Visibility.Collapsed; |
217 |
private void information() |
221 |
textBlocksing.Text = artist1[x]; |
222 |
textBlocksong.Text = title1[x]; |
223 |
textBlockalbum.Text = album_name1[x]; |
224 |
textBox1.Text = pic1[x]; |
225 |
mediaElementsong.Source = new Uri(location1[x]); |
226 |
mediaElementsong.Play(); |
227 |
Binding bing = new Binding(); |
228 |
bing.Source = textBox1; |
229 |
bing.Path = new PropertyPath("Text"); |
230 |
image1.SetBinding(TextBox.TextProperty, bing); |
235 |
MessageBox.Show("没有地址!!"); |
240 |
private void buttondown_Click(object sender, RoutedEventArgs e) |
248 |
MessageBox.Show("出什么问题了?下不了"); |
251 |
private string albumid(string some) |
254 |
XDocument xdo = XDocument.Load("albumid/"+some+".xml"); |
255 |
var album = (from query in xdo.Elements("album") |
256 |
select query).FirstOrDefault().Value.Split(']'); |
257 |
Random rid = new Random(); |
258 |
id=album[rid.Next(0, 200)]; |
262 |
private void radioButton1_Checked(object sender, RoutedEventArgs e) |
266 |
albumurl = albumid("动漫"); |
269 |
StreamWriter win = new StreamWriter("stye.txt"); |
280 |
private void radioButton2_Checked(object sender, RoutedEventArgs e) |
282 |
albumurl = albumid("华语"); |
285 |
StreamWriter win = new StreamWriter("stye.txt"); |
290 |
private void radioButton3_Checked(object sender, RoutedEventArgs e) |
292 |
albumurl = albumid("欧美"); |
295 |
StreamWriter win = new StreamWriter("stye.txt"); |
300 |
private void radioButton4_Checked(object sender, RoutedEventArgs e) |
302 |
albumurl = albumid("日语"); |
305 |
StreamWriter win = new StreamWriter("stye.txt"); |
310 |
private void radioButton5_Checked(object sender, RoutedEventArgs e) |
312 |
albumurl = albumid("韩语"); |
315 |
StreamWriter win = new StreamWriter("stye.txt"); |
319 |
private void xmlMusic(string some) |
322 |
WebClient webc = new WebClient(); |
323 |
webc.OpenReadAsync(new Uri(httpurl + some + "/type/3")); |
324 |
webc.OpenReadCompleted += new OpenReadCompletedEventHandler(webc_OpenReadCompleted); |
327 |
void webc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) |
329 |
int a = 1, b = 1, c = 1, d = 1, e1 = 1, f = 1, g = 1, h = 1, j = 1, k = 1; |
331 |
songApi songuri = new songApi(); |
334 |
using (StreamReader read = new StreamReader(e.Result, Encoding.UTF8)) |
336 |
webxml = read.ReadToEnd(); |
338 |
for (int i = 0; i < 60; i++) |
342 |
a = webxml.IndexOf("<title><![CDATA[", a + 16); |
343 |
b = webxml.IndexOf("]]></title>", b + 11); |
344 |
title1[i] = webxml.Substring(a + 16, b - a - 16); |
346 |
c = webxml.IndexOf("<album_name><![CDATA[", c + 21); |
347 |
d = webxml.IndexOf("]]></album_name>", d + 16); |
348 |
album_name1[i] = webxml.Substring(c + 21, d - c - 21); |
350 |
e1 = webxml.IndexOf("<artist>", e1 + 8); |
351 |
f = webxml.IndexOf("</artist>", f + 9); |
352 |
artist1[i] = webxml.Substring(e1 + 8, f - e1 - 8); |
354 |
g = webxml.IndexOf("<location>", g + 10); |
355 |
h = webxml.IndexOf("</location>", h + 11); |
356 |
location1[i] = songuri.GetLocation(webxml.Substring(g + 10, h - g - 10)); |
358 |
j = webxml.IndexOf("<pic>", j + 5); |
359 |
k = webxml.IndexOf("</pic>", k + 6); |
360 |
string p = webxml.Substring(j + 5, k - j - 5); |
361 |
pic1[i] = p.Replace("_1", "_2"); |
369 |
textBlock4.Text = "按播放键,播放"; |
370 |
buttonstart.IsEnabled = true; |
371 |
buttondown.IsEnabled = true; |
377 |
MessageBox.Show ("貌似网络不行~\\(≧▽≦)//~啦啦啦"); |
380 |
private void checkBox1_Unchecked(object sender, RoutedEventArgs e) |
384 |
ImageBrush back = new ImageBrush(); |
385 |
back.ImageSource = new BitmapImage(new Uri("Images/back.jpg", UriKind.Relative)); |
386 |
this.Background = back; |
390 |
MessageBox.Show("找不到图back.jpg!"); |
391 |
this.Background = Brushes.SkyBlue; |
397 |
private void checkBox1_Checked(object sender, RoutedEventArgs e) |
399 |
this.Background = Brushes.Transparent; |
403 |
private void mediaElementsong_MediaEnded(object sender, RoutedEventArgs e) |
412 |
private void mediaElementsong_MediaFailed(object sender, ExceptionRoutedEventArgs e) |
414 |
textBlock4.Visibility = Visibility.Visible; |
415 |
textBlock4.Text = "歌曲加载失败!!"; |
417 |
private void MenuItem2_Click(object sender, RoutedEventArgs e) |
422 |
private void MenuItem1_Click(object sender, RoutedEventArgs e) |
424 |
MessageBox.Show("作者:无限的天空1989" + '\n' + "联系方式:gaozhao0331@163.com" + |
1 |
'\n' + "说明:本软件音乐资源使用《虾米网》,纯" + '\n' + "属个人娱乐作品,有不足出错的地方请见谅."); |