Browse Source

Merge branch 'auto-update' of https://github.com/ionite34/StabilityMatrix into auto-update

pull/14/head
JT 1 year ago
parent
commit
beced21462
  1. 30
      StabilityMatrix/LaunchPage.xaml
  2. 31
      StabilityMatrix/ViewModels/SelectInstallLocationsViewModel.cs

30
StabilityMatrix/LaunchPage.xaml

@ -19,8 +19,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Page.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVisConverter"/>
<BooleanToVisibilityConverter x:Key="BoolToVisConverter" />
<!-- Manually copied style since can't inherit: https://github.com/lepoco/wpfui/blob/main/src/Wpf.Ui/Styles/Controls/ComboBox.xaml -->
<ControlTemplate TargetType="{x:Type ComboBoxItem}" x:Key="SelectPackageDropDownStyle">
<Grid>
@ -58,10 +58,8 @@
VerticalAlignment="Top"
d:DataContext="{d:DesignInstance Type=models:InstalledPackage,
IsDesignTimeCreatable=True}">
<TextBlock Margin="0,5,0,5" Text="{Binding DisplayName}" />
<TextBlock Margin="0,0,0,5">
<Run Text="{Binding FullPath, Mode=OneWay}"/>
</TextBlock>
<TextBlock Margin="0,5,0,5" Text="{Binding DisplayName, Mode=OneWay}" />
<TextBlock Margin="0,0,0,5" Text="{Binding FullPath, Mode=OneWay}" />
</StackPanel>
</Grid>
</Grid>
@ -186,7 +184,7 @@
<TextBlock
Margin="0,5,0,5"
Name="NameTextBlock"
Text="{Binding DisplayName}" />
Text="{Binding DisplayName, Mode=OneWay}" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
@ -208,13 +206,15 @@
TextWrapping="Wrap"
VerticalAlignment="Stretch" />
</ScrollViewer>
<ui:Button Grid.Row="2" Grid.ColumnSpan="2"
Margin="24,0,24,8"
Command="{Binding LaunchWebUiCommand}"
Appearance="Success"
FontSize="12"
HorizontalAlignment="Stretch"
Visibility="{Binding ShowWebUiButton, Converter={StaticResource BoolToVisConverter}}"
Content="Open Web UI"/>
<ui:Button
Appearance="Success"
Command="{Binding LaunchWebUiCommand}"
Content="Open Web UI"
FontSize="12"
Grid.ColumnSpan="2"
Grid.Row="2"
HorizontalAlignment="Stretch"
Margin="24,0,24,8"
Visibility="{Binding ShowWebUiButton, Converter={StaticResource BoolToVisConverter}}" />
</Grid>
</Page>

31
StabilityMatrix/ViewModels/SelectInstallLocationsViewModel.cs

@ -102,20 +102,29 @@ public partial class SelectInstallLocationsViewModel : ObservableObject
}
// No settings.json
// Check if the directory is empty
// Check if the directory is %APPDATA%\StabilityMatrix: hide badge and set directory valid
if (DataDirectory == DefaultInstallLocation)
{
IsStatusBadgeVisible = false;
IsDirectoryValid = true;
return true;
}
// Check if the directory is empty: hide badge and set directory to valid
var isEmpty = !Directory.EnumerateFileSystemEntries(DataDirectory).Any();
// If not, show error badge, and set directory to invalid to prevent continuing
if (!isEmpty)
if (isEmpty)
{
IsStatusBadgeVisible = true;
IsDirectoryValid = false;
DirectoryStatusText = InvalidDirectoryText;
return false;
IsStatusBadgeVisible = false;
IsDirectoryValid = true;
return true;
}
// Otherwise, hide badge and set directory to valid
IsStatusBadgeVisible = false;
IsDirectoryValid = true;
return true;
// Not empty and not appdata: show error badge, and set directory to invalid
IsStatusBadgeVisible = true;
IsDirectoryValid = false;
DirectoryStatusText = InvalidDirectoryText;
return false;
}
[RelayCommand]

Loading…
Cancel
Save