示例#1
0
        public ExportingDialog(iMetaLibrary.Scanners.MovieScanner MovieScanner, iMetaLibrary.Scanners.TvScanner TvScanner)
        {
            this.Build();

            notebook1.ShowTabs   = false;
            notebook1.ShowBorder = false;
            bkgWorker            = new System.ComponentModel.BackgroundWorker();
            bkgWorker.WorkerSupportsCancellation = true;
            bkgWorker.DoWork += HandleBkgWorkerDoWork;
            System.Timers.Timer pulsar = new System.Timers.Timer(50)
            {
                AutoReset = true
            };
            pulsar.Elapsed += delegate {
                pbarExporting.Pulse();
            };

            this.buttonCancel.Clicked += delegate(object sender, EventArgs e)
            {
                bkgWorker.CancelAsync();
                this.Destroy();
            };

            this.buttonOk.Clicked += delegate(object sender, EventArgs e) {
                if (notebook1.Page == 0)
                {
                    string folder = filechooserbutton1.Filename;
                    if (String.IsNullOrEmpty(folder) || !System.IO.Directory.Exists(folder))
                    {
                        MessageBox.Show("Invalid export location specfied.");
                        return;
                    }
                    this.buttonOk.Visible = false;
                    bkgWorker.RunWorkerAsync(new object[] { folder, MovieScanner, TvScanner });
                    pulsar.Start();
                    notebook1.Page = 1;
                }
                else
                {
                    // final page.
                    this.Destroy();
                }
            };

            bkgWorker.RunWorkerCompleted += delegate(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) {
                pulsar.Stop();
                if (e.Result as bool? == true)
                {
                    notebook1.Page            = 2;
                    this.buttonOk.Visible     = true;
                    this.buttonCancel.Visible = false;
                }
                else
                {
                    notebook1.Page            = 3;
                    this.buttonOk.Visible     = true;
                    this.buttonCancel.Visible = false;
                }
            };
        }
示例#2
0
        void HandleBkgWorkerDoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            try
            {
                object[] parameters = e.Argument as object[];
                string   exportdir  = parameters[0] as string;
                iMetaLibrary.Scanners.MovieScanner MovieScanner = (iMetaLibrary.Scanners.MovieScanner)parameters[1];
                iMetaLibrary.Scanners.TvScanner    TvScanner    = (iMetaLibrary.Scanners.TvScanner)parameters[2];

                string html = iMetaGui.ResourceReader.ReadResource("ExportTemplate.html");
                foreach (System.Text.RegularExpressions.Match match in System.Text.RegularExpressions.Regex.Matches(html, "<!--@Resource\\(\"([^\"]*)\"\\)-->", System.Text.RegularExpressions.RegexOptions.Singleline))
                {
                    string resource = iMetaGui.ResourceReader.ReadResource(match.Groups[1].Value);
                    Logger.Log("Resouce match: " + match.Groups[1].Value);
                    html = html.Replace(match.Value, resource);
                }
                if (bkgWorker.CancellationPending)
                {
                    return;
                }

                html = html.Replace("<!--@Movies-->", MovieScanner.CreateHtmlElement(exportdir));
                if (bkgWorker.CancellationPending)
                {
                    return;
                }
                html = html.Replace("<!--@TvShows-->", TvScanner.CreateHtmlElement(exportdir));
                if (bkgWorker.CancellationPending)
                {
                    return;
                }
                System.IO.File.WriteAllText(System.IO.Path.Combine(exportdir, "imeta_catalog.html"), html);
                e.Result = true;
            }
            catch (Exception ex)
            {
                Logger.Log(ex.Message + Environment.NewLine + ex.StackTrace);
                e.Result = false;
            }
        }
示例#3
0
        private void SetupMovieScanner()
        {
            #region setup the movie scanner
            this.MovieScanner            = new iMetaLibrary.Scanners.MovieScanner();
            this.MovieScanner.Started   += delegate { };
            this.MovieScanner.Completed += delegate
            {
                if (notebook1.Page == 0)
                {
                    topbar.IsStatusPulsing = false;
                }
                UpdateStatusText("Movies Found: {0}".FormatStr(this.MovieScanner.Items.Count), true);
            };
            this.MovieScanner.ItemAdded += delegate(Meta Item)
            {
                UpdateStatusText("Movie Found: {0}".FormatStr(Item.Filename), true);
            };
            this.MovieScanner.ScanningItem += delegate(Meta Item)
            {
                UpdateStatusText("Scanning File: {0}".FormatStr(Item.Filename), true);
            };
            this.MovieScanner.AllItemsFound += delegate(iMetaLibrary.Metadata.Meta[] NewItems) {
                SortedDictionary <string, List <iMetaLibrary.Metadata.MovieMeta> > storeItems = new SortedDictionary <string, List <iMetaLibrary.Metadata.MovieMeta> >();
                foreach (iMetaLibrary.Metadata.MovieMeta meta in NewItems)
                {
                    string indexer = meta.StartChar.ToString();
                    if (!storeItems.ContainsKey(indexer))
                    {
                        storeItems.Add(indexer, new List <MovieMeta>());
                    }
                    storeItems[indexer].Add(meta);
                }
                guiMovieList.AddToStore(storeItems);
            };
            guiMovieList.ItemActivated += delegate(MovieMeta Meta)
            {
                using (iMetaGui.MovieEditor editor = new iMetaGui.MovieEditor(Meta))
                {
                    editor.Run();
                    editor.Destroy();
                }
            };

            /*
             * btnMoviesFolders1.Activated += delegate {
             *      using(iMetaGui.FolderListGui flg = new iMetaGui.FolderListGui("Movie Folders", "Here you can configure the folders to scan for Movies.", iMetaLibrary.Settings.MovieFolders)){
             *              flg.Run();
             *              if(flg.DialogResult == ResponseType.Ok)
             *              {
             *                      iMetaLibrary.Settings.MovieFolders = flg.Folders;
             *                      iMetaLibrary.Settings.SaveSettings();
             *              }
             *      }
             * };
             * btnMoviesRefresh.Activated += delegate {
             *      MovieMeta[] movies = guiMovieList.GetSelected();
             *      MovieScanner.RefreshFiles(movies);
             * };
             */
            #endregion
        }