Skip to content

Commit 4c8f044

Browse files
committed
fix vs warning "The property 'IsEmpty' was not found in type 'String'", Add button: Download full editor in browser (instead of installer) #131
1 parent 375e6fe commit 4c8f044

File tree

3 files changed

+88
-15
lines changed

3 files changed

+88
-15
lines changed

Diff for: UnityLauncherPro/MainWindow.xaml

+62-10
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,21 @@
5050
<Grid>
5151
<!-- search box -->
5252
<Grid Background="{DynamicResource ThemeTextBoxBackground}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="222" Margin="6,5,0,0" Height="20" >
53-
<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="{DynamicResource ThemeSearchPlaceholder}" Visibility="{Binding Text.IsEmpty, Converter={StaticResource MyBoolToVisibilityConverter}, ElementName=txtSearchBox}" Height="24" />
53+
<!--<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="{DynamicResource ThemeSearchPlaceholder}" Visibility="{Binding Text.IsEmpty, Converter={StaticResource MyBoolToVisibilityConverter}, ElementName=txtSearchBox}" Height="24" />-->
54+
<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="{DynamicResource ThemeSearchPlaceholder}" Height="24">
55+
<TextBlock.Style>
56+
<Style TargetType="TextBlock">
57+
<Setter Property="Visibility" Value="Collapsed" />
58+
<Style.Triggers>
59+
<DataTrigger Binding="{Binding Text, ElementName=txtSearchBox}" Value="">
60+
<Setter Property="Visibility" Value="Visible" />
61+
</DataTrigger>
62+
</Style.Triggers>
63+
</Style>
64+
</TextBlock.Style>
65+
</TextBlock>
66+
67+
5468
<TextBox MinWidth="100" CaretBrush="{DynamicResource ThemeSearchCaret}" x:Name="txtSearchBox" Background="Transparent" BorderBrush="{x:Null}" Foreground="{DynamicResource ThemeSearchForeground}" SelectionBrush="{DynamicResource ThemeSearchSelection}" BorderThickness="0" Margin="2,2,0,0" UndoLimit="64" TextChanged="OnSearchTextChanged" PreviewKeyDown="TxtSearchBox_PreviewKeyDown" TabIndex="1" />
5569
<Button x:Name="btnClearSearch" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" BorderThickness="0" HorizontalAlignment="Right" VerticalAlignment="Top" Height="23" Width="23" Background="Transparent" Padding="0,2" BorderBrush="{x:Null}" Click="OnClearProjectSearchClick" IsTabStop="False">
5670
<TextBlock Text="" FontSize="8" Foreground="{DynamicResource ThemeSearchClose}" Padding="5,3,4,4" HorizontalAlignment="Center">
@@ -261,7 +275,18 @@
261275
<Grid>
262276
<!-- search box -->
263277
<Grid Background="{DynamicResource ThemeTextBoxBackground}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="222" Margin="6,5,0,0" Height="20" >
264-
<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="{DynamicResource ThemeSearchPlaceholder}" Visibility="{Binding Text.IsEmpty, Converter={StaticResource MyBoolToVisibilityConverter}, ElementName=txtSearchBoxUnity}" Height="24" />
278+
<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="{DynamicResource ThemeSearchPlaceholder}" Height="24">
279+
<TextBlock.Style>
280+
<Style TargetType="TextBlock">
281+
<Setter Property="Visibility" Value="Collapsed" />
282+
<Style.Triggers>
283+
<DataTrigger Binding="{Binding Text, ElementName=txtSearchBoxUnity}" Value="">
284+
<Setter Property="Visibility" Value="Visible" />
285+
</DataTrigger>
286+
</Style.Triggers>
287+
</Style>
288+
</TextBlock.Style>
289+
</TextBlock>
265290
<TextBox MinWidth="100" CaretBrush="{DynamicResource ThemeSearchCaret}" x:Name="txtSearchBoxUnity" Background="Transparent" BorderBrush="{x:Null}" Foreground="{DynamicResource ThemeSearchForeground}" SelectionBrush="{DynamicResource ThemeSearchSelection}" BorderThickness="0" Margin="2,2,0,0" UndoLimit="64" PreviewKeyDown="TxtSearchBoxUnity_PreviewKeyDown" TextChanged="TxtSearchBoxUnity_TextChanged" />
266291
<Button x: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">
267292
<TextBlock Text="" FontSize="8" Foreground="{DynamicResource ThemeSearchCaret}" Padding="5,3,4,4" HorizontalAlignment="Center">
@@ -377,7 +402,18 @@
377402
<Grid>
378403
<!-- search box -->
379404
<Grid Background="{DynamicResource ThemeTextBoxBackground}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="222" Margin="6,5,0,0" Height="20" >
380-
<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="{DynamicResource ThemeSearchPlaceholder}" Visibility="{Binding Text.IsEmpty, Converter={StaticResource MyBoolToVisibilityConverter}, ElementName=txtSearchBoxUpdates}" Height="24" />
405+
<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="{DynamicResource ThemeSearchPlaceholder}" Height="24">
406+
<TextBlock.Style>
407+
<Style TargetType="TextBlock">
408+
<Setter Property="Visibility" Value="Collapsed" />
409+
<Style.Triggers>
410+
<DataTrigger Binding="{Binding Text, ElementName=txtSearchBoxUpdates}" Value="">
411+
<Setter Property="Visibility" Value="Visible" />
412+
</DataTrigger>
413+
</Style.Triggers>
414+
</Style>
415+
</TextBlock.Style>
416+
</TextBlock>
381417
<TextBox MinWidth="100" CaretBrush="{DynamicResource ThemeSearchCaret}" x:Name="txtSearchBoxUpdates" Background="Transparent" BorderBrush="{x:Null}" Foreground="{DynamicResource ThemeSearchForeground}" SelectionBrush="{DynamicResource ThemeSearchSelection}" BorderThickness="0" Margin="2,2,0,0" UndoLimit="64" PreviewKeyDown="TxtSearchBoxUpdates_PreviewKeyDown" TextChanged="TxtSearchBoxUpdates_TextChanged" />
382418
<Button x: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">
383419
<TextBlock Text="" FontSize="8" Foreground="{DynamicResource ThemeSearchClose}" Padding="5,3,4,4" HorizontalAlignment="Center">
@@ -450,19 +486,23 @@
450486
<Grid VerticalAlignment="Bottom" Margin="4,0,8,5">
451487
<Grid.ColumnDefinitions>
452488
<ColumnDefinition Width="20*" />
453-
<ColumnDefinition Width="33*" />
454-
<ColumnDefinition Width="33*" />
489+
<ColumnDefinition Width="18*" />
490+
<ColumnDefinition Width="28*" />
491+
<ColumnDefinition Width="26*" />
455492
</Grid.ColumnDefinitions>
456493
<Grid.RowDefinitions>
457494
<RowDefinition Height="32" />
458495
</Grid.RowDefinitions>
459496
<Button Grid.Column="0" Style="{StaticResource CustomButton}" x:Name="btnDownloadInBrowser" Margin="5,0,0,0" BorderBrush="{x:Null}" Click="BtnDownloadInBrowser_Click">
460-
<Label Content="_Download in browser" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
497+
<Label Content="_Download installer in browser" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
461498
</Button>
462-
<Button Grid.Column="1" Style="{StaticResource CustomButton}" x:Name="btnDownloadInstallUpdate" Margin="5,0,0,0" BorderBrush="{x:Null}" Click="btnDownloadInstallUpdate_Click">
499+
<Button Grid.Column="1" Style="{StaticResource CustomButton}" x:Name="btnDownloadInBrowserFull" Margin="5,0,0,0" BorderBrush="{x:Null}" Click="BtnDownloadInBrowserFull_Click">
500+
<Label Content="_Download editor in browser" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
501+
</Button>
502+
<Button Grid.Column="2" Style="{StaticResource CustomButton}" x:Name="btnDownloadInstallUpdate" Margin="5,0,0,0" BorderBrush="{x:Null}" Click="btnDownloadInstallUpdate_Click">
463503
<Label Content="Download &amp; Install" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
464504
</Button>
465-
<Button Grid.Column="2" Style="{StaticResource CustomButton}" x:Name="btnOpenWebsite" Margin="5,0,0,0" BorderBrush="{x:Null}" Click="BtnOpenWebsite_Click" >
505+
<Button Grid.Column="3" Style="{StaticResource CustomButton}" x:Name="btnOpenWebsite" Margin="5,0,0,0" BorderBrush="{x:Null}" Click="BtnOpenWebsite_Click" >
466506
<Label Content="Release _Notes" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
467507
</Button>
468508
</Grid>
@@ -537,10 +577,22 @@
537577
<Button x:Name="btnRefreshBuildReport" Style="{StaticResource CustomButton}" ToolTip="Get latest Build Report from Editor.log" Content="" Height="22" Width="22" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="16" Margin="0,4,10,0" Padding="1,-2,1,1" BorderBrush="{x:Null}" Click="BtnRefreshBuildReport_Click"/>
538578
<!--<CheckBox x:Name="chkAutoUpdateBuildReport" Content="AutoUpdate" Foreground="{DynamicResource ButtonForeground}" Margin="0,0,0,3" ToolTip="" HorizontalAlignment="Right" VerticalAlignment="Top" Height="26" VerticalContentAlignment="Center" IsEnabled="False"/>-->
539579

