public void UpdateFrequency(List <int> notes) { KeyboardLetterList list = keyboardData.letterList; int notesAvailable = 0; int notesInRange = 0; lowFreq = 0; highFreq = 0; foreach (string key in list.Keys) { list[key].frequency = 0; } foreach (int note in notes) { notesAvailable++; string perfKey = FFXIVKeybindDat.NoteByteToPerformanceKey((byte)note); if (list.ContainsKey(perfKey)) { notesInRange++; list[perfKey].frequency++; } else { if (note <= 0) { lowFreq++; } if (note >= 38) { highFreq++; } } } this.Text = string.Empty; if (notesAvailable == 0) { this.Text = "No notes playing on this track."; } else if (notesInRange == 0) { this.Text = "All notes out of range."; } this.Refresh(); }
public void UpdateNoteKeys(FFXIVKeybindDat hotkeys) { KeyboardLetterList list = keyboardData.letterList; foreach (string key in list.Keys) { list[key].key = string.Empty; string pk = FFXIVKeybindDat.NoteKeyToPerformanceKey(key); if (!string.IsNullOrEmpty(pk)) { list[key].key = hotkeys[pk].ToString(); } } this.Refresh(); }
private void KeyboardControl_Paint(object sender, PaintEventArgs e) { KeyboardLetterList list = keyboardData.letterList; // Get max frequency foreach (string key in list.Keys) { if (list.ContainsKey(key)) { KeyboardUiLetter letter = keyboardData.letterList[key]; if (letter.frequency > maxFreq) { maxFreq = letter.frequency; } } } foreach (string key in list.Keys) { if (list.ContainsKey(key)) { KeyboardUiLetter letter = keyboardData.letterList[key]; if (!letter.sup) { DrawKey(letter, e); } } } foreach (string key in list.Keys) { if (list.ContainsKey(key)) { KeyboardUiLetter letter = keyboardData.letterList[key]; if (letter.sup) { DrawKey(letter, e); } } } //SolidBrush freqBrush = new SolidBrush(Color.FromArgb(120, Color.Red)); if (lowFreq > 0) { float f = (lowFreq / 1024f).Clamp(0.01f, 1.0f); SizeF freqSize = new SizeF(f * (this.Width / 4), this.Height); RectangleF freqRect = new RectangleF(new PointF(0, 0), freqSize); LinearGradientBrush lgrad = new LinearGradientBrush(freqRect, Color.Red, Color.Transparent, LinearGradientMode.Horizontal); e.Graphics.FillRectangle(lgrad, freqRect); } if (highFreq > 0) { float f = (highFreq / 1024f).Clamp(0.01f, 1.0f); SizeF freqSize = new SizeF(f * (this.Width / 4), this.Height); RectangleF freqRect = new RectangleF(new PointF(this.Width - freqSize.Width, 0), freqSize); LinearGradientBrush lgrad = new LinearGradientBrush(freqRect, Color.Transparent, Color.Red, LinearGradientMode.Horizontal); e.Graphics.FillRectangle(lgrad, freqRect); } RectangleF rect = new RectangleF(0, 0, this.Width, this.Height); if (this.Enabled) { Pen rectPen = new Pen(Color.Black); e.Graphics.DrawRectangle(rectPen, new Rectangle(0, 0, this.Width - 1, this.Height - 1)); } if (true) { // Fade out if it's disabled or text is showing if (!string.IsNullOrEmpty(this.Text) || !this.Enabled) { SolidBrush disabledBrush = new SolidBrush(Color.FromArgb(120, Color.White)); e.Graphics.FillRectangle(disabledBrush, rect); } if (!string.IsNullOrEmpty(overrideText)) { PointF center = new PointF(rect.X + rect.Width / 2, rect.Y + rect.Height / 2); SizeF textSize = e.Graphics.MeasureString(this.overrideText, textLargeFont); PointF textPos = new PointF(center.X - textSize.Width / 2, center.Y - textSize.Height / 2); e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(80, 30, 30)), new RectangleF(textPos, textSize)); e.Graphics.DrawString(this.overrideText, textLargeFont, new SolidBrush(Color.White), this.Width / 2, this.Height / 2, centerTextFormat); } // Show custom message else if (!string.IsNullOrEmpty(this.Text)) { PointF center = new PointF(rect.X + rect.Width / 2, rect.Y + rect.Height / 2); SizeF textSize = e.Graphics.MeasureString(this.Text, textLargeFont); PointF textPos = new PointF(center.X - textSize.Width / 2, center.Y - textSize.Height / 2); e.Graphics.FillRectangle(new SolidBrush(Color.Black), new RectangleF(textPos, textSize)); e.Graphics.DrawString(this.Text, textLargeFont, new SolidBrush(Color.White), this.Width / 2, this.Height / 2, centerTextFormat); } } }