Example #1
0
        public void InitializeShow(iMetaLibrary.Metadata.TvShowMeta TvShowMeta, iMetaLibrary.Metadata.TvFileMeta[] Episodes)
        {
            /*
             * var enumerator = store.GetEnumerator();
             * while(enumerator.MoveNext())
             * {
             *      ((GuiComponents.TvEpisodeNodeItem)enumerator.Current).Meta.MetaUpdated -= MetaUpdated;
             * }
             */
            /*
             * store.Foreach(delegate(TreeModel modelOuter, TreePath pathOuter, TreeIter iterOuter)
             *           {
             *                              TreeIter childIter;
             *                              modelOuter.IterChildren(out childIter);
             *                              modelOuter.Foreach(delegate(TreeModel model, TreePath path, TreeIter iter)
             *                  {
             *                                      GuiComponents.TvEpisodeNodeItem node = model.GetValue(iter, 0) as GuiComponents.TvEpisodeNodeItem;
             *                                      if(node != null)
             *                                              node.Meta.MetaUpdated -= MetaUpdated;
             *                                      return true;
             *                              });
             *                              return true;
             *                       });
             */
            store.Clear();
            string showtitle = TvShowMeta == null ? Episodes[0].ShowTitle : TvShowMeta.Title;

            this.TvShowMeta = TvShowMeta;
            this.Episodes   = Episodes;
            //lblShowName.Markup = "<span font=\"18\" weight=\"bold\">{0}</span> <span size=\"small\"> [{1} Episode{2}]</span>".FormatStr(showtitle.HtmlEncode(), Episodes.Length, Episodes.Length == 1 ? "" : "s");

            if (Poster != null)
            {
                Poster.Dispose();
                Poster = null;
            }

            System.Drawing.Image poster = Episodes[0].GetPoster();
            if (poster != null)
            {
                Poster = GuiHelper.ImageToPixbufIcon(poster, 230, 320);
                poster.Dispose();
                poster = null;
            }
            SortedList <int, List <iMetaLibrary.Metadata.TvFileMeta> > seasons = new SortedList <int, List <iMetaLibrary.Metadata.TvFileMeta> >();

            foreach (iMetaLibrary.Metadata.TvFileMeta file in Episodes)
            {
                if (!seasons.ContainsKey(file.Season))
                {
                    seasons.Add(file.Season, new List <iMetaLibrary.Metadata.TvFileMeta>());
                }
                seasons[file.Season].Add(file);
            }
            foreach (int season in seasons.Keys)
            {
                var iter = store.AppendValues(new KeyNode(season == 0 ? "Specials" : "Season {0}".FormatStr(season)));
                foreach (iMetaLibrary.Metadata.TvFileMeta meta in seasons[season])
                {
                    store.AppendValues(iter, new GuiComponents.TvEpisodeNodeItem(meta));
                    meta.MetaUpdated += MetaUpdated;
                }
            }
            treeview.ExpandAll();
            //txtShowInfoTvdbId.Buffer.Text = TvShowMeta == null ? "" : TvShowMeta.Id.ToString();
            //txtShowInfoRuntime.Buffer.Text = TvShowMeta == null ? "" : TvShowMeta.Runtime.ToString();
            txtTitle.Text       = showtitle;
            txtMpaa.Text        = TvShowMeta == null ? "" : TvShowMeta.Mpaa;
            txtPremiered.Text   = TvShowMeta == null ? "" : TvShowMeta.Premiered;
            txtStudio.Text      = TvShowMeta == null ? "" : TvShowMeta.Studio;
            txtGenres.Text      = TvShowMeta == null ? "" : String.Join(", ", TvShowMeta.Genres);
            txtPlot.Buffer.Text = TvShowMeta == null ? "" : TvShowMeta.Plot;
            switch (TvShowMeta == null ? "" : TvShowMeta.Status)
            {
            // Continuing - Series currently still in production this is generally the status that should be set during the initial run of a season
            case "Continuing": cboStatus.Active = 0; break;

            // Ended - For a series which has finished it's run and is not producing any new episodes.
            case "Ended ": cboStatus.Active = 1; break;

            // On Hiatus - For series where the current season has ended and it's return status is unknown.
            case "On Hiatus": cboStatus.Active = 2; break;

            // Other - Not commonly used, potentially for series that are in production and have yet to air at all.
            default: cboStatus.Active = 3; break;
            }
            this.QueueDraw();
        }
