public static void SetToolMode(ToolMode mode)
        {
            //Log._Debug($"SetToolMode: {mode}");

            if (mode == ToolMode.None)
            {
#if !TAM
                UITrafficManager.deactivateButtons();
#endif
            }

            bool toolModeChanged = (mode != _toolMode);
            if (toolModeChanged && activeSubTool != null)
            {
                if ((_toolMode == ToolMode.TimedLightsSelectNode || _toolMode == ToolMode.TimedLightsShowLights || _toolMode == ToolMode.TimedLightsAddNode || _toolMode == ToolMode.TimedLightsRemoveNode))                   // TODO refactor to SubToolMode
                {
                    if (mode != ToolMode.TimedLightsSelectNode && mode != ToolMode.TimedLightsShowLights && mode != ToolMode.TimedLightsAddNode && mode != ToolMode.TimedLightsRemoveNode)
                    {
                        activeSubTool.Cleanup();
                    }
                }
                else
                {
                    activeSubTool.Cleanup();
                }
            }
            _toolMode = mode;

            SelectedNodeId    = 0;
            SelectedSegmentId = 0;

            activeSubTool = null;
            //Log._Debug($"Getting activeSubTool for mode {_toolMode} {subTools.Count}");
            activeSubTool = subTools[(int)_toolMode];
            //subTools.TryGetValue((int)_toolMode, out activeSubTool);
            //Log._Debug($"activeSubTool is now {activeSubTool}");

            if (toolModeChanged && activeSubTool != null)
            {
                activeSubTool.OnActivate();
            }
        }