protected void figureOutKeyboardSize() { keyboardWidth = Game.GraphicsDevice.Viewport.Width; keyboardHeight = Game.GraphicsDevice.Viewport.Height * 40 / 100; int keyWidth = keyboardWidth / 10; int keyHeight = keyboardHeight / 4; keys = null; for (int i = 0; i < quertyList.Length; i++) { singleKey key = new singleKey(); if (keys == null) { keys = new List <singleKey>(); key.KeyChar = quertyList[i]; key.key = i; key.Bounds = new Rectangle(0, GraphicsDevice.Viewport.Height - keyboardHeight, keyWidth, keyHeight); key.DrawingBounds = new Rectangle(key.Bounds.X + key.Bounds.Width * 5 / 100, key.Bounds.Y + key.Bounds.Height * 5 / 100, keyWidth - key.Bounds.Width * 5 / 100 - key.Bounds.Width * 5 / 100, keyHeight - key.Bounds.Height * 5 / 100 - key.Bounds.Height * 5 / 100); keys.Add(key); } else { if (i < 10) { key.KeyChar = quertyList[i]; key.key = i; key.Bounds = new Rectangle(keys[keys.Count - 1].Bounds.X + keyWidth, GraphicsDevice.Viewport.Height - keyboardHeight, keyWidth, keyHeight); key.DrawingBounds = new Rectangle(key.Bounds.X + key.Bounds.Width * 5 / 100, key.Bounds.Y + key.Bounds.Height * 5 / 100, keyWidth - key.Bounds.Width * 5 / 100 - key.Bounds.Width * 5 / 100, keyHeight - key.Bounds.Height * 5 / 100 - key.Bounds.Height * 5 / 100); keys.Add(key); } else if (i == 10) { key.KeyChar = quertyList[i]; key.key = i; key.Bounds = new Rectangle((GraphicsDevice.Viewport.Width - keyWidth * 9) / 2, GraphicsDevice.Viewport.Height - keyboardHeight + keyHeight, keyWidth, keyHeight); key.DrawingBounds = new Rectangle(key.Bounds.X + key.Bounds.Width * 5 / 100, key.Bounds.Y + key.Bounds.Height * 5 / 100, keyWidth - key.Bounds.Width * 5 / 100 - key.Bounds.Width * 5 / 100, keyHeight - key.Bounds.Height * 5 / 100 - key.Bounds.Height * 5 / 100); keys.Add(key); } else if (i < 19) { key.KeyChar = quertyList[i]; key.key = i; key.Bounds = new Rectangle(keys[keys.Count - 1].Bounds.X + keyWidth, GraphicsDevice.Viewport.Height - keyboardHeight + keyHeight, keyWidth, keyHeight); key.DrawingBounds = new Rectangle(key.Bounds.X + key.Bounds.Width * 5 / 100, key.Bounds.Y + key.Bounds.Height * 5 / 100, keyWidth - key.Bounds.Width * 5 / 100 - key.Bounds.Width * 5 / 100, keyHeight - key.Bounds.Height * 5 / 100 - key.Bounds.Height * 5 / 100); keys.Add(key); } else if (i == 19) { key.KeyChar = quertyList[i]; key.key = i; key.Bounds = new Rectangle((GraphicsDevice.Viewport.Width - keyWidth * 9) / 2, GraphicsDevice.Viewport.Height - keyboardHeight + keyHeight * 2, keyWidth, keyHeight); key.DrawingBounds = new Rectangle(key.Bounds.X + key.Bounds.Width * 5 / 100, key.Bounds.Y + key.Bounds.Height * 5 / 100, keyWidth - key.Bounds.Width * 5 / 100 - key.Bounds.Width * 5 / 100, keyHeight - key.Bounds.Height * 5 / 100 - key.Bounds.Height * 5 / 100); keys.Add(key); } else if (i < 28) { key.KeyChar = quertyList[i]; key.key = i; key.Bounds = new Rectangle(keys[keys.Count - 1].Bounds.X + keyWidth, GraphicsDevice.Viewport.Height - keyboardHeight + keyHeight * 2, keyWidth, keyHeight); key.DrawingBounds = new Rectangle(key.Bounds.X + key.Bounds.Width * 5 / 100, key.Bounds.Y + key.Bounds.Height * 5 / 100, keyWidth - key.Bounds.Width * 5 / 100 - key.Bounds.Width * 5 / 100, keyHeight - key.Bounds.Height * 5 / 100 - key.Bounds.Height * 5 / 100); keys.Add(key); } else if (i == 28) { key.KeyChar = quertyList[i]; key.key = i; key.Bounds = new Rectangle((GraphicsDevice.Viewport.Width - keyWidth * 9) / 2, GraphicsDevice.Viewport.Height - keyboardHeight + keyHeight * 3, keyWidth * 2, keyHeight); key.DrawingBounds = new Rectangle(key.Bounds.X + key.Bounds.Width * 5 / 100, key.Bounds.Y + key.Bounds.Height * 5 / 100, key.Bounds.Width - key.Bounds.Width * 5 / 100 - key.Bounds.Width * 5 / 100, key.Bounds.Height - key.Bounds.Height * 5 / 100 - key.Bounds.Height * 5 / 100); keys.Add(key); } else if (i == 29) { key.KeyChar = quertyList[i]; key.key = i; key.Bounds = new Rectangle(keys[keys.Count - 1].Bounds.X + keys[keys.Count - 1].Bounds.Width, GraphicsDevice.Viewport.Height - keyboardHeight + keyHeight * 3, keyWidth * 4, keyHeight); key.DrawingBounds = new Rectangle(key.Bounds.X + key.Bounds.Width * 5 / 100, key.Bounds.Y + key.Bounds.Height * 5 / 100, key.Bounds.Width - key.Bounds.Width * 5 / 100 - key.Bounds.Width * 5 / 100, key.Bounds.Height - key.Bounds.Height * 5 / 100 - key.Bounds.Height * 5 / 100); keys.Add(key); } else if (i == 30) { key.KeyChar = quertyList[i]; key.key = i; key.Bounds = new Rectangle(keys[keys.Count - 1].Bounds.X + keys[keys.Count - 1].Bounds.Width, GraphicsDevice.Viewport.Height - keyboardHeight + keyHeight * 3, keyWidth * 3, keyHeight); key.DrawingBounds = new Rectangle(key.Bounds.X + key.Bounds.Width * 5 / 100, key.Bounds.Y + key.Bounds.Height * 5 / 100, key.Bounds.Width - key.Bounds.Width * 5 / 100 - key.Bounds.Width * 5 / 100, key.Bounds.Height - key.Bounds.Height * 5 / 100 - key.Bounds.Height * 5 / 100); keys.Add(key); } } } }
protected void figureOutKeyboardSize() { keyboardWidth = Game.GraphicsDevice.Viewport.Width; keyboardHeight = Game.GraphicsDevice.Viewport.Height * 40/100; int keyWidth = keyboardWidth / 10; int keyHeight = keyboardHeight / 4; keys = null; for (int i = 0; i < quertyList.Length; i++ ) { singleKey key = new singleKey(); if (keys == null) { keys = new List<singleKey>(); key.KeyChar = quertyList[i]; key.key = i; key.Bounds = new Rectangle(0, GraphicsDevice.Viewport.Height - keyboardHeight, keyWidth, keyHeight); key.DrawingBounds = new Rectangle(key.Bounds.X + key.Bounds.Width * 5 / 100, key.Bounds.Y + key.Bounds.Height * 5 / 100, keyWidth - key.Bounds.Width * 5 / 100 - key.Bounds.Width * 5 / 100, keyHeight - key.Bounds.Height * 5 / 100 - key.Bounds.Height * 5 / 100); keys.Add(key); } else { if (i < 10) { key.KeyChar = quertyList[i]; key.key = i; key.Bounds = new Rectangle(keys[keys.Count - 1].Bounds.X + keyWidth, GraphicsDevice.Viewport.Height - keyboardHeight, keyWidth, keyHeight); key.DrawingBounds = new Rectangle(key.Bounds.X + key.Bounds.Width * 5 / 100, key.Bounds.Y + key.Bounds.Height * 5 / 100, keyWidth - key.Bounds.Width * 5 / 100 - key.Bounds.Width * 5 / 100, keyHeight - key.Bounds.Height * 5 / 100 - key.Bounds.Height * 5 / 100); keys.Add(key); } else if (i == 10) { key.KeyChar = quertyList[i]; key.key = i; key.Bounds = new Rectangle((GraphicsDevice.Viewport.Width - keyWidth * 9)/2, GraphicsDevice.Viewport.Height - keyboardHeight + keyHeight, keyWidth, keyHeight); key.DrawingBounds = new Rectangle(key.Bounds.X + key.Bounds.Width * 5 / 100, key.Bounds.Y + key.Bounds.Height * 5 / 100, keyWidth - key.Bounds.Width * 5 / 100 - key.Bounds.Width * 5 / 100, keyHeight - key.Bounds.Height * 5 / 100 - key.Bounds.Height * 5 / 100); keys.Add(key); } else if (i < 19) { key.KeyChar = quertyList[i]; key.key = i; key.Bounds = new Rectangle(keys[keys.Count - 1].Bounds.X + keyWidth, GraphicsDevice.Viewport.Height - keyboardHeight + keyHeight, keyWidth, keyHeight); key.DrawingBounds = new Rectangle(key.Bounds.X + key.Bounds.Width * 5 / 100, key.Bounds.Y + key.Bounds.Height * 5 / 100, keyWidth - key.Bounds.Width * 5 / 100 - key.Bounds.Width * 5 / 100, keyHeight - key.Bounds.Height * 5 / 100 - key.Bounds.Height * 5 / 100); keys.Add(key); } else if (i == 19) { key.KeyChar = quertyList[i]; key.key = i; key.Bounds = new Rectangle((GraphicsDevice.Viewport.Width - keyWidth * 9) / 2, GraphicsDevice.Viewport.Height - keyboardHeight + keyHeight * 2, keyWidth, keyHeight); key.DrawingBounds = new Rectangle(key.Bounds.X + key.Bounds.Width * 5 / 100, key.Bounds.Y + key.Bounds.Height * 5 / 100, keyWidth - key.Bounds.Width * 5 / 100 - key.Bounds.Width * 5 / 100, keyHeight - key.Bounds.Height * 5 / 100 - key.Bounds.Height * 5 / 100); keys.Add(key); } else if (i < 28) { key.KeyChar = quertyList[i]; key.key = i; key.Bounds = new Rectangle(keys[keys.Count - 1].Bounds.X + keyWidth, GraphicsDevice.Viewport.Height - keyboardHeight + keyHeight * 2, keyWidth, keyHeight); key.DrawingBounds = new Rectangle(key.Bounds.X + key.Bounds.Width * 5 / 100, key.Bounds.Y + key.Bounds.Height * 5 / 100, keyWidth - key.Bounds.Width * 5 / 100 - key.Bounds.Width * 5 / 100, keyHeight - key.Bounds.Height * 5 / 100 - key.Bounds.Height * 5 / 100); keys.Add(key); } else if (i == 28) { key.KeyChar = quertyList[i]; key.key = i; key.Bounds = new Rectangle((GraphicsDevice.Viewport.Width - keyWidth * 9) / 2, GraphicsDevice.Viewport.Height - keyboardHeight + keyHeight * 3, keyWidth*2, keyHeight); key.DrawingBounds = new Rectangle(key.Bounds.X + key.Bounds.Width * 5 / 100, key.Bounds.Y + key.Bounds.Height * 5 / 100, key.Bounds.Width - key.Bounds.Width * 5 / 100 - key.Bounds.Width * 5 / 100, key.Bounds.Height - key.Bounds.Height * 5 / 100 - key.Bounds.Height * 5 / 100); keys.Add(key); } else if (i == 29) { key.KeyChar = quertyList[i]; key.key = i; key.Bounds = new Rectangle(keys[keys.Count - 1].Bounds.X + keys[keys.Count - 1].Bounds.Width, GraphicsDevice.Viewport.Height - keyboardHeight + keyHeight * 3, keyWidth * 4, keyHeight); key.DrawingBounds = new Rectangle(key.Bounds.X + key.Bounds.Width * 5 / 100, key.Bounds.Y + key.Bounds.Height * 5 / 100, key.Bounds.Width - key.Bounds.Width * 5 / 100 - key.Bounds.Width * 5 / 100, key.Bounds.Height - key.Bounds.Height * 5 / 100 - key.Bounds.Height * 5 / 100); keys.Add(key); } else if (i == 30) { key.KeyChar = quertyList[i]; key.key = i; key.Bounds = new Rectangle(keys[keys.Count -1].Bounds.X + keys[keys.Count - 1].Bounds.Width, GraphicsDevice.Viewport.Height - keyboardHeight + keyHeight * 3, keyWidth * 3, keyHeight); key.DrawingBounds = new Rectangle(key.Bounds.X + key.Bounds.Width * 5 / 100, key.Bounds.Y + key.Bounds.Height * 5 / 100, key.Bounds.Width - key.Bounds.Width * 5 / 100 - key.Bounds.Width * 5 / 100, key.Bounds.Height - key.Bounds.Height * 5 / 100 - key.Bounds.Height * 5 / 100); keys.Add(key); } } } }