public XGPControlCell AddLabelCell(string label, int x, int y, int w, Color c) { XGPControlCell ctrl = AddControlCell(null, x, y, w, c); ctrl.Text = label; return(ctrl); }
XGPControlCell AddDisabledControl(int x, int y, string label, string param) { XGPControlCell ctrl = AddLabelCell(label, x, y, 4, labelColor); ctrl.Enabled = false; ctrl = AddLabelCell(param, x + 4, y, 3, labelColor); ctrl.Enabled = false; return(ctrl); }
protected void HittestAndOffsetValue(Point p, int val) { XGPControlCell c = HitTest(p); if (c != null) { if (val == 1) { c.Increment(); } else if (val == -1) { c.Decrement(); } else { c.Offset(val); } Invalidate(c.HitTestRect); for (int i = 0; i < c.RelativeXGP.Count; i++) { Invalidate(c.RelativeXGP[i].HitTestRect); } } }
void PaintScreen(Graphics g) { foreach (var ctrl in XGControls) { ctrl.Paint(g); } { XGPControlCell ctrl = HitTest(mousePos); string status = ""; Color color = Color.LightGray; if (ctrl != null) { color = ctrl.BaseColor; status = ctrl.Description; } SizeF sz = g.MeasureString(status, XGPControlCell.Font); Color darkColor = Color.FromArgb(color.A, color.R / 4, color.G / 4, color.B / 4); using (Brush darkBrush = new SolidBrush(darkColor)) { //g.FillRectangle(darkBrush, new RectangleF(new Point(6, ClientSize.Height - 24), sz)); g.DrawString(Status, XGPControlCell.Font, darkBrush, new Point(6, ClientSize.Height - 24)); } } }
public XGPControlCell AddTriggerCell(string label, int x, int y, int w, Color c, Action act) { XGPControlCell ctrl = AddControlCell(null, x, y, w, c); ctrl.Text = label; ctrl.Trigger = act; return(ctrl); }
protected void HittestAndTrigger(Point p) { XGPControlCell c = HitTest(p); if (c != null && c.Trigger != null) { c.Trigger.Invoke(); } }
protected XGPControlCell HitTest(Point p) { XGPControlCell hit = XGControls.Find(c => c.HitTestRect.Contains(p)); if (lastHitObject != hit) { mouseRepeatCount = 0; lastHitObject = hit; Invalidate(new Rectangle(0, ClientSize.Height - 24, ClientSize.Width, 24)); } return(hit); }
public XGPControlCell AddControlCell(XGMidiParameter target, int x, int y, int w, Color c) { y += 2; XGPControlCell ctrl = new XGPControlCell() { Location = new Point(CellW * x + 6, CellH * y + 6), Size = new Size(CellW * w, CellH), BaseColor = c, TargetParameter = target, }; XGControls.Add(ctrl); return ctrl; }
public XGPControlCell AddControlCell(XGMidiParameter target, int x, int y, int w, Color c) { y += 2; XGPControlCell ctrl = new XGPControlCell() { Location = new Point(CellW * x + 6, CellH * y + 6), Size = new Size(CellW * w, CellH), BaseColor = c, TargetParameter = target, }; XGControls.Add(ctrl); return(ctrl); }
private void PartParameter_MouseDown(object sender, MouseEventArgs e) { mouseRepeatCount = 0; mousePos = new Point(e.X, e.Y); if (e.Button == MouseButtons.Left) { if (mouseOffset == -1) { mouseOffset = -10; } else { mouseOffset = 1; } } if (e.Button == MouseButtons.Right) { if (mouseOffset == 1) { mouseOffset = 10; } else { mouseOffset = -1; } } if (e.Button == MouseButtons.Middle) { XGPControlCell ctrl = HitTest(e.Location); if (ctrl != null && ctrl.TargetParameter != null) { ctrl.TargetParameter.Pick(); RedrawOnRequestComplete(); } } }
void ReCreateScreen(int[] noteNumbers) { XGControls.Clear(); Drums.Clear(); Array.Reverse(noteNumbers); { int x = 0; int y = 0; AddLabelCell("N#", x, y, 1, Color.Black); x++; AddLabelCell("ON", x, y, 1, Color.Gray); x++; AddLabelCell("NoteName", x, y, 4, Color.Gray); x += 4; AddLabelCell("PCs", x, y, 1, Color.Olive); x++; AddLabelCell("PTn", x, y, 1, Color.Purple); x++; AddLabelCell("VOL", x, y, 1, Color.Green); x++; AddLabelCell("PAN", x, y, 1, Color.Olive); x++; AddLabelCell("REV", x, y, 1, Color.Maroon); x++; AddLabelCell("CHO", x, y, 1, Color.Teal); x++; AddLabelCell("VAR", x, y, 1, Color.Navy); x++; AddLabelCell("LPF", x, y, 1, Color.Green); x++; AddLabelCell("Rsn", x, y, 1, Color.Green); x++; AddLabelCell("HPF", x, y, 1, Color.Green); x++; AddLabelCell("Atk", x, y, 1, Color.Teal); x++; AddLabelCell("Dc1", x, y, 1, Color.Teal); x++; AddLabelCell("Dc2", x, y, 1, Color.Teal); x++; AddLabelCell("Bf", x, y, 1, Color.Olive); x++; AddLabelCell("Bg", x, y, 1, Color.Olive); x++; AddLabelCell("Tf", x, y, 1, Color.Olive); x++; AddLabelCell("Tg", x, y, 1, Color.Olive); x++; } for (int i = 0; i < noteNumbers.Length; i++) { int x = 0; int y = i + 1; int n = noteNumbers[i]; if (n < 13 || n > 91) { AddTriggerCell(n.ToString(), x, y, 1, Color.Black, () => { }); x++; continue; } XGDrumParams param = new XGDrumParams(Device, TargetMap - 1, n); Drums.Add(param); XGPControlCell noteOnCell = AddTriggerCell(n.ToString(), x, y, 1, Color.Black, () => param.ReSendAll()); x++; bool noteOn = false; noteOnCell.Decrement = () => { if (!noteOn) { noteOn = true; int noteNum = n; int channel = TargetChannel - 1; Device.Write(0x640090 | noteNum << 8 | channel); while ((System.Windows.Forms.Control.MouseButtons & System.Windows.Forms.MouseButtons.Right) != 0) { System.Threading.Thread.Sleep(0); System.Windows.Forms.Application.DoEvents(); } Device.Write(0x000080 | noteNum << 8 | channel); noteOn = false; } }; noteOnCell.GetDescriptionFunc = () => "DblClick: ReSend / RightClick: AUDITION"; AddControlCell(param.RcvNoteOn, x, y, 1, Color.LightGray); x++; XGPControlCell toneNameCell = AddLabelCell("", x, y, 4, Color.LightGray); x += 4; toneNameCell.GetTextFunc = () => { var part = new XGPartParams(Device, TargetChannel - 1); int bankMSB = part.ProgramMSB.Value; int progNum = part.ProgramNumber.Value; return(MidiProgramNumber.GetDrumToneName(bankMSB, progNum, n)); }; AddControlCell(param.PitchCoarse, x, y, 1, Color.Yellow); x++; AddControlCell(param.PitchFine, x, y, 1, Color.Magenta); x++; AddControlCell(param.Volume, x, y, 1, Color.Lime); x++; AddControlCell(param.Pan, x, y, 1, Color.Yellow); x++; AddControlCell(param.Reverb, x, y, 1, Color.Red); x++; AddControlCell(param.Chorus, x, y, 1, Color.Cyan); x++; AddControlCell(param.Variation, x, y, 1, Color.Blue); x++; AddControlCell(param.LPFCutoffFreq, x, y, 1, Color.Lime); x++; AddControlCell(param.LPFResonance, x, y, 1, Color.Lime); x++; AddControlCell(param.HPFCutoffFreq, x, y, 1, Color.Lime); x++; AddControlCell(param.EGAttackRate, x, y, 1, Color.Cyan); x++; AddControlCell(param.EGDecay1Rate, x, y, 1, Color.Cyan); x++; AddControlCell(param.EGDecay2Rate, x, y, 1, Color.Cyan); x++; AddControlCell(param.EQBassFreq, x, y, 1, Color.Yellow); x++; AddControlCell(param.EQBassGain, x, y, 1, Color.Yellow); x++; AddControlCell(param.EQTrebleFreq, x, y, 1, Color.Yellow); x++; AddControlCell(param.EQTrebleGain, x, y, 1, Color.Yellow); x++; } AdjustWindowSize(); textBox1.Width = (this.ClientSize.Width - textBox1.Left - 12); }
void CreateEffectRack(int x, XGEffectParams efctParam) { XGEffectBlockType efctBlock = efctParam.BlockType; efctParam.ReLink(); XGEffect efctDef = efctParam.Effect ?? XGEffect.AllEffects[0]; switch (efctBlock) { case XGEffectBlockType.Reverb: valueColor = Color.Red; labelColor = Color.Maroon; break; case XGEffectBlockType.Chorus: valueColor = Color.Cyan; labelColor = Color.Teal; break; case XGEffectBlockType.Variation: valueColor = Color.Blue; labelColor = Color.Navy; break; case XGEffectBlockType.Insertion1: valueColor = Color.Lime; labelColor = Color.Green; break; case XGEffectBlockType.Insertion2: valueColor = Color.Yellow; labelColor = Color.FromArgb(0xFF, 0x8B, 0x8B, 0x00); break; case XGEffectBlockType.Insertion3: valueColor = Color.Magenta; labelColor = Color.Purple; break; case XGEffectBlockType.Insertion4: valueColor = Color.LightGray; labelColor = Color.Gray; break; } Parameters.Add(efctParam.EffectType); int y = 0; AddLabelCell("---- " + efctBlock.ToString(), x, 0, 5, labelColor); y++; XGPControlCell selectedEffectCell = AddTriggerCell(efctDef.Name, x, y, 7, valueColor, () => { }); selectedEffectCell.Offset = (v) => PopMenu(efctBlock); selectedEffectCell.GetDescriptionFunc = () => "Click to Change Effect " + efctBlock; y++; AddTriggerCell("[ReSend]", x, y, 2, valueColor, () => efctParam.ReSendAll()).GetDescriptionFunc = () => "DblClick to ReSend All " + efctParam.Name + "s."; AddTriggerCell("[Dump]", x + 2, y, 2, valueColor, () => { efctParam.RequestDump(); DoFunc(() => Device.AllDumpRequestHasDone, ReCreateScreen); }).GetDescriptionFunc = () => "DblClick to Request Dump All " + efctParam.Name + "s. "; AddTriggerCell(" ", x + 4, y, 3, labelColor, () => { }); y++; bool insertionConnect = efctBlock >= XGEffectBlockType.Insertion1 || efctBlock == XGEffectBlockType.Variation && efctParam.VariationConnect.Value == 0; switch (efctBlock) { case XGEffectBlockType.Reverb: AddDisabledControl(x, y++, "Connect", "System"); AddControl(x, y++, "Return", efctParam.Return); AddControl(x, y++, "Pan", efctParam.Pan); AddDisabledControl(x, y++, "---", "---"); AddDisabledControl(x, y++, "---", "---"); //AddDisabledControl(x, y++, "Part", "---"); break; case XGEffectBlockType.Chorus: AddDisabledControl(x, y++, "Connect", "System"); AddControl(x, y++, "Return", efctParam.Return); AddControl(x, y++, "Pan", efctParam.Pan); AddControl(x, y++, "Reverb", efctParam.SendToReverb); AddDisabledControl(x, y++, "---", "---"); break; case XGEffectBlockType.Variation: AddControl(x, y++, "Connect", efctParam.VariationConnect).Offset += v => { efctParam.ReLink(); ReCreateScreen(); }; if (insertionConnect) { AddControl(x, y++, "Part", efctParam.PartNumber); AddDisabledControl(x, y++, "---", "---"); AddDisabledControl(x, y++, "---", "---"); AddDisabledControl(x, y++, "---", "---"); } else { //AddDisabledControl(x, y++, "Part", "---"); AddControl(x, y++, "Return", efctParam.Return); AddControl(x, y++, "Pan", efctParam.Pan); AddControl(x, y++, "Reverb", efctParam.SendToReverb); AddControl(x, y++, "Chorus", efctParam.SendToChorus); } break; case XGEffectBlockType.Insertion1: case XGEffectBlockType.Insertion2: case XGEffectBlockType.Insertion3: case XGEffectBlockType.Insertion4: AddDisabledControl(x, y++, "Connect", "Insertion"); //AddDisabledControl(x, y++, "Return", "---"); //AddDisabledControl(x, y++, "Pan", "---"); //AddDisabledControl(x, y++, "Reverb", "---"); //AddDisabledControl(x, y++, "Chorus", "---"); AddControl(x, y++, "Part", efctParam.PartNumber); AddDisabledControl(x, y++, "---", "---"); AddDisabledControl(x, y++, "---", "---"); AddDisabledControl(x, y++, "---", "---"); break; } AddControl(x, y++, "---- Params ----", "---------"); for (int i = 0; i < 16; i++) { XGEffect.XGEffectParam p = efctDef.ParameterTypes[i]; // If "ENS DETUNE" is selected in Chorus Block, some parameters are not available. bool notAvailable = (efctBlock == XGEffectBlockType.Chorus && efctDef.EffectValue == 0x5700 && (i >= 10)); if (p != null) { if ((p.InsertionOnly && !insertionConnect) || (notAvailable)) { AddDisabledControl(x, y++, p.Name, "---"); } else { AddControl(x, y++, p.Name, efctParam.EffectParameters[i]); } } else { AddDisabledControl(x, y++, "---", "---"); } } }
protected XGPControlCell HitTest(Point p) { XGPControlCell hit = XGControls.Find(c => c.HitTestRect.Contains(p)); if (lastHitObject != hit) { mouseRepeatCount = 0; lastHitObject = hit; Invalidate(new Rectangle(0, ClientSize.Height - 24, ClientSize.Width, 24)); } return hit; }
protected string HittestAndDescription(Point p) { XGPControlCell c = HitTest(p); return(c != null ? c.Description : ""); }