Repository navigation
Expand file tree
/
Copy pathSettingsForm.cs
More file actions
152 lines (131 loc) · 6.16 KB
/
Copy pathSettingsForm.cs
File metadata and controls
152 lines (131 loc) · 6.16 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
using System;
using System.Drawing;
using System.Windows.Forms;
namespace MusicVisualizer
{
public partial class SettingsForm : Form
{
private readonly VisualizerSettings _s;
private readonly VisualizerPanel _visual;
public SettingsForm(VisualizerSettings settings, VisualizerPanel visual)
{
InitializeComponent();
_s = settings;
_visual = visual;
// Устанавливаем границы вручную в правильном порядке
trackHue.MinValue = 0; trackHue.MaxValue = 360;
trackSaturation.MinValue = 0; trackSaturation.MaxValue = 200;
trackBrightness.MinValue = 0; trackBrightness.MaxValue = 200;
trackBallSize.MinValue = 0; trackBallSize.MaxValue = 35;
trackMaxRadius.MinValue = 0; trackMaxRadius.MaxValue = 30;
trackBars.MinValue = 0; trackBars.MaxValue = 224;
trackBarSmooth.MinValue = 0; trackBarSmooth.MaxValue = 80;
trackBassBoost.MinValue = 0; trackBassBoost.MaxValue = 40;
trackHighBoost.MinValue = 0; trackHighBoost.MaxValue = 30;
trackMaxParticles.MinValue = 0; trackMaxParticles.MaxValue = 500;
trackSpawnThreshold.MinValue = 0; trackSpawnThreshold.MaxValue = 75;
trackGlowIntensity.MinValue = 0; trackGlowIntensity.MaxValue = 200;
LoadToControls();
// подписки на события...
}
// Загружаем текущие значения настроек в контролы
private void LoadToControls()
{
// Цвет
trackHue.Value = (int)_s.HueShift; // 0..360
trackSaturation.Value = (int)(_s.Saturation * 100); // 0..200
trackBrightness.Value = (int)(_s.Brightness * 100); // 0..200
panelBgColor.BackColor = Color.FromArgb(_s.BackgroundR, _s.BackgroundG, _s.BackgroundB);
// Геометрия
trackBallSize.Value = (int)(_s.BallSizeRatio * 100) - 20;
trackMaxRadius.Value = (int)(_s.MaxRadiusRatio * 100) - 30;
trackBars.Value = _s.Bars - 32;
trackBarSmooth.Value = (int)(_s.BarSmoothing * 100) - 10;
trackBassBoost.Value = (int)(_s.BassBoost * 10) - 10; // 10..50
trackHighBoost.Value = (int)(_s.HighFreqBoost * 10); // 0..30
// Частицы
chkParticles.Checked = _s.ParticlesEnabled;
trackMaxParticles.Value = _s.MaxParticles; // 0..500
trackSpawnThreshold.Value = (int)(_s.SpawnThreshold * 100) - 5;
// Свечение
chkGlow.Checked = _s.GlowEnabled;
trackGlowIntensity.Value = (int)(_s.GlowIntensity * 100); // 0..200
}
// Кнопка «Применить»
private void btnApply_Click(object sender, EventArgs e)
{
SaveFromControls();
_s.Save();
}
// Кнопка «OK» — применить и закрыть
private void btnOk_Click(object sender, EventArgs e)
{
SaveFromControls();
_s.Save();
DialogResult = DialogResult.OK;
Close();
}
// Кнопка «Отмена»
private void btnCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
// Кнопка «Сбросить» — вернуть дефолтные значения
private void btnReset_Click(object sender, EventArgs e)
{
var def = new VisualizerSettings();
_s.HueShift = def.HueShift;
_s.Saturation = def.Saturation;
_s.Brightness = def.Brightness;
_s.BackgroundR = def.BackgroundR;
_s.BackgroundG = def.BackgroundG;
_s.BackgroundB = def.BackgroundB;
_s.BallSizeRatio = def.BallSizeRatio;
_s.MaxRadiusRatio = def.MaxRadiusRatio;
_s.Bars = def.Bars;
_s.BarSmoothing = def.BarSmoothing;
_s.BassBoost = def.BassBoost;
_s.HighFreqBoost = def.HighFreqBoost;
_s.ParticlesEnabled = def.ParticlesEnabled;
_s.MaxParticles = def.MaxParticles;
_s.SpawnThreshold = def.SpawnThreshold;
_s.GlowEnabled = def.GlowEnabled;
_s.GlowIntensity = def.GlowIntensity;
LoadToControls();
}
// Выбор фонового цвета через стандартный ColorDialog
private void panelBgColor_Click(object sender, EventArgs e)
{
using var dlg = new ColorDialog { Color = panelBgColor.BackColor };
if (dlg.ShowDialog() == DialogResult.OK)
panelBgColor.BackColor = dlg.Color;
}
private void SaveFromControls()
{
_s.HueShift = trackHue.Value;
_s.Saturation = trackSaturation.Value / 100f;
_s.Brightness = trackBrightness.Value / 100f;
_s.BackgroundR = panelBgColor.BackColor.R;
_s.BackgroundG = panelBgColor.BackColor.G;
_s.BackgroundB = panelBgColor.BackColor.B;
// trackBallSize: 0..35 в ползунке → 20..55 реально
_s.BallSizeRatio = (trackBallSize.Value + 20) / 100f;
// trackMaxRadius: 0..30 → 30..60
_s.MaxRadiusRatio = (trackMaxRadius.Value + 30) / 100f;
// trackBars: 0..224 → 32..256
_s.Bars = trackBars.Value + 32;
// trackBarSmooth: 0..80 → 10..90
_s.BarSmoothing = (trackBarSmooth.Value + 10) / 100f;
// trackBassBoost: 0..40 → 10..50
_s.BassBoost = (trackBassBoost.Value + 10) / 10f;
_s.HighFreqBoost = trackHighBoost.Value / 10f;
_s.ParticlesEnabled = chkParticles.Checked;
_s.MaxParticles = trackMaxParticles.Value;
// trackSpawnThreshold: 0..75 → 5..80
_s.SpawnThreshold = (trackSpawnThreshold.Value + 5) / 100f;
_s.GlowEnabled = chkGlow.Checked;
_s.GlowIntensity = trackGlowIntensity.Value / 100f;
}
}
}