Skip to content

Commit 7f388c2

Browse files
committed
add winform demo;
1 parent d7f525e commit 7f388c2

12 files changed

+450
-0
lines changed

CodeWF.EventBus.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeWF.EventBus.ConsoleAOT"
3636
EndProject
3737
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeWF.EventBus.AvaAOT", "src\CodeWF.EventBus.AvaAOT\CodeWF.EventBus.AvaAOT.csproj", "{47D9CEE8-DE72-4FD7-97B5-28FDBD233101}"
3838
EndProject
39+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsFormsApp1_4_8", "src\WindowsFormsApp1_4_8\WindowsFormsApp1_4_8.csproj", "{F683A892-B28D-46EE-B86B-2BE2F4F4B997}"
40+
EndProject
3941
Global
4042
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4143
Debug|Any CPU = Debug|Any CPU
@@ -74,6 +76,10 @@ Global
7476
{47D9CEE8-DE72-4FD7-97B5-28FDBD233101}.Debug|Any CPU.Build.0 = Debug|Any CPU
7577
{47D9CEE8-DE72-4FD7-97B5-28FDBD233101}.Release|Any CPU.ActiveCfg = Release|Any CPU
7678
{47D9CEE8-DE72-4FD7-97B5-28FDBD233101}.Release|Any CPU.Build.0 = Release|Any CPU
79+
{F683A892-B28D-46EE-B86B-2BE2F4F4B997}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
80+
{F683A892-B28D-46EE-B86B-2BE2F4F4B997}.Debug|Any CPU.Build.0 = Debug|Any CPU
81+
{F683A892-B28D-46EE-B86B-2BE2F4F4B997}.Release|Any CPU.ActiveCfg = Release|Any CPU
82+
{F683A892-B28D-46EE-B86B-2BE2F4F4B997}.Release|Any CPU.Build.0 = Release|Any CPU
7783
EndGlobalSection
7884
GlobalSection(SolutionProperties) = preSolution
7985
HideSolutionNode = FALSE
@@ -88,6 +94,7 @@ Global
8894
{934EB790-8C1E-4FD6-8C9E-3DC9BDB5D5E5} = {A7FA457D-7E77-4B21-958F-F45A51EF8163}
8995
{080C70B1-8169-40CF-B43C-065E6DB68038} = {FABFCEA3-4F5D-4473-AF45-A507D1463B1A}
9096
{47D9CEE8-DE72-4FD7-97B5-28FDBD233101} = {FABFCEA3-4F5D-4473-AF45-A507D1463B1A}
97+
{F683A892-B28D-46EE-B86B-2BE2F4F4B997} = {FABFCEA3-4F5D-4473-AF45-A507D1463B1A}
9198
EndGlobalSection
9299
GlobalSection(ExtensibilityGlobals) = postSolution
93100
SolutionGuid = {7685ED0A-581B-42BC-9613-64AD00D124D6}

src/WindowsFormsApp1_4_8/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
5+
</startup>
6+
</configuration>

src/WindowsFormsApp1_4_8/Form1.Designer.cs

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/WindowsFormsApp1_4_8/Form1.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using CodeWF.EventBus;
2+
using System;
3+
using System.Windows.Forms;
4+
5+
namespace WindowsFormsApp1_4_8
6+
{
7+
public class TimeCommand : Command
8+
{
9+
public int Id { get; set; }
10+
}
11+
public partial class Form1 : Form
12+
{
13+
public Form1()
14+
{
15+
InitializeComponent();
16+
17+
EventBus.Default.Subscribe(this);
18+
19+
var btn = new Button();
20+
btn.Text = "publish";
21+
btn.Click += (s, e) => EventBus.Default.Publish(new TimeCommand() { Id = DateTime.Now.Millisecond });
22+
this.Controls.Add(btn);
23+
}
24+
25+
[EventHandler]
26+
private void ReceiveCommand(TimeCommand command)
27+
{
28+
MessageBox.Show($"收到ID:{command.Id}");
29+
}
30+
}
31+
}

