Finished SaveAs function.

Updated dependencies.
About page now uses version from assembly.
This commit is contained in:
Creeper Lv
2026-02-15 00:58:31 +11:00
parent a024bf9737
commit d93e222ba7
9 changed files with 157 additions and 59 deletions

View File

@@ -1,33 +1,34 @@
<Project>
<!-- https://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management -->
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<!-- Avalonia packages -->
<!-- Important: keep version in sync! -->
<PackageVersion Include="Avalonia" Version="11.3.11" />
<PackageVersion Include="Avalonia.AvaloniaEdit" Version="11.4.0-rc1" />
<PackageVersion Include="Avalonia.Themes.Fluent" Version="11.3.11" />
<PackageVersion Include="Avalonia.Fonts.Inter" Version="11.3.11" />
<PackageVersion Include="Avalonia.Diagnostics" Version="11.3.11" />
<PackageVersion Include="Avalonia.Desktop" Version="11.3.11" />
<PackageVersion Include="Avalonia.iOS" Version="11.3.11" />
<PackageVersion Include="Avalonia.Browser" Version="11.3.11" />
<PackageVersion Include="Avalonia.Android" Version="11.3.11" />
<PackageVersion Include="AvaloniaEdit.TextMate" Version="11.4.0-rc1" />
<PackageVersion Include="Deadpikle.AvaloniaProgressRing" Version="0.10.11-preview20251127001" />
<PackageVersion Include="DialogHost.Avalonia" Version="0.10.4" />
<PackageVersion Include="Jint" Version="4.5.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="10.0.2" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="10.0.2" />
<PackageVersion Include="Microsoft.Maui.Graphics" Version="10.0.11" />
<PackageVersion Include="Microsoft.Maui.Graphics.Skia" Version="10.0.11" />
<PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.4" />
<PackageVersion Include="PanAndZoom" Version="11.3.9.1" />
<PackageVersion Include="SkiaSharp" Version="3.116.1" />
<!-- https://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management -->
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<Version>1.0.0.0</Version>
</PropertyGroup>
<ItemGroup>
<!-- Avalonia packages -->
<!-- Important: keep version in sync! -->
<PackageVersion Include="Avalonia" Version="11.3.12" />
<PackageVersion Include="Avalonia.AvaloniaEdit" Version="11.4.1" />
<PackageVersion Include="Avalonia.Themes.Fluent" Version="11.3.12" />
<PackageVersion Include="Avalonia.Fonts.Inter" Version="11.3.12" />
<PackageVersion Include="Avalonia.Diagnostics" Version="11.3.12" />
<PackageVersion Include="Avalonia.Desktop" Version="11.3.12" />
<PackageVersion Include="Avalonia.iOS" Version="11.3.12" />
<PackageVersion Include="Avalonia.Browser" Version="11.3.12" />
<PackageVersion Include="Avalonia.Android" Version="11.3.12" />
<PackageVersion Include="AvaloniaEdit.TextMate" Version="11.4.1" />
<PackageVersion Include="Deadpikle.AvaloniaProgressRing" Version="0.10.11-preview20251127001" />
<PackageVersion Include="DialogHost.Avalonia" Version="0.10.4" />
<PackageVersion Include="Jint" Version="4.5.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="11.0.0-preview.1.26104.118" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="11.0.0-preview.1.26104.118" />
<PackageVersion Include="Microsoft.Maui.Graphics" Version="10.0.11" />
<PackageVersion Include="Microsoft.Maui.Graphics.Skia" Version="10.0.11" />
<PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.4" />
<PackageVersion Include="PanAndZoom" Version="11.3.9.1" />
<PackageVersion Include="SkiaSharp" Version="3.116.1" />
<PackageVersion Include="SkiaSharp.NativeAssets.WebAssembly" Version="3.116.1" />
<PackageVersion Include="Xamarin.AndroidX.Core.SplashScreen" Version="1.0.1.15" />
</ItemGroup>
<PackageVersion Include="Xamarin.AndroidX.Core.SplashScreen" Version="1.2.0.1" />
</ItemGroup>
</Project>

View File

