Esempio n. 1
0
        public void ReloadShowNames()
        {
            IEnumerable <string> files = null;

            try
            {
#if NOT_NET4
                files = Directory.GetDirectories(Location);
#else
                files = Directory.EnumerateDirectories(Location);
#endif
            }
            catch (Exception e)
            {
                string msg = "ShowMedia::ReloadShowNames(): Error while listing directories.\n" + e.ToString();
                Program.LogWrite(msg);
                MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            ShowNames.Clear();
            ShowMedia.Clear();

            foreach (string currentFile in files)
            {
                string fileName = currentFile.Substring(Location.Length);
                //MessageBox.Show("Location = " + Location + "\n\nLength = " + Location.Length.ToString() + "\n\n" + currentFile + "\n\n" + fileName);

                if (!fileName.Equals("PlayLists", StringComparison.CurrentCultureIgnoreCase))
                {
                    ShowNames.Add(fileName);
                    ShowMedia.Add(new TrackCollection(engine, fileName, Location + fileName + Settings.slash));
                }
            }
        }
Esempio n. 2
0
        public Track FindTrackByName(string ShowName, string TrackName)
        {
            var show = ShowMedia.Find(
                delegate(TrackCollection trackCollection)
            {
                return(trackCollection.Name.Equals(ShowName));
            }
                );

            if (show == null)
            {
                throw new InvalidShowNameFoundException(ShowName);
            }
#if NOT_NET4
            Track result = null;
            foreach (Track t in show.Tracks)
            {
                if (t.Name.Equals(TrackName))
                {
                    result = t;
                    break;
                }
            }
#else
            var result = show.Tracks.First(track => track.Name.Equals(TrackName));
#endif

            /*var result = show.Tracks.Find(
             *  delegate(Track track)
             *  {
             *      return track.Name.Equals(TrackName);
             *  }
             *  );
             */
            if (result == null)
            {
                throw new InvalidTrackFoundException(ShowName + Settings.slash + TrackName);
            }

            return(result);
        }
        /// <summary>
        /// Handles the OnMouseDoubleClick event of the DataGridPopularItems control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MouseButtonEventArgs"/> instance containing the event data.</param>
        private void DataGridPopularItems_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            // Continue only if a ROW was clicked
                        DataGridRow row =
                            ItemsControl.ContainerFromElement((DataGrid) sender, e.OriginalSource as DependencyObject)
                            as DataGridRow;
                        if ( row == null ) return;

                        // Continue only if a valid COLUMN was clicked
                        string columnClicked = ( (DataGrid) sender ).CurrentCell.Column.Header.ToString();
                        if ( columnClicked.IsAnyOf("X") ) return;

                        // Get ID of item from row
                        DataRowView drView = DataGridPopularItems.SelectedItem as DataRowView;
                        if ( drView == null ) return;
                        DataRow itemData = drView.Row;
                        int itemId = Convert.ToInt32(itemData.ItemArray.GetValue(0));

                        ShowMedia ShowItem = new ShowMedia(itemId);

                        ( Application.Current.MainWindow as MainWindow ).ShowPopup(ShowItem);
        }
Esempio n. 4
0
        public void UpdateTrackDisplay(string ShowName)
        {
            var item = ShowMedia.Find(
                delegate(TrackCollection t)
            {
                return(t.Name.Equals(ShowName));
            }
                );

            if (item == null)
            {
                throw new InvalidShowNameFoundException();
            }
            TrackDisplayList.Items.Clear();

            if (item != null)
            {
                foreach (Track t in item.Tracks)
                {
                    TrackDisplayList.Items.Add(t.Name).SubItems.Add(t.Duration);
                }
            }
        }