Skip to content

Commit 5afc21e

Browse files
committed
性能组件移动到公共组件中,在服务器端和客户端提供一致的呈现。
1 parent 0f84aef commit 5afc21e

8 files changed

Lines changed: 63 additions & 31 deletions

File tree

软件系统客户端模版/FormSuper.Designer.cs renamed to CommonLibrary/BasicSupport/FormSuper.Designer.cs

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
using System.Text;
88
using System.Windows.Forms;
99

10-
namespace 软件系统客户端模版
10+
namespace CommonLibrary
1111
{
1212
public partial class FormSuper : Form
1313
{
14-
public FormSuper()
14+
public FormSuper(Func<int[]> getDataFunction)
1515
{
1616
InitializeComponent();
17+
GetDataFunction = getDataFunction;
1718
}
1819

1920
private void FormSuper_Load(object sender, EventArgs e)
@@ -37,25 +38,22 @@ private void FormSuper_FormClosing(object sender, FormClosingEventArgs e)
3738
IsWindowShow = false;
3839
}
3940

40-
41+
private Func<int[]> GetDataFunction = null;
4142

4243
private bool IsWindowShow { get; set; }
4344

4445
private void Timer_Tick(object sender, EventArgs e)
4546
{
46-
HslCommunication.OperateResultBytes result = UserClient.Net_simplify_client.ReadFromServer(CommonLibrary.CommonHeadCode.SimplifyHeadCode.性能计数, new byte[0]);
47-
//解析
48-
if (result.IsSuccess)
47+
if (GetDataFunction != null)
4948
{
50-
int[] data = new int[result.Content.Length / 4];
51-
for (int i = 0; i < data.Length; i++)
52-
{
53-
data[i] = BitConverter.ToInt32(result.Content, i * 4);
54-
}
55-
if (IsWindowShow)
49+
int[] data = GetDataFunction();
50+
if (data != null)
5651
{
57-
pictureBox1.Image?.Dispose();
58-
pictureBox1.Image = HslCommunication.BasicFramework.SoftPainting.GetGraphicFromArray(data, pictureBox1.Width - 2, pictureBox1.Height - 2, 7, Color.Blue);
52+
if (IsWindowShow)
53+
{
54+
pictureBox1.Image?.Dispose();
55+
pictureBox1.Image = HslCommunication.BasicFramework.SoftPainting.GetGraphicFromArray(data, pictureBox1.Width - 2, pictureBox1.Height - 2, 7, Color.Blue);
56+
}
5957
}
6058
}
6159
}

CommonLibrary/CommonLibrary.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@
6767
</Compile>
6868
<Compile Include="AccountSupport\ServerAccount.cs" />
6969
<Compile Include="AccountSupport\UserAccount.cs" />
70+
<Compile Include="BasicSupport\FormSuper.cs">
71+
<SubType>Form</SubType>
72+
</Compile>
73+
<Compile Include="BasicSupport\FormSuper.Designer.cs">
74+
<DependentUpon>FormSuper.cs</DependentUpon>
75+
</Compile>
7076
<Compile Include="BasicSupport\FormUpdateLog.cs">
7177
<SubType>Form</SubType>
7278
</Compile>
@@ -97,6 +103,9 @@
97103
<EmbeddedResource Include="AccountSupport\FormPasswordModify.resx">
98104
<DependentUpon>FormPasswordModify.cs</DependentUpon>
99105
</EmbeddedResource>
106+
<EmbeddedResource Include="BasicSupport\FormSuper.resx">
107+
<DependentUpon>FormSuper.cs</DependentUpon>
108+
</EmbeddedResource>
100109
<EmbeddedResource Include="BasicSupport\FormUpdateLog.resx">
101110
<DependentUpon>FormUpdateLog.cs</DependentUpon>
102111
</EmbeddedResource>

软件系统客户端模版/FormMainWindow.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,25 @@ private void 消息发送ToolStripMenuItem_Click(object sender, EventArgs e)
270270

271271
private void 开发中心ToolStripMenuItem_Click(object sender, EventArgs e)
272272
{
273-
using (FormSuper fs = new FormSuper())
273+
using (FormSuper fs = new FormSuper(() =>
274+
{
275+
OperateResultBytes result = UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode.性能计数, new byte[0]);
276+
//解析
277+
if (result.IsSuccess)
278+
{
279+
int[] data = new int[result.Content.Length / 4];
280+
for (int i = 0; i < data.Length; i++)
281+
{
282+
data[i] = BitConverter.ToInt32(result.Content, i * 4);
283+
}
284+
return data;
285+
}
286+
else
287+
{
288+
return null;
289+
}
290+
291+
}))
274292
{
275293
fs.ShowDialog();
276294
}

软件系统客户端模版/软件系统客户端模版.csproj

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,6 @@
8383
<Compile Include="FormRegisterAccount.Designer.cs">
8484
<DependentUpon>FormRegisterAccount.cs</DependentUpon>
8585
</Compile>
86-
<Compile Include="FormSuper.cs">
87-
<SubType>Form</SubType>
88-
</Compile>
89-
<Compile Include="FormSuper.Designer.cs">
90-
<DependentUpon>FormSuper.cs</DependentUpon>
91-
</Compile>
9286
<Compile Include="FormUpdateRemote.cs">
9387
<SubType>Form</SubType>
9488
</Compile>
@@ -125,9 +119,6 @@
125119
<EmbeddedResource Include="FormRegisterAccount.resx">
126120
<DependentUpon>FormRegisterAccount.cs</DependentUpon>
127121
</EmbeddedResource>
128-
<EmbeddedResource Include="FormSuper.resx">
129-
<DependentUpon>FormSuper.cs</DependentUpon>
130-
</EmbeddedResource>
131122
<EmbeddedResource Include="FormUpdateRemote.resx">
132123
<DependentUpon>FormUpdateRemote.cs</DependentUpon>
133124
</EmbeddedResource>

软件系统服务端模版/FormServerWindow.Designer.cs

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

软件系统服务端模版/FormServerWindow.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,18 @@ private void MaintenanceInitialization()
316316
}
317317

318318

319+
private void label_GC_Memery_Click(object sender, EventArgs e)
320+
{
321+
//点击了性能组件
322+
using (FormSuper fs = new FormSuper(() =>
323+
{
324+
return SoftCachePerfomance.GetIntArray();
325+
}))
326+
{
327+
fs.ShowDialog();
328+
}
329+
}
330+
319331
#endregion
320332

321333
#region 软件更新服务引擎
@@ -890,7 +902,7 @@ public void ThreadTimeTick()
890902

891903
#region 服务器内存性能缓存小模块
892904

893-
private SoftCacheArrayInt SoftCachePerfomance = new SoftCacheArrayInt(400, 0);
905+
private SoftCacheArrayInt SoftCachePerfomance = new SoftCacheArrayInt(500, 0);
894906

895907
private void AddPerfomace(long value)
896908
{
@@ -1196,5 +1208,7 @@ private void SendUserMail(string subject, string body)
11961208
}
11971209

11981210
#endregion
1211+
1212+
11991213
}
12001214
}

0 commit comments

Comments
 (0)