private void PasteCast(IDVDInfo profile, CastInformation castInformation) { profile.ClearCast(); for (var castIndex = 0; castIndex < (castInformation.CastList?.Length ?? 0); castIndex++) { var item = castInformation.CastList[castIndex]; if (item is Divider divider) { var apiDividerType = ApiConstantsToText.GetApiDividerType(divider.Type); profile.AddCastDivider(divider.Caption.NotNull(), apiDividerType); } else if (item is CastMember cast) { profile.AddCast(cast.FirstName.NotNull(), cast.MiddleName.NotNull(), cast.LastName.NotNull(), cast.BirthYear, cast.Role.NotNull(), cast.CreditedAs.NotNull(), cast.Voice, cast.Uncredited, cast.Puppeteer); } else { throw new NotImplementedException($"Unknown crew item {item}"); } } this.Api.SaveDVDToCollection(profile); this.Api.ReloadCurrentDVD(); this.Api.UpdateProfileInListDisplay(profile.GetProfileID()); }
private void CopyCast(IDVDInfo profile) { var castCount = profile.GetCastCount(); var castList = new List <object>(castCount); for (var castIndex = 0; castIndex < castCount; castIndex++) { profile.GetCastByIndex(castIndex, out var firstName, out var middleName, out var lastName, out var birthYear, out var role, out var creditedAs, out var voice, out var uncredited, out var puppeteer); if (firstName != null) { castList.Add(new CastMember() { FirstName = firstName.NotNull(), MiddleName = middleName.NotNull(), LastName = lastName.NotNull(), BirthYear = birthYear, Role = role.NotNull(), CreditedAs = creditedAs.NotNull(), Voice = voice, Uncredited = uncredited, Puppeteer = puppeteer, }); } else { profile.GetCastDividerByIndex(castIndex, out var caption, out var apiDividerType); var dividerType = ApiConstantsToText.GetDividerType(apiDividerType); castList.Add(new Divider() { Caption = caption.NotNull(), Type = dividerType, }); } } var castInformation = new CastInformation() { Title = profile.GetTitle().NotNull(), CastList = castList.ToArray(), }; var xml = DVDProfilerSerializer <CastInformation> .ToString(castInformation, CastInformation.DefaultEncoding); try { Clipboard.SetDataObject(xml, true, 4, 250); } catch (Exception ex) //clipboard in use { MessageBox.Show(ex.Message, MessageBoxTexts.CriticalErrorHeader, MessageBoxButtons.OK, MessageBoxIcon.Error); } }