@@ -28,7 +28,7 @@
</Border>
<TextBlock FontSize="36" TextAlignment="Center" Margin="0,0,0,30">Progrart</TextBlock>
</Grid>
<TextBlock FontSize="18" TextAlignment="Center">Version: 0.0.0.0-preview</TextBlock>
<TextBlock FontSize="18" TextAlignment="Center" Name="VerTextBlock">Version: {0}</TextBlock>
<TextBlock FontSize="24" TextAlignment="Center" Margin="0,25">Third-Party Libs</TextBlock>
<TextBlock FontSize="17" TextAlignment="Center">Avalonia - github.com/avaloniaui</TextBlock>
<TextBlock FontSize="17" TextAlignment="Center">SkiaSharp - github.com/mono/SkiaSharp</TextBlock>

View File

@@ -5,36 +5,37 @@ using Avalonia.Media;
using Avalonia.Media.Imaging;
using Progrart.Controls.TabSystem;
using SkiaSharp;
using System.Reflection;
namespace Progrart.Pages;
public partial class AboutPage : UserControl,ITabPage
public partial class AboutPage : UserControl, ITabPage
{
public AboutPage()
{
InitializeComponent();
public AboutPage()
{
InitializeComponent();
VerTextBlock.Text = string.Format(VerTextBlock.Text ?? "Version: {0}", Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "0.0.0.0");
}
public void BindButton(TabButton button)
{
button.Title="About";
}
{
button.Title = "About";
}
public void Execute()
{
}
public void Execute()
{
}
public bool IsModified()
{
return false;
}
public bool IsModified()
{
return false;
}
public void Save()
{
}
public void Save()
{
}
public void SetHost(TabHost host)
{
}
public void SetHost(TabHost host)
{
}
}

View File

@@ -81,6 +81,7 @@ namespace Progrart.Pages
{
void LoadDocument(IStorageFile file);
Task Save();
async Task SaveAs() { return;}
bool IsSameFile(IStorageFile file);
void Execute(ExecuteArguments? args = null);
}

View File

@@ -153,8 +153,43 @@ public partial class ProgrartEditorPage : UserControl, ITabPage, IEditorPage
await sw.FlushAsync();
});
}
else await SaveAs();
}
public async Task SaveAs()
{
var provider = TopLevel.GetTopLevel(this)?.StorageProvider;
if (provider is null)
{
return;
}
var file = await provider.SaveFilePickerAsync(new FilePickerSaveOptions
{
SuggestedStartLocation = App.CurrentOpenFolder,
FileTypeChoices = new[]
{
new FilePickerFileType("Progrart File")
{
Patterns = new[] { "*.progrart" },
MimeTypes = new[] { "text/plain" }
}
},
Title = "Save Progrart File"
});
if (file is not null)
{
string content = "";
await Dispatcher.UIThread.InvokeAsync(() => { content = CodeEditor.Text; });
this.file = file;
using var stream = await file.OpenWriteAsync();
stream.SetLength(0);
using var sw = new StreamWriter(stream);
await sw.WriteAsync(content);
await sw.FlushAsync();
}
return;
}
public void SetHost(TabHost host)
{

View File

@@ -3,6 +3,7 @@ using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Platform.Storage;
using Avalonia.Threading;
using Jint.Runtime;
using Newtonsoft.Json;
using Progrart.Controls;
using Progrart.Controls.TabSystem;
@@ -85,7 +86,51 @@ public partial class ProjectEditor : UserControl, ITabPage, IEditorPage
sw.Flush();
sw.Close();
}
public async Task SaveAs()
{
var provider = TopLevel.GetTopLevel(this)?.StorageProvider;
if (provider is null)
{
return;
}
var file = await provider.SaveFilePickerAsync(new FilePickerSaveOptions
{
SuggestedStartLocation = App.CurrentOpenFolder,
FileTypeChoices =
[
new FilePickerFileType("Progrart Project File")
{
Patterns = ["*.progrart-project"],
MimeTypes = ["application/json"]
}
],
Title = "Save Progrart Project"
});
if (file is not null)
{
Project project = new Project();
await Dispatcher.UIThread.InvokeAsync(() =>
{
project.OutputDir = this.OutputDirBox.Text ?? "";
project.Arguments = ProjectWideArguments.ObtainArguments();
foreach (var item in ConfigurationHolder.Children)
{
if (item is ConfigEditor editor)
{
project.Configurations.Add(editor.ObtainConfiguration());
}
}
});
this.file = file;
using var stream = await file.OpenWriteAsync();
stream.SetLength(0);
using var sw = new StreamWriter(stream);
sw.WriteLine(JsonConvert.SerializeObject(project, Formatting.Indented));
sw.Flush();
sw.Close();
}
return;
}
public void SetHost(TabHost host)
{
}

