private readonly PopupListbox allowedCountriesWindow; // pop-up window managing allowed countries for filtering /// Initializes a new instance of the <see cref="UpdatePriceSettings"/> class. /// <param name="lastPresetName">The last preset used by this settings windows under which it is stored in Properties.Settings.Default</param> /// <param name="title">Title of the window</param> public UpdatePriceSettings(string lastPresetName, string title) { InitializeComponent(); loadPresets(); Text = title; allowedExpansionsWindow = new PopupListbox("Allowed Expansions"); allowedCountriesWindow = new PopupListbox("Allowed Countries"); comboBoxPriceEstUpdateMode.SelectedIndex = 0; comboBoxPriceEstMinPriceMatch.SelectedIndex = 0; List <string> countryNames = new List <string>(MKMHelpers.CountryNames.Count); foreach (var code in MKMHelpers.CountryNames) { countryNames.Add(code.Value); } allowedCountriesWindow.SetDataSource(countryNames); this.lastPresetName = lastPresetName; string lastPreset = Properties.Settings.Default[lastPresetName].ToString(); if (comboBoxPresets.Items.Contains(lastPreset)) { comboBoxPresets.SelectedIndex = comboBoxPresets.Items.IndexOf(lastPreset); UpdateSettingsGUI(presets[lastPreset]); } }
private readonly PopupListbox allowedCountriesWindow; // pop-up window managing allowed countries for filtering /// Initializes a new instance of the <see cref="UpdatePriceSettings"/> class. /// <param name="lastPresetName">The last preset used by this settings windows under which it is stored in Properties.Settings.Default</param> /// <param name="title">Title of the window</param> public UpdatePriceSettings(string lastPresetName, string title) { InitializeComponent(); loadPresets(); Text = title; allowedExpansionsWindow = new PopupListbox("Allowed Expansions"); allowedCountriesWindow = new PopupListbox("Allowed Countries"); comboBoxPriceEstMinPriceMatch.SelectedIndex = 0; List <string> countryNames = new List <string>(MKMHelpers.CountryNames.Count); foreach (var code in MKMHelpers.CountryNames) { countryNames.Add(code.Value); } allowedCountriesWindow.SetDataSource(countryNames); groupBoxPriceGuides.Visible = MKMHelpers.SAmCommercial; if (MKMHelpers.SAmCommercial) { comboBoxPriceEstUpdateMode.Items.Add("Use Price Guides"); // fill the comboboxes for price guides string tooltip = ""; foreach (var guideDesc in MKMHelpers.PriceGuides) { comboBoxPriceGuidesFoils.Items.Add(guideDesc.Value.Code); comboBoxPriceGuidesNonFoils.Items.Add(guideDesc.Value.Code); tooltip += guideDesc.Value.Code + ": " + guideDesc.Value.Documentation + "\n"; if (guideDesc.Value.Code == "TREND") { comboBoxPriceGuidesNonFoils.SelectedIndex = comboBoxPriceGuidesNonFoils.Items.Count - 1; } else if (guideDesc.Value.Code == "TRENDFOIL") { comboBoxPriceGuidesFoils.SelectedIndex = comboBoxPriceGuidesFoils.Items.Count - 1; } } toolTip1.SetToolTip(comboBoxPriceGuidesFoils, tooltip); toolTip1.SetToolTip(comboBoxPriceGuidesNonFoils, tooltip); comboBoxPriceGuidesFoils.SelectedIndexChanged += new EventHandler(comboBoxPriceGuidesFoils_SelectedIndexChanged); comboBoxPriceGuidesNonFoils.SelectedIndexChanged += new EventHandler(comboBoxPriceGuidesNonFoils_SelectedIndexChanged); } comboBoxPriceEstUpdateMode.SelectedIndex = 0; this.lastPresetName = lastPresetName; string lastPreset = Properties.Settings.Default[lastPresetName].ToString(); if (comboBoxPresets.Items.Contains(lastPreset)) { comboBoxPresets.SelectedIndex = comboBoxPresets.Items.IndexOf(lastPreset); UpdateSettingsGUI(presets[lastPreset]); } }
/// 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; } }