private void SelectedPitchCount_ValueChanged(Microsoft.UI.Xaml.Controls.NumberBox sender, Microsoft.UI.Xaml.Controls.NumberBoxValueChangedEventArgs args)
        {
            if (args.NewValue == this.Lanes.Children.Count)
            {
                return;
            }

            if (args.NewValue > args.OldValue)
            {
                for (var currentAdd = 0; currentAdd < args.NewValue - args.OldValue; currentAdd++)
                {
#pragma warning disable CA2000 // Dispose objects before losing scope
                    var lane = new LaneSetupControl(this.AvailableSymbols, this.AvailableNotes, this.AvailableKeys);
#pragma warning restore CA2000 // Dispose objects before losing scope
                    lane.PropertyChanged += this.Lane_PropertyChanged;
                    this.Lanes.Children.Add(lane);
                }
            }

            if (args.NewValue < args.OldValue)
            {
                for (var currentAdd = 0; currentAdd < args.OldValue - args.NewValue; currentAdd++)
                {
                    ((LaneSetupControl)this.Lanes.Children[this.Lanes.Children.Count - 1]).Dispose();
                    this.Lanes.Children.RemoveAt(this.Lanes.Children.Count - 1);
                }
            }
        }
        private void OptimizeKeyboard_Click(object sender, RoutedEventArgs e)
        {
            foreach (var lane in this.Lanes.Children)
            {
                ((LaneSetupControl)lane).Dispose();
            }

            this.Lanes.Children.Clear();

            var keyboardKeys = new VirtualKey[]
            {
                VirtualKey.Number1,
                VirtualKey.Number2,
                VirtualKey.Number3,
                VirtualKey.Number4,
                VirtualKey.Number5,
                VirtualKey.Number6,
                VirtualKey.Number7,
            };

            this.SelectedPitchCount.Maximum = Math.Max(keyboardKeys.Length, this.notes.Count);

            var notes = new string[] { "C", "D", "E", "F", "G", "A", "B" };

            var currentSymbol = '\uF146';

            for (var currentAdd = 0; currentAdd < keyboardKeys.Length; currentAdd++)
            {
#pragma warning disable CA2000 // Dispose objects before losing scope
                var lane = new LaneSetupControl(this.AvailableSymbols, this.AvailableNotes, this.AvailableKeys);
#pragma warning restore CA2000 // Dispose objects before losing scope
                lane.PropertyChanged += this.Lane_PropertyChanged;
                this.Lanes.Children.Add(lane);

                foreach (var note in this.AvailableNotes.Where(note => note.Value.StartsWith(notes[currentAdd], StringComparison.OrdinalIgnoreCase)).ToList())
                {
                    lane.SelectedNotes.Add(note);
                }

                lane.SelectedKeys.Add(this.AvailableKeys.First(key => string.Equals(key.Value, keyboardKeys[currentAdd].ToString(), StringComparison.Ordinal)));

                lane.SelectedSymbol  = this.AvailableSymbols.First(symbol => string.Equals(symbol.Value, currentSymbol.ToString(), StringComparison.Ordinal));
                lane.PitchBackground = new SolidColorBrush(RetrieveColor());

                if (currentSymbol != '\uF155')
                {
                    currentSymbol++;
                }
            }

            this.SelectedPitchCount.Value = keyboardKeys.Length;
        }
        private void OptimizeXbox_Click(object sender, RoutedEventArgs e)
        {
            foreach (var lane in this.Lanes.Children)
            {
                ((LaneSetupControl)lane).Dispose();
            }

            this.Lanes.Children.Clear();

            const int newLanes = 7;

            this.SelectedPitchCount.Maximum = Math.Max(newLanes, this.notes.Count);

            var gamepadKeys = new VirtualKey[newLanes * 2] {
                VirtualKey.Number1, VirtualKey.Y, VirtualKey.Number2, VirtualKey.X, VirtualKey.Number3, VirtualKey.B, VirtualKey.Number4, VirtualKey.A, VirtualKey.Number5, VirtualKey.GamepadDPadUp, VirtualKey.Number6, VirtualKey.GamepadDPadDown, VirtualKey.Number7, VirtualKey.GamepadDPadLeft
            };
            var notes = new string[newLanes] {
                "C", "D", "E", "F", "G", "A", "B"
            };
            var colors = new Color[newLanes] {
                Colors.Orange, Colors.Blue, Colors.Red, Colors.Green, Colors.Gray, Colors.Purple, Colors.DeepPink
            };
            var symbols = new string[newLanes] {
                "\uF095", "\uF096", "\uF094", "\uF093", "\uF0AD", "\uF0AE", "\uF0B0"
            };

            for (var currentAdd = 0; currentAdd < newLanes; currentAdd++)
            {
#pragma warning disable CA2000 // Dispose objects before losing scope
                var lane = new LaneSetupControl(this.AvailableSymbols, this.AvailableNotes, this.AvailableKeys);
#pragma warning restore CA2000 // Dispose objects before losing scope
                lane.PropertyChanged += this.Lane_PropertyChanged;
                this.Lanes.Children.Add(lane);

                foreach (var note in this.AvailableNotes.ToList().Where(note => note.Value.StartsWith(notes[currentAdd], StringComparison.InvariantCultureIgnoreCase)))
                {
                    lane.SelectedNotes.Add(note);
                }

                lane.SelectedKeys.Add(this.AvailableKeys.First(key => string.Equals(key.Value, gamepadKeys[currentAdd * 2].ToString(), StringComparison.Ordinal)));
                lane.SelectedKeys.Add(this.AvailableKeys.First(key => string.Equals(key.Value, gamepadKeys[(currentAdd * 2) + 1].ToString(), StringComparison.Ordinal)));

                lane.SelectedSymbol  = this.AvailableSymbols.First(symbol => string.Equals(symbol.Value, symbols[currentAdd], StringComparison.Ordinal));
                lane.PitchBackground = new SolidColorBrush(colors[currentAdd]);
            }

            this.SelectedPitchCount.Value = newLanes;
        }