public MainWindow() { InitializeComponent(); Playlists playlists = new Playlists(this); account = new Account(); sliderVolume = sldVolume.Value; audioPlayer = new AudioPlayer(this); queuePage = new QueuePage(this); // DispatcherTimer setup dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += new EventHandler((object sender, EventArgs e) => { PlaceInSongSlider.Value = audioPlayer.CurrentPlaceInSongPercentage(); }); dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 10); dispatcherTimer.Start(); Main.Content = playlists; account.logout += () => { LoginWindow login = new LoginWindow(); login.Show(); this.Close(); }; TextInfo info = new CultureInfo("en-US", false).TextInfo; // search function that can be used everywhere in app, on enter function inputSearch.KeyDown += (object sender, KeyEventArgs e) => { if (e.Key == Key.Enter) { Main.Content = new SearchResults(info.ToTitleCase(inputSearch.Text), user, this); } }; //btnPlay.Click += (object sender, RoutedEventArgs e) => audioPlayer.OnButtonPlayClick(sender, e); //btnMute.Click += (object sender, RoutedEventArgs e) => audioPlayer.Mute(); sldVolume.ValueChanged += (object sender, RoutedPropertyChangedEventArgs <double> e) => { float value = (float)e.NewValue / 100; if (value >= .75) { PackIconVolume.Kind = MaterialDesignThemes.Wpf.PackIconKind.VolumeHigh; } else if (value >= .25 && value < .75) { PackIconVolume.Kind = MaterialDesignThemes.Wpf.PackIconKind.VolumeMedium; } else if (value > 0 && value < .25) { PackIconVolume.Kind = MaterialDesignThemes.Wpf.PackIconKind.VolumeLow; } else if (value == 0) { PackIconVolume.Kind = MaterialDesignThemes.Wpf.PackIconKind.VolumeOff; } audioPlayer.SetVolume(value); }; //btnAccount.Click += (object sender, RoutedEventArgs e) => Main.Content = account; btnPlaylists.Click += (object sender, RoutedEventArgs e) => Main.Content = new Playlists(this); }
private void ButtonClickQueue(object sender, RoutedEventArgs e) { if (Main.Content != queuePage) { queuePage.InitialiseQueuePage(); Main.Content = queuePage; } else { if (playlistSongs != null) { Main.Content = playlistSongs; } else { Playlists playlists = new Playlists(this); Main.Content = playlists; } } }