Added combo list to change theme

This commit is contained in:
Konrad Pierzyński 2019-01-23 00:33:41 +01:00
parent 93bb0a8e08
commit 8e3e2ccc72
3 changed files with 9 additions and 12 deletions

View File

@ -13,12 +13,6 @@ namespace Magazyn
/// </summary> /// </summary>
public partial class App : Application public partial class App : Application
{ {
protected override void OnStartup(StartupEventArgs e)
{
ChangeTheme(2);
base.OnStartup(e);
}
public void ChangeTheme(int index) public void ChangeTheme(int index)
{ {
Resources.MergedDictionaries.Clear(); Resources.MergedDictionaries.Clear();

View File

@ -23,7 +23,7 @@
<Label Content="Lista owoców:" FontWeight="Bold" HorizontalAlignment="Left" Margin="10,4,0,0" VerticalAlignment="Top" Width="100"/> <Label Content="Lista owoców:" FontWeight="Bold" HorizontalAlignment="Left" Margin="10,4,0,0" VerticalAlignment="Top" Width="100"/>
<Button x:Name="prevButton" Content="Poprzednia" HorizontalAlignment="Left" Margin="10,0,0,52" VerticalAlignment="Bottom" Width="105" Click="prevButton_Click"/> <Button x:Name="prevButton" Content="Poprzednia" HorizontalAlignment="Left" Margin="10,0,0,52" VerticalAlignment="Bottom" Width="105" Click="prevButton_Click"/>
<Button x:Name="nextButton" Content="Następna" HorizontalAlignment="Right" Margin="0,0,10,52" VerticalAlignment="Bottom" Width="105" Click="nextButton_Click"/> <Button x:Name="nextButton" Content="Następna" HorizontalAlignment="Right" Margin="0,0,10,52" VerticalAlignment="Bottom" Width="105" Click="nextButton_Click"/>
<Button Name="themeButton" Content="Theme" Margin="10,0,0,10" VerticalAlignment="Bottom" Height="35" HorizontalAlignment="Left" Width="80" Click="themeButton_Click"/> <ComboBox SelectionChanged="themeCombo_SelectionChanged" x:Name="themeCombo" HorizontalAlignment="Left" Margin="10,0,0,10" VerticalAlignment="Bottom" Width="162"/>
</Grid> </Grid>

View File

@ -25,7 +25,6 @@ namespace Magazyn
{ {
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
int i = 0;
public int size = 4; public int size = 4;
public int page = 0; public int page = 0;
@ -38,7 +37,11 @@ namespace Magazyn
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
this.Initialized += MainWindow_Initialized; ; this.Initialized += MainWindow_Initialized;
themeCombo.Items.Add("Jasno/Niebieski");
themeCombo.Items.Add("Jasno/Zielony");
themeCombo.Items.Add("Ciemno/Pomarańczowy");
themeCombo.SelectedIndex = 0;
client = new HttpClient(); client = new HttpClient();
} }
@ -155,10 +158,10 @@ namespace Magazyn
RefreshListOfFruits(); RefreshListOfFruits();
} }
private void themeButton_Click(object sender, RoutedEventArgs e) private void themeCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
var app = App.Current as App; var app = App.Current as App;
app.ChangeTheme(i++); app.ChangeTheme(themeCombo.SelectedIndex);
} }
} }
} }