-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainForm.cs
More file actions
213 lines (174 loc) · 8.93 KB
/
Copy pathMainForm.cs
File metadata and controls
213 lines (174 loc) · 8.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
using System;
using System.Globalization;
using System.IO;
using System.Windows.Forms;
using Gigasoft.ProEssentials;
using Gigasoft.ProEssentials.Enums;
namespace HeatmapSpectrogram
{
/// <summary>
/// ProEssentials WinForms Heatmap — Spectrogram — 2D Contour Chart (.NET 8)
///
/// Code-built WinForms port. 183 subsets × 512 points = 93,696 Z values
/// rendered as a 2D contour heatmap (frequency vs time vs amplitude) via
/// SGraphPlottingMethod.ContourColors, log Y axis, GPU ComputeShader.
///
/// PORT NOTES (only host pieces changed; the data loader and the entire
/// chart configuration are IDENTICAL to the WPF code-behind):
/// - MessageBox / MessageBoxButton.OK -> WinForms MessageBox / MessageBoxButtons.OK
/// - Application.Current.Shutdown() -> Application.Exit()
/// - PesgoWpf control -> Pesgo
/// (No explicit colors — uses ContourColorSet enum — so the WPF
/// System.Windows.Media using simply drops.)
/// </summary>
public class MainForm : Form
{
private Pesgo Pesgo1;
public MainForm()
{
Pesgo1 = new Pesgo();
Pesgo1.Dock = DockStyle.Fill;
Controls.Add(Pesgo1);
Text = "ProEssentials — WinForms Heatmap Spectrogram 2D Contour";
ClientSize = new System.Drawing.Size(1400, 900);
MinimumSize = new System.Drawing.Size(900, 500);
StartPosition = FormStartPosition.CenterScreen;
this.Load += MainForm_Load;
this.FormClosing += MainForm_FormClosing;
}
// -----------------------------------------------------------------------
// MainForm_Load — chart initialization (WinForms Form.Load)
// BELOW: IDENTICAL to WPF.
// -----------------------------------------------------------------------
private void MainForm_Load(object sender, EventArgs e)
{
// Step 1 — Declare data dimensions
Pesgo1.PeData.Subsets = 183;
Pesgo1.PeData.Points = 512;
Pesgo1.PeData.DuplicateDataX = DuplicateData.PointIncrement;
Pesgo1.PeData.DuplicateDataY = DuplicateData.SubsetIncrement;
Pesgo1.PeData.X[0, 511] = 0;
Pesgo1.PeData.Y[0, 182] = 0;
Pesgo1.PeData.Z[182, 511] = 0;
// Step 2 — Load Heatmap.txt
int nSubsetCount = 0;
int nPointCount = 0;
string[] fileArray = { "", "" };
try
{
fileArray = File.ReadAllLines("Heatmap.txt");
}
catch
{
MessageBox.Show(
"Heatmap.txt not found.\n\nMake sure Heatmap.txt is in the same folder as the executable.",
"File Not Found", MessageBoxButtons.OK);
Application.Exit();
return;
}
for (int i = 0; i < fileArray.Length; i++)
{
string line = fileArray[i];
if (line.Length < 3) continue;
var columns = line.Split('\t');
float fX = float.Parse(columns[0], CultureInfo.InvariantCulture.NumberFormat);
float fY = float.Parse(columns[1], CultureInfo.InvariantCulture.NumberFormat);
float fZ = float.Parse(columns[2], CultureInfo.InvariantCulture.NumberFormat);
if (nSubsetCount == 0)
Pesgo1.PeData.X[0, nPointCount] = fX + 20.0F;
if (nPointCount == 0)
Pesgo1.PeData.Y[0, nSubsetCount] = fY * (i + 1000) / 100.0F;
Pesgo1.PeData.Z[nSubsetCount, nPointCount] = fZ;
nPointCount++;
if (nPointCount > 511)
{
nPointCount = 0;
nSubsetCount++;
}
}
// Step 3 — Axis scale
Pesgo1.PeGrid.Configure.YAxisScaleControl = Gigasoft.ProEssentials.Enums.ScaleControl.Log;
// Step 4 — Visual styling — dark theme
Pesgo1.PeColor.BitmapGradientMode = true;
Pesgo1.PeColor.QuickStyle = QuickStyle.DarkNoBorder;
Pesgo1.PeColor.GridBold = true;
// Step 5 — Contour color plotting method
Pesgo1.PePlot.Allow.ContourColors = true;
Pesgo1.PePlot.Allow.ContourColorsShadows = true;
Pesgo1.PeColor.ContourColorBlends = 10;
// ContourColorBlends must always be set BEFORE ContourColorSet
Pesgo1.PeColor.ContourColorSet = ContourColorSet.BlueCyanGreenYellowBrownWhite;
Pesgo1.PeLegend.ContourLegendPrecision = ContourLegendPrecision.ZeroDecimals;
Pesgo1.PeLegend.ContourStyle = true;
Pesgo1.PePlot.Method = SGraphPlottingMethod.ContourColors;
Pesgo1.PeUserInterface.Menu.DataShadow = MenuControl.Hide;
// Step 6 — Zoom and interaction
Pesgo1.PeUserInterface.Scrollbar.MouseWheelZoomFactor = 1.4F;
Pesgo1.PeUserInterface.Scrollbar.MouseWheelZoomSmoothness = 2;
Pesgo1.PeGrid.GridBands = false;
Pesgo1.PeUserInterface.Allow.ZoomStyle = ZoomStyle.Ro2Not;
Pesgo1.PeUserInterface.Allow.Zooming = AllowZooming.HorzAndVert;
Pesgo1.PeUserInterface.Scrollbar.MouseWheelFunction = MouseWheelFunction.HorizontalVerticalZoom;
Pesgo1.PeUserInterface.Scrollbar.ScrollingVertZoom = true;
Pesgo1.PeUserInterface.Scrollbar.ScrollingHorzZoom = true;
// Step 7 — Legend and grid
Pesgo1.PeLegend.Location = LegendLocation.Left;
Pesgo1.PeGrid.InFront = true;
Pesgo1.PeGrid.LineControl = GridLineControl.Both;
Pesgo1.PeGrid.Style = GridStyle.Dot;
// Step 8 — Disable non-contour plot methods from the right-click menu
Pesgo1.PePlot.Allow.Line = false;
Pesgo1.PePlot.Allow.Point = false;
Pesgo1.PePlot.Allow.Bar = false;
Pesgo1.PePlot.Allow.Area = false;
Pesgo1.PePlot.Allow.Spline = false;
Pesgo1.PePlot.Allow.SplineArea = false;
Pesgo1.PePlot.Allow.PointsPlusLine = false;
Pesgo1.PePlot.Allow.PointsPlusSpline = false;
Pesgo1.PePlot.Allow.BestFitCurve = false;
Pesgo1.PePlot.Allow.BestFitLine = false;
Pesgo1.PePlot.Allow.Stick = false;
// Step 9 — Titles and fonts
Pesgo1.PeString.MainTitle = "Wave Data - Heatmap - Spectrogram Example";
Pesgo1.PeString.SubTitle = "";
Pesgo1.PeGrid.Configure.AutoMinMaxPadding = 0;
Pesgo1.PeFont.FontSize = Gigasoft.ProEssentials.Enums.FontSize.Large;
Pesgo1.PeFont.Fixed = true;
Pesgo1.PeUserInterface.Dialog.Axis = false;
Pesgo1.PeUserInterface.Dialog.Style = false;
Pesgo1.PeUserInterface.Dialog.Subsets = false;
Pesgo1.PeConfigure.TextShadows = TextShadows.BoldText;
Pesgo1.PeFont.MainTitle.Bold = true;
Pesgo1.PeFont.SubTitle.Bold = true;
Pesgo1.PeFont.Label.Bold = true;
// Step 10 — Export defaults
Pesgo1.PeSpecial.DpiX = 600;
Pesgo1.PeSpecial.DpiY = 600;
Pesgo1.PeUserInterface.Dialog.AllowEmfExport = false;
Pesgo1.PeUserInterface.Dialog.AllowWmfExport = false;
Pesgo1.PeUserInterface.Dialog.ExportSizeDef = ExportSizeDef.NoSizeOrPixel;
Pesgo1.PeUserInterface.Dialog.ExportTypeDef = ExportTypeDef.Png;
Pesgo1.PeUserInterface.Dialog.ExportDestDef = ExportDestDef.Clipboard;
Pesgo1.PeUserInterface.Dialog.ExportUnitXDef = "1280";
Pesgo1.PeUserInterface.Dialog.ExportUnitYDef = "768";
Pesgo1.PeUserInterface.Dialog.ExportImageDpi = 300;
// Step 11 — Rendering engine
Pesgo1.PeConfigure.Composite2D3D = Composite2D3D.Foreground;
Pesgo1.PeConfigure.RenderEngine = RenderEngine.Direct3D;
Pesgo1.PeData.ComputeShader = true;
// Step 12 — Cursor prompt
Pesgo1.PeUserInterface.Cursor.PromptTracking = true;
Pesgo1.PeUserInterface.Cursor.PromptStyle = CursorPromptStyle.XYZValues;
Pesgo1.PeUserInterface.Cursor.PromptLocation = CursorPromptLocation.Text;
Pesgo1.PeUserInterface.Cursor.HourGlassThreshold = 9999999;
Pesgo1.PeFunction.Force3dxNewColors = true;
Pesgo1.PeFunction.Force3dxVerticeRebuild = true;
Pesgo1.PeFunction.ReinitializeResetImage();
Pesgo1.Invalidate();
}
// WPF Window.Closing -> WinForms FormClosing
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
}
}
}