Example #2
0
        private void SetupTvScanner()
        {
            #region setup the tv scanner
            this.TvScanner            = new iMetaLibrary.Scanners.TvScanner();
            this.TvScanner.Started   += delegate {  };
            this.TvScanner.Completed += delegate
            {
                if (notebook1.Page == 1)
                {
                    topbar.IsStatusPulsing = false;
                }
                UpdateStatusText("TV Shows: {0}, Episodes: {1}".FormatStr(TvScanner.NumberOfShows, TvScanner.Items.Count), false);
            };
            this.TvScanner.ItemAdded += delegate(Meta Item)
            {
                UpdateStatusText("Found Episode: {0}".FormatStr(Item.Filename), false);
            };
            this.TvScanner.ScanningItem += delegate(Meta Item)
            {
                UpdateStatusText("Scanning File: {0}".FormatStr(Item.Filename), false);
            };
            this.TvScanner.AllItemsFound += delegate(iMetaLibrary.Metadata.Meta[] NewItems) {
                List <TvShowNode> storeItems = new List <TvShowNode>();
                foreach (string key in TvScanner.Shows.Keys)                // need to check if already in the store...
                {
                    List <TvFileMeta> episodes = TvScanner.Shows[key];
                    // construct these off the main thread

                    var  enumerator = storeItems.GetEnumerator();
                    bool showfound  = false;
                    while (enumerator.MoveNext())
                    {
                        TvShowNode node = (TvShowNode)enumerator.Current;
                        if (node.Title.ToLower() == episodes[0].ShowTitle.ToLower())
                        {
                            showfound             = true;
                            node.NumberOfEpisodes = episodes.Count;
                            break;
                        }
                    }
                    if (!showfound)
                    {
                        System.Drawing.Image poster = episodes[0].GetPoster();
                        storeItems.Add(new TvShowNode()
                        {
                            Title            = episodes[0].ShowTitle,
                            NumberOfEpisodes = episodes.Count,
                            Poster           = poster == null ? Images.NoPosterSmallPixbuf : GuiHelper.ImageToPixbufIcon(poster, 120, 180)
                        });

                        if (poster != null)
                        {
                            poster.Dispose();
                        }
                    }
                }
                guiTvShowList.AddToStore(storeItems);
            };
            guiTvShowList.ItemActivated += delegate(string Label)
            {
                if (String.IsNullOrEmpty(Label) || TvScanner.Shows == null || !TvScanner.Shows.ContainsKey(Label))
                {
                    return;
                }
                TvShowMeta showmeta = TvScanner.Shows[Label][0].LoadShowMeta();

                Gtk.Application.Invoke(delegate
                {
                    // show the tv show gui
                    guiTvShow.InitializeShow(showmeta, TvScanner.Shows[Label].ToArray());
                    topbar.TvShowsButtonIsActive = false;
                    nbkTvShows.Page = 1;
                });
            };

            /*
             * btnTvBack.Activated += delegate {
             *      nbkTvShows.Page = 0;
             * };
             * btnTvFolders.Activated += delegate {
             *      using(iMetaGui.FolderListGui flg = new iMetaGui.FolderListGui("TV Folders", "Here you can configure the folders to scan for TV episodes.", iMetaLibrary.Settings.TvFolders)){
             *              flg.Run();
             *              if(flg.DialogResult == ResponseType.Ok)
             *              {
             *                      iMetaLibrary.Settings.TvFolders = flg.Folders;
             *                      iMetaLibrary.Settings.SaveSettings();
             *              }
             *      }
             * };*/
            #endregion
        }
Example #3
0
        public EpisodesEditorGui(iMetaLibrary.Metadata.TvFileMeta Meta)
        {
            this.Build();

            this.Meta = Meta;

            this.buttonOk.Clicked += HandleButtonOkhandleClicked;

            string tbnFile = Meta.Filename.Substring(0, Meta.Filename.LastIndexOf(".") + 1) + "tbn";

            if (System.IO.File.Exists(tbnFile))
            {
                using (System.Drawing.Image image = System.Drawing.Image.FromFile(tbnFile))
                {
                    imgThumbnail.Pixbuf = GuiHelper.ImageToPixbufIcon(image, 320, 240);
                }
                //UsingTbnFile = true;
            }
            else
            {
                //picThumbnail.Image = Resources.noposter;
            }

            store = new NodeStore(typeof(TvEpisodeNode));

            //List<iMetaLibrary.Metadata.TvEpisodeMeta> episodes = new List<iMetaLibrary.Metadata.TvEpisodeMeta>();
            bool first = true;

            foreach (iMetaLibrary.Metadata.TvEpisodeMeta episode in Meta.Episodes)
            {
                //episodes.Add(episode.Clone());
                iMetaLibrary.Metadata.TvEpisodeMeta epmeta = episode.Clone();
                if (first)
                {
                    episodeEditor.Initialize(epmeta);
                    first = false;
                }
                store.AddNode(new TvEpisodeNode(epmeta));
            }
            nvEpisodeList.NodeStore = store;

            nvEpisodeList.AppendColumn("Episode", new Gtk.CellRendererText(), "text", 0);

            nvEpisodeList.NodeSelection.Changed += delegate(object o, System.EventArgs args) {
                Gtk.NodeSelection selection = (Gtk.NodeSelection)o;
                TvEpisodeNode     node      = (TvEpisodeNode)selection.SelectedNode;
                // check selection hasnt changed
                if (node == SelectedEpisodeNode)
                {
                    return;
                }
                // check if current data in episode editor is valid
                if (!episodeEditor.IsValid())
                {
                    nvEpisodeList.NodeSelection.SelectNode(SelectedEpisodeNode);
                    return;
                }
                else     // if valid saved the data to the meta object
                {
                    episodeEditor.Save();
                    // this reassignment to itself forces the listbox to revalidate it and updates the text in the listbox if change, otherwise it doesnt update
                    //lstEpisodes.Items[SelectedEpisodeIndex] = lstEpisodes.Items[SelectedEpisodeIndex];
                }
                // update selected epsiode index
                SelectedEpisodeNode = node;
                // initialize the newly selected episode data
                episodeEditor.Initialize(node.Meta);
            };
        }