Skip to content

Commit

Permalink
Replace slider with textbox
Browse files Browse the repository at this point in the history
  • Loading branch information
siegrest committed Feb 15, 2018
1 parent 676141d commit 0c4e915
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
7 changes: 4 additions & 3 deletions Pricer/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@
</GroupBox>
<GroupBox Header="Universal settings" HorizontalAlignment="Left" Height="170" Margin="435,10,0,0" VerticalAlignment="Top" Width="180">
<Grid>
<Slider x:Name="Slider_LowerPrice" Width="150" Maximum="100" SmallChange="0" IsSnapToTickEnabled="True" LargeChange="0" Height="22" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,31,-22,0" ToolTip="How much % of the price should be reduced?" ValueChanged="Slider_LowerPrice_ValueChanged"/>
<Label x:Name="Label_LowerPrice" Content="Lower price by 0%" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Padding="2" Height="20" Width="101"/>
<CheckBox x:Name="CheckBox_Fallback" Content="PoePrices Fallback" HorizontalAlignment="Left" Margin="10,61,0,0" VerticalAlignment="Top" ToolTip="Send item data to PoePrices API when there's no local match" IsChecked="True" Height="15" Width="116"/>
<Label Content="Lower price by" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Padding="2" Height="20" Width="82"/>
<CheckBox x:Name="CheckBox_Fallback" Content="PoePrices Fallback" HorizontalAlignment="Left" Margin="10,38,0,0" VerticalAlignment="Top" ToolTip="Send item data to PoePrices API when there's no local match" IsChecked="True" Height="15" Width="116"/>
<TextBox x:Name="TextBox_LowerPrice" HorizontalAlignment="Left" Height="23" Margin="97,10,0,0" Text="0" VerticalAlignment="Top" Width="29" ToolTip="How much % of the price should be reduced?" AllowDrop="False" VerticalScrollBarVisibility="Disabled"/>
<Label Content="%" HorizontalAlignment="Left" Margin="126,10,0,0" VerticalAlignment="Top" Padding="2" Height="20" Width="15"/>
</Grid>
</GroupBox>

Expand Down
26 changes: 14 additions & 12 deletions Pricer/SettingsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,26 @@ 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);
Settings.pasteDelay = delay;
}
}

// 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;
Expand All @@ -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();
}

Expand Down Expand Up @@ -111,13 +120,6 @@ private void Button_Download_Click(object sender, RoutedEventArgs e) {
});
}

/// <summary>
/// Updates label based on current slider value
/// </summary>
private void Slider_LowerPrice_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) {
Label_LowerPrice.Content = "Lower price by " + Slider_LowerPrice.Value + "%";
}

/// <summary>
/// Enables/disables other controls based on checkbox
/// </summary>
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0c4e915

Please sign in to comment.