540-
541580
<!-- search box -->
542581
<Grid Background="{DynamicResource ThemeTextBoxBackground}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="222" Margin="6,5,0,0" Height="20" >
543-
<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="{DynamicResource ThemeSearchPlaceholder}" Visibility="{Binding Text.IsEmpty, Converter={StaticResource MyBoolToVisibilityConverter}, ElementName=txtSearchBoxBuildReport}" Height="24" IsEnabled="False" />
582+
<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="{DynamicResource ThemeSearchPlaceholder}" Height="24">
583+
<TextBlock.Style>
584+
<Style TargetType="TextBlock">
585+
<Setter Property="Visibility" Value="Collapsed" />
586+
<Setter Property="IsEnabled" Value="False" />
587+
<Style.Triggers>
588+
<DataTrigger Binding="{Binding Text, ElementName=txtSearchBoxBuildReport}" Value="">
589+
<Setter Property="Visibility" Value="Visible" />
590+
<Setter Property="IsEnabled" Value="True" />
591+
</DataTrigger>
592+
</Style.Triggers>
593+
</Style>
594+
</TextBlock.Style>
595+
</TextBlock>
544596
<TextBox MinWidth="100" CaretBrush="{DynamicResource ThemeSearchCaret}" x:Name="txtSearchBoxBuildReport" Background="Transparent" BorderBrush="{x:Null}" Foreground="{DynamicResource ThemeSearchForeground}" SelectionBrush="{DynamicResource ThemeSearchSelection}" BorderThickness="0" Margin="2,2,0,0" UndoLimit="64" PreviewKeyDown="TxtSearchBoxBuildReport_PreviewKeyDown" TextChanged="TxtSearchBoxBuildReport_TextChanged" />
545597
<Button x:Name="btnClearBuildReportSearch" 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="BtnClearBuildReportSearch_Click">
546598
<TextBlock Text="" FontSize="8" Foreground="{DynamicResource ThemeSearchCaret}" Padding="5,3,4,4" HorizontalAlignment="Center">

