-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCustomCombiner.cs
More file actions
694 lines (554 loc) · 23.1 KB
/
CustomCombiner.cs
File metadata and controls
694 lines (554 loc) · 23.1 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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SharpOcarina.SayakaGL;
namespace SharpOcarina
{
public partial class CustomCombiner : Form
{
public ulong CombinerCommand = 0;
public ulong E2Command = 0;
public ulong D9Command = 0;
bool OutdoorLight = false;
bool AffectedByPointLight = false;
public ObjFile.Group target;
public MainForm mainf;
public bool D9lock,E2lock;
public CustomCombiner(MainForm _mainf, ObjFile.Group _target, bool _outdoorLight, bool _affectedByPointLight)
{
target = _target;
mainf = _mainf;
OutdoorLight = _outdoorLight;
AffectedByPointLight = _affectedByPointLight;
CombinerCommand = target.CustomDL[0];
D9Command = target.CustomDL[1];
E2Command = target.CustomDL[2];
InitializeComponent();
CompiledD9.Text = D9Command.ToString("X14");
CompiledE2.Text = E2Command.ToString("X14");
Init();
UpdateCombinerComboBox();
UpdateGeometryModeCheckboxes();
UpdateOtherModeLCheckboxes();
}
public void Init()
{
Object[] objs = new[]
{
"Combined color",
"Texture0 color",
"Texture1 color",
"Prim color",
"Vtx color",
"Env color",
"1.0",
"Noise",
"0.0",
"0.0",
"0.0",
"0.0",
"0.0",
"0.0",
"0.0",
"0.0",
};
C1A.Items.AddRange(objs);
C2A.Items.AddRange(objs);
objs = new[]
{
"Combined color",
"Texture0 color",
"Texture1 color",
"Prim color",
"Vtx color",
"Env color",
"Keycenter",
"Convk4",
"0.0",
"0.0",
"0.0",
"0.0",
"0.0",
"0.0",
"0.0",
"0.0",
};
C1B.Items.AddRange(objs);
C2B.Items.AddRange(objs);
objs = new[]
{
"Combined color",
"Texture0 color",
"Texture1 color",
"Prim color",
"Vtx color",
"Env color",
"Keyscale",
"Combined alpha",
"Texture0 alpha",
"Texture1 alpha",
"Prim alpha",
"Vtx alpha",
"Env alpha",
"LOD frac",
"Prim LOD frac",
"Convk5",
"0.0",
"0.0",
"0.0",
"0.0",
"0.0",
"0.0",
"0.0",
"0.0",
"0.0",
"0.0",
"0.0",
"0.0",
"0.0",
"0.0",
"0.0",
"0.0",
};
C1C.Items.AddRange(objs);
C2C.Items.AddRange(objs);
objs = new[]
{
"Combined color",
"Texture0 color",
"Texture1 color",
"Prim color",
"Vtx color",
"Env color",
"1.0",
"0.0",
};
C1D.Items.AddRange(objs);
C2D.Items.AddRange(objs);
objs = new[]
{
"Combined alpha",
"Texture0 alpha",
"Texture1 alpha",
"Prim alpha",
"Vtx alpha",
"Env alpha",
"1.0",
"0.0",
};
A1A.Items.AddRange(objs);
A2A.Items.AddRange(objs);
A1B.Items.AddRange(objs);
A2B.Items.AddRange(objs);
A1D.Items.AddRange(objs);
A2D.Items.AddRange(objs);
objs = new[]
{
"Combined alpha",
"Texture0 alpha",
"Texture1 alpha",
"Prim alpha",
"Vtx alpha",
"Env alpha",
"Prim LOD frac",
"0.0",
};
A1C.Items.AddRange(objs);
A2C.Items.AddRange(objs);
objs = new[]
{
"G_BL_CLR_IN — In the first cycle, parameter is color from input pixel. In the second cycle, parameter is the numerator of the formula as computed for the first cycle.",
"G_BL_CLR_MEM — Takes color from the framebuffer",
"G_BL_CLR_BL — Takes color from the blend color register",
"G_BL_CLR_FOG — Takes color from the fog color register",
};
P1.Items.AddRange(objs);
P2.Items.AddRange(objs);
M1.Items.AddRange(objs);
M2.Items.AddRange(objs);
objs = new[]
{
"G_BL_A_IN — Parameter is alpha value of input pixel",
"G_BL_A_FOG — Alpha value from the fog color register",
"G_BL_A_SHADE — Calculated alpha value for the pixel, presumably",
"G_BL_0 — Constant 0.0 value",
};
A1.Items.AddRange(objs);
A2.Items.AddRange(objs);
objs = new[]
{
"G_BL_1MA — 1.0 - source alpha",
"G_BL_A_MEM — Framebuffer alpha value",
"G_BL_1 — Constant 1.0 value",
"G_BL_0 — Constant 0.0 value",
};
B1.Items.AddRange(objs);
B2.Items.AddRange(objs);
objs = new[]
{
"No comparisons are made, so doesn't affect the process",
"Compare to the alpha value of the blend color register. Draw only if input alpha is larger than the blend color alpha.",
"Compare to a random dither value in the range 0.0 < x < 1.0. Creates stippling transparency effects, among other uses.",
};
G_MDSFT_ALPHACOMPARE.Items.AddRange(objs);
objs = new[]
{
"CVG_DST_CLAMP — clamps the value if FORCE_BL, otherwise\"new\"",
"CVG_DST_WRAP — Always wraps the coverage value on overflow",
"CVG_DST_FULL — Force coverage value to fully-on (hence \"full\")",
"CVG_DST_SAVE — Don't overwrite buffer coverage value",
};
CVG_DST_.Items.AddRange(objs);
objs = new[]
{
"ZMODE_OPA — Opaque surfaces",
"ZMODE_INTER — Interpenetrating surfaces",
"ZMODE_XLU — Translucent surfaces",
"ZMODE_DEC — Decal surfaces",
};
ZMODE_.Items.AddRange(objs);
}
private void Ok_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
Sync();
this.Close();
}
private void Sync()
{
target.CustomDL[0] = CombinerCommand;
target.CustomDL[1] = D9Command;
target.CustomDL[2] = E2Command;
mainf.SetCustomCombinerData(target);
}
private void UpdateCombinerComboBox()
{
UcodeSimulator.UnpackedCombinerStruct Unpacked = UcodeSimulator.UnpackCombinerMux(((uint)((CombinerCommand >> 32) & 0xFFFFFFFF)), (uint)(CombinerCommand & (ulong)0xFFFFFFFF));
DebugConsole.WriteLine("" + ((uint)((CombinerCommand & (ulong)0xFFFFFF00000000 >> 32) & 0xFFFFFFFF)).ToString("X8"));
DebugConsole.WriteLine("" + ((uint)((CombinerCommand >> 32) & 0xFFFFFFFF)).ToString("X8"));
//DebugConsole.WriteLine("" + ((uint)(CombinerCommand & (ulong)0xFFFFFFFF)).ToString("X8"));
C1A.SelectedIndex = Unpacked.cA[0];
C1B.SelectedIndex = Unpacked.cB[0];
C1C.SelectedIndex = Unpacked.cC[0];
C1D.SelectedIndex = Unpacked.cD[0];
C2A.SelectedIndex = Unpacked.cA[1];
C2B.SelectedIndex = Unpacked.cB[1];
C2C.SelectedIndex = Unpacked.cC[1];
C2D.SelectedIndex = Unpacked.cD[1];
A1A.SelectedIndex = Unpacked.aA[0];
A1B.SelectedIndex = Unpacked.aB[0];
A1C.SelectedIndex = Unpacked.aC[0];
A1D.SelectedIndex = Unpacked.aD[0];
A2A.SelectedIndex = Unpacked.aA[1];
A2B.SelectedIndex = Unpacked.aB[1];
A2C.SelectedIndex = Unpacked.aC[1];
A2D.SelectedIndex = Unpacked.aD[1];
CompiledCombiner.Text = CombinerCommand.ToString("X14");
if (PreviewCheckbox.Checked)
Sync();
}
private void PackCombiner()
{
CombinerCommand = 0;
CombinerCommand = (ulong)(0 | (((ulong)C1A.SelectedIndex << (20+32)))
| (((ulong)C1B.SelectedIndex << 28))
| (((ulong)C1C.SelectedIndex << (15+32)))
| (((ulong)C1D.SelectedIndex << 15))
| (((ulong)C2A.SelectedIndex << (5+32)))
| (((ulong)C2B.SelectedIndex << 24))
| (((ulong)C2C.SelectedIndex << (0+32)))
| (((ulong)C2D.SelectedIndex << 6))
| (((ulong)A1A.SelectedIndex << (12+32)))
| (((ulong)A1B.SelectedIndex << 12))
| (((ulong)A1C.SelectedIndex << (9+32)))
| (((ulong)A1D.SelectedIndex << 9))
| (((ulong)A2A.SelectedIndex << 21))
| (((ulong)A2B.SelectedIndex << 3))
| (((ulong)A2C.SelectedIndex << 18))
| (((ulong)A2D.SelectedIndex << 0)));
CompiledCombiner.Text = CombinerCommand.ToString("X14");
if (PreviewCheckbox.Checked)
Sync();
}
private void UpdateGeometryModeCheckboxes()
{
D9lock = true;
G_ZBUFFER.Checked = (((D9Command >> 0) & 0x1) != 0);
G_SHADE.Checked = (((D9Command >> 2) & 0x1) != 0);
G_CULL_FRONT.Checked = (((D9Command >> 9) & 0x1) != 0);
G_CULL_BACK.Checked = (((D9Command >> 10) & 0x1) != 0);
G_FOG.Checked = (((D9Command >> 16) & 0x1) != 0);
G_LIGHTING.Checked = (((D9Command >> 17) & 0x1) != 0);
G_TEXTURE_GEN.Checked = (((D9Command >> 18) & 0x1) != 0);
G_TEXTURE_GEN_LINEAR.Checked = (((D9Command >> 19) & 0x1) != 0);
G_SHADING_SMOOTH.Checked = (((D9Command >> 21) & 0x1) != 0);
G_CLIPPING.Checked = (((D9Command >> 23) & 0x1) != 0);
CompiledD9.Text = D9Command.ToString("X14");
//DebugConsole.WriteLine((D9Command >> 2).ToString("X16"));
if (PreviewCheckbox.Checked)
Sync();
D9lock = false;
}
private void UpdateOtherModeLCheckboxes()
{
E2lock = true;
G_MDSFT_ALPHACOMPARE.SelectedIndex = (int) ((E2Command >> 0) & 0x3);
G_MDSFT_ZSRCSEL.Checked = (((E2Command >> 2) & 0x1) != 0);
AA_EN.Checked = (((E2Command >> 3) & 0x1) != 0);
Z_CMP.Checked = (((E2Command >> 4) & 0x1) != 0);
Z_UPD.Checked = (((E2Command >> 5) & 0x1) != 0);
IM_RD.Checked = (((E2Command >> 6) & 0x1) != 0);
CLR_ON_CVG.Checked = (((E2Command >> 7) & 0x1) != 0);
CVG_DST_.SelectedIndex = (int)((E2Command >> 8) & 0x3);
ZMODE_.SelectedIndex = (int)((E2Command >> 10) & 0x3);
CVG_X_ALPHA.Checked = (((E2Command >> 12) & 0x1) != 0);
ALPHA_CVG_SEL.Checked = (((E2Command >> 13) & 0x1) != 0);
FORCE_BL.Checked = (((E2Command >> 14) & 0x1) != 0);
B2.SelectedIndex = (int)((E2Command >> 16) & 0x3);
B1.SelectedIndex = (int)((E2Command >> 18) & 0x3);
M2.SelectedIndex = (int)((E2Command >> 20) & 0x3);
M1.SelectedIndex = (int)((E2Command >> 22) & 0x3);
A2.SelectedIndex = (int)((E2Command >> 24) & 0x3);
A1.SelectedIndex = (int)((E2Command >> 26) & 0x3);
P2.SelectedIndex = (int)((E2Command >> 28) & 0x3);
P1.SelectedIndex = (int)((E2Command >> 30) & 0x3);
CompiledE2.Text = E2Command.ToString("X14");
if (PreviewCheckbox.Checked)
Sync();
E2lock = false;
}
private void PackGeometryMode()
{
D9Command = 0;
D9Command = (ulong)(0 | (((ulong)(G_ZBUFFER.Checked ? 1 : 0) << (0)))
| (((ulong)(G_SHADE.Checked ? 1 : 0) << 2))
| (((ulong)(G_CULL_FRONT.Checked ? 1 : 0) << 9))
| (((ulong)(G_CULL_BACK.Checked ? 1 : 0) << 10))
| (((ulong)(G_FOG.Checked ? 1 : 0) << 16))
| (((ulong)(G_LIGHTING.Checked ? 1 : 0) << 17))
| (((ulong)(G_TEXTURE_GEN.Checked ? 1 : 0) << 18))
| (((ulong)(G_TEXTURE_GEN_LINEAR.Checked ? 1 : 0) << 19))
| (((ulong)(G_SHADING_SMOOTH.Checked ? 1 : 0) << 21))
| (((ulong)(G_CLIPPING.Checked ? 1 : 0) << 23))
| (((ulong)0xFFFFFF << 32))
);
CompiledD9.Text = D9Command.ToString("X14");
if (PreviewCheckbox.Checked)
Sync();
}
private void PackOtherModeL()
{
E2Command = 0;
E2Command = (ulong)(0 | (((ulong)(G_MDSFT_ALPHACOMPARE.SelectedIndex) << 0))
| (((ulong)(G_MDSFT_ZSRCSEL.Checked ? 1 : 0) << 2))
| (((ulong)(AA_EN.Checked ? 1 : 0) << 3))
| (((ulong)(Z_CMP.Checked ? 1 : 0) << 4))
| (((ulong)(Z_UPD.Checked ? 1 : 0) << 5))
| (((ulong)(IM_RD.Checked ? 1 : 0) << 6))
| (((ulong)(CLR_ON_CVG.Checked ? 1 : 0) << 7))
| (((ulong)(CVG_DST_.SelectedIndex) << 8))
| (((ulong)(ZMODE_.SelectedIndex) << 10))
| (((ulong)(CVG_X_ALPHA.Checked ? 1 : 0) << 12))
| (((ulong)(ALPHA_CVG_SEL.Checked ? 1 : 0) << 13))
| (((ulong)(FORCE_BL.Checked ? 1 : 0) << 14))
| (((ulong)(B2.SelectedIndex) << 16))
| (((ulong)(B1.SelectedIndex) << 18))
| (((ulong)(M2.SelectedIndex) << 20))
| (((ulong)(M1.SelectedIndex) << 22))
| (((ulong)(A2.SelectedIndex) << 24))
| (((ulong)(A1.SelectedIndex) << 26))
| (((ulong)(P2.SelectedIndex) << 28))
| (((ulong)(P1.SelectedIndex) << 30))
| (((ulong)0x00001C << 32))
);
CompiledE2.Text = E2Command.ToString("X14");
if (PreviewCheckbox.Checked)
Sync();
}
private void CombinerComboBox_SelectionChangeCommitted(object sender, EventArgs e)
{
PackCombiner();
}
private void CustomCombiner_FormClosed(object sender, FormClosedEventArgs e)
{
MainForm.customcombiner_visible = false;
MainForm.customcombiner = null;
}
private void CompiledCombiner_KeyDown(object sender, KeyEventArgs e)
{
ulong temp = 0;
if (e.KeyCode == Keys.Enter)
{
if (!UInt64.TryParse(CompiledCombiner.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out temp))
{
temp = 0;
}
CombinerCommand = temp;
UpdateCombinerComboBox();
}
}
private void CompiledCombiner_Leave(object sender, EventArgs e)
{
ulong temp = 0;
if (!UInt64.TryParse(CompiledCombiner.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out temp))
{
temp = 0;
}
CombinerCommand = temp;
UpdateCombinerComboBox();
}
private void DefaultButton_Click(object sender, EventArgs e)
{
ulong[] defaults = GetDefaults(target);
CombinerCommand = defaults[0];
D9Command = defaults[1];
E2Command = defaults[2];
CompiledCombiner.Text = CombinerCommand.ToString("X14");
CompiledD9.Text = D9Command.ToString("X14");
CompiledE2.Text = E2Command.ToString("X14");
UpdateCombinerComboBox();
UpdateGeometryModeCheckboxes();
UpdateOtherModeLCheckboxes();
}
public ulong[] GetDefaults(ObjFile.Group group)
{
bool IsTranslucent = ((group.TintAlpha >> 24) != 255);
ulong[] output = new ulong[4];
if (IsTranslucent == true)
{
output[0] = 0x167E03FF0FFDFF;
output[2] = 0x1C00000000 | (ulong)(0x081049D8 | ((group.IgnoreFog) ? 0x00000000 : 0xC0000000) | ((group.Decal) ? 0xC00 : 0x000));
}
else
{
output[0] = 0x127E03FFFFFDF8;
output[2] = 0x1C00000000 | (ulong)(0x08110078 | ((group.SmoothRGBAEdges) ? 0x4000 : 0x3000) | ((group.IgnoreFog) ? 0x00000000 : 0xC0000000) | ((group.Decal) ? 0xC00 : 0x000));
}
if ((group.ReverseLight) ? !OutdoorLight : OutdoorLight)
{
if (IsTranslucent == true || !group.BackfaceCulling)
{
// Helpers.Append64(ref DList, 0xD9F3FBFF00000000);
if (!group.Metallic && group.BackfaceCulling) output[1] = 0xFFFFFF00030400 | (ulong)(AffectedByPointLight ? 0x400000 : 0x000000);
else if (!group.Metallic && !group.BackfaceCulling) output[1] = 0xFFFFFF00030000 | (ulong)(AffectedByPointLight ? 0x400000 : 0x000000);
else output[1] = 0xFFFFFF000E0400;
}
else
{
// Helpers.Append64(ref DList, 0xD9F3FFFF00000000);
if (!group.Metallic) output[1] = 0xFFFFFF00030400 | (ulong)(AffectedByPointLight ? 0x400000 : 0x000000);
else output[1] = 0xFFFFFF000E0400;
}
}
else
{
if (IsTranslucent == true || !group.BackfaceCulling)
{
if (!group.Metallic && group.BackfaceCulling) output[1] = 0xF1FBFF00000000;
else if (!group.Metallic && !group.BackfaceCulling) output[1] = 0xFFFFFF00010000;
else output[1] = 0xFFFFFF000C0400;
}
else
{
if (!group.Metallic) output[1] = 0xFFFFFF00000400;
else output[1] = 0xFFFFFF000C0400;
}
}
return output;
}
private void CompiledE2_KeyDown(object sender, KeyEventArgs e)
{
ulong temp = 0;
if (e.KeyCode == Keys.Enter)
{
if (!UInt64.TryParse(CompiledE2.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out temp))
{
temp = 0;
}
E2Command = temp;
UpdateOtherModeLCheckboxes();
}
}
private void CompiledE2_Leave(object sender, EventArgs e)
{
ulong temp = 0;
if (!UInt64.TryParse(CompiledE2.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out temp))
{
temp = 0;
}
E2Command = temp;
UpdateOtherModeLCheckboxes();
}
private void CompiledD9_KeyDown(object sender, KeyEventArgs e)
{
ulong temp = 0;
if (e.KeyCode == Keys.Enter)
{
if (!UInt64.TryParse(CompiledD9.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out temp))
{
temp = 0;
}
D9Command = temp;
UpdateGeometryModeCheckboxes();
}
}
private void CompiledD9_Leave(object sender, EventArgs e)
{
ulong temp = 0;
if (!UInt64.TryParse(CompiledD9.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out temp))
{
temp = 0;
}
D9Command = temp;
UpdateGeometryModeCheckboxes();
}
private void PreviewCheckbox_CheckedChanged(object sender, EventArgs e)
{
if (PreviewCheckbox.Checked)
Sync();
}
private void GeometryMode_CheckedChange(object sender, EventArgs e)
{
if (!D9lock) PackGeometryMode();
}
private void OtherModeL_CheckedChanged(object sender, EventArgs e)
{
if (!E2lock) PackOtherModeL();
}
private void ToClipboardButton_Click(object sender, EventArgs e)
{
string outputmsg = "#FD" + CombinerCommand.ToString("X14")
+ "#E2" + E2Command.ToString("X14")
+ "#D9" + D9Command.ToString("X14");
Clipboard.SetText(outputmsg);
}
private void AdjustWidthComboBox_DropDown(object sender, System.EventArgs e)
{
ComboBox senderComboBox = (ComboBox)sender;
int width = senderComboBox.DropDownWidth;
Graphics g = senderComboBox.CreateGraphics();
Font font = senderComboBox.Font;
int vertScrollBarWidth =
(senderComboBox.Items.Count > senderComboBox.MaxDropDownItems)
? SystemInformation.VerticalScrollBarWidth : 0;
int newWidth;
foreach (string item in ((ComboBox)sender).Items)
{
string s = item;
newWidth = (int)g.MeasureString(s, font).Width
+ vertScrollBarWidth;
if (width < newWidth)
{
width = newWidth;
}
}
senderComboBox.DropDownWidth = width;
}
}
}