Пример #1
0
        private string Render(bool showPreview)
        {
            string _tmpPath = Helpers.GetUniqueFilename(".jpg");

            string _moviePath = Helpers.IsDirectory(fsMovieFile.Filepath) ? System.IO.Path.Combine(fsMovieFile.Filepath, "dummy.mkv") : fsMovieFile.Filepath;

            using (MovieSheetsGenerator _gen = new MovieSheetsGenerator(SheetType.Main, _moviePath))
            {
                _gen.SelectedTemplate = this.TemplateSelector.TemplatesCombobox.SelectedItem as TemplateItem;

                if (tabMetadata.IsSelected)
                {
                    if (!_gen.CreateMoviesheetFromMetadata(this.fsMetadata.Filepath, _moviePath, _tmpPath, false))
                    {
                        if (!string.IsNullOrEmpty(_gen.LastError))
                        {
                            MessageBox.Show(_gen.LastError);
                        }
                    }
                }
                else if (tabCustom.IsSelected)
                {
                    if (!_gen.CreateMoviesheetFromCustomData(this.fsBackdrop.Filepath, this.fsCover.Filepath,
                                                             this.fsFanart1.Filepath, this.fsFanart2.Filepath, this.fsFanart3.Filepath,
                                                             this.fsNfo.Filepath, this.fsMovieFile.Filepath, _tmpPath, false))
                    {
                        if (!string.IsNullOrEmpty(_gen.LastError))
                        {
                            MessageBox.Show(_gen.LastError);
                        }
                    }
                }

                try
                {
                    this.Debug.Text = IndentXMLString(_gen.RenderedXML);
                }
                catch (Exception ex)
                {
                    Loggy.Logger.DebugException("Indenting:", ex);
                }

                if (File.Exists(_tmpPath) && showPreview)
                {
                    PreviewImage.Show(this, _tmpPath);
                }
                _gen.ClearGarbage();
            }

            return(_tmpPath);
        }
Пример #2
0
        private void GenerateMetadataButton_Click(object sender, RoutedEventArgs e)
        {
            nfoFileType nfotype = nfoFileType.Unknown;

            string _tmpPath = Helpers.GetUniqueFilename(".jpg");

            try
            {
                MovieSheetsGenerator _gen = new MovieSheetsGenerator(SheetType.Main, fsMovieFile.Filepath);
                _gen.SelectedTemplate = this.TemplateSelector.TemplatesCombobox.SelectedItem as TemplateItem;

                if (_gen.CreateMoviesheetFromCustomData(this.fsBackdrop.Filepath, this.fsCover.Filepath,
                                                        this.fsFanart1.Filepath, this.fsFanart2.Filepath, this.fsFanart3.Filepath,
                                                        this.fsNfo.Filepath, this.fsMovieFile.Filepath, _tmpPath, false))
                {
                    SaveFileDialog _sfd = new SaveFileDialog();
                    _sfd.Title      = "Select target metadata file name";
                    _sfd.Filter     = this.FindResource("metadataFilter") as string;
                    _sfd.DefaultExt = ".tgmd";

                    if ((bool)_sfd.ShowDialog())
                    {
                        MoviesheetsUpdateManager       _man    = MoviesheetsUpdateManager.CreateManagerFromMetadata(_sfd.FileName, fsMovieFile.Filepath);
                        MoviesheetsUpdateManagerParams _params = new MoviesheetsUpdateManagerParams(fsBackdrop.Filepath,
                                                                                                    fsFanart1.Filepath,
                                                                                                    fsFanart2.Filepath,
                                                                                                    fsFanart3.Filepath,
                                                                                                    nfoHelper.LoadNfoFile(fsMovieFile.Filepath, fsNfo.Filepath, out nfotype),
                                                                                                    fsCover.Filepath,
                                                                                                    _gen.MovieSheetPreviewTempPath);
                        _man.GenerateUpdateFile(_params, _gen.SelectedTemplate.TemplateName);
                        _man = null;
                    }
                }
                else
                {
                    MessageBox.Show(_gen.LastError);
                }
            }
            finally
            {
                try
                {
                    File.Delete(_tmpPath);
                }
                catch { }
            }
        }