private void RepeatButton_Click(object sender, RoutedEventArgs e) { Button but = sender as Button; if (!isRepeat && !Player.settings.getMode("loop")) { but.MouseLeave -= Button_MouseLeave; ((Path)but.FindName(but.Name + "Path")).Fill = new SolidColorBrush(Color.FromRgb(255, 255, 255)); PathGeometry pg = new PathGeometry(); pg.FillRule = FillRule.Nonzero; PathFigureCollectionConverter pfcc = new PathFigureCollectionConverter(); pg.Figures = (PathFigureCollection)pfcc.ConvertFrom("M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4zm-4-2V9h-1l-2 1v1h1.5v4H13z"); ((Path)but.FindName(but.Name + "Path")).Data = pg; Player.settings.setMode("loop", true); } else { Player.settings.setMode("loop", false); if (!isRepeat) { PathGeometry pg = new PathGeometry(); pg.FillRule = FillRule.Nonzero; PathFigureCollectionConverter pfcc = new PathFigureCollectionConverter(); pg.Figures = (PathFigureCollection)pfcc.ConvertFrom("M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z"); ((Path)but.FindName(but.Name + "Path")).Data = pg; isRepeat = true; } else { isRepeat = false; but.MouseLeave += Button_MouseLeave; ((Path)but.FindName(but.Name + "Path")).Fill = new SolidColorBrush(Color.FromRgb(98, 114, 123)); } } }
public ContentAttributeExample() { var pfcc = new PathFigureCollectionConverter(); const string Figures = "M 20,20 L 140,20 L 140,140 L 20,140 L 20,20 M 80,30 L 130,80 L 80,130 L 30,80 L 80,30 M 60,60 L 100,60 L 100,100 L 60,100 L 60,60 M 80,65 L 95,80 L 80,95 L 65,80 L 80,65"; var pfc = (PathFigureCollection)pfcc.ConvertFrom(Figures); var path = new Path { Stroke = Brushes.Blue, StrokeThickness = 1.5, Fill = Brushes.LightBlue, StrokeStartLineCap = PenLineCap.Square, StrokeEndLineCap = PenLineCap.Square, Opacity = 0.6, Data = new PathGeometry(pfc) { FillRule = FillRule.Nonzero } }; var panel = new StackPanel(); panel.Children.Add(new TextBlock { Text = "The ContentAttribute lets you mix text and figures. The figure is defined by\nM 20,20 L 140,20 L 140,140 L 20,140 L 20,20 M 80,30 L 130,80 L 80,130 L 30,80 L 80,30 M 60,60 L 100,60 L 100,100 L 60,100 L 60,60 M 80,65 L 95,80 L 80,95 L 65,80 L 80,65" }); panel.Children.Add(path); this.Content1 = panel; }
private void Player_PlayStateChange(int NewState) { // MessageBox.Show(NewState.ToString()); if (NewState == 3) { SongNameLabel.Content = String.Join(", ", Playlist[CurrentMediaIndex].Performers) + " - " + Playlist[CurrentMediaIndex].Title; } if (NewState == 8) { if (!Player.settings.getMode("loop")) { PathGeometry pg = new PathGeometry(); pg.FillRule = FillRule.Nonzero; PathFigureCollectionConverter pfcc = new PathFigureCollectionConverter(); pg.Figures = (PathFigureCollection)pfcc.ConvertFrom("M8 5v14l11-7z"); ToggleButtonPath.Data = pg; ((Path)FindName("PlayTrackButton" + CurrentMediaIndex.ToString() + "Path")).Data = pg; Player.controls.stop(); if (isRepeat) { if (CurrentMediaIndex + 1 == Playlist.Count) { CurrentMediaIndex = 0; Player.currentMedia = Playlist[CurrentMediaIndex].Media; } else { CurrentMediaIndex++; Player.currentMedia = Playlist[CurrentMediaIndex].Media; } } else { if (CurrentMediaIndex + 1 != Playlist.Count) { CurrentMediaIndex++; Player.currentMedia = Playlist[CurrentMediaIndex].Media; } } System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 10); dispatcherTimer.Start(); } } }
private void TrackPlayButton_Click(object sender, RoutedEventArgs e) { Button but = sender as Button; //("M8 5v14l11-7z"); M6 19h4V5H6v14zm8 - 14v14h4V5h - 4z if (CurrentMediaIndex == int.Parse(but.Name.Substring("PlayTrackButton".Length))) { PlayerToggle(); } else { PathGeometry pg = new PathGeometry(); pg.FillRule = FillRule.Nonzero; PathFigureCollectionConverter pfcc = new PathFigureCollectionConverter(); pg.Figures = (PathFigureCollection)pfcc.ConvertFrom("M8 5v14l11-7z"); ((Path)FindName("PlayTrackButton" + CurrentMediaIndex.ToString() + "Path")).Data = pg; Player.controls.stop(); CurrentMediaIndex = int.Parse(but.Name.Substring("PlayTrackButton".Length)); Player.currentMedia = Playlist[CurrentMediaIndex].Media; PlayerToggle(); } }
private void PrevButton_Click(object sender, RoutedEventArgs e) { PathGeometry pg = new PathGeometry(); pg.FillRule = FillRule.Nonzero; PathFigureCollectionConverter pfcc = new PathFigureCollectionConverter(); pg.Figures = (PathFigureCollection)pfcc.ConvertFrom("M8 5v14l11-7z"); ((Path)FindName("PlayTrackButton" + CurrentMediaIndex.ToString() + "Path")).Data = pg; Player.controls.stop(); if (CurrentMediaIndex == 0) { CurrentMediaIndex = Playlist.Count - 1; Player.currentMedia = Playlist.Last().Media; } else { CurrentMediaIndex--; Player.currentMedia = Playlist[CurrentMediaIndex].Media; } PlayerToggle(); }
private void PlayerToggle() { if (Player.playState != WMPPlayState.wmppsPlaying) { Player.controls.play(); PathGeometry pg = new PathGeometry(); pg.FillRule = FillRule.Nonzero; PathFigureCollectionConverter pfcc = new PathFigureCollectionConverter(); pg.Figures = (PathFigureCollection)pfcc.ConvertFrom("M6 19h4V5H6v14zm8-14v14h4V5h-4z"); ToggleButtonPath.Data = pg; ((Path)FindName("PlayTrackButton" + CurrentMediaIndex.ToString() + "Path")).Data = pg; } else { Player.controls.pause(); PathGeometry pg = new PathGeometry(); pg.FillRule = FillRule.Nonzero; PathFigureCollectionConverter pfcc = new PathFigureCollectionConverter(); pg.Figures = (PathFigureCollection)pfcc.ConvertFrom("M8 5v14l11-7z"); ToggleButtonPath.Data = pg; ((Path)FindName("PlayTrackButton" + CurrentMediaIndex.ToString() + "Path")).Data = pg; } }
private void PlaylistButton_Click(object sender, RoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Multiselect = true; ofd.DefaultExt = ".mp3"; ofd.Filter = "Audio files (*.mp3)|*.mp3"; ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); if (ofd.ShowDialog() == true) { //Playlist.Clear(); foreach (string filename in ofd.FileNames) { var mp3File = TagLib.File.Create(filename); Playlist.Add(new Track { Media = Player.newMedia(filename), Title = mp3File.Tag.Title, Performers = mp3File.Tag.Performers, Duration = mp3File.Properties.Duration.ToString("mm\\:ss") }); Console.WriteLine("Artist: " + String.Join(", ", mp3File.Tag.Performers)); Console.WriteLine("Track number: " + mp3File.Tag.Track); Console.WriteLine("Title: " + mp3File.Tag.Title); Console.WriteLine("Album: " + mp3File.Tag.Album); Console.WriteLine("Year: " + mp3File.Tag.Year); Console.WriteLine("Genre: " + mp3File.Tag.FirstGenre); Console.WriteLine("Bitrate: " + mp3File.Properties.AudioBitrate + " kbps"); Console.WriteLine("Channels: " + mp3File.Properties.AudioChannels); Console.WriteLine("Duration: " + mp3File.Properties.Duration.ToString("mm\\:ss")); RowDefinition gridRow = new RowDefinition(); gridRow.Height = new GridLength(50); Style st = FindResource("PlayerButton") as Style; PlaylistGrid.RowDefinitions.Add(gridRow); Button TrackPlayButton = new Button() { Name = "PlayTrackButton" + (Playlist.Count - 1).ToString(), Style = st, Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255)), Background = Brushes.Transparent, Height = 40, Width = 40, Cursor = Cursors.Hand, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(10, 0, 10, 0), }; TrackPlayButton.MouseEnter += TrackPlayButton_MouseEnter; TrackPlayButton.MouseLeave += TrackPlayButton_MouseLeave; TrackPlayButton.Click += TrackPlayButton_Click; PathGeometry pg = new PathGeometry(); pg.FillRule = FillRule.Nonzero; PathFigureCollectionConverter pfcc = new PathFigureCollectionConverter(); pg.Figures = (PathFigureCollection)pfcc.ConvertFrom("M8 5v14l11-7z"); Path ButtonPath = new Path() { Name = "PlayTrackButton" + (Playlist.Count - 1).ToString() + "Path", Fill = new SolidColorBrush(Color.FromRgb(255, 255, 255)), Data = pg, Stretch = Stretch.Fill, Height = 15, Width = 11, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; Grid PathGrid = new Grid() { Width = 10, Height = 15, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; Label TrackName = new Label() { Content = String.Join(", ", mp3File.Tag.Performers) + " - " + mp3File.Tag.Title, Foreground = Brushes.White, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(60, 0, 0, 0), }; PathGrid.Children.Add(ButtonPath); TrackPlayButton.Content = PathGrid; Border Container = new Border() { Height = 50, Background = Brushes.Transparent, BorderBrush = new SolidColorBrush(Color.FromRgb(55, 70, 79)), BorderThickness = new Thickness(0, 0, 0, 2), Child = TrackPlayButton }; Grid.SetRow(Container, Playlist.Count - 1); Grid.SetColumn(Container, 0); Grid.SetRow(TrackName, Playlist.Count - 1); Grid.SetColumn(TrackName, 0); PlaylistGrid.Children.Add(Container); PlaylistGrid.Children.Add(TrackName); if (PlaylistGrid.FindName(ButtonPath.Name) == null) { PlaylistGrid.RegisterName(ButtonPath.Name, ButtonPath); } if (PlaylistScroll.Height < 250) { PlaylistScroll.Height += 50; } } } Player.controls.stop(); if (Playlist.Count > 0) { Player.currentMedia = Playlist[0].Media; CurrentMediaIndex = 0; PlayerToggle(); } }