View File

@@ -40,8 +40,8 @@
</ItemGroup>
<ItemGroup>
<Compile Update="Controls\TargetEditor.axaml.cs">
<DependentUpon>TargetEditor.axaml</DependentUpon>
</Compile>
<Compile Update="Controls\TargetEditor.axaml.cs">
<DependentUpon>TargetEditor.axaml</DependentUpon>
</Compile>
</ItemGroup>
</Project>

View File

@@ -47,7 +47,7 @@
<Separator/>
<MenuItem Header="_Save" Click="MenuItem_Save_Click"/>
<MenuItem Header="Save A_ll" Click="MenuItem_SaveAll_Click"/>
<MenuItem Header="Save _As"/>
<MenuItem Header="Save _As" Click="MenuItem_SaveAs_Click"/>
</MenuItem>
<MenuItem Header="_Tools">
<MenuItem Header="_Settings" Name="SettingsMenuItem" Click="SettingsMenuItem_Click"/>
@@ -55,7 +55,7 @@
<MenuItem Header="_Help">
<MenuItem Header="_About" Name="AboutItem"/>
</MenuItem>
<Separator/>
<Separator Name="ExitItemSeparator"/>
<MenuItem Header="_Exit" Name="ExitItem" Click="ExitItem_Click"/>
</MenuFlyout>
</Button.Flyout>
@@ -122,7 +122,7 @@
<Button Name="SaveButton" Click="SaveButton_Click">
<PathIcon Foreground="#2288EE" Data="F1 M 3 6.799999 C 3 6.240001 3.193333 5.766666 3.58 5.379999 C 3.966666 4.993332 4.44 4.799999 5 4.799999 L 13.36 4.799999 C 13.92 4.799999 14.4 5 14.799999 5.4 L 16.4 7 C 16.799999 7.4 17 7.879999 17 8.44 L 17 16.799999 C 17 17.360001 16.806667 17.833332 16.42 18.219999 C 16.033333 18.606667 15.559999 18.799999 15 18.799999 L 5 18.799999 C 4.44 18.799999 3.966666 18.606667 3.58 18.219999 C 3.193333 17.833332 3 17.360001 3 16.799999 Z M 5 5.799999 C 4.733333 5.799999 4.5 5.9 4.3 6.099999 C 4.1 6.3 4 6.533334 4 6.799999 L 4 16.799999 C 4 17.066666 4.1 17.299999 4.3 17.5 C 4.5 17.699999 4.733333 17.799999 5 17.799999 L 5 13.28 C 5 12.88 5.146667 12.533333 5.44 12.24 C 5.733333 11.946667 6.093333 11.799999 6.52 11.799999 L 13.52 11.799999 C 13.92 11.799999 14.266666 11.946667 14.559999 12.24 C 14.853333 12.533333 14.999999 12.893333 15 13.32 L 15 17.799999 C 15.266665 17.799999 15.499999 17.699999 15.7 17.5 C 15.9 17.299999 16 17.066666 16 16.799999 L 16 8.44 C 16 8.146667 15.906666 7.906667 15.719999 7.719999 L 14.08 6.08 C 13.893332 5.893333 13.653332 5.799999 13.36 5.799999 L 13 5.799999 L 13 8.28 C 13 8.706667 12.853333 9.066667 12.559999 9.36 C 12.266665 9.653334 11.906666 9.799999 11.48 9.799999 L 7.52 9.799999 C 7.093333 9.799999 6.733333 9.653334 6.44 9.36 C 6.146667 9.066667 6 8.706667 6 8.28 L 6 5.799999 Z M 7 5.799999 L 7 8.28 C 7 8.440001 7.046667 8.566667 7.14 8.66 C 7.233333 8.753333 7.346666 8.799999 7.48 8.799999 L 11.52 8.799999 C 11.653333 8.799999 11.766666 8.753333 11.86 8.66 C 11.953333 8.566667 12 8.453333 12 8.32 L 12 5.799999 Z M 14 17.799999 L 14 13.28 C 14 13.146667 13.953333 13.033333 13.86 12.94 C 13.766665 12.846666 13.653332 12.799999 13.52 12.799999 L 6.52 12.799999 C 6.36 12.799999 6.233333 12.846666 6.14 12.94 C 6.046666 13.033333 6 13.146667 6 13.28 L 6 17.799999 Z " VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button>
<Button Name="SaveAsButton">
<Button Name="SaveAsButton" Click="SaveAsButton_Click">
<PathIcon Foreground="#2288EE" Data="F1 M 5 4.799999 C 4.44 4.799999 3.966666 4.993332 3.58 5.379999 C 3.193333 5.766666 3 6.240001 3 6.799999 L 3 14.799999 C 3 15.36 3.193333 15.833333 3.58 16.219999 C 3.966666 16.606667 4.44 16.799999 5 16.799999 L 13 16.799999 C 13.559999 16.799999 14.033333 16.606667 14.42 16.219999 C 14.806665 15.833333 14.999999 15.36 15 14.799999 L 15 8.44 C 14.999999 7.879999 14.799999 7.4 14.4 7 L 12.799999 5.4 C 12.399999 5 11.919999 4.799999 11.36 4.799999 Z M 4 6.799999 C 4 6.533334 4.1 6.3 4.3 6.099999 C 4.5 5.9 4.733333 5.799999 5 5.799999 L 6 5.799999 L 6 7.28 C 6 7.706666 6.146667 8.066666 6.44 8.36 C 6.733333 8.653334 7.093333 8.799999 7.52 8.799999 L 9.52 8.799999 C 9.919999 8.799999 10.266666 8.653334 10.559999 8.36 C 10.853333 8.066666 11 7.706666 11 7.28 L 11 5.799999 L 11.36 5.799999 C 11.653333 5.799999 11.893333 5.893333 12.08 6.08 L 13.719999 7.719999 C 13.906666 7.906667 14 8.146667 14 8.44 L 14 14.799999 C 14 15.066666 13.9 15.299999 13.7 15.5 C 13.499999 15.7 13.266666 15.799999 13 15.799999 L 13 12.28 C 13 11.88 12.853333 11.533333 12.559999 11.24 C 12.266665 10.946667 11.906666 10.799999 11.48 10.799999 L 6.52 10.799999 C 6.093333 10.799999 5.733333 10.946667 5.44 11.24 C 5.146667 11.533333 5 11.893333 5 12.32 L 5 15.799999 C 4.733333 15.799999 4.5 15.7 4.3 15.5 C 4.1 15.299999 4 15.066666 4 14.799999 Z M 7 7.28 L 7 5.799999 L 10 5.799999 L 10 7.28 C 10 7.44 9.953333 7.566667 9.86 7.66 C 9.766665 7.753333 9.653332 7.799999 9.52 7.799999 L 7.52 7.799999 C 7.36 7.799999 7.233333 7.753333 7.14 7.66 C 7.046667 7.566667 7 7.453333 7 7.32 Z M 12 12.28 L 12 15.799999 L 6 15.799999 L 6 12.28 C 6 12.146667 6.046666 12.033334 6.14 11.94 C 6.233333 11.846666 6.346666 11.799999 6.48 11.799999 L 11.52 11.799999 C 11.653333 11.799999 11.766666 11.846666 11.86 11.94 C 11.953333 12.033334 12 12.146667 12 12.28 Z M 8.52 18.799999 C 7.559999 18.799999 6.733333 18.466665 6.04 17.799999 L 13.52 17.799999 C 14.186666 17.799999 14.766666 17.553333 15.259999 17.059999 C 15.753332 16.566666 16 15.986666 16 15.32 L 16 7.839999 C 16.666666 8.533333 17 9.36 17 10.32 L 17 15.279999 C 17 16.266666 16.66 17.099998 15.98 17.779999 C 15.299999 18.459999 14.466665 18.799999 13.48 18.799999 Z " VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button>
<Button Name="NewFileButton">

View File

@@ -164,6 +164,11 @@ public partial class MainView : UserControl
});
}
});
if (OperatingSystem.IsBrowser())
{
ExitItem.IsVisible = false;
ExitItemSeparator.IsVisible = false;
}
}
private void Execute()
@@ -351,4 +356,14 @@ public partial class MainView : UserControl
{
TryExit();
}
private void MenuItem_SaveAs_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
if (MainTabHost.GetCurrentPage() is IEditorPage editor) Task.Run(async () => await editor.SaveAs());
}
private void SaveAsButton_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
if (MainTabHost.GetCurrentPage() is IEditorPage editor) Task.Run(async () => await editor.SaveAs());
}
}