Skip to content

Commit e6ef8bb

Browse files
committed
fix valid data path tick
1 parent 53c04f3 commit e6ef8bb

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

AnnoMapEditor/MainWindow.xaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66
xmlns:controls="clr-namespace:AnnoMapEditor.Controls"
7+
xmlns:utils="clr-namespace:AnnoMapEditor.Utils"
78
mc:Ignorable="d"
89
Title="MainWindow" Height="450" Width="800"
910
Background="#182B3F">
@@ -51,6 +52,7 @@
5152
<Setter Property="Width" Value="auto" />
5253
<Setter Property="Padding" Value="2,6,2,6" />
5354
</Style>
55+
<utils:BooleanToVisibilityConverter x:Key="VisibleOnTrue" />
5456
</Window.Resources>
5557
<Grid>
5658
<Grid.ColumnDefinitions>
@@ -63,7 +65,7 @@
6365
<Button Click="Configure_Click" Style="{StaticResource DefaultButtonStyle}" Width="200" HorizontalAlignment="Left">Set RDA path...</Button>
6466
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
6567
<TextBlock Style="{StaticResource DefaultLabelStyle}" Text="{Binding Settings.DataPath, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" />
66-
<TextBlock Style="{StaticResource DefaultLabelStyle}" Text="" Visibility="{Binding Settings.IsValidDataPath, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" />
68+
<TextBlock Style="{StaticResource DefaultLabelStyle}" Text="" Visibility="{Binding Settings.IsValidDataPath, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource VisibleOnTrue}}" />
6769
</StackPanel>
6870
</StackPanel>
6971
</Grid>

AnnoMapEditor/MainWindow.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private async void OpenFile_Click(object sender, RoutedEventArgs e)
4444

4545
if (true == picker.ShowDialog())
4646
{
47-
if (string.IsNullOrEmpty(Settings.Instance.DataPath))
47+
if (!Settings.Instance.IsValidDataPath)
4848
{
4949
int end = picker.FileName.IndexOf(@"\data\session");
5050
if (end == -1)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Windows;
4+
using System.Windows.Data;
5+
6+
namespace AnnoMapEditor.Utils
7+
{
8+
[ValueConversion(typeof(bool), typeof(Visibility))]
9+
public sealed class BooleanToVisibilityConverter : IValueConverter
10+
{
11+
public object Convert(object value, Type targetType,
12+
object parameter, CultureInfo culture)
13+
{
14+
return (value is bool b && b) ? Visibility.Visible : Visibility.Collapsed;
15+
}
16+
17+
public object ConvertBack(object value, Type targetType,
18+
object parameter, CultureInfo culture)
19+
{
20+
return Equals(value, Visibility.Visible);
21+
}
22+
}
23+
}

AnnoMapEditor/Utils/Settings.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public string? DataPath
2424
}
2525
}
2626
}
27-
private string? _dataPath = UserSettings.Default.DataPath;
27+
private string? _dataPath;
2828

2929
public bool IsValidDataPath
3030
{
@@ -33,6 +33,11 @@ public bool IsValidDataPath
3333
}
3434
private bool _isValidDataPath = false;
3535

36+
public Settings()
37+
{
38+
DataPath = UserSettings.Default.DataPath;
39+
}
40+
3641
private static string? CorrectDataPath(string? path)
3742
{
3843
if (path is null)

0 commit comments

Comments
 (0)