src/WindowsFormsApp1_4_8/Program.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using System.Windows.Forms;
6+
7+
namespace WindowsFormsApp1_4_8
8+
{
9+
internal static class Program
10+
{
11+
/// <summary>
12+
/// 应用程序的主入口点。
13+
/// </summary>
14+
[STAThread]
15+
static void Main()
16+
{
17+
Application.EnableVisualStyles();
18+
Application.SetCompatibleTextRenderingDefault(false);
19+
Application.Run(new Form1());
20+
}
21+
}
22+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// 有关程序集的一般信息由以下
6+
// 控制。更改这些特性值可修改
7+
// 与程序集关联的信息。
8+
[assembly: AssemblyTitle("WindowsFormsApp1_4_8")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("WindowsFormsApp1_4_8")]
13+
[assembly: AssemblyCopyright("Copyright © 2025")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// 将 ComVisible 设置为 false 会使此程序集中的类型
18+
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19+
//请将此类型的 ComVisible 特性设置为 true。
20+
[assembly: ComVisible(false)]
21+
22+
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23+
[assembly: Guid("f683a892-b28d-46ee-b86b-2be2f4f4b997")]
24+
25+
// 程序集的版本信息由下列四个值组成:
26+
//
27+
// 主版本
28+
// 次版本
29+
// 生成号
30+
// 修订号
31+
//
32+
[assembly: AssemblyVersion("1.0.0.0")]
33+
[assembly: AssemblyFileVersion("1.0.0.0")]

src/WindowsFormsApp1_4_8/Properties/Resources.Designer.cs

Lines changed: 71 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<root>
3+
<!--
4+
Microsoft ResX Schema
5+
6+
Version 2.0
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
11+
associated with the data types.
12+
13+
Example:
14+
15+
... ado.net/XML headers & schema ...
16+
<resheader name="resmimetype">text/microsoft-resx</resheader>
17+
<resheader name="version">2.0</resheader>
18+
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19+
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20+
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21+
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22+
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23+
<value>[base64 mime encoded serialized .NET Framework object]</value>
24+
</data>
25+
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26+
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27+
<comment>This is a comment</comment>
28+
</data>
29+
30+
There are any number of "resheader" rows that contain simple
31+
name/value pairs.
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
37+
mimetype set.
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
41+
extensible. For a given mimetype the value must be set accordingly:
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
45+
read any of the formats listed below.
46+
47+
mimetype: application/x-microsoft.net.object.binary.base64
48+
value : The object must be serialized with
49+
: System.Serialization.Formatters.Binary.BinaryFormatter
50+
: and then encoded with base64 encoding.
51+
52+
mimetype: application/x-microsoft.net.object.soap.base64
53+
value : The object must be serialized with
54+
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55+
: and then encoded with base64 encoding.
56+
57+
mimetype: application/x-microsoft.net.object.bytearray.base64
58+
value : The object must be serialized into a byte array
59+
: using a System.ComponentModel.TypeConverter
60+
: and then encoded with base64 encoding.
61+
-->
62+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63+
<xsd:element name="root" msdata:IsDataSet="true">
64+
<xsd:complexType>
65+
<xsd:choice maxOccurs="unbounded">
66+
<xsd:element name="metadata">
67+
<xsd:complexType>
68+
<xsd:sequence>
69+
<xsd:element name="value" type="xsd:string" minOccurs="0" />
70+
</xsd:sequence>
71+
<xsd:attribute name="name" type="xsd:string" />
72+
<xsd:attribute name="type" type="xsd:string" />
73+
<xsd:attribute name="mimetype" type="xsd:string" />
74+
</xsd:complexType>
75+
</xsd:element>
76+
<xsd:element name="assembly">
77+
<xsd:complexType>
78+
<xsd:attribute name="alias" type="xsd:string" />
79+
<xsd:attribute name="name" type="xsd:string" />
80+
</xsd:complexType>
81+
</xsd:element>
82+
<xsd:element name="data">
83+
<xsd:complexType>
84+
<xsd:sequence>
85+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
86+
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
87+
</xsd:sequence>
88+
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
89+
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
90+
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
91+
</xsd:complexType>
92+
</xsd:element>
93+
<xsd:element name="resheader">
94+
<xsd:complexType>
95+
<xsd:sequence>
96+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
97+
</xsd:sequence>
98+
<xsd:attribute name="name" type="xsd:string" use="required" />
99+
</xsd:complexType>
100+
</xsd:element>
101+
</xsd:choice>
102+
</xsd:complexType>
103+
</xsd:element>
104+
</xsd:schema>
105+
<resheader name="resmimetype">
106+
<value>text/microsoft-resx</value>
107+
</resheader>
108+
<resheader name="version">
109+
<value>2.0</value>
110+
</resheader>
111+
<resheader name="reader">
112+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
113+
</resheader>
114+
<resheader name="writer">
115+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116+
</resheader>
117+
</root>

src/WindowsFormsApp1_4_8/Properties/Settings.Designer.cs

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
3+
<Profiles>
4+
<Profile Name="(Default)" />
5+
</Profiles>
6+
<Settings />
7+
</SettingsFile>

0 commit comments

Comments
 (0)