示例#1
0
        public static KeyBinding Parse(string value)
        {
            if (value == "none")
            {
                return(KeyBinding.Empty);
            }

            var keys         = new List <DoomKey>();
            var mouseButtons = new List <DoomMouseButton>();

            var split = value.Split(',').Select(x => x.Trim());

            foreach (var s in split)
            {
                var key = DoomKeyEx.Parse(s);

                if (key != DoomKey.Unknown)
                {
                    keys.Add(key);

                    continue;
                }

                var mouseButton = DoomMouseButtonEx.Parse(s);

                if (mouseButton != DoomMouseButton.Unknown)
                {
                    mouseButtons.Add(mouseButton);
                }
            }

            return(new KeyBinding(keys, mouseButtons));
        }
示例#2
0
        public override string ToString()
        {
            var keyValues   = this.keys.Select(key => DoomKeyEx.ToString(key));
            var mouseValues = this.mouseButtons.Select(button => DoomMouseButtonEx.ToString(button));
            var values      = keyValues.Concat(mouseValues).ToArray();

            if (values.Length > 0)
            {
                return(string.Join(", ", values));
            }
            else
            {
                return("none");
            }
        }