//-----------------------Animations----------------------- private void MarqueeTrackName(string trackName) { TrackNameTextBlock.Text = trackName; TrackNameTextBlock.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); var Width = TrackNameTextBlock.DesiredSize.Width; double height = TrackNameWrapper.ActualHeight - TrackNameTextBlock.ActualHeight; TrackNameTextBlock.Margin = new Thickness(0, height / 2, 0, 0); Storyboard marquee = new Storyboard(); //Marquee DoubleAnimation marqueeAnimation = new DoubleAnimation { From = -Width, To = TrackNameWrapper.ActualWidth, RepeatBehavior = RepeatBehavior.Forever, Duration = new Duration(TimeSpan.FromSeconds(10)), }; Storyboard.SetTarget(marqueeAnimation, TrackNameTextBlock); Storyboard.SetTargetProperty(marqueeAnimation, new PropertyPath("(Canvas.Right)")); marquee.Children.Add(marqueeAnimation); //Apply marquee.Begin(this); }
private void ResetTrackUIs() { //Reset track name TrackNameTextBlock.BeginAnimation(Canvas.RightProperty, null); TrackNameTextBlock.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); var Width = TrackNameTextBlock.DesiredSize.Width; Canvas.SetRight(TrackNameTextBlock, (TrackNameWrapper.ActualWidth - Width) / 2); //Reset track time TimeTextBlock.Text = "00:00 | 00:00"; //Set Music Slider to start MusicSlider.Minimum = 0; MusicSlider.Maximum = 1; MusicSlider.Value = 0; }
//--------------------------Events-------------------------- private void Window_Loaded(object sender, RoutedEventArgs e) { //Stuffz threadz AddTracks = new BackgroundWorker() { WorkerReportsProgress = true, }; AddTracks.DoWork += AddTracks_DoWork; AddTracks.ProgressChanged += AddTracks_ProgressChanged; AddTracks.RunWorkerCompleted += AddTracks_RunWorkerCompleted; //Set stuffz TrackNameTextBlock.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); var Width = TrackNameTextBlock.DesiredSize.Width; Canvas.SetRight(TrackNameTextBlock, (TrackNameWrapper.ActualWidth - Width) / 2); model = Model.GetInstance(); MusicBox = MusicBox.getInstance(); MusicBox.SetTrackEndedEvent(LoopMode_trackEndEventHandler); MusicBox.SetMediaOpenedUIUpdate(MediaOpened_EventHandler); }