Ejemplo n.º 1
0
        private void ShowView(KeyboardViewId id)
        {
            if (!this.views.Contains(id))
            {
                this.CreateView(id);
            }

            this.active = (KeyboardView)this.views[id];

            this.image.Source = this.active.Image;

            this.image.InvalidateMeasure();

            this.scaleX  = this.active.Image.Width / (double)this.image.Width;
            this.scaleY  = this.active.Image.Height / (double)this.image.Height;
            this.offsetX = 0;
            this.offsetY = this.input.Height;
        }
Ejemplo n.º 2
0
        private void CreateView(KeyboardViewId id)
        {
            var hf    = 40;
            var sz    = 80;
            var szh   = 120;
            var full  = new[] { sz, sz, sz, sz, sz, sz, sz, sz, sz, sz };
            var image = default(System.Drawing.Bitmap);
            var view  = new KeyboardView {
                RowHeight = sz
            };

            switch (id)
            {
            case KeyboardViewId.Lowercase:
                image = Resources.GetBitmap(Resources.BitmapResources.Keyboard_Lowercase);
                view.RowColumnOffset = new[] { 0, hf, 0, 0 };
                view.ColumnWidth     = new[] {
                    full,
                    new[] { sz, sz, sz, sz, sz, sz, sz, sz, sz },
                    new[] { szh, sz, sz, sz, sz, sz, sz, sz, szh },
                    new[] { szh, sz, sz * 4, sz, sz, szh }
                };
                view.Keys = new[] {
                    new[] { 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p' },
                    new[] { 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l' },
                    new[] { '\0', 'z', 'x', 'c', 'v', 'b', 'n', 'm', '\0' },
                    new[] { '\0', ',', ' ', '.', '\0', '\0' }
                };
                view.SpecialKeys = new[] {
                    null,
                    null,
                    new Action[] { () => this.ShowView(KeyboardViewId.Uppercase), null, null, null, null, null, null, null, () => this.Backspace() },
                    new Action[] { () => this.ShowView(KeyboardViewId.Numbers), null, null, null, () => this.Cancel(), () => this.Close() }
                };

                break;

            case KeyboardViewId.Uppercase:
                image = Resources.GetBitmap(Resources.BitmapResources.Keyboard_Uppercase);
                view.RowColumnOffset = new[] { 0, hf, 0, 0 };
                view.ColumnWidth     = new[] {
                    full,
                    new[] { sz, sz, sz, sz, sz, sz, sz, sz, sz },
                    new[] { szh, sz, sz, sz, sz, sz, sz, sz, szh },
                    new[] { szh, sz, sz * 4, sz, sz, szh }
                };
                view.Keys = new[] {
                    new[] { 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P' },
                    new[] { 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L' },
                    new[] { '\0', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '\0' },
                    new[] { '\0', ',', ' ', '.', '\0', '\0' }
                };
                view.SpecialKeys = new[] {
                    null,
                    null,
                    new Action[] { () => this.ShowView(KeyboardViewId.Lowercase), null, null, null, null, null, null, null, () => this.Backspace() },
                    new Action[] { () => this.ShowView(KeyboardViewId.Numbers), null, null, null, () => this.Cancel(), () => this.Close() }
                };

                break;

            case KeyboardViewId.Numbers:
                image = Resources.GetBitmap(Resources.BitmapResources.Keyboard_Numbers);
                view.RowColumnOffset = new[] { 0, 0, 0, 0 };
                view.ColumnWidth     = new[] {
                    full,
                    full,
                    new[] { szh, sz, sz, sz, sz, sz, sz, sz, szh },
                    new[] { szh, sz, sz * 4, sz, sz, szh }
                };
                view.Keys = new[] {
                    new[] { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' },
                    new[] { '@', '#', '$', '%', '&', '*', '-', '+', '(', ')' },
                    new[] { '\0', '!', '"', '\'', ':', ';', '/', '?', '\0' },
                    new[] { '\0', ',', ' ', '.', '\0', '\0' }
                };
                view.SpecialKeys = new[] {
                    null,
                    null,
                    new Action[] { () => this.ShowView(KeyboardViewId.Symbols), null, null, null, null, null, null, null, () => this.Backspace() },
                    new Action[] { () => this.ShowView(KeyboardViewId.Lowercase), null, null, null, () => this.Cancel(), () => this.Close() }
                };

                break;

            case KeyboardViewId.Symbols:
                image = Resources.GetBitmap(Resources.BitmapResources.Keyboard_Symbols);
                view.RowColumnOffset = new[] { 0, 0, 0, 0 };
                view.ColumnWidth     = new[] {
                    full,
                    full,
                    new[] { szh, sz, sz, sz, sz, sz, sz, sz, szh },
                    new[] { szh, sz, sz * 4, sz, sz, szh }
                };
                view.Keys = new[] {
                    new[] { '~', '`', '|', '•', '√', 'π', '÷', '×', '{', '}' },
                    new[] { '\t', '£', '¢', '€', 'º', '^', '_', '=', '[', ']' },
                    new[] { '\0', '™', '®', '©', '¶', '\\', '<', '>', '\0' },
                    new[] { '\0', ',', ' ', '.', '\0', '\0' }
                };
                view.SpecialKeys = new[] {
                    null,
                    null,
                    new Action[] { () => this.ShowView(KeyboardViewId.Numbers), null, null, null, null, null, null, null, () => this.Backspace() },
                    new Action[] { () => this.ShowView(KeyboardViewId.Lowercase), null, null, null, () => this.Cancel(), () => this.Close() }
                };

                break;
            }

            view.Image = BitmapImage.FromGraphics(Graphics.FromImage(image));

            this.views.Add(id, view);
        }