Skip to content

Commit

Permalink
Added "About" dialog
Browse files Browse the repository at this point in the history
Corrected handling of unassigned shortcuts
Modified toolbar sorting
  • Loading branch information
gusmanb committed Oct 29, 2023
1 parent 2ee3dee commit 65ca766
Show file tree
Hide file tree
Showing 15 changed files with 160 additions and 11 deletions.
Binary file added Artwork/IconAbout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ZXBStudio/Assets/Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ZXBStudio/Assets/IconAbout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ZXBStudio/Classes/ZXKeybMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static ZXKeybMapperSource[] GetKeybCommands()
if (!mappings.ContainsKey(SourceId))
return null;

return mappings[SourceId].FirstOrDefault(m => m.Key == Key && m.Modifiers == Modifiers)?.CommandId;
return mappings[SourceId].FirstOrDefault(m => m.Key != Key.None && m.Key == Key && m.Modifiers == Modifiers)?.CommandId;
}
public static bool UpdateCommands(Guid SourceId, ZXKeybCommand[] Commands)
{
Expand Down
25 changes: 25 additions & 0 deletions ZXBStudio/Dialogs/ZXAboutDialog.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="320" d:DesignHeight="511"
Width="320" Height="511"
MaxWidth="320" MaxHeight="511"
MinWidth="320" MinHeight="511"
x:Class="ZXBasicStudio.ZXAboutDialog"
Title="About..." CanResize="False"
WindowStartupLocation="CenterScreen"
Topmost="True">
<Grid RowDefinitions="2.7*,1*,0.5*,0.5*,0.5*,0.5*,1.5*,1.6*,*,0.4*,0.4*,0.4*,*">
<Image Margin="10" Width="128" Height="128" VerticalAlignment="Top" Source="avares://ZXBasicStudio/Assets/IconAbout.png"></Image>
<TextBlock Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="36" FontWeight="Black">ZX Basic Studio</TextBlock>
<TextBlock Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="24">Beta release</TextBlock>
<TextBlock Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="16" Name="txtBuild">Build 1.3.5.6</TextBlock>
<TextBlock Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="16" Name="txtDate">2023-10-29</TextBlock>
<TextBlock Grid.Row="6" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20" TextAlignment="Center" TextWrapping="Wrap" FontWeight="DemiBold">The ZX Basic Studio development team</TextBlock>
<TextBlock Grid.Row="7" VerticalAlignment="Center" TextAlignment="Center" HorizontalAlignment="Center" FontSize="18" TextWrapping="Wrap">El Dr. Gusman, Duefectu, AdolFITO, SirRickster</TextBlock>
<TextBlock Grid.Row="8" VerticalAlignment="Center" TextAlignment="Center" HorizontalAlignment="Center" FontSize="16" TextWrapping="Wrap">Many thanks to Boriel for the ZX Basic compiler and his support to this project.</TextBlock>
<TextBlock Grid.Row="10" VerticalAlignment="Center" TextAlignment="Center" HorizontalAlignment="Center" FontSize="12" TextWrapping="Wrap">(C) 2023, El Dr. Gusman</TextBlock>
<Button Name="btnClose" Grid.Row="12">Close</Button>
</Grid>
</Window>
36 changes: 36 additions & 0 deletions ZXBStudio/Dialogs/ZXAboutDialog.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using System;

namespace ZXBasicStudio;

public partial class ZXAboutDialog : Window
{
public ZXAboutDialog()
{
InitializeComponent();

btnClose.Click += BtnClose_Click;

var name = System.Reflection.Assembly.GetExecutingAssembly().GetName();

if(name == null || name.Version == null)
{
txtBuild.Text = "Unknown build";
txtDate.Text = "Unknown date";
return;
}

DateTime buildDate = new DateTime(2000, 1, 1).AddDays(name.Version.Build);

txtBuild.Text = $"Build {name.Version.ToString()}";
txtDate.Text = buildDate.ToString("yyyy-MM-dd");
}

private void BtnClose_Click(object? sender, RoutedEventArgs e)
{
this.Close();
}
}
23 changes: 16 additions & 7 deletions ZXBStudio/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
<MenuItem Header="Project" IsEnabled="{Binding FileInfo.ProjectLoaded}" Name="mnuCloseProject" Icon="{SvgImage /Svg/White/diagram-project-cross-solid.svg}"></MenuItem>
<MenuItem Header="File" IsEnabled="{Binding FileInfo.FileLoaded}" Name="mnuCloseFile" Icon="{SvgImage /Svg/White/file-circle-xmark-solid.svg}"></MenuItem>
</MenuItem>
<MenuItem Header="Exit" Name="mnuExitApplication" Icon="{svg:SvgImage /Svg/White/exit-solid.svg}"></MenuItem>
<Separator></Separator>
<MenuItem Header="Exit" Name="mnuExitApplication" Icon="{svg:SvgImage /Svg/White/exit-solid.svg}"></MenuItem>
</MenuItem>
<MenuItem Header="Project">
<MenuItem Header="Configure project" IsEnabled="{Binding FileInfo.ProjectLoaded}" Name="mnuConfigureProject" Icon="{SvgImage /Svg/White/gears-solid.svg}"></MenuItem>
Expand Down Expand Up @@ -80,6 +81,13 @@
<Separator></Separator>
<MenuItem Header="Restore layout" Name="mnuRestoreLayout" Icon="{SvgImage /Svg/White/clock-rotate-left-solid.svg}"></MenuItem>
</MenuItem>
<MenuItem Header="Help">
<MenuItem Header="ZX Basic Studio repository" Name="mnuRepo" Icon="{SvgImage /Svg/White/github.svg}"></MenuItem>
<Separator></Separator>
<MenuItem Header="ZX Basic help" Name="mnuZXHelp" Icon="{SvgImage /Svg/White/circle-question-solid.svg}"></MenuItem>
<Separator></Separator>
<MenuItem Header="About..." Name="mnuAbout" Icon="{SvgImage /Svg/White/circle-info-solid.svg}"></MenuItem>
</MenuItem>
</Menu>
<StackPanel Spacing="2" Orientation="Horizontal" Grid.Row="1" Grid.ColumnSpan="5" Margin="5">
<Button Classes="toolbar" Name="btnOpenProject" ToolTip.Tip="Open project">
Expand All @@ -98,12 +106,6 @@
<svg:Svg Path="/Svg/floppy-multiple-disk-solid.svg"></svg:Svg>
</Button>
<Line StartPoint="0,0" EndPoint="0,24" Stroke="White" Margin="5,0,5,0"></Line>
<Button Classes="toolbar" Name="btnFontIncrease" IsEnabled="{Binding FileInfo.FileLoaded}" ToolTip.Tip="Font size increase">
<svg:Svg Path="/Svg/font-increase.svg"></svg:Svg>
</Button>
<Button Classes="toolbar" Name="btnFontDecrease" IsEnabled="{Binding FileInfo.FileLoaded}" ToolTip.Tip="Font size decrease">
<svg:Svg Path="/Svg/font-decrease.svg"></svg:Svg>
</Button>
<Button Classes="toolbar" Name="btnCollapse" IsEnabled="{Binding FileInfo.FileLoaded}" ToolTip.Tip="Collapse code">
<svg:Svg Path="/Svg/square-minus-solid.svg"></svg:Svg>
</Button>
Expand All @@ -120,6 +122,13 @@
<svg:Svg Path="/Svg/circle-xmark-solid.svg"></svg:Svg>
</Button>
<Line StartPoint="0,0" EndPoint="0,24" Stroke="White" Margin="5,0,5,0"></Line>
<Button Classes="toolbar" Name="btnFontIncrease" IsEnabled="{Binding FileInfo.FileLoaded}" ToolTip.Tip="Increase font size (global)">
<svg:Svg Path="/Svg/font-increase.svg"></svg:Svg>
</Button>
<Button Classes="toolbar" Name="btnFontDecrease" IsEnabled="{Binding FileInfo.FileLoaded}" ToolTip.Tip="Decrease font size (global)">
<svg:Svg Path="/Svg/font-decrease.svg"></svg:Svg>
</Button>
<Line StartPoint="0,0" EndPoint="0,24" Stroke="White" Margin="5,0,5,0"></Line>
<ComboBox Classes="toolbar" Grid.Row="1" Grid.Column="2" Name="cbModel" Width="110" SelectedIndex="0" FontSize="10">
<ComboBoxItem>Spectrum 48k</ComboBoxItem>
<ComboBoxItem>Spectrum 128k</ComboBoxItem>
Expand Down
58 changes: 56 additions & 2 deletions ZXBStudio/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using CoreSpectrum.Enums;
using CoreSpectrum.SupportClasses;
using HarfBuzzSharp;
using Metsys.Bson;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SkiaSharp;
Expand Down Expand Up @@ -55,14 +56,15 @@ namespace ZXBasicStudio
{
public partial class MainWindow : ZXWindowBase //, IObserver<RawInputEventArgs>
{
const string repoUrl = "https://github.com/gusmanb/ZXBasicStudio";
const string zxbHelpUrl = "https://zxbasic.readthedocs.io/en/docs/";

#region Shortcut handling

internal static Guid KeybSourceId = Guid.Parse("72af48c7-4d62-4bef-8676-63c10d99de20");

internal static ZXKeybCommand[] KeybCommands =
{
new ZXKeybCommand { CommandId = Guid.Parse("21bc5c34-df5e-449e-a826-88e1f42d7810"), CommandName = "Exit application", Key = Key.None, Modifiers = KeyModifiers.None },
new ZXKeybCommand { CommandId = Guid.Parse("62c23849-7312-41ac-8788-9f6d851cc3b9"), CommandName = "Build and run", Key = Key.F5, Modifiers = KeyModifiers.None },
new ZXKeybCommand { CommandId = Guid.Parse("d9222ec4-5d7a-4b04-b9e3-e29d6d8bca78"), CommandName = "Build and debug", Key = Key.F6, Modifiers = KeyModifiers.None },
new ZXKeybCommand { CommandId = Guid.Parse("57aff55a-f4a1-4a57-a532-a38117e1a532"), CommandName = "Pause emulation", Key = Key.F7, Modifiers = KeyModifiers.None },
Expand All @@ -77,6 +79,7 @@ public partial class MainWindow : ZXWindowBase //, IObserver<RawInputEventArgs>
new ZXKeybCommand { CommandId = Guid.Parse("7b50369f-3f48-4653-99c1-26e566691e3c"), CommandName = "Debug View", Key = Key.F10, Modifiers = KeyModifiers.Control | KeyModifiers.Shift },
new ZXKeybCommand { CommandId = Guid.Parse("86b341a1-8d07-4af2-b4b0-ca953cd3dbc0"), CommandName = "Play View", Key = Key.F11, Modifiers = KeyModifiers.Control | KeyModifiers.Shift },
new ZXKeybCommand { CommandId = Guid.Parse("424f7395-c29d-44f9-8f9e-43b8891ec261"), CommandName = "All tools View", Key = Key.F12, Modifiers = KeyModifiers.Control | KeyModifiers.Shift },
new ZXKeybCommand { CommandId = Guid.Parse("21bc5c34-df5e-449e-a826-88e1f42d7810"), CommandName = "Exit application", Key = Key.None, Modifiers = KeyModifiers.None }
};

Dictionary<Guid, Action> _shortcuts = new Dictionary<Guid, Action>();
Expand Down Expand Up @@ -158,7 +161,9 @@ public MainWindow()
mnuAllToolsView.Click += ToolsLayout;
mnuDebugView.Click += DebugLayout;
mnuPlayView.Click += PlayLayout;

mnuRepo.Click += OpenRepository;
mnuZXHelp.Click += OpenZXHelp;
mnuAbout.Click += OpenAbout;
#endregion

#region Attach toolbar events
Expand Down Expand Up @@ -278,6 +283,22 @@ public MainWindow()
ZXLayoutPersister.RestoreLayout(grdMain, dockLeft, dockRight, dockBottom, new[] { _playerDock });
}

private void OpenAbout(object? sender, RoutedEventArgs e)
{
ZXAboutDialog zXAboutDialog = new ZXAboutDialog();
zXAboutDialog.ShowDialog(this);
}

private void OpenZXHelp(object? sender, RoutedEventArgs e)
{
OpenUrl(zxbHelpUrl);
}

private void OpenRepository(object? sender, RoutedEventArgs e)
{
OpenUrl(repoUrl);
}

#region File manipulation
private void PeExplorer_SelectedPathChanged(object? sender, System.EventArgs e)
{
Expand Down Expand Up @@ -1840,6 +1861,39 @@ private void BtnMapKeyboard_Click(object? sender, RoutedEventArgs e)
emu.EnableKeyMapping = btnMapKeyboard.IsChecked ?? false;
}

private void OpenUrl(string Url)
{

if (string.IsNullOrWhiteSpace(Url))
return;

try
{
ProcessStartInfo processInfo = new()
{
FileName = Url,
UseShellExecute = true
};

Process.Start(processInfo);
}
catch
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Process.Start("xdg-open", Url);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Process.Start("open", Url);
}
else
{
return;
}
}
}

private async void DumpRegisters(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
var select = await StorageProvider.SaveFilePickerAsync(new Avalonia.Platform.Storage.FilePickerSaveOptions
Expand Down
1 change: 1 addition & 0 deletions ZXBStudio/Svg/White/circle-info-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ZXBStudio/Svg/White/circle-question-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ZXBStudio/Svg/White/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ZXBStudio/Svg/circle-info-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ZXBStudio/Svg/circle-question-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ZXBStudio/Svg/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 65ca766

Please sign in to comment.