public void UpdateMedia(Media FinalMedia)
        {
            DataTable table = _MCDB.Tables["csv"];

            DataRow[] foundRows;
            foundRows = table.Select("ID = " + FinalMedia.GetID().ToString());
            DataRow DR = foundRows[0];
            
            DR["Type"] = FinalMedia.GetType().Name;
            DR["Name"] = FinalMedia.GetName();
            DR["Path"] = FinalMedia.GetPath();
            DR["Size"] = FinalMedia.GetSize();
            DR["Rating"] = FinalMedia.GetRating();
            DR["AudioType"] = "";
            DR["IsHD"] = "";

            if (FinalMedia.GetType().Name.Equals("Video"))
            {
                DR["IsHD"] = ((Video)FinalMedia).IsHD();
            }
            if (FinalMedia.GetType().Name.Equals("Audio"))
            {
                DR["AudioType"] = ((Audio)FinalMedia).GetAudioType();
            }
        }
        private void EditMedia_Click(object sender, RoutedEventArgs e)
        {
            DataRow selectedRow = ((DataRowView)GetSelectedRow().DataContext).Row;
            Boolean valid = false;
            if (((String)selectedRow["Type"]).Equals("Video"))
            {
                _SelectedMedia = new Video((String)selectedRow["Name"], (String)selectedRow["Path"], (String)selectedRow["Size"], Int32.Parse((String)selectedRow["Rating"]), (((String)selectedRow["IsHD"]).Equals("true")));
                valid = true;
            }
            else if (((String)selectedRow["Type"]).Equals("Audio"))
            {
                _SelectedMedia = new Audio((String)selectedRow["Name"], (String)selectedRow["Path"], (String)selectedRow["Size"], Int32.Parse((String)selectedRow["Rating"]), (String)selectedRow["AudioType"]);
                valid = true;
            }
            else if (((String)selectedRow["Type"]).Equals("Image"))
            {
                _SelectedMedia = new Image((String)selectedRow["Name"], (String)selectedRow["Path"], (String)selectedRow["Size"], Int32.Parse((String)selectedRow["Rating"]));
                valid = true;
            }

            if (valid)
            {
                _SelectedMedia.SetID(Int32.Parse((String)selectedRow["ID"]));

                Debug debug = new Debug();
                debug.Show("APPEL EDITMEDIA AVEC ID " + _SelectedMedia.GetID());

                MediaWindow mediaWindow = new MediaWindow(_SelectedMedia);
                mediaWindow.ShowDialog();
            }
             
        }
        //This is the constructor called in case of a Media Edit, meaning we need to fill the contents
        public MediaWindow(Media editMedia)
        {
            InitializeComponent();
            MediaLabel.Content = "Edit Media";
            Submit.Content = "Save";
            Submit.IsEnabled = true;

            MediaIDLabel.Visibility = System.Windows.Visibility.Visible;
            MediaID.Text = editMedia.GetID().ToString();
            MediaID.Visibility = System.Windows.Visibility.Visible;
            
            MediaName.Text      = editMedia.GetName();
            MediaPath.Text      = editMedia.GetPath();
            MediaSize.Text      = editMedia.GetSize();
            MediaRating.Value   = editMedia.GetRating();
            
            if (editMedia.GetType().Name.Equals("Video"))
            {
                MediaVideoQualityLabel.IsEnabled = true;
                MediaVideoQuality.IsEnabled = true;
                MediaVideoQuality.IsChecked = ((Video)(editMedia)).IsHD();
                _mediaType = MediaType.Video;
            }
            else if (editMedia.GetType().Name.Equals("Audio"))
            {
                MediaAudioType.Text = ((Audio)(editMedia)).GetAudioType().ToString();
                _mediaType = MediaType.Audio;
            }
            else if (editMedia.GetType().Name.Equals("Image"))
            {
                _mediaType = MediaType.Image;
            }
            _edit = true;
        }
        public void AddMedia(Media FinalMedia)
        {
            DataTable table = _MCDB.Tables["csv"];

            DataRow DR = table.NewRow();

            DR["ID"] = Int32.Parse(((String) table.Compute("Max(ID)", String.Empty))) + 1;
            DR["Type"] = FinalMedia.GetType().Name;
            DR["Name"] = FinalMedia.GetName();
            DR["Path"] = FinalMedia.GetPath();
            DR["Size"] = FinalMedia.GetSize();
            DR["Rating"] = FinalMedia.GetRating();
            
            if (FinalMedia.GetType().Name.Equals("Video"))
            {
                DR["IsHD"] = ((Video) FinalMedia).IsHD();
            }
            if (FinalMedia.GetType().Name.Equals("Audio"))
            {
                DR["AudioType"] = ((Audio) FinalMedia).GetAudioType();
            }
            
            table.Rows.Add(DR);
        }
Exemple #5
0
 public Media GetMedia(Int32 id)
 {
     return(this._mediaList.Find(Media => Media.GetID() == id));
 }
Exemple #6
0
 public void AddMedia(Media media)
 {
     this._mediaList.Add(media);
 }
 public void AddMedia(Media media)
 {
     this._mediaList.Add(media);
 }