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

304 port UI to blazor proof of concept #308

Merged
merged 59 commits into from
Apr 21, 2024
Merged
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
77279bd
Add a Razor class library but for some reason the Razor component can…
ekolis Feb 17, 2024
289cbfa
Add HTML boilerplate
ekolis Feb 17, 2024
521a392
Rename FrEee.WinForms to FrEee.UI.WinForms
ekolis Feb 18, 2024
c82cf84
Update namespaces
ekolis Feb 18, 2024
6649c9f
Update project/solutoin
ekolis Feb 18, 2024
2a7d4fc
Undo some accidentally committed changes
ekolis Feb 18, 2024
4d57c72
Blazorified the GameProgressBar
ekolis Feb 24, 2024
3f3c06f
Adjust styling
ekolis Feb 24, 2024
ff5d8ea
Don't allow progress bar to overflow
ekolis Feb 24, 2024
b1dd595
Set up the new font thingy, not using it yet because I haven't found …
ekolis Feb 24, 2024
4581f77
Fix right text of progress bar not getting set
ekolis Feb 24, 2024
3078993
Fix crashing when refreshing progress bar
ekolis Feb 25, 2024
5fa2033
comments for things to clean up
ekolis Feb 25, 2024
7a3d828
Wrap view model properties without having useless local fields
ekolis Feb 25, 2024
4d7bdca
Move some code from WinForms to the Blazor view model
ekolis Mar 3, 2024
403b8b2
Fix crash when calling a WinForms modal dialog from Blazor while debu…
ekolis Mar 3, 2024
3dfea0d
Remove references to nonexitent FrEee.UI project
ekolis Mar 9, 2024
318f9d3
Add comment, that's weird that it's inconsistent
ekolis Mar 9, 2024
d2e59b0
Fix progress bar not refreshing again
ekolis Mar 9, 2024
312727d
Add resource display but it's broken. Also added Blazor test form.
ekolis Mar 9, 2024
07b7e7b
Actually render the Blazor view in the resource display
ekolis Mar 10, 2024
641abbf
Try to fix the resource displays' colors and icons but not quite. Ico…
ekolis Mar 10, 2024
0f7b6b2
Fixed resource displays (hopefully the symlinks will persist in the b…
ekolis Mar 10, 2024
9d8d934
Fix Blazor image path issue by moving index.html to the root. This fe…
ekolis Mar 10, 2024
c0bbce8
Delete empty wwwroot folder
ekolis Mar 10, 2024
497ebb5
Install a couple NuGet packages to fix inability to put Blazor-based …
ekolis Mar 16, 2024
f5ac3f4
Combine multile ResourceDisplays into a ResourceQuantityDisplay
ekolis Mar 16, 2024
a1d5c26
Refactor some code into a base BlazorControl
ekolis Mar 17, 2024
f4045b6
Remove unneeded analytics packages and a using statement
ekolis Mar 17, 2024
e127e9f
Adjust a few things in the BlazorControl
ekolis Mar 17, 2024
71defb2
Get rid of a generic type parameter, somehow partially fix resource d…
ekolis Mar 17, 2024
6285af2
Get rid of the other generic type parameter for BlazorControl
ekolis Mar 17, 2024
e0fc416
Fix BlazorWebView based controls in WinForms designer by using some s…
ekolis Mar 17, 2024
97a9a24
Fix resource inventory display
ekolis Mar 17, 2024
cfe8f60
Delerte an unused method
ekolis Mar 17, 2024
9b9e6b4
Move controls that have been converted to Blazor to their own namespa…
ekolis Mar 17, 2024
61caecb
Adjust namespaces of moved controls
ekolis Mar 17, 2024
7383ef8
Moved the wrong control oops
ekolis Mar 17, 2024
042f3e8
GamePictureBox is now Blazor; for some reason there's a scvroll bar
ekolis Mar 17, 2024
7441c71
Actually show text on full size GamePictureBox forms
ekolis Mar 17, 2024
7723a07
Display name of Blazor control in WinForms designer
ekolis Mar 17, 2024
4acdbc8
Add a pie chart Blazor component, the HTML checks out in a browser bu…
ekolis Mar 30, 2024
85a8d6b
Fix pie chart rendering
ekolis Mar 30, 2024
4491642
Blazor galaxy map WIP
ekolis Mar 30, 2024
9c5a374
Somewhat fix layout of galaxy map, somewhat break that of resource di…
ekolis Mar 31, 2024
305464a
Fix image alignment/sizing
ekolis Mar 31, 2024
b953961
Implement presence map mode
ekolis Mar 31, 2024
44388df
Set up MEF and dropdown for galaxy map modes
ekolis Mar 31, 2024
722b853
Trying to draw warp lines
ekolis Mar 31, 2024
1ced0a2
Draw warp lines, but they're scaled wrong
ekolis Mar 31, 2024
9756e4e
Delete unused function
ekolis Mar 31, 2024
624d1d2
Cleaning up the map, add green grid because green grids are cool
ekolis Mar 31, 2024
f7cc423
Don't place star systems off the lower or right edges of the map
ekolis Mar 31, 2024
da131bb
Fixed map rendering
ekolis Mar 31, 2024
80e4526
Render the selected star system with a white border
ekolis Apr 7, 2024
18abc2f
Clicking a system actually selects it
ekolis Apr 7, 2024
2184af8
Get rid of background click handler for galaxy map because it's causi…
ekolis Apr 7, 2024
ca9cedd
Fix numbers being hidden on the resourve display
ekolis Apr 21, 2024
c251d5e
Fix vertical alignment of resource display text
ekolis Apr 21, 2024
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
Prev Previous commit
Next Next commit
Fix BlazorWebView based controls in WinForms designer by using some s…
…ort of abtsractoin
ekolis committed Mar 17, 2024
commit e0fc4161c4c1bd1cc40658d2c9e290cd35215ee5
1 change: 1 addition & 0 deletions FrEee.UI.Blazor/WebExtensions.cs
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;

namespace FrEee.UI.Blazor
{
13 changes: 9 additions & 4 deletions FrEee.UI.WinForms/Controls/BlazorControl.cs
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using FrEee.UI.WinForms.Utility.Extensions;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.WebView.WindowsForms;
using Microsoft.Extensions.DependencyInjection;
@@ -27,13 +28,10 @@ public BlazorControl()
// set up Blazor
try
{
var services = new ServiceCollection();
services.AddWindowsFormsBlazorWebView();
var parameters = new Dictionary<string, object?> { ["VM"] = VM };
var blazorView = new BlazorWebView
{
HostPage = "index.html",
Services = services.BuildServiceProvider(),
Padding = new(0),
Margin = new(0),
Dock = DockStyle.Fill,
@@ -44,14 +42,15 @@ public BlazorControl()
Text = "blazorWebView1",
AutoScroll = false
};
blazorView.InitializeServices(); // the code in this method can't go here directly because it crashes th eWinForms designer
blazorView.RootComponents.Add(new RootComponent("#app", BlazorComponentType, parameters));
Controls.Add(blazorView);
}
catch
{
// Blazor could not be loaded, display a dummy label
VM = new();
Controls.Add(new Label { Text = "Blazor Control"});
Controls.Add(new Label { Text = Name, Dock = DockStyle.Fill });
}

ResumeLayout(false);
@@ -66,5 +65,11 @@ public BlazorControl()
/// The view model for this Blazor control. Should be overridden.
/// </summary>
protected virtual object VM { get; } = new();

/// <summary>
/// Initializes services for this Blazor control's web view. Should be overridden.
/// </summary>
/// <param name="blazorView">The web view.</param>
protected virtual void InitializeServices(BlazorWebView blazorView) { }
}
}
120 changes: 120 additions & 0 deletions FrEee.UI.WinForms/Controls/BlazorControl.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
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">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</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.Runtime.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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<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" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</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>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
13 changes: 13 additions & 0 deletions FrEee.UI.WinForms/Utility/Extensions/GuiExtensions.cs
Original file line number Diff line number Diff line change
@@ -5,6 +5,8 @@
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Microsoft.AspNetCore.Components.WebView.WindowsForms;
using Microsoft.Extensions.DependencyInjection;

namespace FrEee.UI.WinForms.Utility.Extensions;

@@ -298,4 +300,15 @@ private static void escapeKeyHandler(object sender, KeyEventArgs e)
form.Close();
}
}

/// <summary>
/// Initializes the services required to run a Blazor web view.
/// </summary>
/// <param name="blazorView">The Blazor web view.</param>
public static void InitializeServices(this BlazorWebView blazorView)
{
var services = new ServiceCollection();
services.AddWindowsFormsBlazorWebView();
blazorView.Services = services.BuildServiceProvider();
}
}