-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainForm.cs
More file actions
278 lines (237 loc) · 12.5 KB
/
Copy pathMainForm.cs
File metadata and controls
278 lines (237 loc) · 12.5 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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
using System;
using System.Drawing;
using System.Windows.Forms;
using Gigasoft.ProEssentials;
using Gigasoft.ProEssentials.Enums;
namespace ProEssentialsWinFormsQuickstart
{
/// <summary>
/// ProEssentials WinForms Quickstart (.NET 8)
///
/// Code-built WinForms port of the WPF ProEssentials Quickstart
/// (Example 100 - Simple Scientific Graph). No .Designer.cs / no .resx -
/// the entire UI is constructed in code so the Visual Studio WinForms
/// designer is never invoked (it does not load the native ProEssentials
/// control reliably). Build + F5 works regardless.
///
/// A single Pesgo scientific chart shows 4 subsets x 120 points of random
/// performance data with gradient/bevel plotting features. The bottom row
/// carries three placeholder buttons and a label, matching the WPF sample
/// shell (intentionally left as stubs for you to wire up).
///
/// The ProEssentials configuration block (MainForm_Load) is IDENTICAL to
/// the WPF code-behind - the same property paths, enums, and arrays work
/// on WinForms and WPF. Only the host shell changed.
/// </summary>
public class MainForm : Form
{
// ProEssentials chart control (WPF PesgoWpf -> WinForms Pesgo)
private Pesgo Pesgo1;
// Bottom-row controls (WPF Buttons + Label in Grid.Row=1)
private Button Button1;
private Button Button2;
private Button Button3;
private Label Label1;
public static Random Rand_Num = new Random(unchecked((int)DateTime.Now.Ticks));
public MainForm()
{
// Window properties (WPF Window attrs -> Form properties)
Text = "ProEssentials WinForms Quickstart";
ClientSize = new Size(1280, 640); // WPF Width/Height
MinimumSize = new Size(400, 400); // WPF MinWidth/MinHeight
StartPosition = FormStartPosition.CenterScreen;
BuildLayout();
// WinForms: initialize the chart in Form.Load - by then the form and
// all child control handles exist and the native PE control is ready.
// (WPF must instead use the chart control's own Loaded event because
// the HwndHost'd native window doesn't exist until the control itself
// loads; WinForms has no such gap.)
this.Load += MainForm_Load;
this.FormClosing += MainForm_FormClosing;
}
// =====================================================================
// BuildLayout - replaces MainWindow.xaml
//
// WPF Grid (Row * + Row 35) -> WinForms: the chart docked Fill plus a
// 35px Panel docked Bottom carrying the three buttons and the label.
// Add the Fill control FIRST, then the docked Bottom panel, so docking
// z-order leaves the chart filling the area above the bottom strip.
// =====================================================================
private void BuildLayout()
{
// Chart (WPF Gigasoft:PesgoWpf inside the Border in Grid.Row=0)
Pesgo1 = new Pesgo();
Pesgo1.Dock = DockStyle.Fill;
Controls.Add(Pesgo1);
// Bottom controls strip (WPF Grid.Row=1, Height=35)
var bottom = new Panel
{
Dock = DockStyle.Bottom,
Height = 35
};
// WPF used absolute Margin offsets (0 / 160 / 320 / 480) with fixed
// 130-wide buttons; reproduce with explicit Location/Size here.
Button1 = new Button
{
Text = "Button1",
Width = 130, Height = 30,
Location = new Point(0, 0)
};
Button2 = new Button
{
Text = "Button2",
Width = 130, Height = 30,
Location = new Point(160, 0)
};
Button3 = new Button
{
Text = "Button3",
Width = 130, Height = 30,
Location = new Point(320, 0)
};
Label1 = new Label
{
Text = "Label1",
AutoSize = true,
Location = new Point(480, 7)
};
bottom.Controls.Add(Button1);
bottom.Controls.Add(Button2);
bottom.Controls.Add(Button3);
bottom.Controls.Add(Label1);
Controls.Add(bottom); // docked Bottom, below the Fill chart
}
// =====================================================================
// MainForm_Load - chart initialization (WinForms Form.Load)
// BELOW THIS LINE: 100% IDENTICAL to the WPF code-behind. The entire
// ProEssentials configuration block is framework-agnostic - the same
// property paths, enums, and arrays work on WinForms and WPF.
// (WPF Color.FromArgb came from System.Windows.Media; on WinForms the
// Gigasoft .NET API takes System.Drawing.Color with the same ARGB args.)
// =====================================================================
private void MainForm_Load(object sender, EventArgs e)
{
Pesgo1.PeFont.SizeGlobalCntl = 1.1F;
//100 *** Simple Scientific Graph ***
//! Right button click to show popup menu. //
//! Double Click to show customization dialog. //
//! Left-Click and drag to draw zoom box. Use popup memu or 'z' to undo zoom. //
// Simple example show the basics of a scientific graph object. //
// Scientific Graph's contain both YData and XData and thus data
// is not plotted equally spaced as the graph object does.
// RenderSizeXdpi is unique to WPF interfaces.
// Default is true, results in sharpest lines all the time.
// Setting false and running on system without 100% TextSize (i.e. 125% or 150% text size) will result in fuzzier lines and text
// as everything will be scaled larger. Some may prefer the slight fuzziness of fully scaled results but we prefer the sharper images.
// Pesgo1.RenderSizeXdpi = true;
Pesgo1.PeUserInterface.Cursor.PromptTracking = true;
Pesgo1.PeUserInterface.Cursor.PromptLocation = CursorPromptLocation.ToolTip;
Pesgo1.PeUserInterface.Cursor.PromptStyle = CursorPromptStyle.XYValues;
// Enable Bar Glass Effect //
Pesgo1.PePlot.Option.BarGlassEffect = true;
// Enable Plotting style gradient and bevel features //
Pesgo1.PePlot.Option.AreaGradientStyle = PlotGradientStyle.VerticalAscentInverse;
Pesgo1.PePlot.Option.AreaBevelStyle = BevelStyle.MediumSmooth;
Pesgo1.PePlot.Option.SplineGradientStyle = PlotGradientStyle.VerticalAscentInverse;
Pesgo1.PePlot.Option.SplineBevelStyle = SplineBevelStyle.MediumSmooth;
Pesgo1.PePlot.Option.PointGradientStyle = PlotGradientStyle.VerticalAscentInverse;
Pesgo1.PeColor.PointBorderColor = Color.FromArgb(100, 0, 0, 0);
Pesgo1.PePlot.Option.LineSymbolThickness = 3;
Pesgo1.PePlot.Option.AreaBorder = 1;
// Prepare images in memory //
Pesgo1.PeConfigure.PrepareImages = true;
// Pass Data //
Pesgo1.PeData.Subsets = 4;
Pesgo1.PeData.Points = 120;
for (int s = 0; s <= 3; s++)
{
int nOffset = (int)(Rand_Num.NextDouble() * 250);
for (int p = 0; p <= 119; p++)
{
Pesgo1.PeData.X[s, p] = (float)((p + 1) * 100.0F);
Pesgo1.PeData.Y[s, p] = (float)((p + 1) * 1 + (Rand_Num.NextDouble() * 250)) + (float)(Math.Sin(((double)(nOffset + p)) * .03F) * 700.0F) - ((s * 140.0F));
}
}
// Set DataShadows to show 3D //
Pesgo1.PePlot.DataShadows = DataShadows.Shadows;
Pesgo1.PeUserInterface.Allow.FocalRect = false;
Pesgo1.PePlot.Method = SGraphPlottingMethod.PointsPlusSpline;
Pesgo1.PeGrid.LineControl = GridLineControl.Both;
Pesgo1.PeGrid.Style = GridStyle.Dot;
Pesgo1.PeUserInterface.Allow.Zooming = AllowZooming.HorzAndVert;
Pesgo1.PeUserInterface.Allow.ZoomStyle = ZoomStyle.Ro2Not;
// Enable middle mouse dragging //
Pesgo1.PeUserInterface.Scrollbar.MouseDraggingX = true;
Pesgo1.PeUserInterface.Scrollbar.MouseDraggingY = true;
Pesgo1.PeString.MainTitle = "Test Results";
Pesgo1.PeString.SubTitle = "";
Pesgo1.PeString.YAxisLabel = "Performance";
Pesgo1.PeString.XAxisLabel = "Duration";
// subset labels //
Pesgo1.PeString.SubsetLabels[0] = "Horsepower";
Pesgo1.PeString.SubsetLabels[1] = "Torque";
Pesgo1.PeString.SubsetLabels[2] = "Temperature";
Pesgo1.PeString.SubsetLabels[3] = "Pressure";
// subset colors //
Pesgo1.PeColor.SubsetColors[0] = Color.FromArgb(255, 213, 0, 69);
Pesgo1.PeColor.SubsetColors[1] = Color.FromArgb(255, 63, 200, 0);
Pesgo1.PeColor.SubsetColors[2] = Color.FromArgb(255, 212, 168, 0);
Pesgo1.PeColor.SubsetColors[3] = Color.FromArgb(255, 169, 0, 153);
// subset line types
Pesgo1.PeLegend.SubsetLineTypes[0] = LineType.MediumSolid;
Pesgo1.PeLegend.SubsetLineTypes[1] = LineType.MediumSolid;
Pesgo1.PeLegend.SubsetLineTypes[2] = LineType.MediumSolid;
Pesgo1.PeLegend.SubsetLineTypes[3] = LineType.MediumSolid;
// subset point types
Pesgo1.PeLegend.SubsetPointTypes[0] = PointType.DotSolid;
Pesgo1.PeLegend.SubsetPointTypes[1] = PointType.UpTriangleSolid;
Pesgo1.PeLegend.SubsetPointTypes[2] = PointType.SquareSolid;
Pesgo1.PeLegend.SubsetPointTypes[3] = PointType.DownTriangleSolid;
Pesgo1.PeLegend.SubsetPointTypes[4] = PointType.DotSolid;
Pesgo1.PeLegend.SubsetPointTypes[5] = PointType.SquareSolid;
Pesgo1.PeLegend.SubsetPointTypes[6] = PointType.DiamondSolid;
Pesgo1.PeLegend.SubsetPointTypes[7] = PointType.UpTriangleSolid;
Pesgo1.PeLegend.SimplePoint = true;
Pesgo1.PeLegend.SimpleLine = true;
Pesgo1.PeLegend.Style = LegendStyle.OneLine;
Pesgo1.PeGrid.Option.MultiAxisStyle = MultiAxisStyle.SeparateAxes;
Pesgo1.PePlot.Option.GradientBars = 8;
Pesgo1.PeConfigure.TextShadows = TextShadows.BoldText;
Pesgo1.PeFont.MainTitle.Bold = true;
Pesgo1.PeFont.SubTitle.Bold = true;
Pesgo1.PeFont.Label.Bold = true;
Pesgo1.PePlot.Option.LineShadows = true;
Pesgo1.PeFont.FontSize = Gigasoft.ProEssentials.Enums.FontSize.Large;
Pesgo1.PeUserInterface.Scrollbar.ScrollingHorzZoom = true;
Pesgo1.PeData.Precision = DataPrecision.OneDecimal;
// Various other features //
Pesgo1.PeFont.Fixed = true;
Pesgo1.PeColor.BitmapGradientMode = false;
Pesgo1.PeColor.QuickStyle = QuickStyle.DarkNoBorder;
Pesgo1.PeGrid.Configure.AutoMinMaxPadding = 1;
Pesgo1.PeConfigure.ImageAdjustLeft = 20;
Pesgo1.PeConfigure.ImageAdjustRight = 20;
Pesgo1.PeConfigure.ImageAdjustTop = 10;
// Set various export defaults //
Pesgo1.PeSpecial.DpiX = 600;
Pesgo1.PeSpecial.DpiY = 600;
// default export setting //
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;
Pesgo1.PeConfigure.RenderEngine = RenderEngine.Direct2D;
Pesgo1.PeConfigure.AntiAliasGraphics = true;
Pesgo1.PeConfigure.AntiAliasText = true;
// Call ReinitializeResetImage at end **'
Pesgo1.PeFunction.ReinitializeResetImage();
Pesgo1.Invalidate();
}
// WinForms Form.FormClosing (WPF Window.Closing -> CancelEventArgs)
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
}
}
}