private static void setSliderValue(Slider lo, Slider hi, int offset) { int val = lo.Value + hi.Value * 256 + offset; if (val < 0) { val = 0; } if (val > 0x0FFF) { val = 0x0FFF; } lo.Value = val % 256; hi.Value = val / 256; }
private Slider createSlider(int posX, int min, int max, int value, Color color, PropertyChangedEventHandler valueChangedHandler, double[] steps, Panel panel) { Slider newCtl = new Slider(); newCtl.Orientation = Orientation.Vertical; newCtl.Top = 48; newCtl.Left = posX; newCtl.Height = pnlEditorBars.ClientRectangle.Height - 48; ; newCtl.Width = sliderWidth; newCtl.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom; newCtl.BackColor = Color.Black; newCtl.ForeColor = color; newCtl.PaintValue = true; newCtl.Hex = chkHex.Checked; newCtl.Logarithmic = false; newCtl.Minimum = 0; newCtl.Maximum = max; newCtl.Value = value; newCtl.Steps = steps; newCtl.StepColor = Color.Snow; newCtl.PropertyChanged += valueChangedHandler; panel.Controls.Add(newCtl); return newCtl; }
private void handleKeyPressShift(KeyEventArgs e) { switch (e.KeyCode) { case Keys.PageUp: { Slider lo = this.envFreqLoSliders[this.SelectedIndex]; Slider hi = this.envFreqHiSliders[this.SelectedIndex]; setSliderValue(lo, hi, +16); } break; case Keys.PageDown: { Slider lo = this.envFreqLoSliders[this.SelectedIndex]; Slider hi = this.envFreqHiSliders[this.SelectedIndex]; setSliderValue(lo, hi, -16); } break; case Keys.Up: { Slider lo = this.envFreqLoSliders[this.SelectedIndex]; Slider hi = this.envFreqHiSliders[this.SelectedIndex]; setSliderValue(lo, hi, +1); } break; case Keys.Down: { Slider lo = this.envFreqLoSliders[this.SelectedIndex]; Slider hi = this.envFreqHiSliders[this.SelectedIndex]; setSliderValue(lo, hi, -1); } break; case Keys.Right: { PictureBox currentPb = pbEnvTypes[this.SelectedIndex]; if ((this.CurrentEffect.Noises[this.SelectedIndex] & 0x80) == 0x80) { // Tenía env. Seleccionar la siguiente. int envType = this.CurrentEffect.EnvTypes[this.SelectedIndex]; for (int i = 0, li = envelopeContextMenu.Items.Count; i < li; ++i) { ToolStripItem m = envelopeContextMenu.Items[i]; if (m.Tag.ToString() == envType.ToString()) { if (i == li - 1) { setEnvelopeValue(envelopeContextMenu.Items[0], currentPb); } else { setEnvelopeValue(envelopeContextMenu.Items[i + 1], currentPb); } } } } else { // Sin env, seleccionar la primera. setEnvelopeValue(envelopeContextMenu.Items[1], currentPb); } } break; case Keys.Left: { PictureBox currentPb = pbEnvTypes[this.SelectedIndex]; if ((this.CurrentEffect.Noises[this.SelectedIndex] & 0x80) == 0x80) { // Tenía env. Seleccionar la siguiente. int envType = this.CurrentEffect.EnvTypes[this.SelectedIndex]; for (int i = 0, li = envelopeContextMenu.Items.Count; i < li; ++i) { ToolStripItem m = envelopeContextMenu.Items[i]; if (m.Tag.ToString() == envType.ToString()) { setEnvelopeValue(envelopeContextMenu.Items[i - 1], currentPb); } } } else { setEnvelopeValue(envelopeContextMenu.Items[envelopeContextMenu.Items.Count - 1], currentPb); } } break; } }