Ejemplo n.º 1
0
        private bool onKeyChanged(object sender, KeyEventArgs e)
        {
            PadButton s = (PadButton)sender;

            if (e.KeyCode == Keys.None)
            {
                preset.currentPart.keyMap.resetButton(s.ID + 1);
                //this.Focus();
                return(true);
            }
            else
            {
                if (!preset.currentPart.keyMap.mapKey(e.KeyValue, s.ID + 1))
                {
                    MessageBox.Show("Кнопка " + e.KeyData.ToString() + " уже назначена.", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
                else
                {
                    //this.Focus();
                    return(true);
                }
            }
        }
Ejemplo n.º 2
0
        private void onButtonClick(object sender, EventArgs e)
        {
            PadButton button = (PadButton)sender;

            if (hlButtons)
            {
                button.HighLightButton = true;
            }
            launchpad.startPlayingNote(button.ID);
        }
Ejemplo n.º 3
0
        private void onButtonRelease(object sender, EventArgs e)
        {
            PadButton button = (PadButton)sender;

            launchpad.stopPlayingNote(button.ID);
            if (hlButtons)
            {
                button.HighLightButton = false;
            }
            if (button.Key >= Keys.F1 && button.Key <= Keys.F24)
            {
                changePresetPart(button.Key - Keys.F1);
            }
        }
Ejemplo n.º 4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

            gfxPath = new GraphicsPath();
            pbPath  = new GraphicsPath();
            if (!Rounded)
            {
                int width  = ClientRectangle.Width - 1;
                int height = ClientRectangle.Height - 1;
                int radius = 3;

                gfxPath.AddLine(radius + 1, 1, (width - radius * 2) - 1, 1);
                gfxPath.AddArc((width - radius * 2) - 1, 1, radius * 2, radius * 2, 270, 90);
                gfxPath.AddLine(width - 1, radius + 1, width - 1, (height - radius * 2) - 1);
                gfxPath.AddArc((width - radius * 2) - 1, (height - radius * 2) - 1, radius * 2, radius * 2, 0, 90);
                gfxPath.AddLine((width - radius * 2) - 1, height - 1, radius + 1, height - 1);
                gfxPath.AddArc(1, (height - radius * 2) - 1, radius * 2, radius * 2, 90, 90);
                gfxPath.AddLine(1, (height - radius * 2) - 1, 1, radius + 1);
                gfxPath.AddArc(1, 1, radius * 2, radius * 2, 180, 90);
                gfxPath.CloseFigure();


                if (this._led != ledDisabled)
                {
                    using (var brush = new PathGradientBrush(gfxPath))
                    {
                        float h = _led.GetHue();
                        float s = _led.GetSaturation();

                        brush.CenterPoint    = new PointF(width / 2f, height / 2f);
                        brush.CenterColor    = PadButton.ColorFromHSV(h, s, 1f);
                        brush.SurroundColors = new[] { PadButton.ColorFromHSV(h, s, 0.55) };
                        brush.FocusScales    = new PointF(0.2f, 0.2f);

                        e.Graphics.FillPath(brush, gfxPath);
                    }
                }
                else
                {
                    bgBrush.Color = this._led;
                    e.Graphics.FillPath(bgBrush, gfxPath);
                }
                if (_hlbutton)
                {
                    pbPath.AddLine(radius, 0, width - radius * 2, 0);
                    pbPath.AddArc(width - radius * 2, 0, radius * 2, radius * 2, 270, 90);
                    pbPath.AddLine(width, radius, width, height - radius * 2);
                    pbPath.AddArc(width - radius * 2, height - radius * 2, radius * 2, radius * 2, 0, 90);
                    pbPath.AddLine(width - radius * 2, height, radius, height);
                    pbPath.AddArc(0, height - radius * 2, radius * 2, radius * 2, 90, 90);
                    pbPath.AddLine(0, height - radius * 2, 0, radius);
                    pbPath.AddArc(0, 0, radius * 2, radius * 2, 180, 90);

                    Pen pen2 = new Pen(Color.Red);
                    e.Graphics.DrawPath(pen2, pbPath);
                }
            }
            else
            {
                int width  = (ClientRectangle.Width - 1) - 10;
                int height = (ClientRectangle.Height - 1) - 10;

                gfxPath.AddEllipse(5, 5, width, height);
                gfxPath.CloseFigure();

                if (this._led != ledDisabled)
                {
                    using (var brush = new PathGradientBrush(gfxPath))
                    {
                        float h = _led.GetHue();
                        float s = _led.GetSaturation();

                        brush.CenterPoint    = new PointF(width / 2f, height / 2f);
                        brush.CenterColor    = PadButton.ColorFromHSV(h, s, 1f);
                        brush.SurroundColors = new[] { PadButton.ColorFromHSV(h, s, 0.50) };
                        brush.FocusScales    = new PointF(0.2f, 0.2f);
                        bgBrush.Color        = this._led;
                        Pen pen = new Pen(bgBrush);
                    }
                }
                else
                {
                    bgBrush.Color = this._led;
                    e.Graphics.FillPath(bgBrush, gfxPath);
                }

                if (_hlbutton)
                {
                    e.Graphics.DrawPath(highlight, gfxPath);
                }
            }



            if (PadButton.EditMode)
            {
                int   x = 0, y = 0;
                SizeF size = e.Graphics.MeasureString(this.Text, TextFont);
                x = (ClientRectangle.Width - 1) / 2 - (int)(size.Width / 2);
                y = (ClientRectangle.Height - 1) / 2 - (int)(size.Height / 2);
                e.Graphics.DrawString(this.Text, TextFont, TextBrush, x, y);

                size = e.Graphics.MeasureString(ID.ToString(), idFont);

                x = (ClientRectangle.Width - 1) / 2 - (int)(size.Width / 2);
                if (this.Rounded)
                {
                    y = (ClientRectangle.Height - 1) - (int)size.Height - 5;
                }
                else
                {
                    y = (ClientRectangle.Height - 1) - (int)size.Height;
                }

                e.Graphics.DrawString(ID.ToString(), idFont, idBrush, x, y);
            }
        }