Beispiel #1
0
        internal OnScreenKeyboard()
        {
            this.views = new Hashtable();

            this.Width      = WindowManager.Instance.ActualWidth;
            this.Height     = WindowManager.Instance.ActualHeight;
            this.Background = new SolidColorBrush(Colors.Red);

            var holder = new StackPanel();

            this.input = new TextBox {
                ForOnScreenKeyboard = true,
                Font   = OnScreenKeyboard.Font,
                Height = 2 * Font.Height
            };

            holder.Children.Add(this.input);

            this.image = new Controls.Image {
                Source  = null,
                Width   = WindowManager.Instance.ActualWidth,
                Height  = WindowManager.Instance.ActualHeight - this.input.Height,
                Stretch = Stretch.Fill
            };

            this.image.TouchUp += this.OnTouchUp;

            holder.Children.Add(this.image);

            this.Child = holder;
        }
Beispiel #2
0
        private UIElement CreatePage()
        {
            var ghiLogo = new GHIElectronics.TinyCLR.UI.Controls.Image()
            {
                Source = BitmapImage.FromGraphics(Graphics.FromImage(Resources.GetBitmap(Resources.BitmapResources.logo)))
            };

            Canvas.SetLeft(ghiLogo, 0);
            Canvas.SetTop(ghiLogo, 0);
            this.canvas.Children.Add(ghiLogo);

            var buttonText = new GHIElectronics.TinyCLR.UI.Controls.Text(this.font, "Enter")
            {
                ForeColor           = Colors.Black,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
            };
            var enterButton = new Button()
            {
                Child  = buttonText,
                Width  = 65,
                Height = 40,
            };

            Canvas.SetLeft(enterButton, 200);
            Canvas.SetTop(enterButton, 230);
            this.canvas.Children.Add(enterButton);

            enterButton.Click += this.EnterButton_Click;

            return(this.canvas);
        }
        internal OnScreenKeyboard()
        {
            this.views      = new Hashtable();
            this.Width      = WindowManager.Instance.ActualWidth;
            this.Height     = WindowManager.Instance.ActualHeight;
            this.Background = (GHIElectronics.TinyCLR.UI.Media.Brush) new SolidColorBrush(Colors.Red);
            StackPanel stackPanel = new StackPanel();
            TextBox    textBox    = new TextBox();

            textBox.ForOnScreenKeyboard = true;
            textBox.Font = OnScreenKeyboard.Font;
            this.input   = textBox;
            stackPanel.Children.Add((UIElement)this.input);
            GHIElectronics.TinyCLR.UI.Controls.Image image = new GHIElectronics.TinyCLR.UI.Controls.Image();
            image.Source        = (ImageSource)null;
            image.Width         = WindowManager.Instance.ActualWidth;
            image.Height        = WindowManager.Instance.ActualHeight - OnScreenKeyboard.Font.Height;
            image.Stretch       = Stretch.Fill;
            this.image          = image;
            this.image.TouchUp += new TouchEventHandler(this.OnTouchUp);
            stackPanel.Children.Add((UIElement)this.image);
            this.Child = (UIElement)stackPanel;
        }
Beispiel #4
0
        /// <summary>
        /// Parses the Image XML into a UI component.
        /// </summary>
        /// <param name="reader">XML reader object.</param>
        /// <returns>Image object.</returns>
        private static GHIElectronics.TinyCLR.UI.Controls.Image LoadImage(XmlReader reader)
        {
            string name    = reader.GetAttribute("Name");
            ushort alpha   = (reader.GetAttribute("Alpha") != null) ? Convert.ToUInt16(reader.GetAttribute("Alpha")) : _defaultDisplayObject.Alpha;
            int    x       = Convert.ToInt32(reader.GetAttribute("X"));
            int    y       = Convert.ToInt32(reader.GetAttribute("Y"));
            int    width   = Convert.ToInt32(reader.GetAttribute("Width"));
            int    height  = Convert.ToInt32(reader.GetAttribute("Height"));
            bool   visible = (reader.GetAttribute("Visible") != null) ? (reader.GetAttribute("Visible") == bool.TrueString) : _defaultDisplayObject.Visible;
            bool   enabled = (reader.GetAttribute("Enabled") != null) ? (reader.GetAttribute("Enabled") == bool.TrueString) : _defaultDisplayObject.Enabled;

            var image = new GHIElectronics.TinyCLR.UI.Controls.Image();// name, alpha, x, y, width, height);

            image.ID         = name;
            image.Visibility = visible ? Visibility.Visible : Visibility.Hidden;
            image.IsEnabled  = enabled;
            image.Width      = width;
            image.Height     = height;

            Canvas.SetLeft(image, x);
            Canvas.SetTop(image, y);

            return(image);
        }
