public ChannelControl() { InitializeComponent(); sliderVolume.IntValue = VolumeLevelConverter.GetVolumeStep(1.0f); pbOnOff.Image = null; pbFxInsert.Image = null; pbKeyZone.Image = null; cbMidiChannel.SelectedIndex = 1; mIgnoreEvents = false; }
void mVstPluginChannel_PresetImported(object sender, ChannelPresetImportEventArgs e) { mIgnoreEvents = true; lblName.Text = PluginChannel.InstrumentPlugin.ProgramName; sliderVolume.IntValue = VolumeLevelConverter.GetVolumeStep(e.ChannelPreset.Volume); sliderPan.IntValue = (int)(e.ChannelPreset.Pan * 127.0f); if (this.IsHandleCreated) { this.BeginInvoke(new Action(() => pbKeyZone.Image = e.ChannelPreset.KeyZoneActive ? Properties.Resources.key_zone_on : Properties.Resources.key_zone_off)); } cbMidiChannel.SelectedIndex = (int)e.ChannelPreset.MidiChannel; if (e.ChannelPreset.InstrumentVstPreset.State != PluginState.Empty) { for (int i = 0; i < cbInstrument.Items.Count(); i++) { if (cbInstrument.Items[i] == e.ChannelPreset.InstrumentVstPreset.Name) { cbInstrument.SelectedIndex = i; mCurrentInstrument = i; } } } else { cbInstrument.SelectedIndex = 0; mCurrentInstrument = 0; } SetPluginStateUI(e.ChannelPreset.InstrumentVstPreset.State); mIgnoreEvents = false; }
private void drawGraphics(Graphics g) { int ringWidthDiv2 = mRingWidth / 2; // Paint background g.SmoothingMode = SmoothingMode.Default; g.FillRectangle(mBackBrush, 0, 0, this.Width, this.Height); g.SmoothingMode = SmoothingMode.AntiAlias; if (Type == RingType.Volume) { float dB = VolumeLevelConverter.GetVolumeDecibel(mValue); int angleVolume0 = 107; int zeroDBValue = Math.Min(mValue, angleVolume0); // calc active range int totalAngle = mStopAngle - mStartAngle; int activeAngle1 = (int)((((float)zeroDBValue - min) / (max - min)) * (float)totalAngle); int inactiveAngle = totalAngle - activeAngle1; int activeAngle2 = 0; // Draw white part g.DrawArc(mRingForePen, ringWidthDiv2, ringWidthDiv2, this.Width - mRingWidth - 1, this.Width - mRingWidth - 1, 180 + mStartAngle, activeAngle1); if (mValue > zeroDBValue) { int startAngle2 = 180 + mStartAngle + activeAngle1; activeAngle2 = (int)((((float)mValue - min) / (max - min)) * (float)totalAngle) - activeAngle1; inactiveAngle -= activeAngle2; //Draw red part g.DrawArc(mRingDBPen, ringWidthDiv2, ringWidthDiv2, this.Width - mRingWidth - 1, this.Width - mRingWidth - 1, startAngle2, activeAngle2); } // Draw greyed out part g.DrawArc(mRingBackPen, ringWidthDiv2, ringWidthDiv2, this.Width - mRingWidth - 1, this.Width - mRingWidth - 1, 180 + mStartAngle + activeAngle1 + activeAngle2, inactiveAngle); string display; if (mValue == min) { // Draw - infinity string //g.DrawString("-", this.Font, mTextBrush, (this.Width / 2) - 20, (this.Height / 2) - 4); //g.DrawString("\u221E", this.Font/* mInfinityFont */, mTextBrush, (this.Width / 2) - 10, (this.Height / 2) - 2); display = "-\u221E dB"; } else { display = string.Format("{0}{1:0.0} dB", dB > 0.0f ? "+" : "", dB); // Draw value string //g.DrawString(display, this.Font, mTextBrush, (this.Width / 2) - 40, (this.Height / 2) - 4); } //g.DrawString("dB", this.Font, mTextBrush, (this.Width / 2) + 9, (this.Height / 2) - 4); //display = mValue.ToString(); // Draw value string float stringWidth = g.MeasureString(display, this.Font).Width; g.DrawString(display, this.Font, mTextBrush, (this.Width / 2) - stringWidth / 2.0f, (this.Width / 2) - 50); } else { // calc active range int totalAngle = mStopAngle - mStartAngle; int activeAngle = (int)((((float)mValue - min) / (max - min)) * (float)totalAngle); int inactiveAngle = totalAngle - activeAngle; string display; // Pan: draw first greyed out part g.DrawArc(mRingBackPen, ringWidthDiv2, ringWidthDiv2, this.Width - mRingWidth - 1, this.Width - mRingWidth - 1, 180 + mStartAngle, activeAngle - 3); // Draw active part g.DrawArc(mRingForePen, ringWidthDiv2, ringWidthDiv2, this.Width - mRingWidth - 1, this.Width - mRingWidth - 1, 180 + mStartAngle + activeAngle - 3, 6); // Draw greyed out part g.DrawArc(mRingBackPen, ringWidthDiv2, ringWidthDiv2, this.Width - mRingWidth - 1, this.Width - mRingWidth - 1, 180 + mStartAngle + activeAngle + 3, inactiveAngle - 3); display = mValue.ToString(); // Draw value string float stringWidth = g.MeasureString(display, this.Font).Width; g.DrawString(display, this.Font, mTextBrush, (this.Width / 2) - stringWidth / 2.0f, (this.Width / 2) - 50); } }