/// <summary>
        /// </summary>
        /// <param name="tp"></param>
        /// <param name="isSelected"></param>
        private void OnTpButtonClicked(TimingPointInfo tp, bool isSelected)
        {
            var t = TimeSpan.FromMilliseconds(tp.StartTime);

            if (!ImGui.Button($"{t.Minutes:00}:{t.Seconds:00}:{t.Milliseconds:000}", new Vector2()))
            {
                return;
            }

            // User is holding control down, so add this SV to the selected ones
            if (KeyboardManager.CurrentState.IsKeyDown(Keys.LeftControl) ||
                KeyboardManager.CurrentState.IsKeyDown(Keys.LeftControl))
            {
                if (isSelected)
                {
                    if (SelectedTimingPoints.Count != 1)
                    {
                        SelectedTimingPoints.Remove(tp);
                    }

                    if (SelectedTimingPoints.Count == 1)
                    {
                        SetInputTextToFirstSelected();
                    }
                }
                else
                {
                    SelectedTimingPoints.Add(tp);

                    if (SelectedTimingPoints.Count == 1)
                    {
                        SetInputTextToFirstSelected();
                    }
                    else
                    {
                        TextTime = "";
                        TextBpm  = "";
                    }
                }
            }
            // Clicking the currently selected button seeks the user to that point in time
            else
            {
                if (isSelected && !AudioEngine.Track.IsDisposed)
                {
                    AudioEngine.Track.Seek(tp.StartTime);

                    var game   = GameBase.Game as QuaverGame;
                    var screen = game?.CurrentScreen as EditorScreen;
                    screen?.SetHitSoundObjectIndex();
                }

                SelectedTimingPoints.Clear();
                SelectedTimingPoints.Add(tp);

                TextTime = tp.StartTime.ToString(CultureInfo.InvariantCulture);
                TextBpm  = $"{tp.Bpm:0.00}";
            }
        }
        /// <summary>
        /// </summary>
        private void SelectClosestPoint()
        {
            if (WorkingMap.TimingPoints.Count == 0)
            {
                return;
            }

            // Find the closest timing point so it can be selected upon opening.
            TimingPointInfo closestTimingPoint = null;
            var             minDiff            = double.MaxValue;

            WorkingMap.TimingPoints.ForEach(x =>
            {
                var diff = Math.Abs(AudioEngine.Track.Time - x.StartTime);

                if (!(diff < minDiff))
                {
                    return;
                }

                minDiff            = diff;
                closestTimingPoint = x;
            });

            if (closestTimingPoint == null)
            {
                return;
            }

            SelectedTimingPoints.Clear();
            SelectedTimingPoints.Add(closestTimingPoint);
            NeedsToScroll = true;

            TextTime = closestTimingPoint.StartTime.ToString(CultureInfo.InvariantCulture);
            TextBpm  = $"{closestTimingPoint.Bpm:0.00}";
        }
        /// <summary>
        /// </summary>
        private void HandleAddRemoveButtons()
        {
            if (ImGui.Button("Add"))
            {
                var tp = new TimingPointInfo()
                {
                    StartTime = (int)AudioEngine.Track.Time,
                    Bpm       = 0
                };

                var game   = GameBase.Game as QuaverGame;
                var screen = game?.CurrentScreen as EditorScreen;
                screen?.Ruleset.ActionManager.Perform(new EditorActionAddTimingPoint(WorkingMap, tp));

                SelectedTimingPoints.Clear();
                SelectedTimingPoints.Add(tp);
                NeedsToScroll = true;

                TextTime = tp.StartTime.ToString(CultureInfo.InvariantCulture);
                TextBpm  = $"{tp.Bpm:0.00}";
            }

            ImGui.SameLine();

            if (ImGui.Button("Remove"))
            {
                if (SelectedTimingPoints.Count == 0)
                {
                    return;
                }

                var game   = GameBase.Game as QuaverGame;
                var screen = game?.CurrentScreen as EditorScreen;

                var lastTp = SelectedTimingPoints.Last();

                screen?.Ruleset.ActionManager.Perform(new EditorActionRemoveTimingPoints(WorkingMap, new List <TimingPointInfo>(SelectedTimingPoints)));

                SelectedTimingPoints.Clear();

                if (WorkingMap.TimingPoints.Count != 0)
                {
                    var sv = WorkingMap.TimingPoints.FindLast(x => x.StartTime <= lastTp.StartTime);

                    if (sv != null)
                    {
                        TextTime = sv.StartTime.ToString(CultureInfo.InvariantCulture);
                        TextBpm  = $"{sv.Bpm:0.00}";
                        SelectedTimingPoints.Add(sv);
                    }
                    else
                    {
                        TextTime = "";
                        TextBpm  = $"";
                    }
                }
                else
                {
                    TextTime = "";
                    TextBpm  = $"";
                }

                NeedsToScroll = true;
            }
        }