Beispiel #5
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);
        }
        private UIElement CreatePage()
        {
            int xButton = 300, yButton = 15, yOffsetButton = 60;
            int xPriceText = 420, yPriceText = 25, yOffsetPriceText = 60;
            var xLine = 280;

            this.canvas.Children.Clear();

            var premiumText = new GHIElectronics.TinyCLR.UI.Controls.Text(this.fontDroid12, "Premium")
            {
                ForeColor           = Colors.Black,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
            };

            var standardText = new GHIElectronics.TinyCLR.UI.Controls.Text(this.fontDroid12, "Standard")
            {
                ForeColor           = Colors.Black,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
            };

            var basicText = new GHIElectronics.TinyCLR.UI.Controls.Text(this.fontDroid12, "Basic")
            {
                ForeColor           = Colors.Black,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
            };

            var freeText = new GHIElectronics.TinyCLR.UI.Controls.Text(this.fontDroid12, "Free")
            {
                ForeColor           = Colors.Black,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
            };

            var premiumButton = new Button()
            {
                Child  = premiumText,
                Width  = 100,
                Height = 40,
            };

            var standardButton = new Button()
            {
                Child  = standardText,
                Width  = 100,
                Height = 40,
            };

            var basicButton = new Button()
            {
                Child  = basicText,
                Width  = 100,
                Height = 40,
            };

            var freeButton = new Button()
            {
                Child  = freeText,
                Width  = 100,
                Height = 40,
            };

            Canvas.SetLeft(premiumButton, xButton);
            Canvas.SetTop(premiumButton, yButton + yOffsetButton * 0);

            Canvas.SetLeft(standardButton, xButton);
            Canvas.SetTop(standardButton, yButton + yOffsetButton * 1);

            Canvas.SetLeft(basicButton, xButton);
            Canvas.SetTop(basicButton, yButton + yOffsetButton * 2);

            Canvas.SetLeft(freeButton, xButton);
            Canvas.SetTop(freeButton, yButton + yOffsetButton * 3);

            var premiumPriceText = new GHIElectronics.TinyCLR.UI.Controls.Text(this.fontDroid14, "4.99$")
            {
                ForeColor = Colors.White,
            };

            var standardPriceText = new GHIElectronics.TinyCLR.UI.Controls.Text(this.fontDroid14, "3.99$")
            {
                ForeColor = Colors.White,
            };

            var basicPriceText = new GHIElectronics.TinyCLR.UI.Controls.Text(this.fontDroid14, "2.99$")
            {
                ForeColor = Colors.White,
            };

            var freePriceText = new GHIElectronics.TinyCLR.UI.Controls.Text(this.fontDroid14, "0.00$")
            {
                ForeColor = Colors.White,
            };


            Canvas.SetLeft(premiumPriceText, xPriceText);
            Canvas.SetLeft(standardPriceText, xPriceText);
            Canvas.SetLeft(basicPriceText, xPriceText);
            Canvas.SetLeft(freePriceText, xPriceText);

            Canvas.SetTop(premiumPriceText, yPriceText + yOffsetPriceText * 0);
            Canvas.SetTop(standardPriceText, yPriceText + yOffsetPriceText * 1);
            Canvas.SetTop(basicPriceText, yPriceText + yOffsetPriceText * 2);
            Canvas.SetTop(freePriceText, yPriceText + yOffsetPriceText * 3);


            this.canvas.Children.Add(premiumButton);
            this.canvas.Children.Add(standardButton);
            this.canvas.Children.Add(basicButton);
            this.canvas.Children.Add(freeButton);

            this.canvas.Children.Add(premiumPriceText);
            this.canvas.Children.Add(standardPriceText);
            this.canvas.Children.Add(basicPriceText);
            this.canvas.Children.Add(freePriceText);

            // line
            var line = new GHIElectronics.TinyCLR.UI.Shapes.Line(0, 250)
            {
                Stroke = new GHIElectronics.TinyCLR.UI.Media.Pen(Colors.Yellow)
            };

            Canvas.SetLeft(line, xLine);
            Canvas.SetTop(line, 10);

            this.canvas.Children.Add(line);

            // Timer
            var timerText = new GHIElectronics.TinyCLR.UI.Controls.Text(this.fontB, DateTime.Now.Day + " / " + DateTime.Now.Month + " / " + DateTime.Now.Year)
            {
                ForeColor = Colors.White,
            };

            Canvas.SetLeft(timerText, 100);
            Canvas.SetTop(timerText, 250);

            this.canvas.Children.Add(timerText);

            var selectVehicleText = new GHIElectronics.TinyCLR.UI.Controls.Text(this.fontB, "Select Vehicle Type:")
            {
                ForeColor = Colors.White,
            };


            Canvas.SetLeft(selectVehicleText, 10);
            Canvas.SetTop(selectVehicleText, yPriceText);

            this.canvas.Children.Add(selectVehicleText);

            var listBox = new ListBox();

            listBox.Items.Add(new ListBoxItemHighlightable("Truck", this.fontB, 4, GHIElectronics.TinyCLR.UI.Media.Colors.Blue, GHIElectronics.TinyCLR.UI.Media.Colors.White, GHIElectronics.TinyCLR.UI.Media.Colors.White));
            listBox.Items.Add(new ListBoxItemHighlightable("Van", this.fontB, 4, GHIElectronics.TinyCLR.UI.Media.Colors.Blue, GHIElectronics.TinyCLR.UI.Media.Colors.White, GHIElectronics.TinyCLR.UI.Media.Colors.White));
            listBox.Items.Add(new ListBoxItemHighlightable("SUV", this.fontB, 4, GHIElectronics.TinyCLR.UI.Media.Colors.Blue, GHIElectronics.TinyCLR.UI.Media.Colors.White, GHIElectronics.TinyCLR.UI.Media.Colors.White));
            listBox.Items.Add(new ListBoxItemHighlightable("Sedan", this.fontB, 4, GHIElectronics.TinyCLR.UI.Media.Colors.Blue, GHIElectronics.TinyCLR.UI.Media.Colors.White, GHIElectronics.TinyCLR.UI.Media.Colors.White));
            listBox.Items.Add(new ListBoxItemHighlightable("Other", this.fontB, 4, GHIElectronics.TinyCLR.UI.Media.Colors.Blue, GHIElectronics.TinyCLR.UI.Media.Colors.White, GHIElectronics.TinyCLR.UI.Media.Colors.White));

            listBox.SelectedIndex = 0;

            Canvas.SetLeft(listBox, 160);
            Canvas.SetTop(listBox, yPriceText);

            this.canvas.Children.Add(listBox);


            var dropDown = new Dropdown()
            {
                Width  = 100,
                Height = 20,
                Font   = fontB
            };

            //var option = new ArrayList();

            //option.Add("text 1");
            //option.Add("text 2");
            //option.Add("text 3");
            //option.Add("text 4");
            //option.Add("text 5");
            //option.Add("text 6");
            //option.Add("text 7");

            //dropDown.Options = option;

            //Canvas.SetLeft(dropDown, 160);
            //Canvas.SetTop(dropDown, yPriceText);

            //this.canvas.Children.Add(dropDown);

            var imageVisa = new GHIElectronics.TinyCLR.UI.Controls.Image()
            {
                Source = BitmapImage.FromGraphics(Graphics.FromImage(Resources.GetBitmap(Resources.BitmapResources.visa)))
            };

            var imageMaster = new GHIElectronics.TinyCLR.UI.Controls.Image()
            {
                Source = BitmapImage.FromGraphics(Graphics.FromImage(Resources.GetBitmap(Resources.BitmapResources.master)))
            };

            var imagePaypal = new GHIElectronics.TinyCLR.UI.Controls.Image()
            {
                Source = BitmapImage.FromGraphics(Graphics.FromImage(Resources.GetBitmap(Resources.BitmapResources.paypal)))
            };

            Canvas.SetLeft(imageVisa, 20);
            Canvas.SetTop(imageVisa, yPriceText + 150);

            this.canvas.Children.Add(imageVisa);

            Canvas.SetLeft(imageMaster, 100);
            Canvas.SetTop(imageMaster, yPriceText + 150);

            this.canvas.Children.Add(imageMaster);

            Canvas.SetLeft(imagePaypal, 180);
            Canvas.SetTop(imagePaypal, yPriceText + 150);

            this.canvas.Children.Add(imagePaypal);


            // Add event
            premiumButton.Click  += this.Button_Click;
            standardButton.Click += this.Button_Click;
            basicButton.Click    += this.Button_Click;
            freeButton.Click     += this.Button_Click;

            return(this.canvas);
        }