Diff for: UnityLauncherPro/MainWindow.xaml.cs

+15
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,21 @@ private void BtnDownloadInBrowser_Click(object sender, RoutedEventArgs e)
14891489
}
14901490
}
14911491

1492+
private void BtnDownloadInBrowserFull_Click(object sender, RoutedEventArgs e)
1493+
{
1494+
var unity = GetSelectedUpdate();
1495+
string url = Tools.GetUnityReleaseURL(unity?.Version);
1496+
if (string.IsNullOrEmpty(url) == false)
1497+
{
1498+
Tools.DownloadInBrowser(url, unity.Version,true);
1499+
}
1500+
else
1501+
{
1502+
Console.WriteLine("Failed getting Unity Installer URL for " + unity?.Version);
1503+
SetStatus("Failed getting Unity Installer URL for " + unity?.Version);
1504+
}
1505+
}
1506+
14921507
private void btnDownloadInstallUpdate_Click(object sender, RoutedEventArgs e)
14931508
{
14941509
var unity = GetSelectedUpdate();

Diff for: UnityLauncherPro/Tools.cs

+11-5
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,9 @@ public static void OpenURL(string url)
544544
Process.Start(url);
545545
}
546546

547-
public static void DownloadInBrowser(string url, string version)
547+
public static void DownloadInBrowser(string url, string version, bool preferFullInstaller = false)
548548
{
549-
string exeURL = ParseDownloadURLFromWebpage(version);
549+
string exeURL = ParseDownloadURLFromWebpage(version, preferFullInstaller);
550550

551551
Console.WriteLine("download exeURL= (" + exeURL + ")");
552552

@@ -711,7 +711,7 @@ static bool DownloadFile(string url, string tempFile)
711711

712712
// parse Unity installer exe from release page
713713
// thanks to https://github.com/softfruit
714-
public static string ParseDownloadURLFromWebpage(string version)
714+
public static string ParseDownloadURLFromWebpage(string version, bool preferFullInstaller = false)
715715
{
716716
string url = "";
717717

@@ -744,7 +744,7 @@ public static string ParseDownloadURLFromWebpage(string version)
744744
string[] lines = sourceHTML.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
745745

746746
// patch version download assistant finder
747-
if (Tools.VersionIsPatch(version))
747+
if (VersionIsPatch(version))
748748
{
749749
for (int i = 0; i < lines.Length; i++)
750750
{
@@ -757,7 +757,7 @@ public static string ParseDownloadURLFromWebpage(string version)
757757
}
758758
}
759759
}
760-
else if (Tools.VersionIsArchived(version))
760+
else if (VersionIsArchived(version))
761761
{
762762
// archived version download assistant finder
763763
for (int i = 0; i < lines.Length; i++)
@@ -795,6 +795,12 @@ public static string ParseDownloadURLFromWebpage(string version)
795795
}
796796
}
797797

798+
// download full installer instead
799+
if (preferFullInstaller)
800+
{
801+
url = url.Replace("UnityDownloadAssistant-" + version + ".exe", "Windows64EditorInstaller/UnitySetup64-" + version + ".exe");
802+
}
803+
798804
// didnt find installer
799805
if (string.IsNullOrEmpty(url))
800806
{

0 commit comments

Comments
 (0)