/// <summary> /// Loads all setting presets stored as .xml files in /Presets/ folder /// and populates the combobox with their names. /// </summary> private void loadPresets() { DirectoryInfo d = new DirectoryInfo(@".//Presets"); FileInfo[] Files = d.GetFiles("*.xml"); presets = new Dictionary <string, MKMBotSettings>(); foreach (FileInfo file in Files) { MKMBotSettings s = new MKMBotSettings(); try { XmlDocument doc = new XmlDocument(); doc.Load(file.FullName); s.Parse(doc); string name = file.Name.Substring(0, file.Name.Length - 4); // cut off the ".xml" presets[name] = s; comboBoxPresets.Items.Add(name); } catch (Exception eError) { MKMHelpers.LogError("reading preset " + file.Name, eError.Message, false); } } comboBoxPresets.SelectedIndex = comboBoxPresets.Items.Add("Choose Preset..."); }
/// <summary> /// Copies all settings from the specified reference settings. /// </summary> /// <param name="refSettings">The reference settings.</param> public void Copy(MKMBotSettings refSettings) { priceMaxChangeLimits.Clear(); foreach (var limit in refSettings.priceMaxChangeLimits) { priceMaxChangeLimits.Add(limit.Key, limit.Value); } priceMaxDifferenceLimits.Clear(); foreach (var limit in refSettings.priceMaxDifferenceLimits) { priceMaxDifferenceLimits.Add(limit.Key, limit.Value); } priceMinRarePrice = refSettings.priceMinRarePrice; priceMinSimilarItems = refSettings.priceMinSimilarItems; priceMaxSimilarItems = refSettings.priceMaxSimilarItems; priceSetPriceBy = refSettings.priceSetPriceBy; priceFactor = refSettings.priceFactor; condAcceptance = refSettings.condAcceptance; logUpdated = refSettings.logUpdated; logLessThanMinimum = refSettings.logLessThanMinimum; logSmallPriceChange = refSettings.logSmallPriceChange; logHighPriceChange = refSettings.logHighPriceChange; logHighPriceVariance = refSettings.logHighPriceVariance; testMode = refSettings.testMode; description = refSettings.description; }
/// <summary> /// Generates the default settings for MKMBot. /// To be used when GUI is not available / relevant. /// </summary> /// <returns>Default settings for all parameters of MKMBot</returns> public static MKMBotSettings GenerateDefaultSettings() { MKMBotSettings s = new MKMBotSettings(); s.priceMaxChangeLimits.Clear(); // empty by default s.priceMaxDifferenceLimits.Clear(); // empty by default s.priceMinRarePrice = 0.05; s.priceMinSimilarItems = 4; // require exactly 4 items s.priceMaxSimilarItems = 4; s.priceSetPriceBy = PriceSetMethod.ByAverage; s.priceFactor = 0.5; s.condAcceptance = AcceptedCondition.OnlyMatching; s.logUpdated = true; s.logLessThanMinimum = true; s.logSmallPriceChange = true; s.logHighPriceChange = true; s.logHighPriceVariance = true; s.testMode = false; return(s); }
public SettingPresetStore(MKMBotSettings toStore) { InitializeComponent(); this.toStore = toStore; }
/// <summary> /// Gathers data from the gui and creates their appropriate representation as the MKMBotSettings object. /// </summary> /// <param name="s">The settings object after the method successfully executes.</param> /// <returns>True if all settings were read, false in case of parsing error.</returns> public bool GenerateBotSettings(out MKMBotSettings s) { s = new MKMBotSettings(); string[] limits = textBoxPriceEstMaxChange.Text.Split(';'); double threshold, allowedChange; for (int i = 1; i < limits.Length; i += 2) { if (double.TryParse(limits[i - 1], NumberStyles.Float, CultureInfo.CurrentCulture, out threshold) && double.TryParse(limits[i], NumberStyles.Float, CultureInfo.CurrentCulture, out allowedChange)) { s.priceMaxChangeLimits.Add(threshold, allowedChange / 100); // convert to percent } else { MessageBox.Show("The max price change limit pair " + limits[i - 1] + ";" + limits[i] + " could not be parsed as a number.", "Incorrect format of max price change format", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } limits = textBoxPriceEstMaxDiff.Text.Split(';'); for (int i = 1; i < limits.Length; i += 2) { if (double.TryParse(limits[i - 1], NumberStyles.Float, CultureInfo.CurrentCulture, out threshold) && double.TryParse(limits[i], NumberStyles.Float, CultureInfo.CurrentCulture, out allowedChange)) { s.priceMaxDifferenceLimits.Add(threshold, allowedChange / 100); // convert to percent } else { MessageBox.Show("The max difference limit pair " + limits[i - 1] + ";" + limits[i] + " could not be parsed as a number.", "Incorrect format of max difference between items", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } s.priceMinRarePrice = Decimal.ToDouble(numericUpDownPriceEstMinPrice.Value); s.priceMinSimilarItems = Decimal.ToInt32(numericUpDownPriceEstMinN.Value); s.priceMaxSimilarItems = Decimal.ToInt32(numericUpDownPriceEstMaxN.Value); if (radioButtonPriceEstPriceByAvg.Checked) { s.priceSetPriceBy = PriceSetMethod.ByAverage; s.priceFactor = (double)trackBarPriceEstAvg.Value / (trackBarPriceEstAvg.Maximum - trackBarPriceEstAvg.Minimum); s.priceFactorWorldwide = (double)trackBarPriceEstAvgWorld.Value / (trackBarPriceEstAvgWorld.Maximum - trackBarPriceEstAvgWorld.Minimum); } else if (radioButtonPriceEstByLowestPrice.Checked) { s.priceSetPriceBy = PriceSetMethod.ByPercentageOfLowestPrice; s.priceFactor = s.priceFactorWorldwide = Decimal.ToDouble(numericUpDownPriceEstLowestPrice.Value) / 100; } else { s.priceSetPriceBy = PriceSetMethod.ByPercentageOfHighestPrice; s.priceFactor = s.priceFactorWorldwide = Decimal.ToDouble(numericUpDownPriceEstHighestPrice.Value) / 100; } s.priceMarkup2 = Decimal.ToDouble(numericUpDownPriceMultCopies2.Value) / 100; s.priceMarkup3 = Decimal.ToDouble(numericUpDownPriceMultCopies3.Value) / 100; s.priceMarkup4 = Decimal.ToDouble(numericUpDownPriceMultCopies4.Value) / 100; s.priceMarkupCap = Decimal.ToDouble(numericUpDownPriceMultCopiesCap.Value); s.priceIgnorePlaysets = checkBoxPricePlaysetIgnore.Checked; if (radioButtonCondMatchOnly.Checked) { s.condAcceptance = AcceptedCondition.OnlyMatching; } else if (radioButtonCondAcceptBetterAlways.Checked) { s.condAcceptance = AcceptedCondition.Anything; } else { s.condAcceptance = AcceptedCondition.SomeMatchesAbove; } s.logUpdated = checkBoxLogUpdated.Checked; s.logLessThanMinimum = checkBoxLogMinItems.Checked; s.logSmallPriceChange = checkBoxLogSmallChange.Checked; s.logLargePriceChangeTooLow = checkBoxLogLargeChangeLow.Checked; s.logLargePriceChangeTooHigh = checkBoxLogLargeChangeHigh.Checked; s.logHighPriceVariance = checkBoxLogHighVariance.Checked; s.testMode = checkBoxTestMode.Checked; s.searchWorldwide = checkBoxPriceEstWorldwide.Checked; return(true); }
/// <summary> /// Updates the GUI controls according to the provided settings. /// </summary> /// <param name="settings">The settings to which to set the GUI.</param> public void UpdateSettingsGUI(MKMBotSettings settings) { textBoxPriceEstMaxChange.Text = ""; foreach (var limitPair in settings.priceMaxChangeLimits) { textBoxPriceEstMaxChange.Text += "" + limitPair.Key + ";" + (limitPair.Value * 100).ToString("f2") + ";"; } textBoxPriceEstMaxDiff.Text = ""; foreach (var limitPair in settings.priceMaxDifferenceLimits) { textBoxPriceEstMaxDiff.Text += "" + limitPair.Key + ";" + (limitPair.Value * 100).ToString("f2") + ";"; } numericUpDownPriceEstMinPrice.Value = new decimal(settings.priceMinRarePrice); numericUpDownPriceEstMinN.Value = new decimal(settings.priceMinSimilarItems); numericUpDownPriceEstMaxN.Value = new decimal(settings.priceMaxSimilarItems); if (settings.priceSetPriceBy == PriceSetMethod.ByAverage) { radioButtonPriceEstPriceByAvg.Checked = true; radioButtonPriceEstByLowestPrice.Checked = false; radioButtonPriceEstHighestPrice.Checked = false; trackBarPriceEstAvg.Value = (int)(settings.priceFactor * (trackBarPriceEstAvg.Maximum - trackBarPriceEstAvg.Minimum) + trackBarPriceEstAvg.Minimum); trackBarPriceEstAvgWorld.Value = (int)(settings.priceFactorWorldwide * (trackBarPriceEstAvgWorld.Maximum - trackBarPriceEstAvgWorld.Minimum) + trackBarPriceEstAvgWorld.Minimum); } else if (settings.priceSetPriceBy == PriceSetMethod.ByPercentageOfLowestPrice) { radioButtonPriceEstPriceByAvg.Checked = false; radioButtonPriceEstByLowestPrice.Checked = true; radioButtonPriceEstHighestPrice.Checked = false; numericUpDownPriceEstLowestPrice.Value = new decimal(settings.priceFactor * 100); } else { radioButtonPriceEstPriceByAvg.Checked = false; radioButtonPriceEstByLowestPrice.Checked = false; radioButtonPriceEstHighestPrice.Checked = true; numericUpDownPriceEstHighestPrice.Value = new decimal(settings.priceFactor * 100); } numericUpDownPriceMultCopies2.Value = new decimal(settings.priceMarkup2 * 100); numericUpDownPriceMultCopies3.Value = new decimal(settings.priceMarkup3 * 100); numericUpDownPriceMultCopies4.Value = new decimal(settings.priceMarkup4 * 100); numericUpDownPriceMultCopiesCap.Value = new decimal(settings.priceMarkupCap); checkBoxPricePlaysetIgnore.Checked = settings.priceIgnorePlaysets; if (settings.condAcceptance == AcceptedCondition.OnlyMatching) { radioButtonCondMatchOnly.Checked = true; radioButtonCondAcceptBetterAlways.Checked = false; radioButtonCondMatchesAbove.Checked = false; } else if (settings.condAcceptance == AcceptedCondition.Anything) { radioButtonCondMatchOnly.Checked = false; radioButtonCondAcceptBetterAlways.Checked = true; radioButtonCondMatchesAbove.Checked = false; } else { radioButtonCondAcceptBetterAlways.Checked = false; radioButtonCondMatchOnly.Checked = false; radioButtonCondMatchesAbove.Checked = true; } checkBoxLogUpdated.Checked = settings.logUpdated; checkBoxLogMinItems.Checked = settings.logLessThanMinimum; checkBoxLogSmallChange.Checked = settings.logSmallPriceChange; checkBoxLogLargeChangeLow.Checked = settings.logLargePriceChangeTooLow; checkBoxLogLargeChangeHigh.Checked = settings.logLargePriceChangeTooHigh; checkBoxLogHighVariance.Checked = settings.logHighPriceVariance; checkBoxTestMode.Checked = settings.testMode; checkBoxPriceEstWorldwide.Checked = settings.searchWorldwide; trackBarPriceEstAvgWorld.Enabled = settings.searchWorldwide; }
/// Gathers data from the GUI and creates their appropriate representation as the MKMBotSettings object. /// <param name="s">The settings object after the method successfully executes.</param> /// <returns>True if all settings were read, false in case of parsing error.</returns> public bool GenerateBotSettings(out MKMBotSettings s) { s = new MKMBotSettings(); string[] limits = textBoxPriceEstMaxChange.Text.Split(';'); double threshold, allowedChange; for (int i = 1; i < limits.Length; i += 2) { if (double.TryParse(limits[i - 1], NumberStyles.Float, CultureInfo.CurrentCulture, out threshold) && double.TryParse(limits[i], NumberStyles.Float, CultureInfo.CurrentCulture, out allowedChange)) { s.PriceMaxChangeLimits.Add(threshold, allowedChange / 100); // convert to percent } else { MessageBox.Show("The max price change limit pair " + limits[i - 1] + ";" + limits[i] + " could not be parsed as a number.", "Incorrect format of max price change format", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } limits = textBoxPriceEstMaxDiff.Text.Split(';'); for (int i = 1; i < limits.Length; i += 2) { if (double.TryParse(limits[i - 1], NumberStyles.Float, CultureInfo.CurrentCulture, out threshold) && double.TryParse(limits[i], NumberStyles.Float, CultureInfo.CurrentCulture, out allowedChange)) { s.PriceMaxDifferenceLimits.Add(threshold, allowedChange / 100); // convert to percent } else { MessageBox.Show("The max difference limit pair " + limits[i - 1] + ";" + limits[i] + " could not be parsed as a number.", "Incorrect format of max difference between items", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } s.PriceMinRarePrice = decimal.ToDouble(numericUpDownPriceEstMinPrice.Value); s.PriceMinSimilarItems = decimal.ToInt32(numericUpDownPriceEstMinN.Value); s.PriceMaxSimilarItems = decimal.ToInt32(numericUpDownPriceEstMaxN.Value); if (radioButtonPriceEstPriceByAvg.Checked) { s.PriceSetPriceBy = PriceSetMethod.ByAverage; s.PriceFactor = (double)trackBarPriceEstAvg.Value / (trackBarPriceEstAvg.Maximum - trackBarPriceEstAvg.Minimum); s.PriceFactorWorldwide = (double)trackBarPriceEstAvgWorld.Value / (trackBarPriceEstAvgWorld.Maximum - trackBarPriceEstAvgWorld.Minimum); } else if (radioButtonPriceEstByLowestPrice.Checked) { s.PriceSetPriceBy = PriceSetMethod.ByPercentageOfLowestPrice; s.PriceFactor = s.PriceFactorWorldwide = decimal.ToDouble(numericUpDownPriceEstLowestPrice.Value) / 100; } else { s.PriceSetPriceBy = PriceSetMethod.ByPercentageOfHighestPrice; s.PriceFactor = s.PriceFactorWorldwide = decimal.ToDouble(numericUpDownPriceEstHighestPrice.Value) / 100; } s.PriceMarkup2 = decimal.ToDouble(numericUpDownPriceMultCopies2.Value) / 100; s.PriceMarkup3 = decimal.ToDouble(numericUpDownPriceMultCopies3.Value) / 100; s.PriceMarkup4 = decimal.ToDouble(numericUpDownPriceMultCopies4.Value) / 100; s.PriceMarkupCap = decimal.ToDouble(numericUpDownPriceMultCopiesCap.Value); s.PriceIgnorePlaysets = checkBoxPricePlaysetIgnore.Checked; if (radioButtonCondMatchOnly.Checked) { s.CondAcceptance = AcceptedCondition.OnlyMatching; } else if (radioButtonCondAcceptBetterAlways.Checked) { s.CondAcceptance = AcceptedCondition.Anything; } else { s.CondAcceptance = AcceptedCondition.SomeMatchesAbove; } s.FilterByExpansions = checkBoxFilterExpansions.Checked; if (checkBoxFilterExpansions.Checked) // set this only if we are filtering by expansions { s.AllowedExpansions = allowedExpansionsWindow.GetSelected(); } s.FilterByCountries = checkBoxFilterCountries.Checked; if (checkBoxFilterCountries.Checked) // set this only if we are filtering by countries { s.AllowedCountryNames = allowedCountriesWindow.GetSelected(); } s.IncludePrivateSellers = checkBoxFilterPrivSeller.Checked; s.IncludeProfessionalSellers = checkBoxFilterProfSeller.Checked; s.IncludePowersellers = checkBoxFilterPowerseller.Checked; s.LogUpdated = checkBoxLogUpdated.Checked; s.LogLessThanMinimum = checkBoxLogMinItems.Checked; s.LogSmallPriceChange = checkBoxLogSmallChange.Checked; s.LogLargePriceChangeTooLow = checkBoxLogLargeChangeLow.Checked; s.LogLargePriceChangeTooHigh = checkBoxLogLargeChangeHigh.Checked; s.LogHighPriceVariance = checkBoxLogHighVariance.Checked; s.TestMode = checkBoxTestMode.Checked; s.SearchWorldwide = checkBoxPriceEstWorldwide.Checked; switch (comboBoxPriceEstUpdateMode.SelectedIndex) { case 0: s.MinPriceUpdateMode = MKMBotSettings.UpdateMode.FullUpdate; break; case 1: s.MinPriceUpdateMode = MKMBotSettings.UpdateMode.UpdateOnlyBelowMinPrice; break; case 2: s.MinPriceUpdateMode = MKMBotSettings.UpdateMode.OnlyEnsureMinPrice; break; } switch (comboBoxPriceEstMinPriceMatch.SelectedIndex) { case 0: s.MyStockMinPriceMatch = MKMBotSettings.MinPriceMatch.Highest; break; case 1: s.MyStockMinPriceMatch = MKMBotSettings.MinPriceMatch.Best; break; } return(true); }
/// Updates the GUI controls according to the provided settings. /// <param name="settings">The settings to which to set the GUI.</param> public void UpdateSettingsGUI(MKMBotSettings settings) { textBoxPriceEstMaxChange.Text = ""; foreach (var limitPair in settings.PriceMaxChangeLimits) { textBoxPriceEstMaxChange.Text += "" + limitPair.Key + ";" + (limitPair.Value * 100).ToString("f2") + ";"; } textBoxPriceEstMaxDiff.Text = ""; foreach (var limitPair in settings.PriceMaxDifferenceLimits) { textBoxPriceEstMaxDiff.Text += "" + limitPair.Key + ";" + (limitPair.Value * 100).ToString("f2") + ";"; } numericUpDownPriceEstMinPrice.Value = new decimal(settings.PriceMinRarePrice); numericUpDownPriceEstMinN.Value = new decimal(settings.PriceMinSimilarItems); numericUpDownPriceEstMaxN.Value = new decimal(settings.PriceMaxSimilarItems); if (settings.PriceSetPriceBy == PriceSetMethod.ByAverage) { radioButtonPriceEstPriceByAvg.Checked = true; radioButtonPriceEstByLowestPrice.Checked = false; radioButtonPriceEstHighestPrice.Checked = false; trackBarPriceEstAvg.Value = (int)(settings.PriceFactor * (trackBarPriceEstAvg.Maximum - trackBarPriceEstAvg.Minimum) + trackBarPriceEstAvg.Minimum); trackBarPriceEstAvgWorld.Value = (int)(settings.PriceFactorWorldwide * (trackBarPriceEstAvgWorld.Maximum - trackBarPriceEstAvgWorld.Minimum) + trackBarPriceEstAvgWorld.Minimum); } else if (settings.PriceSetPriceBy == PriceSetMethod.ByPercentageOfLowestPrice) { radioButtonPriceEstPriceByAvg.Checked = false; radioButtonPriceEstByLowestPrice.Checked = true; radioButtonPriceEstHighestPrice.Checked = false; numericUpDownPriceEstLowestPrice.Value = new decimal(settings.PriceFactor * 100); } else { radioButtonPriceEstPriceByAvg.Checked = false; radioButtonPriceEstByLowestPrice.Checked = false; radioButtonPriceEstHighestPrice.Checked = true; numericUpDownPriceEstHighestPrice.Value = new decimal(settings.PriceFactor * 100); } numericUpDownPriceMultCopies2.Value = new decimal(settings.PriceMarkup2 * 100); numericUpDownPriceMultCopies3.Value = new decimal(settings.PriceMarkup3 * 100); numericUpDownPriceMultCopies4.Value = new decimal(settings.PriceMarkup4 * 100); numericUpDownPriceMultCopiesCap.Value = new decimal(settings.PriceMarkupCap); checkBoxPricePlaysetIgnore.Checked = settings.PriceIgnorePlaysets; if (settings.CondAcceptance == AcceptedCondition.OnlyMatching) { radioButtonCondMatchOnly.Checked = true; radioButtonCondAcceptBetterAlways.Checked = false; radioButtonCondMatchesAbove.Checked = false; } else if (settings.CondAcceptance == AcceptedCondition.Anything) { radioButtonCondMatchOnly.Checked = false; radioButtonCondAcceptBetterAlways.Checked = true; radioButtonCondMatchesAbove.Checked = false; } else { radioButtonCondAcceptBetterAlways.Checked = false; radioButtonCondMatchOnly.Checked = false; radioButtonCondMatchesAbove.Checked = true; } allowedExpansionsWindow.SetDataSource(MKMDbManager.Instance.GetAllExpansionNames(true)); // to make sure we are up to date checkBoxFilterExpansions.Checked = settings.FilterByExpansions; allowedExpansionsWindow.SetSelected(settings.AllowedExpansions); checkBoxFilterCountries.Checked = settings.FilterByCountries; allowedCountriesWindow.SetSelected(settings.AllowedCountryNames); checkBoxFilterPrivSeller.Checked = settings.IncludePrivateSellers; checkBoxFilterProfSeller.Checked = settings.IncludeProfessionalSellers; checkBoxFilterPowerseller.Checked = settings.IncludePowersellers; checkBoxLogUpdated.Checked = settings.LogUpdated; checkBoxLogMinItems.Checked = settings.LogLessThanMinimum; checkBoxLogSmallChange.Checked = settings.LogSmallPriceChange; checkBoxLogLargeChangeLow.Checked = settings.LogLargePriceChangeTooLow; checkBoxLogLargeChangeHigh.Checked = settings.LogLargePriceChangeTooHigh; checkBoxLogHighVariance.Checked = settings.LogHighPriceVariance; checkBoxTestMode.Checked = settings.TestMode; checkBoxPriceEstWorldwide.Checked = settings.SearchWorldwide; trackBarPriceEstAvgWorld.Enabled = settings.SearchWorldwide; switch (settings.MinPriceUpdateMode) { case MKMBotSettings.UpdateMode.FullUpdate: comboBoxPriceEstUpdateMode.SelectedIndex = 0; break; case MKMBotSettings.UpdateMode.UpdateOnlyBelowMinPrice: comboBoxPriceEstUpdateMode.SelectedIndex = 1; break; case MKMBotSettings.UpdateMode.OnlyEnsureMinPrice: comboBoxPriceEstUpdateMode.SelectedIndex = 2; break; } switch (settings.MyStockMinPriceMatch) { case MKMBotSettings.MinPriceMatch.Highest: comboBoxPriceEstMinPriceMatch.SelectedIndex = 0; break; case MKMBotSettings.MinPriceMatch.Best: comboBoxPriceEstMinPriceMatch.SelectedIndex = 1; break; } }
public void setSettings(MKMBotSettings s) { this.settings = s; }
public MKMBot(MKMBotSettings settings) { this.settings = settings; }
public MKMBot() { this.settings = GenerateDefaultSettings(); }
/// <summary> /// Fills this instance from data stored in XML. /// </summary> /// <param name="s">XML document representing an instance of MKMBotSettings. <seealso cref="Serialize()" /></param> /// <returns>True if parsing was succesful, false if it was not (in that case, the structure will remain unchanged).</returns> public bool Parse(XmlDocument s) { MKMBotSettings temp = new MKMBotSettings(); try { XmlNode root = s.GetElementsByTagName("MKMBotSettings").Item(0); double threshold, allowedChange; string[] limits; foreach (XmlNode child in root.ChildNodes) { switch (child.Name) { case "priceMaxChangeLimits": limits = child.InnerText.Split(';'); for (int i = 1; i < limits.Length; i += 2) { if (double.TryParse(limits[i - 1], NumberStyles.Float, CultureInfo.InvariantCulture, out threshold) && double.TryParse(limits[i], NumberStyles.Float, CultureInfo.InvariantCulture, out allowedChange)) { temp.priceMaxChangeLimits.Add(threshold, allowedChange); } else { return(false); } } break; case "priceMaxDifferenceLimits": limits = child.InnerText.Split(';'); for (int i = 1; i < limits.Length; i += 2) { if (double.TryParse(limits[i - 1], NumberStyles.Float, CultureInfo.InvariantCulture, out threshold) && double.TryParse(limits[i], NumberStyles.Float, CultureInfo.InvariantCulture, out allowedChange)) { temp.priceMaxDifferenceLimits.Add(threshold, allowedChange); } else { return(false); } } break; } } foreach (XmlNode att in root.Attributes) { switch (att.Name) { case "priceMinRarePrice": temp.priceMinRarePrice = double.Parse(att.Value, CultureInfo.InvariantCulture); break; case "priceMinSimilarItems": temp.priceMinSimilarItems = int.Parse(att.Value, CultureInfo.InvariantCulture); break; case "priceMaxSimilarItems": temp.priceMaxSimilarItems = int.Parse(att.Value, CultureInfo.InvariantCulture); break; case "priceSetPriceBy": temp.priceSetPriceBy = (PriceSetMethod)Enum.Parse(typeof(PriceSetMethod), att.Value); break; case "priceFactor": temp.priceFactor = double.Parse(att.Value, CultureInfo.InvariantCulture); break; case "condAcceptance": temp.condAcceptance = (AcceptedCondition)Enum.Parse(typeof(AcceptedCondition), att.Value); break; case "logUpdated": temp.logUpdated = bool.Parse(att.Value); break; case "logLessThanMinimum": temp.logLessThanMinimum = bool.Parse(att.Value); break; case "logSmallPriceChange": temp.logSmallPriceChange = bool.Parse(att.Value); break; case "logHighPriceChange": temp.logHighPriceChange = bool.Parse(att.Value); break; case "logHighPriceVariance": temp.logHighPriceVariance = bool.Parse(att.Value); break; case "testMode": temp.testMode = bool.Parse(att.Value); break; case "description": temp.description = att.Value; break; } } } catch (Exception) { return(false); } this.Copy(temp); // nothing failed, let's keep the settings return(true); }