Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small changes #25

Merged
merged 3 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion Fuyu.Launcher/Fuyu.Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<PropertyGroup>
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<ApplicationIcon>Resources\icon.ico</ApplicationIcon>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<ApplicationIcon>Resources\icon.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
Expand All @@ -25,10 +25,29 @@
<ProjectReference Include="../Fuyu.Platform.Launcher/Fuyu.Platform.Launcher.csproj" />
</ItemGroup>

<ItemGroup>
<Resource Include="Resources\icon.ico" />
</ItemGroup>

<ItemGroup>
<Content Update="wwwroot\**">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<Compile Update="Resources\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Resources\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions Fuyu.Launcher/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
xmlns:blazor="clr-namespace:Microsoft.AspNetCore.Components.WebView.Wpf;assembly=Microsoft.AspNetCore.Components.WebView.Wpf"
xmlns:local="clr-namespace:Fuyu.Launcher"
mc:Ignorable="d"
Icon="Resources\Icon.ico"
WindowStartupLocation="CenterScreen"
Title="Fuyu.Launcher" Height="450" Width="800">
<Grid>
Expand Down
63 changes: 63 additions & 0 deletions Fuyu.Launcher/Resources/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

101 changes: 101 additions & 0 deletions Fuyu.Launcher/Resources/Resources.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema

Version 1.3

The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.

Example:

... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>

There are any number of "resheader" rows that contain simple
name/value pairs.

Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.

The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:

Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.

mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
54 changes: 54 additions & 0 deletions Fuyu.Platform.Common/Collections/ThreadDictionary.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System.Collections.Generic;

namespace Fuyu.Platform.Common.Collections
{
// NOTE: Why not ConcurrentDictionary<T1, T2>? Because it's horribly slow
// in .NET 8.0, let alone .NET Framework 4.7.1. Manual locking is
// about 700x faster in most use-cases.

public class ThreadDictionary<T1, T2>
{
private readonly Dictionary<T1, T2> _dictionary;
private readonly object _lock;

public ThreadDictionary()
{
_dictionary = new Dictionary<T1, T2>();
_lock = new object();
}

public Dictionary<T1, T2> ToDictionary()
{
return _dictionary;
}

public T2 Get(T1 key)
{
return _dictionary[key];
}

public void Set(T1 key, T2 value)
{
lock (_lock)
{
_dictionary[key] = value;
}
}

public void Add(T1 key, T2 value)
{
lock (_lock)
{
_dictionary.Add(key, value);
}
}

public void Remove(T1 key)
{
lock (_lock)
{
_dictionary.Remove(key);
}
}
}
}
63 changes: 63 additions & 0 deletions Fuyu.Platform.Common/Collections/ThreadList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System.Collections.Generic;

namespace Fuyu.Platform.Common.Collections
{
// NOTE: Why not ConcurrentBag<T>? While it's performance is very fast in
// in intensive parallel access under .NET 8.0, it leaves a lot to be
// desired in .NET Framework 4.7.1. For random read-write, List with
// manual lock was still faster for me.

public class ThreadList<T>
{
private readonly List<T> _list;
private readonly object _lock;

public ThreadList()
{
_list = new List<T>();
_lock = new object();
}

public List<T> ToList()
{
return _list;
}

public T Get(int index)
{
return _list[index];
}

public void Set(int index, T value)
{
lock (_lock)
{
_list[index] = value;
}
}

public void Add(T value)
{
lock (_lock)
{
_list.Add(value);
}
}

public void Remove(T value)
{
lock (_lock)
{
_list.Remove(value);
}
}

public void RemoveAt(int index)
{
lock (_lock)
{
_list.RemoveAt(index);
}
}
}
}
27 changes: 27 additions & 0 deletions Fuyu.Platform.Common/Collections/ThreadObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace Fuyu.Platform.Common.Collections
{
public class ThreadObject<T>
{
private T _object;
private readonly object _lock;

public ThreadObject(T value)
{
_object = value;
_lock = new object();
}

public T Get()
{
return _object;
}

public void Set(T value)
{
lock (_lock)
{
_object = value;
}
}
}
}
Loading