Skip to content

Commit 0ddbf7f

Browse files
committed
Version 0.9.0-Beta part 1
Multiples changes: -Fixes a crashunder certain conditions while opening or exporting files and folders. -Add VP/VPC editing / creation -Add file previewer Previewer uses Magick.NET to handle image files and LibVLCSharp for audio and videos. All formats except for .ani are supported for preview What left for part 2: Text file preview on a separated window for tables, scripts, etc Settings configuration window, mostly for the previewer. Support for configurable 3rd party external viewers
1 parent 812ce18 commit 0ddbf7f

40 files changed

+1648
-139
lines changed

VP.NET.GUI/Assets/icons/new.png

5.59 KB
Loading
3.1 KB
Loading

VP.NET.GUI/Assets/icons/pause.png

2.21 KB
Loading

VP.NET.GUI/Assets/icons/play.png

3.69 KB
Loading
47.9 KB
Loading
96.4 KB
Loading

VP.NET.GUI/Assets/icons/stop.png

1017 Bytes
Loading

VP.NET.GUI/Models/APNGHelper.cs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using Metsys.Bson;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace VP.NET.GUI.Models
10+
{
11+
/*
12+
* Reads a stream to verify if it is a valid APNG file
13+
* Checks for acTL chuck presence. No other data loading is done.
14+
*/
15+
public class APNGHelper
16+
{
17+
private static byte[] FrameSignature = { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A };
18+
19+
public static bool IsApng(MemoryStream ms)
20+
{
21+
if (!IsBytesEqual(ReadBytes(ms,FrameSignature.Length), FrameSignature))
22+
throw new Exception("File signature incorrect.");
23+
24+
var s = Encoding.ASCII.GetString(ReadBytes(ms, 5000));
25+
if(s.Contains("acTL"))
26+
{
27+
ms.Seek(0, SeekOrigin.Begin);
28+
return true;
29+
}
30+
ms.Seek(0, SeekOrigin.Begin);
31+
return false;
32+
}
33+
34+
public static bool IsBytesEqual(byte[] byte1, byte[] byte2)
35+
{
36+
if (byte1.Length != byte2.Length)
37+
return false;
38+
39+
for (int i = 0; i < byte1.Length; i++)
40+
{
41+
if (byte1[i] != byte2[i])
42+
return false;
43+
}
44+
return true;
45+
}
46+
47+
public static byte[] ReadBytes(Stream ms, int count)
48+
{
49+
var buffer = new byte[count];
50+
51+
if (ms.Read(buffer, 0, count) != count)
52+
throw new Exception("End reached.");
53+
54+
return buffer;
55+
}
56+
}
57+
}

VP.NET.GUI/Models/Log.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static void Add(LogSeverity logSeverity, string from, Exception exception
6969
/// Write a string to VS console
7070
/// </summary>
7171
/// <param name="data"></param>
72-
public async static void WriteToConsole(string data)
72+
public static void WriteToConsole(string data)
7373
{
7474
try
7575
{

VP.NET.GUI/Models/Settings.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Avalonia.Controls;
22
using System;
3+
using System.Diagnostics.CodeAnalysis;
34
using System.IO;
45
using System.Text;
56
using System.Text.Encodings.Web;
@@ -13,6 +14,7 @@ namespace VP.NET.GUI.Models
1314
/// </summary>
1415
public class Settings
1516
{
17+
public string? LastAddFilesPath { get; set; } = null;
1618
public string? LastVPLoadPath { get; set; } = null;
1719
public string? LastFileExtractionPath { get; set; } = null;
1820
public string? ToolLastLZ41FileDecompressionOpenPath { get; set; } = null;
@@ -25,6 +27,9 @@ public class Settings
2527
public string? ToolLastVPCompressionDestinationPath { get; set; } = null;
2628
public string? ToolLastFolderToVPFolderPath { get; set; } = null;
2729
public string? ToolLastFolderToVPVPSavePath { get; set; } = null;
30+
public bool PreviewerEnabled { get; set; } = true;
31+
32+
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "<Pending>")]
2833
public void Load()
2934
{
3035
try
@@ -46,6 +51,8 @@ public void Load()
4651
ToolLastVPDecompressionDestinationPath = tempSettings.ToolLastVPDecompressionDestinationPath;
4752
ToolLastVPCompressionOpenPath = tempSettings.ToolLastVPCompressionOpenPath;
4853
ToolLastVPCompressionDestinationPath = tempSettings.ToolLastVPCompressionDestinationPath;
54+
PreviewerEnabled = tempSettings.PreviewerEnabled;
55+
LastAddFilesPath = tempSettings.LastAddFilesPath;
4956
}
5057

5158
}
@@ -56,6 +63,7 @@ public void Load()
5663
}
5764
}
5865

66+
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "<Pending>")]
5967
public void Save(bool writeIni = true)
6068
{
6169
try

0 commit comments

Comments
 (0)