protected override List <MenuItem> CreateMenuItems()
        {
            if (menuSelector != null)
            {
                lastSelectorIndex = menuSelector.Index;
            }

            var menus = new List <MenuItem>();

            string currentSpeedSet = LocoCruiseControl.GetTargetSpeed().HasValue ? $"\n\n\nSet to {LocoCruiseControl.GetTargetSpeed():0} km/h" : "\n\n\nSpeed not set";

            int hash = 1;

            if (!LocoCruiseControl.IsSet)
            {
                menus.Add(new MenuItem("Set current speed", "Set", () => SetCruiseControl()));
                hash += 2;
            }

            menus.Add(new MenuItem("30 km/h" + currentSpeedSet, "Set", () => SetCruiseControl(30.0f)));
            menus.Add(new MenuItem("60 km/h" + currentSpeedSet, "Set", () => SetCruiseControl(60.0f)));

            if (LocoCruiseControl.IsSet)
            {
                menus.Add(new MenuItem("+ 5 km/h" + currentSpeedSet, "Add", () => UpdateTargetSpeed(5.0f)));
                menus.Add(new MenuItem("- 5 km/h" + currentSpeedSet, "Sub", () => UpdateTargetSpeed(-5.0f)));
                menus.Add(new MenuItem("Reset", "Cancel", () => ResetCruiseControl()));
                hash += 4;
            }
            menus.Add(GetExitMenu());

            //if nothing changed try to keep old selector index, otherwise set it to 0
            if (hash != lastSelectoritemsHash)
            {
                lastSelectorIndex     = 0;
                lastSelectoritemsHash = hash;
            }

            return(menus);
        }
 private void UpdateTargetSpeed(float speedDiff)
 {
     float speed = LocoCruiseControl.UpdateTargetSpeed(speedDiff);
     //CallMessageSubPage($"Speed set to {speed:0.#} km/h", "", MESSAGE_TIMEOUT);
 }
 private void SetCruiseControl(float?speed = null)
 {
     float speedSet = LocoCruiseControl.SetCruiseControl(speed);
     //CallMessageSubPage($"Speed set to {speedSet:0.#} km/h", "", MESSAGE_TIMEOUT);
 }
 private void ResetCruiseControl()
 {
     LocoCruiseControl.ResetCruiseControl();
     CallMessageSubPage($"Cruise control disabled", "", MESSAGE_TIMEOUT);
 }