public void ReadValues(Data data, string path) { Accounts.ReadValues(data, path + @"Accounts\"); try { int numClasses = int.Parse(data.GetValue(@"" + path + @"PrinterMappings\numClasses")); for (int i = 0; i < numClasses; i++) { PrinterMapping tmp = new PrinterMapping(); tmp.ReadValues(data, @"" + path + @"PrinterMappings\" + i + @"\"); PrinterMappings.Add(tmp); } } catch {} try { int numClasses = int.Parse(data.GetValue(@"" + path + @"TitleReplacement\numClasses")); for (int i = 0; i < numClasses; i++) { TitleReplacement tmp = new TitleReplacement(); tmp.ReadValues(data, @"" + path + @"TitleReplacement\" + i + @"\"); TitleReplacement.Add(tmp); } } catch {} try { AskSwitchDefaultPrinter = bool.Parse(data.GetValue(@"" + path + @"AskSwitchDefaultPrinter")); } catch { AskSwitchDefaultPrinter = true; } try { Language = Data.UnescapeString(data.GetValue(@"" + path + @"Language")); } catch { Language = ""; } try { LastUsedProfileGuid = Data.UnescapeString(data.GetValue(@"" + path + @"LastUsedProfileGuid")); } catch { LastUsedProfileGuid = "DefaultGuid"; } try { LoggingLevel = (LoggingLevel)Enum.Parse(typeof(LoggingLevel), data.GetValue(@"" + path + @"LoggingLevel")); } catch { LoggingLevel = LoggingLevel.Error; } try { PrimaryPrinter = Data.UnescapeString(data.GetValue(@"" + path + @"PrimaryPrinter")); } catch { PrimaryPrinter = "PDFCreator"; } try { UpdateInterval = (UpdateInterval)Enum.Parse(typeof(UpdateInterval), data.GetValue(@"" + path + @"UpdateInterval")); } catch { UpdateInterval = UpdateInterval.Weekly; } }
public void StoreValues(Data data, string path) { Accounts.StoreValues(data, path + @"Accounts\"); for (int i = 0; i < PrinterMappings.Count; i++) { PrinterMapping tmp = PrinterMappings[i]; tmp.StoreValues(data, @"" + path + @"PrinterMappings\" + i + @"\"); } data.SetValue(@"" + path + @"PrinterMappings\numClasses", PrinterMappings.Count.ToString()); for (int i = 0; i < TitleReplacement.Count; i++) { TitleReplacement tmp = TitleReplacement[i]; tmp.StoreValues(data, @"" + path + @"TitleReplacement\" + i + @"\"); } data.SetValue(@"" + path + @"TitleReplacement\numClasses", TitleReplacement.Count.ToString()); data.SetValue(@"" + path + @"AskSwitchDefaultPrinter", AskSwitchDefaultPrinter.ToString()); data.SetValue(@"" + path + @"Language", Data.EscapeString(Language)); data.SetValue(@"" + path + @"LastUsedProfileGuid", Data.EscapeString(LastUsedProfileGuid)); data.SetValue(@"" + path + @"LoggingLevel", LoggingLevel.ToString()); data.SetValue(@"" + path + @"PrimaryPrinter", Data.EscapeString(PrimaryPrinter)); data.SetValue(@"" + path + @"UpdateInterval", UpdateInterval.ToString()); }
public void StoreValues(Data data, string path) { Accounts.StoreValues(data, path + @"Accounts\"); JobHistory.StoreValues(data, path + @"JobHistory\"); for (int i = 0; i < PrinterMappings.Count; i++) { PrinterMapping tmp = PrinterMappings[i]; tmp.StoreValues(data, @"" + path + @"PrinterMappings\" + i + @"\"); } data.SetValue(@"" + path + @"PrinterMappings\numClasses", PrinterMappings.Count.ToString()); RssFeed.StoreValues(data, path + @"RssFeed\"); for (int i = 0; i < TitleReplacement.Count; i++) { TitleReplacement tmp = TitleReplacement[i]; tmp.StoreValues(data, @"" + path + @"TitleReplacement\" + i + @"\"); } data.SetValue(@"" + path + @"TitleReplacement\numClasses", TitleReplacement.Count.ToString()); UsageStatistics.StoreValues(data, path + @"UsageStatistics\"); data.SetValue(@"" + path + @"ConversionTimeout", ConversionTimeout.ToString(System.Globalization.CultureInfo.InvariantCulture)); data.SetValue(@"" + path + @"EnableTips", EnableTips.ToString()); data.SetValue(@"" + path + @"Language", Data.EscapeString(Language)); data.SetValue(@"" + path + @"LoggingLevel", LoggingLevel.ToString()); data.SetValue(@"" + path + @"NextUpdate", NextUpdate.ToString("yyyy-MM-dd HH:mm:ss")); data.SetValue(@"" + path + @"UnitOfMeasurement", UnitOfMeasurement.ToString()); data.SetValue(@"" + path + @"UpdateInterval", UpdateInterval.ToString()); }
public PrinterMapping Copy() { PrinterMapping copy = new PrinterMapping(); copy.PrinterName = PrinterName; copy.ProfileGuid = ProfileGuid; return(copy); }
public void ReplaceWith(PrinterMapping source) { if (PrinterName != source.PrinterName) { PrinterName = source.PrinterName; } if (ProfileGuid != source.ProfileGuid) { ProfileGuid = source.ProfileGuid; } }
public override bool Equals(object o) { if (!(o is PrinterMapping)) { return(false); } PrinterMapping v = o as PrinterMapping; if (!PrinterName.Equals(v.PrinterName)) { return(false); } if (!ProfileGuid.Equals(v.ProfileGuid)) { return(false); } return(true); }
public void ReadValues(Data data, string path = "") { Accounts.ReadValues(data, path + @"Accounts\"); JobHistory.ReadValues(data, path + @"JobHistory\"); try { int numClasses = int.Parse(data.GetValue(@"" + path + @"PrinterMappings\numClasses")); for (int i = 0; i < numClasses; i++) { PrinterMapping tmp = new PrinterMapping(); tmp.ReadValues(data, @"" + path + @"PrinterMappings\" + i + @"\"); PrinterMappings.Add(tmp); } } catch {} RssFeed.ReadValues(data, path + @"RssFeed\"); try { int numClasses = int.Parse(data.GetValue(@"" + path + @"TitleReplacement\numClasses")); for (int i = 0; i < numClasses; i++) { TitleReplacement tmp = new TitleReplacement(); tmp.ReadValues(data, @"" + path + @"TitleReplacement\" + i + @"\"); TitleReplacement.Add(tmp); } } catch {} UsageStatistics.ReadValues(data, path + @"UsageStatistics\"); ConversionTimeout = int.TryParse(data.GetValue(@"" + path + @"ConversionTimeout"), System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out var tmpConversionTimeout) ? tmpConversionTimeout : 60; EnableTips = bool.TryParse(data.GetValue(@"" + path + @"EnableTips"), out var tmpEnableTips) ? tmpEnableTips : true; try { Language = Data.UnescapeString(data.GetValue(@"" + path + @"Language")); } catch { Language = ""; } LicenseExpirationReminder = DateTime.TryParse(data.GetValue(@"" + path + @"LicenseExpirationReminder"), System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out var tmpLicenseExpirationReminder) ? tmpLicenseExpirationReminder : DateTime.Now; LoggingLevel = Enum.TryParse <LoggingLevel>(data.GetValue(@"" + path + @"LoggingLevel"), out var tmpLoggingLevel) ? tmpLoggingLevel : LoggingLevel.Error; NextUpdate = DateTime.TryParse(data.GetValue(@"" + path + @"NextUpdate"), System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out var tmpNextUpdate) ? tmpNextUpdate : DateTime.Now; UnitOfMeasurement = Enum.TryParse <UnitOfMeasurement>(data.GetValue(@"" + path + @"UnitOfMeasurement"), out var tmpUnitOfMeasurement) ? tmpUnitOfMeasurement : UnitOfMeasurement.Centimeter; UpdateInterval = Enum.TryParse <UpdateInterval>(data.GetValue(@"" + path + @"UpdateInterval"), out var tmpUpdateInterval) ? tmpUpdateInterval : UpdateInterval.Weekly; }