private void buttonDefaultReset_Click(object sender, EventArgs e) { Data = new VisualizationData(); textBoxDataProcessTim.Text = "100"; textBoxDataSendTim.Text = "20"; LoadVisualizationPreset(Data); }
private void ChangeVisualizationPresetData(VisualizationData data) { if (timerLEDUpdate != null) { timerLEDUpdate.Interval = textBoxDataSendTim.Text.ToDouble(); } if (timer != null) { timer.Interval = textBoxDataProcessTim.Text.ToDouble(); } if (timerVolumeUpdate != null) { timerVolumeUpdate.Interval = textBoxVolumeUpdateTim.Text.ToDouble(); } data.DataProcessingTimerInterval = textBoxDataProcessTim.Text.ToDouble(); data.DataSendingTimerInterval = textBoxDataSendTim.Text.ToDouble(); data.DataVolumeProcessingTimerInterval = textBoxVolumeUpdateTim.Text.ToDouble(); data.ColourLink[0] = lowFreqComboBox.SelectedIndex; data.ColourLink[1] = midFreqComboBox.SelectedIndex; data.ColourLink[2] = hightFreqComboBox.SelectedIndex; data.ColourLink[3] = volumeComboBox.SelectedIndex; data.Coefficient[0] = textBoxLFC.Text.ToDouble(); data.Coefficient[1] = textBoxMFC.Text.ToDouble(); data.Coefficient[2] = textBoxHFC.Text.ToDouble(); data.Coefficient[3] = textBoxVolC.Text.ToDouble(); data.Frequency[0] = textBoxFreqL.Text.ToDouble(); data.Frequency[1] = textBoxFreqM.Text.ToDouble(); data.Frequency[2] = textBoxFreqH.Text.ToDouble(); data.BufferSize = 1 << bufferTrackBar.Value; data.RiseMaxStep[0] = textBoxRiseR.Text.ToDouble(); data.RiseMaxStep[1] = textBoxRiseG.Text.ToDouble(); data.RiseMaxStep[2] = textBoxRiseB.Text.ToDouble(); data.RiseMaxStep[3] = textBoxRiseV.Text.ToDouble(); data.FallMaxStep[0] = textBoxFallR.Text.ToDouble(); data.FallMaxStep[1] = textBoxFallG.Text.ToDouble(); data.FallMaxStep[2] = textBoxFallB.Text.ToDouble(); data.FallMaxStep[3] = textBoxFallV.Text.ToDouble(); data.ColourDefault[0] = textBoxColR.Text.ToDouble(); data.ColourDefault[1] = textBoxColG.Text.ToDouble(); data.ColourDefault[2] = textBoxColB.Text.ToDouble(); data.ColourDefault[3] = textBoxColV.Text.ToDouble(); data.LeaderMul[0] = textBoxLeaderR.Text.ToDouble(); data.LeaderMul[1] = textBoxLeaderG.Text.ToDouble(); data.LeaderMul[2] = textBoxLeaderB.Text.ToDouble(); data.FollowerMul[0] = textBoxFollowerR.Text.ToDouble(); data.FollowerMul[1] = textBoxFollowerG.Text.ToDouble(); data.FollowerMul[2] = textBoxFollowerB.Text.ToDouble(); data.AutoVolumeEnable = autoVolumeCheckBox.Checked; data.AutoVolumeTarget = textBoxAutoVolTarget.Text.ToDouble(); data.AutoVolumeCounterMax = textBoxAutoVolCounter.Text.ToInt(); data.AutoVolumeMulHysteresis = textBoxAutoVolStep.Text.ToDouble(); data.VolumeTrack = brightnessTrackBar.Value; data.VisualizationEnable = autoEnableVisCB.Checked; }
private void LoadVisualizationPreset(VisualizationData data) { textBoxDataSendTim.Text = data.DataSendingTimerInterval.ToString(); textBoxDataProcessTim.Text = data.DataProcessingTimerInterval.ToString(); textBoxVolumeUpdateTim.Text = data.DataVolumeProcessingTimerInterval.ToString(); lowFreqComboBox.SelectedIndex = data.ColourLink[0]; midFreqComboBox.SelectedIndex = data.ColourLink[1]; hightFreqComboBox.SelectedIndex = data.ColourLink[2]; volumeComboBox.SelectedIndex = data.ColourLink[3]; textBoxLFC.Text = data.Coefficient[0].ToString(); textBoxMFC.Text = data.Coefficient[1].ToString(); textBoxHFC.Text = data.Coefficient[2].ToString(); textBoxVolC.Text = data.Coefficient[3].ToString(); textBoxFreqL.Text = data.Frequency[0].ToString(); textBoxFreqM.Text = data.Frequency[1].ToString(); textBoxFreqH.Text = data.Frequency[2].ToString(); textBoxRiseR.Text = data.RiseMaxStep[0].ToString(); textBoxRiseG.Text = data.RiseMaxStep[1].ToString(); textBoxRiseB.Text = data.RiseMaxStep[2].ToString(); textBoxRiseV.Text = data.RiseMaxStep[3].ToString(); textBoxFallR.Text = data.FallMaxStep[0].ToString(); textBoxFallG.Text = data.FallMaxStep[1].ToString(); textBoxFallB.Text = data.FallMaxStep[2].ToString(); textBoxFallV.Text = data.FallMaxStep[3].ToString(); int k = 0; for (int buf = data.BufferSize; buf > 0; buf >>= 1) { k++; } bufferTrackBar.Value = k - 1; textBoxColR.Text = data.ColourDefault[0].ToString(); textBoxColG.Text = data.ColourDefault[1].ToString(); textBoxColB.Text = data.ColourDefault[2].ToString(); textBoxColV.Text = data.ColourDefault[3].ToString(); textBoxLeaderR.Text = data.LeaderMul[0].ToString(); textBoxLeaderG.Text = data.LeaderMul[1].ToString(); textBoxLeaderB.Text = data.LeaderMul[2].ToString(); textBoxFollowerR.Text = data.FollowerMul[0].ToString(); textBoxFollowerG.Text = data.FollowerMul[1].ToString(); textBoxFollowerB.Text = data.FollowerMul[2].ToString(); autoVolumeCheckBox.Checked = data.AutoVolumeEnable; textBoxAutoVolTarget.Text = data.AutoVolumeTarget.ToString(); textBoxAutoVolCounter.Text = data.AutoVolumeCounterMax.ToString(); textBoxAutoVolStep.Text = data.AutoVolumeMulHysteresis.ToString(); brightnessTrackBar.Value = data.VolumeTrack; autoEnableVisCB.Checked = data.VisualizationEnable; }
private void MainForm_Shown(object sender, EventArgs e) { Data = new VisualizationData(); Data.LoadFromRegistry(); ComportReloadButton_Click(this, new EventArgs()); RegistryKey key = Registry.CurrentUser.OpenSubKey(subKey, false); if (key != null) { autoConnectCB.Checked = Convert.ToBoolean(key?.GetValue("AutoConnect")); formMinimizeCB.Checked = Convert.ToBoolean(key?.GetValue("Minimize")); if (autoConnectCB.Checked) { try { serialPort.PortName = Convert.ToString(key?.GetValue("SerialPort")); comportBox.Items.Clear(); comportBox.Items.Add(serialPort.PortName); comportBox.SelectedIndex = 0; serialPort.Open(); Buffer = new RxBuffer(2048, RxDataActions, RxAltDataActions); } catch { MessageBox.Show("Не удалось подключиться.", "Error"); } } if (formMinimizeCB.Checked) { this.WindowState = FormWindowState.Minimized; } } key?.Close(); if (Data.VisualizationEnable) { autoEnableVisCB.Checked = Data.VisualizationEnable; Thread.Sleep(100); Button1_Click(this, new EventArgs()); } }