-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
18,492 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<UserControl x:Class="CactusPie.MapLocation.Minimap.ThemeSelector" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:CactusPie.MapLocation.Minimap" | ||
mc:Ignorable="d" | ||
d:DesignHeight="300" d:DesignWidth="300"> | ||
<ComboBox Name="ThemeComboBox" SelectedIndex="0" SelectionChanged="ThemeComboBox_OnSelectionChanged"> | ||
<ComboBoxItem>Light Theme</ComboBoxItem> | ||
<ComboBoxItem>Dark Theme</ComboBoxItem> | ||
<ComboBoxItem>Colorful Light Theme</ComboBoxItem> | ||
<ComboBoxItem>Colorful Dark Theme</ComboBoxItem> | ||
</ComboBox> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using CactusPie.MapLocation.Minimap.Data; | ||
using CactusPie.MapLocation.Minimap.Themes; | ||
|
||
namespace CactusPie.MapLocation.Minimap; | ||
|
||
public partial class ThemeSelector : UserControl | ||
{ | ||
private readonly MapConfiguration _mapConfiguration; | ||
|
||
public ThemeSelector(MapConfiguration mapConfiguration) | ||
{ | ||
_mapConfiguration = mapConfiguration; | ||
InitializeComponent(); | ||
} | ||
|
||
protected override void OnInitialized(EventArgs e) | ||
{ | ||
base.OnInitialized(e); | ||
|
||
if (_mapConfiguration.Theme != null) | ||
{ | ||
ThemeComboBox.SelectedItem = ThemeComboBox.Items | ||
.Cast<ComboBoxItem>() | ||
.FirstOrDefault(x => x.Content as string == _mapConfiguration.Theme); | ||
} | ||
} | ||
|
||
private void ThemeComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) | ||
{ | ||
string? selectedThemeName = (e.AddedItems[0] as ComboBoxItem)?.Content as string; | ||
|
||
if (selectedThemeName == null) | ||
{ | ||
throw new InvalidOperationException("Invalid theme name"); | ||
} | ||
|
||
ThemesController.ThemeTypes themeType = selectedThemeName switch | ||
{ | ||
"Light Theme" => ThemesController.ThemeTypes.Light, | ||
"Dark Theme" => ThemesController.ThemeTypes.Dark, | ||
"Colorful Light Theme" => ThemesController.ThemeTypes.ColourfulLight, | ||
"Colorful Dark Theme" => ThemesController.ThemeTypes.ColourfulDark, | ||
_ => throw new ArgumentOutOfRangeException($"Invalid theme name: {selectedThemeName}") | ||
}; | ||
|
||
ThemesController.SetTheme(themeType); | ||
} | ||
} |
Oops, something went wrong.