rearrange and add new editor button

This commit is contained in:
bluepilledgreat 2025-01-23 14:36:07 +00:00
parent 802ae6a613
commit 4aee0a33f1
3 changed files with 22 additions and 6 deletions

View File

@ -43,10 +43,16 @@
SyntaxHighlighting="XML" SyntaxHighlighting="XML"
TextChanged="OnCodeChanged" /> TextChanged="OnCodeChanged" />
<ui:Button
Grid.Row="2"
Margin="10"
Command="{Binding Path=OpenThemeFolderCommand, Mode=OneTime}"
Content="Open Theme Folder" />
<Grid <Grid
Grid.Row="2" Grid.Row="2"
Margin="10" Margin="10"
HorizontalAlignment="Center"> HorizontalAlignment="Right">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
@ -54,15 +60,14 @@
<ui:Button <ui:Button
Grid.Column="0" Grid.Column="0"
Margin="0,0,5,0" Margin="0,0,4,0"
HorizontalAlignment="Center"
Command="{Binding Path=PreviewCommand, Mode=OneTime}" Command="{Binding Path=PreviewCommand, Mode=OneTime}"
Content="Preview" /> Content="Preview" />
<ui:Button <ui:Button
Grid.Column="1" Grid.Column="1"
Margin="5,0,0,0" Margin="4,0,0,0"
HorizontalAlignment="Center" Appearance="Primary"
Command="{Binding Path=SaveCommand, Mode=OneTime}" Command="{Binding Path=SaveCommand, Mode=OneTime}"
Content="Save" /> Content="Save" />
</Grid> </Grid>

View File

@ -136,10 +136,13 @@ namespace Bloxstrap.UI.Elements.Editor
{ {
CustomBootstrapperSchema.ParseSchema(); CustomBootstrapperSchema.ParseSchema();
string themeContents = File.ReadAllText(Path.Combine(Paths.CustomThemes, name, "Theme.xml")); string directory = Path.Combine(Paths.CustomThemes, name);
string themeContents = File.ReadAllText(Path.Combine(directory, "Theme.xml"));
themeContents = ToCRLF(themeContents); // make sure the theme is in CRLF. a function expects CRLF. themeContents = ToCRLF(themeContents); // make sure the theme is in CRLF. a function expects CRLF.
var viewModel = new BootstrapperEditorWindowViewModel(); var viewModel = new BootstrapperEditorWindowViewModel();
viewModel.Directory = directory;
viewModel.Name = name; viewModel.Name = name;
viewModel.Title = $"Editing \"{name}\""; viewModel.Title = $"Editing \"{name}\"";
viewModel.Code = themeContents; viewModel.Code = themeContents;

View File

@ -16,6 +16,9 @@ namespace Bloxstrap.UI.ViewModels.Editor
public ICommand PreviewCommand => new RelayCommand(Preview); public ICommand PreviewCommand => new RelayCommand(Preview);
public ICommand SaveCommand => new RelayCommand(Save); public ICommand SaveCommand => new RelayCommand(Save);
public ICommand OpenThemeFolderCommand => new RelayCommand(OpenThemeFolder);
public string Directory { get; set; } = "";
public string Name { get; set; } = ""; public string Name { get; set; } = "";
public string Title { get; set; } = "Editing \"Custom Theme\""; public string Title { get; set; } = "Editing \"Custom Theme\"";
@ -66,5 +69,10 @@ namespace Bloxstrap.UI.ViewModels.Editor
Frontend.ShowMessageBox($"Failed to save theme: {ex.Message}", MessageBoxImage.Error, MessageBoxButton.OK); Frontend.ShowMessageBox($"Failed to save theme: {ex.Message}", MessageBoxImage.Error, MessageBoxButton.OK);
} }
} }
private void OpenThemeFolder()
{
Process.Start("explorer.exe", Directory);
}
} }
} }