Skip to content

Commit dfe3337

Browse files
committed
make clear search buttons work, load updates list on entering tab, add Tabs enum
1 parent 2f8ddc8 commit dfe3337

File tree

5 files changed

+54
-5
lines changed

5 files changed

+54
-5
lines changed

UnityLauncherPro/Data/Tabs.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace UnityLauncherPro
2+
{
3+
public enum Tabs
4+
{
5+
Projects = 0,
6+
Unitys = 1,
7+
Updates = 2,
8+
Settings = 3
9+
}
10+
11+
}

UnityLauncherPro/GetUnityInstallations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static UnityInstallation[] Scan(string[] rootFolders)
4545
unity.Path = exePath;
4646
unity.Installed = installDate;
4747

48-
// add to dictionary, if not there yet NOTE should notify that there are 2 same versions..? this might happen with preview builds..
48+
// add to list, if not there yet NOTE should notify that there are 2 same versions..? this might happen with preview builds..
4949
if (results.Contains(unity) == true)
5050
{
5151
Console.WriteLine("Warning: 2 same versions found for " + version);

UnityLauncherPro/MainWindow.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
</Grid>
244244

245245
<!-- main content : Tabs -->
246-
<TabControl Grid.Row="1" x:Name="tabControl" Background="{DynamicResource MainBackgroundColor}" BorderBrush="{x:Null}" Padding="0" Margin="0">
246+
<TabControl Grid.Row="1" x:Name="tabControl" Background="{DynamicResource MainBackgroundColor}" BorderBrush="{x:Null}" Padding="0" Margin="0" SelectionChanged="OnTabSelectionChanged">
247247

248248
<!-- Tab: Projects-->
249249
<TabItem Header="Projects" Style="{DynamicResource TabItemStyle1}" Padding="0,0,0,0" Margin="-1,1,1,-1" BorderBrush="{x:Null}">
@@ -252,7 +252,7 @@
252252
<Grid Background="{DynamicResource TextBoxBackground}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="222" Margin="6,5,0,0" Height="20" >
253253
<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="#7F919191" Visibility="{Binding ElementName=txtSearchBox, Path=Text.IsEmpty, Converter={StaticResource MyBoolToVisibilityConverter}}" Height="24" />
254254
<TextBox MinWidth="100" CaretBrush="#FFE2E2E2" Name="txtSearchBox" Background="Transparent" BorderBrush="{x:Null}" Foreground="#FFC7C7C7" SelectionBrush="#FF003966" BorderThickness="0" Margin="2,2,0,0" UndoLimit="64" TextChanged="OnSearchTextChanged" />
255-
<Button Name="btnClearSearch" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" BorderThickness="0" HorizontalAlignment="Right" VerticalAlignment="Top" Height="23" Width="23" Background="Transparent" Padding="0,2" Visibility="Visible" BorderBrush="{x:Null}">
255+
<Button Name="btnClearSearch" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" BorderThickness="0" HorizontalAlignment="Right" VerticalAlignment="Top" Height="23" Width="23" Background="Transparent" Padding="0,2" Visibility="Visible" BorderBrush="{x:Null}" Click="OnClearProjectSearchClick">
256256
<TextBlock Text="" FontSize="8" Foreground="{DynamicResource ButtonForeground}" Padding="5,3,4,4" HorizontalAlignment="Center">
257257
<TextBlock.Style>
258258
<Style TargetType="TextBlock">
@@ -379,7 +379,7 @@
379379
<Grid Background="{DynamicResource TextBoxBackground}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="222" Margin="6,5,0,0" Height="20" >
380380
<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="#7F919191" Visibility="{Binding ElementName=txtSearchBoxUnity, Path=Text.IsEmpty, Converter={StaticResource MyBoolToVisibilityConverter}}" Height="24" />
381381
<TextBox MinWidth="100" CaretBrush="#FFE2E2E2" Name="txtSearchBoxUnity" Background="Transparent" BorderBrush="{x:Null}" Foreground="#FFC7C7C7" SelectionBrush="#FF003966" BorderThickness="0" Margin="2,2,0,0" UndoLimit="64" />
382-
<Button Name="btnClearUnitySearch" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" BorderThickness="0" HorizontalAlignment="Right" VerticalAlignment="Top" Height="23" Width="23" Background="Transparent" Padding="0,2" Visibility="Visible" BorderBrush="{x:Null}">
382+
<Button Name="btnClearUnitySearch" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" BorderThickness="0" HorizontalAlignment="Right" VerticalAlignment="Top" Height="23" Width="23" Background="Transparent" Padding="0,2" Visibility="Visible" BorderBrush="{x:Null}" Click="OnClearUnitySearchClick">
383383
<TextBlock Text="" FontSize="8" Foreground="#FFC3C3C3" Padding="5,3,4,4" HorizontalAlignment="Center">
384384
<TextBlock.Style>
385385
<Style TargetType="TextBlock">
@@ -450,7 +450,7 @@
450450
<Grid Background="{DynamicResource TextBoxBackground}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="222" Margin="6,5,0,0" Height="20" >
451451
<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="#7F919191" Visibility="{Binding ElementName=txtSearchBoxUpdates, Path=Text.IsEmpty, Converter={StaticResource MyBoolToVisibilityConverter}}" Height="24" />
452452
<TextBox MinWidth="100" CaretBrush="#FFE2E2E2" Name="txtSearchBoxUpdates" Background="Transparent" BorderBrush="{x:Null}" Foreground="#FFC7C7C7" SelectionBrush="#FF003966" BorderThickness="0" Margin="2,2,0,0" UndoLimit="64" />
453-
<Button Name="btnClearUpdatesSearch" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" BorderThickness="0" HorizontalAlignment="Right" VerticalAlignment="Top" Height="23" Width="23" Background="Transparent" Padding="0,2" Visibility="Visible" BorderBrush="{x:Null}">
453+
<Button Name="btnClearUpdatesSearch" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" BorderThickness="0" HorizontalAlignment="Right" VerticalAlignment="Top" Height="23" Width="23" Background="Transparent" Padding="0,2" Visibility="Visible" BorderBrush="{x:Null}" Click="OnClearUpdateSearchClick">
454454
<TextBlock Text="" FontSize="8" Foreground="#FFC3C3C3" Padding="5,3,4,4" HorizontalAlignment="Center">
455455
<TextBlock.Style>
456456
<Style TargetType="TextBlock">

UnityLauncherPro/MainWindow.xaml.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,15 @@ private async void OnGetUnityUpdatesClick(object sender, RoutedEventArgs e)
157157
{
158158
var button = (Button)sender;
159159
button.IsEnabled = false;
160+
160161
var task = GetUnityUpdates.Scan();
161162
var items = await task;
162163
// TODO handle errors?
164+
if (items == null) return;
163165
updatesSource = GetUnityUpdates.Parse(items);
166+
if (updatesSource == null) return;
164167
dataGridUpdates.ItemsSource = updatesSource;
168+
165169
button.IsEnabled = true;
166170
}
167171

@@ -196,5 +200,38 @@ private void OnWindowKeyDown(object sender, KeyEventArgs e)
196200
break;
197201
}
198202
}
203+
204+
private async void OnTabSelectionChanged(object sender, SelectionChangedEventArgs e)
205+
{
206+
// if going into updates tab, fetch list (first time only)
207+
if (((TabControl)sender).SelectedIndex == (int)Tabs.Updates)
208+
{
209+
if (updatesSource == null)
210+
{
211+
var task = GetUnityUpdates.Scan();
212+
var items = await task;
213+
// TODO handle errors?
214+
if (items == null) return;
215+
updatesSource = GetUnityUpdates.Parse(items);
216+
if (updatesSource == null) return;
217+
dataGridUpdates.ItemsSource = updatesSource;
218+
}
219+
}
220+
}
221+
222+
private void OnClearProjectSearchClick(object sender, RoutedEventArgs e)
223+
{
224+
txtSearchBox.Text = "";
225+
}
226+
227+
private void OnClearUnitySearchClick(object sender, RoutedEventArgs e)
228+
{
229+
txtSearchBoxUnity.Text = "";
230+
}
231+
232+
private void OnClearUpdateSearchClick(object sender, RoutedEventArgs e)
233+
{
234+
txtSearchBoxUpdates.Text = "";
235+
}
199236
}
200237
}

UnityLauncherPro/UnityLauncherPro.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
<Generator>MSBuild:Compile</Generator>
7676
<SubType>Designer</SubType>
7777
</ApplicationDefinition>
78+
<Compile Include="Data\Tabs.cs" />
7879
<Compile Include="GetProjects.cs" />
7980
<Compile Include="GetUnityInstallations.cs" />
8081
<Compile Include="GetUnityUpdates.cs" />

0 commit comments

Comments
 (0)