private void TryLoadIgnore(string fileName, bool silent) { try { _ignore = DVDProfilerSerializer <Ignore.IgnoreConfiguration> .Deserialize(fileName); } catch { if (!silent) { MessageBox.Show("The ignore file cannot be read.", "Read error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } _ignore = null; } if (_ignore != null) { IgnoreFileTextBox.Text = fileName; UpdateIgnoreLabel(); } else { IgnoreFileTextBox.Text = string.Empty; IgnoresLoadedLabel.Text = string.Empty; } }
public static void Initialize(TestContext _) { var fileName = "Test2.xml"; var collection = DVDProfilerSerializer <Collection> .Deserialize(fileName); _graph = GraphBuilder.Build(collection.DVDList); }
private void LogException(Exception ex) { ex = WrapCOMException(ex); ExceptionXml exceptionXml = new ExceptionXml(ex); DVDProfilerSerializer <ExceptionXml> .Serialize(ErrorFile, exceptionXml); }
private void LogException(Exception ex) { ex = this.WrapCOMException(ex); var exceptionXml = new ExceptionXml(ex); DVDProfilerSerializer <ExceptionXml> .Serialize(_errorFile, exceptionXml); }
private static ExtendedProfileTuple CreateExtendedProfileTuple(DVD profile, FileInfo fileInfo) { String rawProfileXml = DVDProfilerSerializer <DVD> .ToString(profile, Collection.DefaultEncoding); ExtendedProfileTuple tuple = new ExtendedProfileTuple(fileInfo, rawProfileXml); return(tuple); }
public void Insert() { if (_pluginData.Any?.Length == 1) { var ddi = DVDProfilerSerializer <DDI.DigitalDownloadInfo> .FromString(_pluginData.Any[0].OuterXml); InsertPluginData(ddi); } }
public void Insert() { if (_pluginData.Any?.Length == 1) { var ef = DVDProfilerSerializer <EF.EnhancedFeatures> .FromString(_pluginData.Any[0].OuterXml); Insert(ef); } }
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); } }
private static DVD GetDvd(ListView listView) { Int32 selectedIndex = listView.SelectedIndices[0]; String xml = (String)(listView.Items[selectedIndex].Tag); DVD dvd = DVDProfilerSerializer <DVD> .FromString(xml, Collection.DefaultEncoding); return(dvd); }
private void TryLoadCollection(string fileName) { _collection = DVDProfilerSerializer <Collection> .Deserialize(fileName); CollectionFileTextBox.Text = fileName; var profileCount = _collection.DVDList?.Length ?? 0; ProfilesLoadedLabel.Text = $"{profileCount:#,0} profiles loaded."; }
private static String GetCleanedProfile(String rawProfileXml) { DVD cleanedProfile = DVDProfilerSerializer <DVD> .FromString(rawProfileXml, Collection.DefaultEncoding); cleanedProfile.LastEditedSpecified = false; cleanedProfile.ProfileTimestamp = new DateTime(0); String cleanedProfileXml = DVDProfilerSerializer <DVD> .ToString(cleanedProfile, Collection.DefaultEncoding); return(cleanedProfileXml); }
public void Insert() { if (_pluginData.Any?.Length == 1) { var epi = DVDProfilerSerializer <EPI.EnhancedPurchaseInfo> .FromString(_pluginData.Any[0].OuterXml); InsertMetaData(epi); InsertPluginData(epi); } }
private static void TryGetSettings() { try { _Settings = DVDProfilerSerializer <Settings> .Deserialize(_SettingsFile); } catch (Exception ex) { MessageBox.Show(String.Format(MessageBoxTexts.FileCantBeRead, _SettingsFile, ex.Message), MessageBoxTexts.WarningHeader, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void SaveIgnore(string fileName) { DVDProfilerSerializer <Ignore.IgnoreConfiguration> .Serialize(fileName, _ignore); IgnoreFileTextBox.Text = fileName; Properties.Settings.Default.IgnoreFile = fileName; Properties.Settings.Default.Save(); UpdateIgnoreLabel(); }
public void Insert() { if (_pluginData.Any?.Length == 1) { var en = DVDProfilerSerializer <EN.EnhancedNotes> .FromString(_pluginData.Any[0].OuterXml); InsertMetaData(en); InsertPluginData(en); } }
public void Load(IDVDProfilerAPI api) { Api = api; if (Directory.Exists(_applicationPath) == false) { Directory.CreateDirectory(_applicationPath); } if (File.Exists(_settingsFile)) { try { _settings = DVDProfilerSerializer <Settings> .Deserialize(_settingsFile); } catch (Exception ex) { MessageBox.Show(string.Format(MessageBoxTexts.FileCantBeRead, _settingsFile, ex.Message), MessageBoxTexts.ErrorHeader, MessageBoxButtons.OK, MessageBoxIcon.Error); } } this.CreateSettings(); if (_settings.DefaultValues.ReceiveFromCastCrewEdit) { this.LoadReceiver(); } if (Directory.Exists(_applicationPath) == false) { Directory.CreateDirectory(_applicationPath); } Api.RegisterForEvent(PluginConstants.EVENTID_FormCreated); _copyCastMenuToken = Api.RegisterMenuItem(PluginConstants.FORMID_Main, PluginConstants.MENUID_Form, @"DVD", "Copy Cast", CopyCastMenuId); _copyCrewMenuToken = Api.RegisterMenuItem(PluginConstants.FORMID_Main, PluginConstants.MENUID_Form, @"DVD", "Copy Crew", CopyCrewMenuId); _pasteMenuToken = Api.RegisterMenuItem(PluginConstants.FORMID_Main, PluginConstants.MENUID_Form, @"DVD", "Paste Cast / Crew", PasteMenuId); _receiverSettingMenuToken = Api.RegisterMenuItem(PluginConstants.FORMID_Main, PluginConstants.MENUID_Form, @"Tools", "Enable Cast/Crew Edit 2 Receiver", ReceiverSettingMenuId); api.SetRegisteredMenuItemChecked(_receiverSettingMenuToken, _settings.DefaultValues.ReceiveFromCastCrewEdit); var pluginVersion = this.PluginVersion.ToString(); if (_settings.CurrentVersion != pluginVersion) { this.OpenReadme(); _settings.CurrentVersion = pluginVersion; } }
private static void ExecuteSave <T>(T configuration, string fileName) where T : class, new() { using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.Read)) { using (var xtw = new XmlTextWriter(fs, Encoding.UTF8)) { xtw.Formatting = Formatting.Indented; DVDProfilerSerializer <T> .Serialize(xtw, configuration); } } }
internal static Collection TryGetCollection(String file) { try { Collection collection = DVDProfilerSerializer <Collection> .Deserialize(file); return(collection); } catch { return(null); } }
private static T TryGetInformationFromData <T>(string data) where T : class, new() { try { var information = DVDProfilerSerializer <T> .FromString(data, CastInformation.DefaultEncoding); return(information); } catch { return(null); } }
public CompareForm(IEnumerable <ProfileTuple> profiles) { InitializeComponent(); String profileXml = profiles.First().ProfileXml; DVD profile = DVDProfilerSerializer <DVD> .FromString(profileXml, Collection.DefaultEncoding); Text += ": " + profile.Title; AddRows(LeftListView, profiles); AddRows(RightListView, profiles); }
private static v2_2.CheckConfiguration LoadFrom_v1_x(string fileName) { var config_v1_1 = DVDProfilerSerializer <v1_1.CheckConfiguration> .Deserialize(fileName); var config_v2_0 = config_v1_1.Upgrade(); var tempFile = Path.GetTempFileName(); Save(config_v2_0, tempFile); var config_v2_2 = DVDProfilerSerializer <v2_2.CheckConfiguration> .Deserialize(tempFile); return(config_v2_2); }
public static void Initialize(TestContext _) { const string SampleXml = "sample.xml"; if (File.Exists(SampleXml)) { File.Delete(SampleXml); } System.IO.Compression.ZipFile.ExtractToDirectory(@"..\..\..\..\sample_xml.zip", "."); var collection = DVDProfilerSerializer <Collection> .Deserialize(SampleXml); _graph = GraphBuilder.Build(collection.DVDList); }
public void Unload() { Api.UnregisterMenuItem(_addMenuToken); try { DVDProfilerSerializer <Settings> .Serialize(_settingsFile, _settings); } catch (Exception ex) { UIServices.ShowMessageBox(string.Format(MessageBoxTexts.FileCantBeWritten, _settingsFile, ex.Message), MessageBoxTexts.ErrorHeader, Buttons.OK, Icon.Error); } _serviceProvider.Api = null; }
private static void SaveSetting() { try { if (Directory.Exists(_SettingsPath) == false) { Directory.CreateDirectory(_SettingsPath); } DVDProfilerSerializer <Settings> .Serialize(_SettingsFile, _Settings); } catch (Exception ex) { MessageBox.Show(String.Format(MessageBoxTexts.FileCantBeWritten, _SettingsFile, ex.Message), MessageBoxTexts.WarningHeader, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private static void TryWriteErrorFile(Exception ex) { try { ExceptionXml xml = new ExceptionXml(ex); String temp = Path.GetTempPath(); String file = Path.Combine(temp, "ProfileHistoryError.xml"); DVDProfilerSerializer <ExceptionXml> .Serialize(file, xml); MessageBox.Show(String.Format(MessageBoxTexts.CriticalError, ex.Message, file), MessageBoxTexts.CriticalErrorHeader, MessageBoxButtons.OK, MessageBoxIcon.Error); } catch { } }
public void Unload() { this.UnloadReceiver(); try { DVDProfilerSerializer <Settings> .Serialize(_settingsFile, _settings); } catch (Exception ex) { MessageBox.Show(string.Format(MessageBoxTexts.FileCantBeWritten, _settingsFile, ex.Message), MessageBoxTexts.ErrorHeader, MessageBoxButtons.OK, MessageBoxIcon.Error); } Api.UnregisterMenuItem(_copyCastMenuToken); Api.UnregisterMenuItem(_copyCrewMenuToken); Api.UnregisterMenuItem(_pasteMenuToken); Api.UnregisterMenuItem(_receiverSettingMenuToken); Api = null; }
private Dictionary <DVD, IEnumerable <ProfileTuple> > Convert() { Dictionary <DVD, IEnumerable <ProfileTuple> > profiles = new Dictionary <DVD, IEnumerable <ProfileTuple> >(_Profiles.Count); foreach (KeyValuePair <DVD, List <ExtendedProfileTuple> > kvp in _Profiles) { if (kvp.Value.Count > 1) { String newestXml = kvp.Value.Last().ProfileXml; DVD newest = DVDProfilerSerializer <DVD> .FromString(newestXml, Collection.DefaultEncoding); IEnumerable <ProfileTuple> profileList = kvp.Value.Select(p => p.Simplify()).ToList(); profiles.Add(newest, profileList); } } return(profiles); }
public void Load(IDVDProfilerAPI api) { _serviceProvider.Api = api; if (IOServices.Folder.Exists(_applicationPath) == false) { IOServices.Folder.CreateFolder(_applicationPath); } if (IOServices.File.Exists(_settingsFile)) { try { _settings = DVDProfilerSerializer <Settings> .Deserialize(_settingsFile); } catch (Exception ex) { UIServices.ShowMessageBox(string.Format(MessageBoxTexts.FileCantBeRead, _settingsFile, ex.Message), MessageBoxTexts.ErrorHeader, Buttons.OK, Icon.Error); } } if (_settings == null) { _settings = new Settings(); } if (_settings.DefaultValues == null) { _settings.DefaultValues = new DefaultValues(); } _serviceProvider.DefaultValues = _settings.DefaultValues; Api.RegisterForEvent(PluginConstants.EVENTID_FormCreated); _addMenuToken = Api.RegisterMenuItem(PluginConstants.FORMID_Main, PluginConstants.MENUID_Form, @"DVD", "Add by DVD Disc ID", AddMenuId); }
private static v2_2.CheckConfiguration LoadFrom_v2_2(string fileName) { var config = DVDProfilerSerializer <v2_2.CheckConfiguration> .Deserialize(fileName); return(config); }
private void CopyCrew(IDVDInfo profile) { var crewCount = profile.GetCrewCount(); var crewList = new List <object>(crewCount); for (var crewIndex = 0; crewIndex < crewCount; crewIndex++) { profile.GetCrewByIndex(crewIndex, out var firstName, out var middleName, out var lastName, out var birthYear, out var apiCreditType, out var apiCreditSubtype, out var creditedAs); if (firstName != null) { var customRole = profile.GetCrewCustomRoleByIndex(crewIndex); var creditType = ApiConstantsToText.GetCreditType(apiCreditType); var creditSubtype = ApiConstantsToText.GetCreditSubType(apiCreditType, apiCreditSubtype); crewList.Add(new CrewMember() { FirstName = firstName.NotNull(), MiddleName = middleName.NotNull(), LastName = lastName.NotNull(), BirthYear = birthYear, CreditType = creditType, CreditSubtype = creditSubtype, CustomRole = customRole, CustomRoleSpecified = !string.IsNullOrWhiteSpace(customRole), CreditedAs = creditedAs.NotNull(), }); } else { profile.GetCrewDividerByIndex(crewIndex, out var caption, out var apiDividerType, out apiCreditType); var dividerType = ApiConstantsToText.GetDividerType(apiDividerType); var creditType = ApiConstantsToText.GetCreditType(apiCreditType); crewList.Add(new CrewDivider() { Caption = caption.NotNull(), Type = dividerType, CreditType = creditType, }); } } var crewInformation = new CrewInformation() { Title = profile.GetTitle().NotNull(), CrewList = crewList.ToArray(), }; var xml = DVDProfilerSerializer <CrewInformation> .ToString(crewInformation, CrewInformation.DefaultEncoding); try { Clipboard.SetDataObject(xml, true, 4, 250); } catch (Exception ex) //clipboard in use { MessageBox.Show(ex.Message, MessageBoxTexts.CriticalErrorHeader, MessageBoxButtons.OK, MessageBoxIcon.Error); } }