예제 #1
0
        private void AddConfigItem(string item, ConfigKind kind)
        {
            var menuItem = new MenuItem(item)
            {
                Label = GetConfigItem(item, kind)
            };

            AddMenuItem(menuItem);
        }
예제 #2
0
        private string GetConfigItem(string item, ConfigKind kind)
        {
            string value;

            switch (kind)
            {
            case ConfigKind.String:
                if (Config.GetConfigString(item, out value))
                {
                    return(value);
                }
                break;

            case ConfigKind.Int:
                if (Config.GetConfigString(item, out value) && int.TryParse(value, out int intVal))
                {
                    return(intVal.ToString());
                }
                break;

            case ConfigKind.Float:
                if (Config.GetConfigString(item, out value) && float.TryParse(value, out float floatVal))
                {
                    return(floatVal.ToString());
                }
                break;

            case ConfigKind.Bool:
                if (Config.GetConfigString(item, out value) && bool.TryParse(value, out bool boolVal))
                {
                    return(boolVal.ToString());
                }
                break;

            case ConfigKind.Control:
                if (Config.GetConfigString(item, out value) && Controls.InputPair.TryParse(value, out Controls.InputPair controlVal))
                {
                    return(controlVal.ToString());
                }
                break;
            }

            return("?");
        }