mirror of
https://github.com/knah/VRCMelonAssistant.git
synced 2024-06-28 02:50:28 +12:00
Open Themes folder working
This commit is contained in:
parent
d7676b4ba9
commit
c07f6da8ce
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using System.Windows;
|
||||
using System.IO;
|
||||
using System.Windows.Media;
|
||||
using ModAssistant.Pages;
|
||||
|
||||
namespace ModAssistant
|
||||
{
|
||||
|
@ -11,6 +12,7 @@ namespace ModAssistant
|
|||
{
|
||||
public static string LoadedTheme { get; private set; }
|
||||
public static List<string> LoadedThemes { get => loadedThemes.Keys.ToList(); }
|
||||
public static string ThemeDirectory => $"{Environment.CurrentDirectory}/Themes";
|
||||
|
||||
private static Dictionary<string, ResourceDictionary> loadedThemes = new Dictionary<string, ResourceDictionary>();
|
||||
private static List<string> preInstalledThemes = new List<string> { "Light", "Dark" };
|
||||
|
@ -23,9 +25,9 @@ namespace ModAssistant
|
|||
ResourceDictionary theme = LoadTheme(localTheme, true);
|
||||
loadedThemes.Add(localTheme, theme);
|
||||
}
|
||||
if (Directory.Exists($"{Environment.CurrentDirectory}/Themes"))
|
||||
if (Directory.Exists(ThemeDirectory))
|
||||
{
|
||||
foreach (string file in Directory.EnumerateFiles($"{Environment.CurrentDirectory}/Themes"))
|
||||
foreach (string file in Directory.EnumerateFiles(ThemeDirectory))
|
||||
{
|
||||
FileInfo info = new FileInfo(file);
|
||||
//Ignore Themes without the xaml extension and ignore themes with the same names as others.
|
||||
|
@ -42,6 +44,8 @@ namespace ModAssistant
|
|||
}
|
||||
//MessageBox.Show($"(DEBUG) Loaded {loadedThemes.Count - 2} themes from Themes folder.");
|
||||
}
|
||||
if (Options.Instance != null && Options.Instance.ApplicationThemeComboBox != null)
|
||||
Options.Instance.ApplicationThemeComboBox.ItemsSource = LoadedThemes;
|
||||
}
|
||||
|
||||
private static ResourceDictionary LoadTheme(string name, bool localUri = false)
|
||||
|
|
|
@ -67,14 +67,14 @@
|
|||
<TextBlock Name="GameTypeTextBlock" Text="{Binding InstallType}" FontSize="16"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="13" Margin="5" Grid.ColumnSpan="2" HorizontalAlignment="Stretch">
|
||||
<StackPanel Grid.Row="13" Grid.ColumnSpan="2" HorizontalAlignment="Stretch">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock HorizontalAlignment="Left" Text="Application Theme: " FontWeight="Bold" FontSize="16" />
|
||||
<TextBlock Margin="5" HorizontalAlignment="Left" Text="Application Theme: " FontWeight="Bold" FontSize="16" />
|
||||
<ComboBox Name="ApplicationThemeComboBox" Grid.Column="2" HorizontalAlignment="Stretch" SelectionChanged="ApplicationThemeComboBox_SelectionChanged" VerticalContentAlignment="Center"></ComboBox>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
|
|
@ -58,7 +58,6 @@ namespace ModAssistant.Pages
|
|||
if (!DesignerProperties.GetIsInDesignMode(this))
|
||||
{
|
||||
if (!Themes.LoadedThemes.Any()) Themes.LoadThemes();
|
||||
ApplicationThemeComboBox.ItemsSource = Themes.LoadedThemes;
|
||||
ApplicationThemeComboBox.SelectedValue = Themes.LoadedTheme;
|
||||
}
|
||||
}
|
||||
|
@ -266,7 +265,12 @@ namespace ModAssistant.Pages
|
|||
|
||||
private void ApplicationThemeOpenThemesFolder_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show("nice going laughShorts this is coming soon");
|
||||
if (Directory.Exists(Themes.ThemeDirectory))
|
||||
{
|
||||
//Code yeeted from ChroMapper
|
||||
string winPath = Themes.ThemeDirectory.Replace("/", "\\").Replace("\\\\", "\\");
|
||||
System.Diagnostics.Process.Start("explorer.exe", winPath);
|
||||
}else MessageBox.Show("Themes folder not found! Try exporting the template...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue