Skip to content

Commit 75f4aec

Browse files
author
g34r
committed
Make syllable practice tab item not visible in non-Hangul key layout
1 parent 55b4b7f commit 75f4aec

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

OpenTyping/MainWindow.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
</Button>
4040
</mah:WindowCommands>
4141
</mah:MetroWindow.RightWindowCommands>
42-
<TabControl>
42+
<TabControl x:Name="MenuTabControl">
4343
<TabItem>
4444
<TabItem.Header>
4545
<StackPanel Orientation="Horizontal">
@@ -74,7 +74,7 @@
7474
</TabItem.Header>
7575
<local:KeyPracticeMenu x:Name="KeyPracticeMenu"/>
7676
</TabItem>
77-
<TabItem>
77+
<TabItem x:Name="SyllablePracticeTabItem">
7878
<TabItem.Header>
7979
<StackPanel Orientation="Horizontal">
8080
<Grid Margin="2 0 6 0">

OpenTyping/MainWindow.xaml.cs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ public MainWindow()
4444
try
4545
{
4646
var keyLayouts =
47-
new List<KeyLayout>(
48-
OpenTyping.KeyLayout.LoadFromDirectory((string)Settings.Default[KeyLayoutDataDirStr]));
47+
new List<KeyLayout>(KeyLayout.LoadFromDirectory((string)Settings.Default[KeyLayoutDataDirStr]));
4948

5049
var layoutName = (string)Settings.Default[KeyLayoutStr];
5150
KeyLayout currentKeylayout = keyLayouts.FirstOrDefault(keyLayout => keyLayout.Name == layoutName);
@@ -86,7 +85,14 @@ public MainWindow()
8685
}
8786

8887
InitializeComponent();
89-
Closed += MainWindow_Closed;
88+
89+
this.Loaded += MainWindow_Loaded;
90+
this.Closed += MainWindow_Closed;
91+
}
92+
93+
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
94+
{
95+
CheckSyllablePractice();
9096
}
9197

9298
private static void MainWindow_Closed(object sender, EventArgs e)
@@ -151,10 +157,29 @@ private void SettingsButton_Click(object sender, RoutedEventArgs e)
151157
Source = CurrentKeyLayout,
152158
};
153159
HomeMenu.SentencePracticeCount.SetBinding(TextBlock.TextProperty, sentencePracticeCountBinding);
160+
161+
CheckSyllablePractice();
154162
}
155163

156164
SentencePracticeMenu.LoadData();
157165
ArticlePracticeMenu.LoadData();
158166
}
167+
168+
private void CheckSyllablePractice()
169+
{
170+
if (CurrentKeyLayout.Character == "한글")
171+
{
172+
SyllablePracticeTabItem.Visibility = Visibility.Visible;
173+
}
174+
else
175+
{
176+
SyllablePracticeTabItem.Visibility = Visibility.Collapsed;
177+
178+
if (SyllablePracticeTabItem.IsSelected)
179+
{
180+
MenuTabControl.SelectedIndex = 0;
181+
}
182+
}
183+
}
159184
}
160185
}

0 commit comments

Comments
 (0)