private void CreateLayout(XElement rootElement, Keyboard keyboard)
        {
            var keyElements = rootElement.Elements("Key");

            if (keyElements == null)
            {
                throw new InvalidOperationException("<Key> element not found in definition!");
            }

            try
            {
                foreach (var keyElement in keyElements)
                {
                    var keyboardKey   = new KeyboardKey();
                    var stateElements = keyElement.Elements("State");
                    foreach (var stateElement in stateElements)
                    {
                        keyboardKey.AddState(GetKeyState(stateElement));
                    }
                    keyboard.AddKey(keyboardKey, GetLocation(keyElement), GetSize(keyElement));
                }
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("<State> element can't read!", ex);
            }

            try
            {
                keyboard.SetGirdSize(Convert.ToInt16(rootElement.Attribute("Rows").Value), Convert.ToInt16(rootElement.Attribute("Cols").Value));
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("Rows Or Cols attiribute can't read!", ex);
            }

            keyboard.PerformKeyboardLayout();
        }
        private void CreateLayout(XElement rootElement, Keyboard keyboard)
        {
            var keyElements = rootElement.Elements("Key");
            if (keyElements == null)
            {
                throw new InvalidOperationException("<Key> element not found in definition!");
            }

            try
            {
                foreach (var keyElement in keyElements)
                {
                    var keyboardKey = new KeyboardKey();
                    var stateElements = keyElement.Elements("State");
                    foreach (var stateElement in stateElements)
                    {
                        keyboardKey.AddState(GetKeyState(stateElement));
                    }
                    keyboard.AddKey(keyboardKey, GetLocation(keyElement), GetSize(keyElement));
                }
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("<State> element can't read!", ex);
            }

            try
            {
                keyboard.SetGirdSize(Convert.ToInt16(rootElement.Attribute("Rows").Value), Convert.ToInt16(rootElement.Attribute("Cols").Value));
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("Rows Or Cols attiribute can't read!", ex);
            }

            keyboard.PerformKeyboardLayout();
        }
示例#3
0
 public void AddKey(KeyboardKey key, Point keyLocation, Size keySize)
 {
     LayoutManager.AddCell(key, keyLocation, keySize);
     Controls.Add(key);
 }
示例#4
0
 public void AddKey(KeyboardKey key, Point keyLocation, Size keySize)
 {
     LayoutManager.AddCell(key, keyLocation, keySize);
     Controls.Add(key);
 }