initial commit
Pulsar .NET 9.0 Windows Release / build (push) Waiting to run
Mirror to Codeberg and Gitea / mirror (push) Waiting to run

This commit is contained in:
i2p
2026-08-27 10:57:58 -06:00
commit 773d05f8f1
1038 changed files with 109261 additions and 0 deletions
Binary file not shown.
+60
View File
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Pulsar.Server.Utilities
{
public class FrameUpdatedEventArgs : EventArgs
{
public float CurrentFramesPerSecond { get; private set; }
public FrameUpdatedEventArgs(float _CurrentFramesPerSecond)
{
CurrentFramesPerSecond = _CurrentFramesPerSecond;
}
}
public delegate void FrameUpdatedEventHandler(FrameUpdatedEventArgs e);
public class FrameCounter
{
public long TotalFrames { get; private set; }
public float TotalSeconds { get; private set; }
public float AverageFramesPerSecond { get; private set; }
public const int MAXIMUM_SAMPLES = 100;
private Queue<float> _sampleBuffer = new Queue<float>();
public event FrameUpdatedEventHandler FrameUpdated;
public void Update(float deltaTime)
{
float currentFramesPerSecond = 1.0f / deltaTime;
_sampleBuffer.Enqueue(currentFramesPerSecond);
if (_sampleBuffer.Count > MAXIMUM_SAMPLES)
{
_sampleBuffer.Dequeue();
AverageFramesPerSecond = _sampleBuffer.Average(i => i);
}
else
{
AverageFramesPerSecond = currentFramesPerSecond;
}
OnFrameUpdated(new FrameUpdatedEventArgs(AverageFramesPerSecond));
TotalFrames++;
TotalSeconds += deltaTime;
}
protected virtual void OnFrameUpdated(FrameUpdatedEventArgs e)
{
FrameUpdatedEventHandler handler = FrameUpdated;
if (handler != null)
handler(e);
}
}
}
@@ -0,0 +1,141 @@
using Pulsar.Server.Models;
using System.Collections;
using System.Windows.Forms;
namespace Pulsar.Server.Utilities
{
public class ListViewColumnSorter : IComparer
{
/// <summary>
/// Specifies the column to be sorted
/// </summary>
private int _columnToSort;
/// <summary>
/// Specifies the order in which to sort (i.e. 'Ascending').
/// </summary>
private SortOrder _orderOfSort;
/// <summary>
/// Case insensitive comparer object
/// </summary>
private readonly CaseInsensitiveComparer _objectCompare;
/// <summary>
/// Specifies if number or text comparision is needed
/// </summary>
private bool _needNumberCompare;
/// <summary>
/// Class constructor. Initializes various elements
/// </summary>
public ListViewColumnSorter()
{
// Initialize the column to '0'
_columnToSort = 0;
// Initialize the sort order to 'none'
_orderOfSort = SortOrder.None;
// Initialize the CaseInsensitiveComparer object
_objectCompare = new CaseInsensitiveComparer();
_needNumberCompare = false;
}
/// <summary>
/// This method is inherited from the IComparer interface. It compares the two objects passed using a case insensitive comparison.
/// </summary>
/// <param name="x">First object to be compared</param>
/// <param name="y">Second object to be compared</param>
/// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns>
public int Compare(object x, object y)
{
// Cast the objects to be compared to ListViewItem objects
var listviewX = (ListViewItem)x;
var listviewY = (ListViewItem)y;
if (listviewX.SubItems[0].Text == ".." || listviewY.SubItems[0].Text == "..")
return 0;
// Compare the two items
int compareResult;
if (_needNumberCompare)
{
long a, b;
if (listviewX.Tag is FileManagerListTag)
{
// fileSize to be compared
a = (listviewX.Tag as FileManagerListTag).FileSize;
b = (listviewY.Tag as FileManagerListTag).FileSize;
compareResult = a >= b ? (a == b ? 0 : 1) : -1;
}
else
{
if (long.TryParse(listviewX.SubItems[_columnToSort].Text, out a)
&& long.TryParse(listviewY.SubItems[_columnToSort].Text, out b))
{
compareResult = a >= b ? (a == b ? 0 : 1) : -1;
}
else
{
compareResult = _objectCompare.Compare(listviewX.SubItems[_columnToSort].Text,
listviewY.SubItems[_columnToSort].Text);
}
}
}
else
{
compareResult = _objectCompare.Compare(listviewX.SubItems[_columnToSort].Text,
listviewY.SubItems[_columnToSort].Text);
}
// Calculate correct return value based on object comparison
if (_orderOfSort == SortOrder.Ascending)
{
// Ascending sort is selected, return normal result of compare operation
return compareResult;
}
else if (_orderOfSort == SortOrder.Descending)
{
// Descending sort is selected, return negative result of compare operation
return (-compareResult);
}
else
{
// Return '0' to indicate they are equal
return 0;
}
}
/// <summary>
/// Gets or sets the number of the column to which to apply the sorting operation (Defaults to '0').
/// </summary>
public int SortColumn
{
set { _columnToSort = value; }
get { return _columnToSort; }
}
/// <summary>
/// Gets or sets the order of sorting to apply (for example, 'Ascending' or 'Descending').
/// </summary>
public SortOrder Order
{
set { _orderOfSort = value; }
get { return _orderOfSort; }
}
/// <summary>
/// Specifies if number or text comparision is needed.
/// </summary>
public bool NeedNumberCompare
{
set { _needNumberCompare = value; }
get { return _needNumberCompare; }
}
}
}
@@ -0,0 +1,58 @@
using System.Windows.Forms;
using Pulsar.Server.Controls;
namespace Pulsar.Server.Utilities
{
/// <summary>
/// Provides extension methods for ListView/AeroListView controls.
/// </summary>
public static class ListViewExtensions
{
/// <summary>
/// Stretches a column of a ListView to fill the remaining width.
/// </summary>
/// <param name="listView">The ListView to modify.</param>
/// <param name="columnIndex">The index of the column to stretch.</param>
public static void StretchColumnByIndex(this ListView listView, int columnIndex)
{
if (listView.Columns.Count == 0 || columnIndex < 0 || columnIndex >= listView.Columns.Count)
return;
int totalWidth = 0;
for (int i = 0; i < listView.Columns.Count; i++)
{
if (i != columnIndex)
totalWidth += listView.Columns[i].Width;
}
int columnWidth = listView.ClientSize.Width - totalWidth;
if (columnWidth > 0)
{
listView.Columns[columnIndex].Width = columnWidth;
}
}
/// <summary>
/// Determines if a column is stretched to fill the remaining width.
/// </summary>
/// <param name="listView">The ListView to check.</param>
/// <param name="columnIndex">The index of the column to check.</param>
/// <returns>True if the column is stretched, false otherwise.</returns>
public static bool IsStretched(this ListView listView, int columnIndex)
{
if (listView.Columns.Count == 0 || columnIndex < 0 || columnIndex >= listView.Columns.Count)
return false;
int totalWidth = 0;
for (int i = 0; i < listView.Columns.Count; i++)
{
if (i != columnIndex)
totalWidth += listView.Columns[i].Width;
}
int expectedWidth = listView.ClientSize.Width - totalWidth;
return expectedWidth > 0 && listView.Columns[columnIndex].Width >= expectedWidth - 1 &&
listView.Columns[columnIndex].Width <= expectedWidth + 1;
}
}
}
+54
View File
@@ -0,0 +1,54 @@
using System;
using System.Runtime.InteropServices;
namespace Pulsar.Server.Utilities
{
/// <summary>
/// Provides access to Win32 API and Microsoft C Runtime Library (msvcrt.dll).
/// </summary>
public static class NativeMethods
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
internal struct LVITEM
{
public uint mask;
public int iItem;
public int iSubItem;
public int state;
public int stateMask;
[MarshalAs(UnmanagedType.LPTStr)]
public string pszText;
public int cchTextMax;
public int iImage;
public IntPtr lParam;
public int iIndent;
public int iGroupId;
public uint cColumns;
public IntPtr puColumns;
public IntPtr piColFmt;
public int iGroup;
};
public const int SB_HORZ = 0;
public const int SB_VERT = 1;
public const int SB_BOTH = 3;
[DllImport("user32.dll", CharSet = CharSet.Auto)]
internal static extern IntPtr SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, EntryPoint = "SendMessage")]
internal static extern IntPtr SendMessageListViewItem(IntPtr hWnd, uint msg, IntPtr wParam, ref LVITEM lParam);
[DllImport("user32.dll")]
internal static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, int vk);
[DllImport("user32.dll")]
internal static extern bool UnregisterHotKey(IntPtr hWnd, int id);
[DllImport("uxtheme.dll", CharSet = CharSet.Unicode)]
internal static extern int SetWindowTheme(IntPtr hWnd, string pszSubAppName, string pszSubIdList);
[DllImport("user32.dll")]
public static extern bool ShowScrollBar(IntPtr hWnd, int wBar, bool bShow);
}
}
@@ -0,0 +1,32 @@
using System;
using System.IO;
using System.IO.Compression;
using System.Linq;
namespace Pulsar.Server.Utilities
{
internal static class PluginPackageImporter
{
public static void Import(string packagePath, string pluginsDir)
{
if (string.IsNullOrWhiteSpace(packagePath) || !File.Exists(packagePath))
throw new FileNotFoundException("Package not found", packagePath);
Directory.CreateDirectory(pluginsDir);
using (var fs = File.OpenRead(packagePath))
using (var zip = new ZipArchive(fs, ZipArchiveMode.Read))
{
var dllEntries = zip.Entries.Where(e => e.FullName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)).ToList();
foreach (var entry in dllEntries)
{
var outPath = Path.Combine(pluginsDir, Path.GetFileName(entry.FullName));
using (var inStream = entry.Open())
using (var outStream = File.Create(outPath))
{
inStream.CopyTo(outStream);
}
}
}
}
}
}
+9
View File
@@ -0,0 +1,9 @@
namespace Pulsar.Server.Utilities
{
public static class ServerVersion
{
public const string Current = "2.4.5";
public static string Display => $"v{Current}";
}
}