internal override void AssertValid(IKeyboardHost host)
        {
            base.AssertValid(host);

            KeyboardValidationException.Assert(Action != null, "Action must be specified");
            KeyboardValidationException.Assert(host.GetAction(Action) != null, "Action must be a valid action name: {0}", Action);
        }
        internal void AssertValid(IKeyboardHost host)
        {
            KeyboardValidationException.Assert(Keys != null, "Keys must be specified");
            KeyboardValidationException.Assert(Keys.Length != 0, "Keys must not be empty");

            foreach (var key in Keys)
            {
                key.AssertValid(host);
            }
        }
        /// <summary>
        /// Validate the layout.
        /// </summary>
        public void AssertValid(IKeyboardHost host)
        {
            KeyboardValidationException.Assert(Rows != null, "Rows must be specified");
            KeyboardValidationException.Assert(Rows.Length != 0, "One or more rows");

            Rows[0].AssertValid(host);
            var row0Width = Rows[0].CalculateWidth();

            for (var rowIndex = 1; rowIndex < Rows.Length; rowIndex++)
            {
                var row = Rows[rowIndex];
                row.AssertValid(host);
                var rowWidth = row.CalculateWidth();

                KeyboardValidationException.Assert(row0Width == rowWidth, "All rows must be same length");
            }
        }
        internal override void AssertValid(IKeyboardHost host)
        {
            base.AssertValid(host);

            KeyboardValidationException.Assert(Conditionals != null, "Conditionals must be specified");
            KeyboardValidationException.Assert(Conditionals.Length != 0, "Conditionals cannot be empty");

            var isFirst    = true;
            var hasDefault = false;
            var width      = Conditionals[0].CalculateWidth();

            var names = new HashSet <string>();

            foreach (var conditional in Conditionals)
            {
                conditional.AssertValid(host);

                if (isFirst)
                {
                    isFirst = false;
                }
                else
                {
                    var otherWidth = conditional.CalculateWidth();
                    KeyboardValidationException.Assert(width == otherWidth, "All Conditionals must have same width");
                }

                if (conditional.Name == null)
                {
                    KeyboardValidationException.Assert(!hasDefault, "Can only have one default conditional");
                    hasDefault = true;
                }
                else
                {
                    KeyboardValidationException.Assert(!names.Contains(conditional.Name), "Names must be unique");
                    names.Add(conditional.Name);
                }
            }

            KeyboardValidationException.Assert(hasDefault, "Must have an unnamed default conditional");
        }
Beispiel #5
0
        internal override void AssertValid(IKeyboardHost host)
        {
            base.AssertValid(host);

            KeyboardValidationException.Assert(StateName != null, "StateName must be specified");
        }