Exemplo n.º 1
0
        public ChangesetDiffViewModel(IApplicationService applicationService, IFilesystemService filesystemService)
        {
            Comments = new ReactiveList <CommentModel>();

            GoToCommentCommand = ReactiveCommand.Create();
            GoToCommentCommand.OfType <int?>().Subscribe(line =>
            {
                var vm = CreateViewModel <CommentViewModel>();
                ReactiveUI.Legacy.ReactiveCommandMixins.RegisterAsyncTask(vm.SaveCommand, async t =>
                {
                    var req      = applicationService.Client.Users[Username].Repositories[Repository].Commits[Branch].Comments.Create(vm.Comment, Filename, line);
                    var response = await applicationService.Client.ExecuteAsync(req);
                    Comments.Add(response.Data);
                    vm.DismissCommand.ExecuteIfCan();
                });
                ShowViewModel(vm);
            });

            this.WhenAnyValue(x => x.Filename).Subscribe(x =>
            {
                if (string.IsNullOrEmpty(x))
                {
                    Title = "Diff";
                }
                else
                {
                    _actualFilename = Path.GetFileName(Filename) ??
                                      Filename.Substring(Filename.LastIndexOf('/') + 1);
                    Title = _actualFilename;
                }
            });

            _loadCommand = ReactiveCommand.CreateAsyncTask(async t =>
            {
                var branch = applicationService.Client.Users[Username].Repositories[Repository].Commits[Branch];

                //Make sure we have this information. If not, go get it
                if (CommitFile == null)
                {
                    var data   = await applicationService.Client.ExecuteAsync(branch.Get());
                    CommitFile = data.Data.Files.First(x => string.Equals(x.Filename, Filename));
                }

                string path;
                using (var stream = filesystemService.CreateTempFile(out path))
                {
                    using (var fs = new StreamWriter(stream))
                    {
                        fs.Write(CommitFile.Patch);
                    }
                }

                SourceItem = new FileSourceItemViewModel {
                    FilePath = path
                };
                await Comments.SimpleCollectionLoad(branch.Comments.GetAll(), t as bool?);
            });
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Add the specified language to this object
        /// </summary>
        public void AddLanguage(string languageCode, bool copyValues)
        {
            if (Languages.ContainsKey(languageCode.ToLower()))
            {
                return;
            }

            // Create the file
            var cleanFilename = Filename.Substring(0, Filename.LastIndexOf('.'));
            var newFilename   = $"{cleanFilename}.{languageCode}.resx";

            File.Delete(newFilename);

            using (var writer = new ResXResourceWriter(newFilename))
            {
                if (copyValues)
                {
                    using (var reader = new ResXResourceReader(Filename))
                    {
                        reader.UseResXDataNodes = true;
                        var dataEnumerator = reader.GetEnumerator();
                        while (dataEnumerator.MoveNext())
                        {
                            var key  = (string)dataEnumerator.Key;
                            var node = (ResXDataNode)dataEnumerator.Value;
                            if (!IsLocalizableString(key, node))
                            {
                                continue;
                            }

                            var value = node.GetValueAsString();
                            // Skip saving unnecessary items
                            if (!string.IsNullOrWhiteSpace(value))
                            {
                                writer.AddResource(key, value);
                            }
                        }
                    }
                }
                writer.Generate();
            }

            // Add the created file to this ResourceHolder
            var languageHolder = new LanguageHolder(languageCode, newFilename);

            Languages.Add(languageCode.ToLower(), languageHolder);

            _stringsTable.Columns.Add(languageCode.ToLower());

            ReadResourceFile(languageHolder.Filename, _stringsTable, languageHolder.LanguageId, true);

            EvaluateAllRows();

            Dirty = true;
            OnLanguageChange();
        }
        public string GetFileExtension()
        {
            if (string.IsNullOrEmpty(Filename) || !Filename.Contains("."))
            {
                return(string.Empty);
            }
            var dotIndex = Filename.LastIndexOf('.');

            return(Filename.Substring(dotIndex));
        }
Exemplo n.º 4
0
 private string GetFileEnding()
 {
     if (!Filename.Contains("."))
     {
         return("");
     }
     if (Filename.EndsWith("."))
     {
         return("");
     }
     return(this.Filename.Substring(Filename.LastIndexOf('.') + 1).ToLower());
 }
Exemplo n.º 5
0
        public ChangesetDiffViewModel(IApplicationService applicationService, IActionMenuFactory actionMenuFactory)
        {
            var comments = new ReactiveList <CommitComment>();

            Comments = comments.CreateDerivedCollection(x => x);

            GoToCommentCommand = ReactiveCommand.Create();
            GoToCommentCommand.OfType <int?>().Subscribe(line =>
            {
//                var vm = this.CreateViewModel<CommentViewModel>();
//                ReactiveUI.Legacy.ReactiveCommandMixins.RegisterAsyncTask(vm.SaveCommand, async t =>
//                {
//                    var req = applicationService.Client.Users[Username].Repositories[Repository].Commits[Branch].Comments.Create(vm.Comment, Filename, line);
//                    var response = await applicationService.Client.ExecuteAsync(req);
//			        comments.Add(response.Data);
//                    Dismiss();
//                });
//                NavigateTo(vm);
            });

            _patch = this.WhenAnyValue(x => x.CommitFile)
                     .IsNotNull().Select(x => x.Patch).ToProperty(this, x => x.Patch);

            this.WhenAnyValue(x => x.Filename).Subscribe(x =>
            {
                if (string.IsNullOrEmpty(x))
                {
                    Title = "Diff";
                }
                else
                {
                    _actualFilename = Path.GetFileName(Filename) ??
                                      Filename.Substring(Filename.LastIndexOf('/') + 1);
                    Title = _actualFilename;
                }
            });

            ShowMenuCommand = ReactiveCommand.CreateAsyncTask(_ =>
            {
                var sheet = actionMenuFactory.Create(Title);
                sheet.AddButton("Add Comment", ReactiveCommand.Create());
                return(sheet.Show());
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(async t =>
            {
                applicationService.GitHubClient.Repository.RepositoryComments.GetForCommit(Username, Repository, Branch)
                .ToBackground(x => comments.Reset(x));
                var commits = await applicationService.GitHubClient.Repository.Commits.Get(Username, Repository, Branch);
                CommitFile  = commits.Files.FirstOrDefault(x => string.Equals(x.Filename, Filename, StringComparison.Ordinal));
            });
        }
Exemplo n.º 6
0
        public ChangesetDiffViewModel(ISessionService sessionService, IActionMenuFactory actionMenuFactory, IAlertDialogFactory alertDialogFactory)
        {
            var comments = new ReactiveList <CommitComment>();

            Comments = comments.CreateDerivedCollection(
                x => new FileDiffCommentViewModel(x.User.Login, x.User.AvatarUrl, x.Body, x.Position ?? 0));

            var gotoCreateCommentCommand = ReactiveCommand.Create().WithSubscription(_ => {
                var vm = new ComposerViewModel(async s => {
                    var cmd = new NewCommitComment(s)
                    {
                        Path = Filename, Position = SelectedPatchLine.Item1
                    };
                    var comment = await sessionService.GitHubClient.Repository.RepositoryComments.Create(Username, Repository, Branch, cmd);
                    _commentCreatedObservable.OnNext(comment);
                    comments.Add(comment);
                }, alertDialogFactory);
                NavigateTo(vm);
            });

            GoToCommentCommand = ReactiveCommand.CreateAsyncTask(this.WhenAnyValue(x => x.SelectedPatchLine).Select(x => x != null),
                                                                 sender => {
                var sheet = actionMenuFactory.Create();
                sheet.AddButton(string.Format("Add Comment on Line {0}", SelectedPatchLine.Item2), gotoCreateCommentCommand);
                return(sheet.Show(sender));
            });

            _patch = this.WhenAnyValue(x => x.CommitFile)
                     .IsNotNull().Select(x => x.Patch).ToProperty(this, x => x.Patch);

            this.WhenAnyValue(x => x.Filename).Subscribe(x =>
            {
                if (string.IsNullOrEmpty(x))
                {
                    Title = "Diff";
                }
                else
                {
                    _actualFilename = Path.GetFileName(Filename) ??
                                      Filename.Substring(Filename.LastIndexOf('/') + 1);
                    Title = _actualFilename;
                }
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(async t =>
            {
                sessionService.GitHubClient.Repository.RepositoryComments.GetAllForCommit(Username, Repository, Branch)
                .ToBackground(x => comments.Reset(x.Where(y => string.Equals(y.Path, Filename))));
                var commits = await sessionService.GitHubClient.Repository.Commits.Get(Username, Repository, Branch);
                CommitFile  = commits.Files.FirstOrDefault(x => string.Equals(x.Filename, Filename, StringComparison.Ordinal));
            });
        }
Exemplo n.º 7
0
        public void SaveBackup()
        {
            if (string.IsNullOrWhiteSpace(Filename))
            {
                return;
            }

            var backupName = Filename;

            backupName = backupName.Insert(Filename.LastIndexOf("."), $".{DateTime.Now:yyyy-MM-dd HH.mm.ss}");
            backupName = Path.Combine(Session.BackupDirectory, Path.GetFileName(backupName));

            Write(backupName, isBackup: true);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Download the File data.
        /// </summary>
        /// <param name="callback">File data as Unity specific object or bytes.</param>
        /// <param name="forceBytes">Stops intelligent conversion of file array (e.g png -> Texture) and forces returning of a raw byte array.</param>
        public IEnumerator Download(Action <object> callback, bool forceBytes = false)
        {
            var manager = Request.Instance;

            using (UnityWebRequest www = manager.Generate("contents/" + Id, UnityWebRequest.kHttpVerbGET))
            {
                yield return(www.Send());

                if (www.isError)
                {
                    Debug.LogError("Failed to Download File: " + www.error);
                }
                else
                {
                    // Get Headers.
                    var headers = www.GetResponseHeaders();
                    // Get data as bytes.
                    Data = www.downloadHandler.data;
                    // Get filename from Content-Disposition header.
                    Filename = headers["Content-Disposition"].Split('"')[1];
                    // Parse Extension.
                    Extension = Filename.Substring(Filename.LastIndexOf('.') + 1).ToLower();
                    // Figure Unity-native ReturnType.
                    SetReturnType();

                    // Convert data to ReturnType.
                    if (forceBytes)
                    {
                        // Specifically asked for bytes.
                        callback(Data);
                    }
                    else if (ReturnType == typeof(Texture))
                    {
                        // Downloaded File is a supported image.
                        var texture = new Texture2D(2, 2);
                        texture.LoadImage(Data);
                        callback(texture);
                    }
                    else
                    {
                        // TODO: Support more file types.
                        // Unsupported file type, returning bytes.
                        Debug.LogWarning(Extension + " is unsupported, returning bytes.");
                        ReturnType = typeof(Byte);
                        callback(Data);
                    }
                }
            }
        }
Exemplo n.º 9
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.Clear(Color.White);

            CircleDoc.Draw(e.Graphics);

            if (Filename != string.Empty)
            {
                this.Text = $"Pulsing circles | {Filename.Substring(Filename.LastIndexOf(@"\") + 1)}";
            }
            else
            {
                this.Text = "Pulsing circles";
            }
        }
Exemplo n.º 10
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.Clear(Color.White);

            BaloonsDoc.DrawBaloons(e.Graphics);

            if (Filename != string.Empty)
            {
                this.Text = $"Moving baloons | {Filename.Substring(Filename.LastIndexOf(@"\") + 1)}";
            }
            else
            {
                this.Text = "Moving baloons";
            }
        }
Exemplo n.º 11
0
        public void SaveBackup()
        {
            if (string.IsNullOrWhiteSpace(Filename))
            {
                return;
            }

            var backupDir  = Global.Config.PathEntries.MovieBackupsAbsolutePath();
            var backupName = Filename;

            backupName = backupName.Insert(Filename.LastIndexOf("."), $".{DateTime.Now:yyyy-MM-dd HH.mm.ss}");
            backupName = Path.Combine(backupDir, Path.GetFileName(backupName));

            Write(backupName, isBackup: true);
        }
Exemplo n.º 12
0
        public void ReadGroups()
        {
            if (MOHD == null || MOHD.nGroups == 0)
            {
                return;
            }

            var directory = Filename.Substring(0, Filename.LastIndexOf('.'));

            Groups = new List <WMOGroup>();
            for (int i = 0; i < MOHD.nGroups; i++)
            {
                try { Groups.Add(new WMOGroup(string.Format("{0}_{1:000}.wmo", directory, i))); }
                catch (FileNotFoundException e) { }
            }
        }
Exemplo n.º 13
0
        public PullRequestDiffViewModel(ISessionService sessionService, IActionMenuFactory actionMenuFactory, IAlertDialogFactory alertDialogFactory)
        {
            var gotoCreateCommentCommand = ReactiveCommand.Create().WithSubscription(_ => {
                var vm = new ComposerViewModel(async s => {
                    var req     = new PullRequestReviewCommentCreate(s, ParentViewModel.HeadSha, Filename, SelectedPatchLine.Item1);
                    var comment = await sessionService.GitHubClient.PullRequest.Comment.Create(ParentViewModel.RepositoryOwner, ParentViewModel.RepositoryName, ParentViewModel.PullRequestId, req);
                    _commentCreatedObservable.OnNext(comment);
                }, alertDialogFactory);
                NavigateTo(vm);
            });

            GoToCommentCommand = ReactiveCommand.CreateAsyncTask(this.WhenAnyValue(x => x.SelectedPatchLine).Select(x => x != null),
                                                                 sender => {
                var sheet = actionMenuFactory.Create();
                sheet.AddButton(string.Format("Add Comment on Line {0}", SelectedPatchLine.Item2), gotoCreateCommentCommand);
                return(sheet.Show(sender));
            });

            this.WhenAnyValue(x => x.PullRequestFile.Patch)
            .IsNotNull()
            .ToProperty(this, x => x.Patch, out _patch);

            var comments = new ReactiveList <PullRequestReviewComment>();

            Comments = comments.CreateDerivedCollection(
                x => new FileDiffCommentViewModel(x.User.Login, x.User.AvatarUrl, x.Body, x.Position ?? 0));

            this.WhenAnyValue(x => x.ParentViewModel.Comments)
            .Merge(this.WhenAnyObservable(x => x.ParentViewModel.Comments.Changed).Select(_ => ParentViewModel.Comments))
            .Select(x => x.Where(y => string.Equals(y.Path, Filename, StringComparison.OrdinalIgnoreCase)).ToList())
            .Subscribe(x => comments.Reset(x));

            this.WhenAnyValue(x => x.PullRequestFile.FileName)
            .ToProperty(this, x => x.Filename, out _filename);

            this.WhenAnyValue(x => x.Filename)
            .Subscribe(x => {
                if (string.IsNullOrEmpty(x))
                {
                    Title = "Diff";
                }
                else
                {
                    Title = Path.GetFileName(Filename) ?? Filename.Substring(Filename.LastIndexOf('/') + 1);
                }
            });
        }
Exemplo n.º 14
0
        public int Load(bool ForceFromInternet = false)
        {
            try
            {
                this.CompletionLevel = MetaCompletionLevel.Loading;
                string filenameNoExtension = Filename.Substring(0, Filename.LastIndexOf("."));
                // if there is already a nfo file, skip it
                string path = new FileInfo(Filename).Directory.FullName;
                this.NfoFile = filenameNoExtension + ".nfo";
                if (!ForceFromInternet && File.Exists(this.NfoFile))
                {
                    // load nfo
                    LoadFromNfo();
                    return(1);
                }
                else
                {
                    this.FileInfo = VideoFileMeta.Load(Filename);
                    // lookup
                    if (LoadFromTheTvDb())
                    {
                        Save();
                    }
                    return(2);
                }
            }
            finally
            {
                if (this.Episodes == null || this.Episodes.Length == 0)
                {
                    this.CompletionLevel = MetaCompletionLevel.None;
                }
                else
                {
                    this.CompletionLevel = MetaCompletionLevel.Full;
                    if (Settings.AutoRenameEpisodes)
                    {
                        RenameEpisode();
                    }
                }

                if (this.Episodes != null && this.Episodes.Length > 0)
                {
                    this.Rating = (from e in this.Episodes select e.Rating).Average();
                }
            }
        }
Exemplo n.º 15
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            var dialog = new OpenFileDialog();

            dialog.Filter = "Pulsing circle files (*.psf)|*.psf";
            dialog.Title  = "Open your game";
            if (Filename != string.Empty)
            {
                dialog.FileName = Filename.Substring(Filename.LastIndexOf(@"\") + 1);
            }

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                Filename = dialog.FileName;
            }
            else
            {
                if (toolStripButton1.Text != "Ста&рт")
                {
                    timer1.Start();
                }
                return;
            }

            try
            {
                using (var stream = new FileStream(Filename, FileMode.Open, FileAccess.Read))
                {
                    var formatter = new BinaryFormatter();
                    CircleDoc = (CircleDoc)formatter.Deserialize(stream);
                    Invalidate(true);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show($"EXCEPTION HAPPENED. HERE ARE THE DETAILS:\n\n{exception}");
            }
            finally
            {
                if (toolStripButton1.Text != "Ста&рт")
                {
                    timer1.Start();
                }
            }
        }
Exemplo n.º 16
0
        public void Init(NavObject navObject)
        {
            Username   = navObject.Username;
            Repository = navObject.Repository;
            Branch     = navObject.Branch;
            Filename   = navObject.Filename;

            _actualFilename = System.IO.Path.GetFileName(Filename);
            if (_actualFilename == null)
            {
                _actualFilename = Filename.Substring(Filename.LastIndexOf('/') + 1);
            }

            Title = _actualFilename;

            _commitFileModel = Mvx.Resolve <IViewModelTxService>().Get() as ChangesetDiffModel;
        }
Exemplo n.º 17
0
        public void Save()
        {
            if (this.Episodes == null || this.Episodes.Length < 1)
            {
                return;
            }

            StringBuilder builder = new StringBuilder();

            foreach (TvEpisodeMeta episode in this.Episodes)
            {
                builder.AppendLine(episode.CreateXElement().ToString());
            }

            string filenameNoExtension = Filename.Substring(0, Filename.LastIndexOf("."));

            File.WriteAllText(filenameNoExtension + ".nfo", builder.ToString());
        }
Exemplo n.º 18
0
 public int Load(bool ForceFromInternet = false)
 {
     this.CompletionLevel = MetaCompletionLevel.Loading;
     try
     {
         string filenameNoExtension = Filename.Substring(0, Filename.LastIndexOf("."));
         // if there is already a nfo file, skip it
         string path = new FileInfo(Filename).Directory.FullName;
         this.NfoFile = filenameNoExtension + ".nfo";
         if (File.Exists(Path.Combine(path, "movie.nfo")) && !ForceFromInternet)
         {
             this.NfoFile = Path.Combine(path, "movie.nfo");
             LoadFromNfo();
             return(1);
         }
         else if (File.Exists(this.NfoFile) && !ForceFromInternet)
         {
             LoadFromNfo();
             return(1);
         }
         else
         {
             if (LoadFromTheMovieDb(ForceFromInternet))
             {
                 Save();
             }
             return(2);
         }
     }
     finally
     {
         if (String.IsNullOrEmpty(this.Title) || String.IsNullOrEmpty(this.Plot) || this.Genres == null || this.Genres.Length == 0 || this.ReleaseDate == DateTime.MinValue || this.Year == 0)
         {
             this.CompletionLevel = MetaCompletionLevel.Partial;
         }
         else
         {
             this.CompletionLevel = MetaCompletionLevel.Full;
         }
     }
 }
Exemplo n.º 19
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.Clear(Color.White);

            var pen = new Pen(Color.Black, 3);

            e.Graphics.DrawRectangle(pen, _left, _top, _width, _height);
            pen.Dispose();

            BallsDoc.DrawHoles(e.Graphics, new Font("Arial", 20));
            BallsDoc.DrawBalls(e.Graphics);

            if (Filename != string.Empty)
            {
                this.Text = $"Balls in Holes | {Filename.Substring(Filename.LastIndexOf(@"\") + 1)}";
            }
            else
            {
                this.Text = "Balls in Holes";
            }
        }
Exemplo n.º 20
0
        public void SaveBackup()
        {
            if (string.IsNullOrWhiteSpace(Filename))
            {
                return;
            }

            var backupName = Filename;

            backupName = backupName.Insert(Filename.LastIndexOf("."), $".{DateTime.Now:yyyy-MM-dd HH.mm.ss}");
            backupName = Path.Combine(Global.Config.PathEntries["Global", "Movie backups"].Path, Path.GetFileName(backupName));

            var directoryInfo = new FileInfo(backupName).Directory;

            if (directoryInfo != null)
            {
                Directory.CreateDirectory(directoryInfo.FullName);
            }

            Write(backupName, backup: true);
        }
Exemplo n.º 21
0
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            var dialog = new SaveFileDialog();

            dialog.Filter = "Balls in Holes file (*.bhf)|*.bhf";
            dialog.Title  = "Save your game";
            if (Filename != string.Empty)
            {
                dialog.FileName = Filename.Substring(Filename.LastIndexOf(@"\") + 1);
            }

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                Filename = dialog.FileName;
            }
            else
            {
                timer1.Start();
                return;
            }

            try
            {
                using (var stream = new FileStream(Filename, FileMode.Create, FileAccess.Write))
                {
                    var formatter = new BinaryFormatter();
                    formatter.Serialize(stream, BallsDoc);
                    Invalidate(true);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show($"EXCEPTION HAPPENED. HERE ARE THE DETAILS:\n\n{exception}");
            }
            finally
            {
                timer1.Start();
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Only retrieve the headers of the file.
        /// </summary>
        /// <param name="callback">Dictionary of headers.</param>
        public IEnumerator GetHeaders(Action <Dictionary <string, string> > callback)
        {
            var manager = Request.Instance;

            using (UnityWebRequest www = manager.Generate("contents/" + Id, UnityWebRequest.kHttpVerbHEAD))
            {
                yield return(www.Send());

                if (www.isError)
                {
                    Debug.LogError("Failed to Download File Headers: " + www.error);
                }
                else
                {
                    var headers = www.GetResponseHeaders();
                    Filename  = headers["Content-Disposition"].Split('"')[1];
                    Extension = Filename.Substring(Filename.LastIndexOf('.') + 1).ToLower();
                    SetReturnType();
                    callback(headers);
                }
            }
        }
Exemplo n.º 23
0
        public XElement CreateXElement()
        {
            string   filenameNoExtension = Filename.Substring(0, Filename.LastIndexOf("."));
            XElement element             = new XElement("episodedetails");

            if (this.TvdbId > 0)
            {
                element.Add(new XElement("tvdbid", this.TvdbId));
            }
            if (this.TvdbSeriesId > 0)
            {
                element.Add(new XElement("tvdbseriesid", this.TvdbSeriesId));
            }
            element.Add(new XElement("title", this.Title ?? ""));
            element.Add(new XElement("showtitle", this.ShowTitle ?? ""));
            if (this.Rating > 0)
            {
                element.Add(new XElement("rating", this.Rating));
            }
            if (this.Aired > new DateTime(1910, 1, 1)) // i doubt think anyone will have a tv show from before 1910 :)
            {
                element.Add(new XElement("aired", this.Aired.ToString("yyyy-MM-dd")));
            }
            if (this.Premiered > new DateTime(1910, 1, 1))
            {
                element.Add(new XElement("premiered", this.Premiered.ToString("yyyy-MM-dd")));
            }
            element.Add(new XElement("season", this.Season));
            element.Add(new XElement("episode", this.Episode));
            element.Add(new XElement("displayseason", this.DisplaySeason));
            element.Add(new XElement("displayepisode", this.DisplayEpisode));
            element.Add(new XElement("plot", this.Plot));
            if (this.EpBookmark > 0)
            {
                element.Add(new XElement("epbookmark", this.EpBookmark));
            }
            if (!String.IsNullOrEmpty(this.Thumb))
            {
                string strThumb = this.Thumb;
                if (this.Thumb.StartsWith("http"))
                {
                    FileInfo thumbFile = new FileInfo(filenameNoExtension + ".tbn");
                    if (thumbFile.Exists || ImageDownloader.DownloadImage(this.Thumb, thumbFile.FullName)) // only set to local file if exists or successfully downloads, if fails keep the URL in there
                    {
                        strThumb = thumbFile.Name;
                    }
                }
                element.Add(new XElement("thumb", strThumb));
            }

            if (this.Directors != null)
            {
                foreach (string director in this.Directors)
                {
                    element.Add(new XElement("director", director));
                }
            }
            if (!String.IsNullOrEmpty(this.Studio))
            {
                element.Add(new XElement("studio", this.Studio));
            }
            if (!String.IsNullOrEmpty(Mpaa))
            {
                element.Add(new XElement("mpaa", this.Mpaa));
            }
            if (this.Actors != null)
            {
                foreach (KeyValuePair <string, string> actor in this.Actors)
                {
                    XElement xActor = new XElement("actor", new XElement("name", actor.Key));
                    if (!String.IsNullOrEmpty(actor.Value))
                    {
                        xActor.Add(new XElement("role", actor.Value));
                    }
                    element.Add(xActor);
                }
            }
            if (this.FileInfo != null)
            {
                XElement fileinfo = this.FileInfo.CreateXElement();
                if (fileinfo != null)
                {
                    element.Add(fileinfo);
                }
            }
            return(element);
        }