Ejemplo n.º 1
0
        /// <summary>
        /// Открытие файла из истории
        /// </summary>
        private void openButton_Click(object sender, RoutedEventArgs e)
        {
            button_animation_size(openFileButton);

            if (HistoryGrid.SelectedItems.Count > 0)
            {
                MediaHistory mHisory = HistoryGrid.SelectedItem as MediaHistory;

                MainWindow winPlayer = new MainWindow();
                winPlayer.Show();
                winPlayer.historyMediaOpen(sender, e, mHisory.Path);
                this.Close();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Действия при открытии файла
        /// </summary>
        private void MediaPlayer_MediaOpened(object sender, RoutedEventArgs e)
        {
            panel_like.Visibility         = Visibility.Hidden;
            img_LikeOrDislike.Visibility  = Visibility.Hidden;
            img_LikeOrDislike.Opacity     = 1;
            img_LikeOrDislike.Width       = 64;
            img_LikeOrDislike.Height      = 64;
            dockPael_MediaElement.Opacity = 1;
            panel_like.Opacity            = 1;

            try
            {
                MediaPlayer.Volume  = (double)slider_volume.Value;
                slider_seek.Maximum = MediaPlayer.NaturalDuration.TimeSpan.TotalMilliseconds;

                timer.Interval = new TimeSpan(0, 0, 1);
                timer.Start();

                MediaHistory mediafile = new MediaHistory();
                mediafile.Name = System.IO.Path.GetFileName(filename);
                TimeSpan timeSpan = TimeSpan.FromSeconds(Convert.ToInt32(MediaPlayer.NaturalDuration.TimeSpan.TotalSeconds));
                mediafile.Duration = string.Format("{0:D2}:{1:D2}:{2:D2}", timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds);
                mediafile.Date     = DateTime.Now;
                mediafile.Favorite = false;
                mediafile.Path     = filename;
                mediafileCash      = mediafile;

                using (MediaHistoryContext db = new MediaHistoryContext())
                {
                    db.Media.Add(mediafile);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка воспроизведения файла!" + ex.Message, "MediaPlayerApp", MessageBoxButton.OK, MessageBoxImage.Error);
                fileIsDrop = false;
                filename   = null;
                buttom_menu_fileOpen_Click(sender, e);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Удаление фрагментов из избранного и истории
 /// </summary>
 private void deleteButton_Click(object sender, RoutedEventArgs e)
 {
     button_animation_size(deleteButton);
     if (HistoryGrid.SelectedItems.Count > 0)
     {
         for (int i = 0; i < HistoryGrid.SelectedItems.Count; i++)
         {
             MediaHistory mHisory = HistoryGrid.SelectedItems[i] as MediaHistory;
             if (mHisory != null)
             {
                 db.Media.Remove(mHisory);
             }
         }
     }
     db.SaveChanges();
     if (favoriteOpen)
     {
         db = new MediaHistoryContext();
         db.Media.Load();
         var BindingList = db.Media.Local.ToBindingList();
         HistoryGrid.ItemsSource = from a in BindingList where (a as MediaHistory).Favorite == true select a;
         this.Closing           += History_Closing;
     }
 }