Skip to content

Commit 0ed9569

Browse files
author
Juan Segura
committed
Removed AvaloniaDialog dependencies
1 parent caac588 commit 0ed9569

File tree

7 files changed

+53
-45
lines changed

7 files changed

+53
-45
lines changed

ZXBSInstaller.Log/ServiceLayer.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,11 @@ private static ExternalTools_Version[] GetBorielBasicVersions(string versionsUrl
519519
// Get all hrefs in the page according to the pattern.
520520
// The pattern is specific for the Boriel Basic repository page, which contains links to the versions in the format <a href="/boriel-basic/zxbasic/releases/download/v1.2.3/zxbasic-v1.2.3-win.zip">zxbasic-v1.2.3-win.zip</a>
521521
var links = GetAllLinks(versionsUrl, @"<a\s+[^>]*href\s*=\s*[""']([^""']+)[""']");
522-
522+
if (links == null)
523+
{
524+
ShowMessage("The Boriel Basic repository could not be accessed. Please check your internet connection or try again later.");
525+
return null;
526+
}
523527
// Parse links extracting versions data
524528
var lst = new List<ExternalTools_Version>();
525529
Regex _regex = new Regex(
@@ -588,6 +592,12 @@ private static ExternalTools_Version[] GetBorielZXBSVersions(string versionsUrl,
588592
{
589593
// Get all hrefs
590594
var links = GetAllLinks(versionsUrl, @"href=""([^""]+)""");
595+
if (links == null)
596+
{
597+
ShowMessage("The ZX Basic Studio repository could not be accessed. Please check your internet connection or try again later.");
598+
return null;
599+
}
600+
591601
// Get only releases
592602
links = links.Where(d => d.Contains("/boriel-basic/ZXBasicStudio/releases/tag/")).ToArray();
593603

@@ -598,6 +608,18 @@ private static ExternalTools_Version[] GetBorielZXBSVersions(string versionsUrl,
598608
var url = link.Replace("/boriel-basic/ZXBasicStudio/releases/tag/", "");
599609
url = $"https://github.com/boriel-basic/ZXBasicStudio/releases/expanded_assets/{url}";
600610
var filesLinks = GetAllLinks(url, @"href=""([^""]+)""");
611+
if (links == null)
612+
{
613+
if (installer)
614+
{
615+
ShowMessage("The ZXBSInstaller repository could not be accessed. Please check your internet connection or try again later.");
616+
}
617+
else
618+
{
619+
ShowMessage("The ZX Basic Studio repository could not be accessed. Please check your internet connection or try again later.");
620+
}
621+
return null;
622+
}
601623
foreach (var fl in filesLinks)
602624
{
603625
if (fl.Contains("download"))
@@ -844,7 +866,7 @@ private static ExternalTools_Version GetZXBSVersion(string exePath)
844866
if (!File.Exists(fileName))
845867
{
846868
// no version.txt file
847-
if(File.Exists(Path.Combine(exePath, "ZXBasicStudio.exe"))
869+
if (File.Exists(Path.Combine(exePath, "ZXBasicStudio.exe"))
848870
|| File.Exists(Path.Combine(exePath, "ZXBasicStudio")))
849871
{
850872
// return "OLD version"

ZXBSInstaller/Controls/MainControl.axaml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,26 @@
7979
</Grid>
8080

8181
<!-- Modals -->
82-
<Grid x:Name="pnlModalOverlay" Grid.ColumnSpan="3" Grid.RowSpan="5" Margin="0" IsVisible="False">
82+
<Grid x:Name="pnlModal" Grid.ColumnSpan="3" Grid.RowSpan="5" Margin="0" IsVisible="False">
8383
<Grid Background="Black" Opacity="0.8"></Grid>
84-
<Grid x:Name="pnlModalContainer">
85-
</Grid>
84+
<Border Background="Black" Width="600" Height="300" BorderBrush="White" BorderThickness="1"
85+
Padding="16" CornerRadius="8" HorizontalAlignment="Center" VerticalAlignment="Center">
86+
<Grid Grid.RowDefinitions="Auto,*,Auto">
87+
<Grid>
88+
<TextBlock x:Name="txtModalTitle" FontSize="20" Margin="0,0,0,8" Foreground="Yellow" Text="ZXBSInstaller"/>
89+
</Grid>
90+
<ScrollViewer Grid.Row="1" Margin="4">
91+
<TextBlock x:Name="txtModalMessage" FontSize="16" Margin="0,0,0,16" TextWrapping="Wrap" Text=""/>
92+
</ScrollViewer>
93+
<Button x:Name="btnModalClose" Grid.Row="2" Width="100" HorizontalAlignment="Right" Click="btnModalClose_Click">
94+
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
95+
<svg:Svg Path="/Assets/cancel.svg" Width="20" Margin="0,0,4,0"></svg:Svg>
96+
<TextBlock Text="Cancel"/>
97+
</StackPanel>
98+
</Button>
99+
</Grid>
100+
</Border>
86101
</Grid>
102+
87103
</Grid>
88104
</UserControl>

ZXBSInstaller/Controls/MainControl.axaml.cs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
using Avalonia.Media;
77
using Avalonia.Threading;
88
using Avalonia.VisualTree;
9-
using MsBox.Avalonia;
10-
using MsBox.Avalonia.Dto;
11-
using MsBox.Avalonia.Enums;
129
using System;
1310
using System.Collections.Generic;
1411
using System.Data;
@@ -92,16 +89,8 @@ private void ShowMessage(string message)
9289
Dispatcher.UIThread.Post(() =>
9390
{
9491
HideStatusPanel();
95-
var box = MessageBoxManager.GetMessageBoxStandard(new MessageBoxStandardParams
96-
{
97-
ButtonDefinitions = ButtonEnum.Ok,
98-
ContentTitle = "ZX Basic Studio Installer",
99-
ContentMessage = message,
100-
Icon = MsBox.Avalonia.Enums.Icon.Info,
101-
WindowIcon = ((Window)this.VisualRoot).Icon,
102-
WindowStartupLocation = WindowStartupLocation.CenterOwner
103-
});
104-
box.ShowAsPopupAsync(this);
92+
txtModalMessage.Text = message;
93+
pnlModal.IsVisible = true;
10594
});
10695
}
10796

@@ -128,17 +117,7 @@ private void GetExternalTools()
128117
if (tools == null)
129118
{
130119
// Error!
131-
var box = MessageBoxManager.GetMessageBoxStandard(new MessageBoxStandardParams
132-
{
133-
ButtonDefinitions = ButtonEnum.Ok,
134-
ContentTitle = "ERROR",
135-
ContentMessage = "Error retrieving the list of tools, please check your Internet connection.\r\nIt may be a temporary server error, report the error to duefectucorp@gmail.com and try again later.",
136-
Icon = MsBox.Avalonia.Enums.Icon.Error,
137-
WindowIcon = ((Window)this.VisualRoot).Icon,
138-
WindowStartupLocation = WindowStartupLocation.CenterOwner
139-
});
140-
box.ShowAsPopupAsync(this);
141-
120+
ShowMessage("Error retrieving the list of tools, please check your Internet connection.\r\nIt may be a temporary server error, report the error to duefectucorp@gmail.com and try again later.");
142121
}
143122
else
144123
{
@@ -531,4 +510,9 @@ private void btnCancel_Click(object? sender, RoutedEventArgs e)
531510
{
532511
ServiceLayer.Cancel = true;
533512
}
513+
514+
private void btnModalClose_Click(object? sender, RoutedEventArgs e)
515+
{
516+
pnlModal.IsVisible = false;
517+
}
534518
}

ZXBSInstaller/MainWindow.axaml.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
using Avalonia.Controls.ApplicationLifetimes;
33
using Avalonia.Interactivity;
44
using Avalonia.Threading;
5-
using MsBox.Avalonia;
6-
using MsBox.Avalonia.Dto;
7-
using MsBox.Avalonia.Enums;
85
using System;
96
using System.Collections.Generic;
107
using System.Diagnostics;

ZXBSInstaller/Program.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@ internal class Program
1616
[STAThread]
1717
public static void Main(string[] args)
1818
{
19-
var assembly = System.Reflection.Assembly.GetEntryAssembly();
20-
var version = assembly.GetName().Version;
21-
Version = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}";
22-
23-
if (args.Contains("--version"))
24-
{
25-
Console.WriteLine($"{Version}");
26-
return;
27-
}
28-
2919
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
3020
}
3121

ZXBSInstaller/ZXBSInstaller.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<ApplicationManifest>app.manifest</ApplicationManifest>
77
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
88
<ApplicationIcon>zxbs.ico</ApplicationIcon>
9-
<Version>1.0.0.7</Version>
9+
<Version>1.0.0.8</Version>
1010
</PropertyGroup>
1111
<ItemGroup>
1212
<None Remove="Assets\cancel.svg" />
@@ -53,7 +53,6 @@
5353
</ItemGroup>
5454

5555
<ItemGroup>
56-
<ProjectReference Include="..\MsBox.Avalonia\MsBox.Avalonia.csproj" />
5756
<ProjectReference Include="..\ZXBSInstaller.Log\ZXBSInstaller.Log.csproj" />
5857
</ItemGroup>
5958

ZXBSInstaller/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.0.7
1+
1.0.0.8

0 commit comments

Comments
 (0)