// works for an arbitrary depth
        // returns the current mode
        public static GuiModus SwitchMode(ref Stack <GuiModus> _prev, GuiModus _new)
        {
            if (_prev == null)
            {
                return(GuiModus.NEUTRAL);
            }
            if (_prev.Count < 1)
            {
                return(GuiModus.NEUTRAL);
            }

            GuiModus prev_l0 = _prev.Peek();

            if (prev_l0 == _new)
            {
                // switch to the mode 1 level deeper in the stack
                _prev.Pop();
                if (_prev.Count == 0)
                {
                    return(GuiModus.NEUTRAL);
                }
                else
                {
                    return(_prev.Peek());
                }
            }
            else
            {
                _prev.Push(_new);
                return(_new);
            }
        }
 public static bool IsSubMode(GuiModus _mode)
 {
     return(_mode == GuiModus.PARAMETER_PICK_VALUE_FIELD ||
            _mode == GuiModus.CALC_PICK_PARAMETER_IN ||
            _mode == GuiModus.CALC_PICK_PARAMETER_OUT ||
            _mode == GuiModus.COMPONENT_PICK_PARAMETER ||
            _mode == GuiModus.COMPONENT_EDIT_PARAMETER ||
            _mode == GuiModus.COMPONENT_PICK_CALC ||
            _mode == GuiModus.COMPONENT_EDIT_CALC ||
            _mode == GuiModus.COMPONENT_CALC_PICK_PARAMETER_IN ||
            _mode == GuiModus.COMPONENT_CALC_PICK_PARAMETER_OUT ||
            _mode == GuiModus.COMPONENT_PICK_COMPONENT ||
            _mode == GuiModus.COMPONENT_PICK_SYMBOL);
 }
 // works only for 3 Levels: Neutral -> Mode -> SubMode !!!
 public static void SwitchFromTo(ref GuiModus _old, ref GuiModus _current, GuiModus _new)
 {
     if (_current == _new)
     {
         if (GuiModusUtils.IsSubMode(_new))
         {
             // returning from sub-mode
             GuiModus tmp = _current;
             _current = _old;
             _old     = tmp;
         }
         else
         {
             // returning from mode
             _old     = _current;
             _current = GuiModus.NEUTRAL;
         }
     }
     else
     {
         _old     = _current;
         _current = _new;
     }
 }
        public static string GuiModusToString(GuiModus _gm)
        {
            switch (_gm)
            {
            case GuiModus.NEUTRAL:
                return("NEUTRAL");

            case GuiModus.PARAMETER_NEW:
                return("PARAMETER_NEW");

            case GuiModus.PARAMETER_EDIT:
                return("PARAMETER_EDIT");

            case GuiModus.PARAMETER_INFO:
                return("PARAMETER_INFO");

            case GuiModus.PARAMETER_PICK_VALUE_FIELD:
                return("PARAMETER_PICK_VALUE_FIELD");

            case GuiModus.CALC_NEW:
                return("CALC_NEW");

            case GuiModus.CALC_EDIT:
                return("CALC_EDIT");

            case GuiModus.CALC_PICK_PARAMETER_IN:
                return("CALC_PICK_PARAMETER_IN");

            case GuiModus.CALC_PICK_PARAMETER_OUT:
                return("CALC_PICK_PARAMETER_OUT");

            case GuiModus.COMPONENT_NEW:
                return("COMPONENT_NEW");

            case GuiModus.COMPONENT_EDIT:
                return("COMPONENT_EDIT");

            case GuiModus.COMPONENT_INFO:
                return("COMPONENT_INFO");

            case GuiModus.COMPONENT_PICK_PARAMETER:
                return("COMPONENT_PICK_PARAMETER");

            case GuiModus.COMPONENT_EDIT_PARAMETER:
                return("COMPONENT_EDIT_PARAMETER");

            case GuiModus.COMPONENT_PICK_CALC:
                return("COMPONENT_PICK_CALC");

            case GuiModus.COMPONENT_EDIT_CALC:
                return("COMPONENT_EDIT_CALC");

            case GuiModus.COMPONENT_CALC_PICK_PARAMETER_IN:
                return("COMPONENT_CALC_PICK_PARAMETER_IN");

            case GuiModus.COMPONENT_CALC_PICK_PARAMETER_OUT:
                return("COMPONENT_CALC_PICK_PARAMETER_OUT");

            case GuiModus.COMPONENT_PICK_COMPONENT:
                return("COMPONENT_PICK_COMPONENT");

            case GuiModus.COMPONENT_PICK_SYMBOL:
                return("COMPONENT_PICK_SYMBOL");

            case GuiModus.NETWORK_ELEM_PICK_COMP:
                return("NETWORK_ELEM_PICK_COMP");

            case GuiModus.COMP_COMPARER_PICK_COMP:
                return("COMP_COMPARER_PICK_COMP");

            case GuiModus.COMP_TO_WS_MAPPER_PICK_COMP:
                return("COMP_TO_WS_MAPPER_PICK_COMP");

            case GuiModus.COMP_TO_COMP_MAPPER_PICK_COMP:
                return("COMP_TO_COMP_MAPPER_PICK_COMP");

            default:
                return("NEUTRAL");
            }
        }
 public static bool IsSubModeOfSubMode(GuiModus _mode)
 {
     return(_mode == GuiModus.COMPONENT_CALC_PICK_PARAMETER_IN ||
            _mode == GuiModus.COMPONENT_CALC_PICK_PARAMETER_OUT);
 }