Пример #1
0
        public void ReplaceWith(ApplicationSettings source)
        {
            Accounts.ReplaceWith(source.Accounts);
            JobHistory.ReplaceWith(source.JobHistory);

            PrinterMappings.Clear();
            for (int i = 0; i < source.PrinterMappings.Count; i++)
            {
                PrinterMappings.Add(source.PrinterMappings[i].Copy());
            }

            RssFeed.ReplaceWith(source.RssFeed);

            TitleReplacement.Clear();
            for (int i = 0; i < source.TitleReplacement.Count; i++)
            {
                TitleReplacement.Add(source.TitleReplacement[i].Copy());
            }

            UsageStatistics.ReplaceWith(source.UsageStatistics);
            if (ConversionTimeout != source.ConversionTimeout)
            {
                ConversionTimeout = source.ConversionTimeout;
            }

            if (EnableTips != source.EnableTips)
            {
                EnableTips = source.EnableTips;
            }

            if (Language != source.Language)
            {
                Language = source.Language;
            }

            if (LicenseExpirationReminder != source.LicenseExpirationReminder)
            {
                LicenseExpirationReminder = source.LicenseExpirationReminder;
            }

            if (LoggingLevel != source.LoggingLevel)
            {
                LoggingLevel = source.LoggingLevel;
            }

            if (NextUpdate != source.NextUpdate)
            {
                NextUpdate = source.NextUpdate;
            }

            if (UnitOfMeasurement != source.UnitOfMeasurement)
            {
                UnitOfMeasurement = source.UnitOfMeasurement;
            }

            if (UpdateInterval != source.UpdateInterval)
            {
                UpdateInterval = source.UpdateInterval;
            }
        }
Пример #2
0
        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 + @"LicenseExpirationReminder", LicenseExpirationReminder.ToString("yyyy-MM-dd HH:mm:ss"));
            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());
        }
Пример #3
0
        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; }
        }
Пример #4
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("[Accounts]");
            sb.AppendLine(Accounts.ToString());

            for (int i = 0; i < PrinterMappings.Count; i++)
            {
                sb.AppendLine(PrinterMappings.ToString());
            }


            for (int i = 0; i < TitleReplacement.Count; i++)
            {
                sb.AppendLine(TitleReplacement.ToString());
            }

            sb.AppendLine("AskSwitchDefaultPrinter=" + AskSwitchDefaultPrinter.ToString());
            sb.AppendLine("Language=" + Language.ToString());
            sb.AppendLine("LastUsedProfileGuid=" + LastUsedProfileGuid.ToString());
            sb.AppendLine("LoggingLevel=" + LoggingLevel.ToString());
            sb.AppendLine("PrimaryPrinter=" + PrimaryPrinter.ToString());
            sb.AppendLine("UpdateInterval=" + UpdateInterval.ToString());

            return(sb.ToString());
        }
Пример #5
0
        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());
        }
Пример #6
0
        public TitleReplacement Copy()
        {
            TitleReplacement copy = new TitleReplacement();

            copy.Replace         = Replace;
            copy.ReplacementType = ReplacementType;
            copy.Search          = Search;
            return(copy);
        }
Пример #7
0
        public void ReplaceWith(TitleReplacement source)
        {
            if (Replace != source.Replace)
            {
                Replace = source.Replace;
            }

            if (ReplacementType != source.ReplacementType)
            {
                ReplacementType = source.ReplacementType;
            }

            if (Search != source.Search)
            {
                Search = source.Search;
            }
        }
Пример #8
0
        public override bool Equals(object o)
        {
            if (!(o is TitleReplacement))
            {
                return(false);
            }
            TitleReplacement v = o as TitleReplacement;

            if (!Replace.Equals(v.Replace))
            {
                return(false);
            }
            if (!ReplacementType.Equals(v.ReplacementType))
            {
                return(false);
            }
            if (!Search.Equals(v.Search))
            {
                return(false);
            }
            return(true);
        }
Пример #9
0
        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;
        }