From 0c4e915cc784c8df6acccf4ab21d76785d4346fb Mon Sep 17 00:00:00 2001 From: siegrest <179900@ttu.ee> Date: Thu, 15 Feb 2018 14:58:38 +0200 Subject: [PATCH] Replace slider with textbox --- Pricer/SettingsWindow.xaml | 7 ++++--- Pricer/SettingsWindow.xaml.cs | 26 ++++++++++++++------------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Pricer/SettingsWindow.xaml b/Pricer/SettingsWindow.xaml index 25e634e..f192fbe 100644 --- a/Pricer/SettingsWindow.xaml +++ b/Pricer/SettingsWindow.xaml @@ -37,9 +37,10 @@ - - diff --git a/Pricer/SettingsWindow.xaml.cs b/Pricer/SettingsWindow.xaml.cs index c1c82d0..8b890e6 100644 --- a/Pricer/SettingsWindow.xaml.cs +++ b/Pricer/SettingsWindow.xaml.cs @@ -55,7 +55,7 @@ private void Button_Apply_Click(object sender, RoutedEventArgs e) { Int32.TryParse(TextBox_Delay.Text, out int delay); if (delay != Settings.pasteDelay) { if (delay < 1 || delay > 500) { - MainWindow.Log("Invalid input (allowed: 1 - 500)", 2); + MainWindow.Log("Invalid input - delay (allowed: 1 - 500)", 2); TextBox_Delay.Text = Settings.pasteDelay.ToString(); } else { MainWindow.Log("Changed delay " + Settings.pasteDelay + " -> " + delay, 0); @@ -63,6 +63,18 @@ private void Button_Apply_Click(object sender, RoutedEventArgs e) { } } + // Lower price % box + Int32.TryParse(TextBox_LowerPrice.Text, out int percentage); + if (percentage != Settings.lowerPricePercentage) { + if (percentage < 0 || percentage > 100) { + MainWindow.Log("Invalid input - percentage (allowed: 0 - 100)", 2); + TextBox_LowerPrice.Text = Settings.lowerPricePercentage.ToString(); + } else { + MainWindow.Log("Changed percentage " + Settings.lowerPricePercentage + " -> " + percentage, 0); + Settings.lowerPricePercentage = percentage; + } + } + // Checkboxes Settings.flag_priceBox = (bool)CheckBox_ShowOverlay.IsChecked; Settings.flag_fallback = (bool)CheckBox_Fallback.IsChecked; @@ -73,9 +85,6 @@ private void Button_Apply_Click(object sender, RoutedEventArgs e) { if ((bool)Radio_Buyout.IsChecked) Settings.prefix = Radio_Buyout.Content.ToString(); else Settings.prefix = Radio_Price.Content.ToString(); - // Slider - Settings.lowerPricePercentage = (int)Slider_LowerPrice.Value; - Hide(); } @@ -111,13 +120,6 @@ private void Button_Download_Click(object sender, RoutedEventArgs e) { }); } - /// - /// Updates label based on current slider value - /// - private void Slider_LowerPrice_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) { - Label_LowerPrice.Content = "Lower price by " + Slider_LowerPrice.Value + "%"; - } - /// /// Enables/disables other controls based on checkbox /// @@ -159,7 +161,7 @@ private void ResetOptions() { ComboBox_Source.SelectedValue = Settings.source; TextBox_Delay.Text = Settings.pasteDelay.ToString(); - Slider_LowerPrice.Value = Settings.lowerPricePercentage; + TextBox_LowerPrice.Text = Settings.lowerPricePercentage.ToString(); CheckBox_Fallback.IsChecked = Settings.flag_fallback; CheckBox_SendEnter.IsChecked = Settings.flag_sendEnter;