Ejemplo n.º 1
0
        public void HideHexKeyboard()
        {
            KeyboardView keyboardView = (KeyboardView)FindViewById <KeyboardView>(Resource.Id.keyboardview);

            keyboardView.Visibility = ViewStates.Gone;
            keyboardView.Enabled    = false;
        }
Ejemplo n.º 2
0
        public void SetUp()
        {
            _keyboard     = new GameObject();
            _keyboardView = _keyboard.AddComponent <KeyboardView>();
            const int numberOfKeys = 2;

            _keyboardView.Buttons = new Button[numberOfKeys];
            for (var i = 0; i < _keyboardView.Buttons.Length; i++)
            {
                var button = new GameObject();
                var text   = new GameObject();
                button.transform.SetParent(_keyboard.transform);
                text.transform.SetParent(button.transform);
                text.AddComponent <Text>().text = ('a' + i).ToString();
                _keyboardView.Buttons[i]        = button.AddComponent <Button>();
                _keyboardView.Buttons[i].image  = button.AddComponent <Image>();


                Assert.AreNotEqual(InGameViewModel.CorrectColor,
                                   ColorUtility.ToHtmlStringRGB(_keyboardView.Buttons[i].image.color));
                Assert.IsTrue(_keyboardView.Buttons[i].interactable);
            }


            _inGameViewModel = new InGameViewModel();
            _keyboardView.SetModel(_inGameViewModel);
        }
        private void CreateCustomKeyboard()
        {
            var activity = Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity;

            var rootView         = activity.FindViewById(global::Android.Resource.Id.Content);
            var activityRootView = (ViewGroup)((ViewGroup)rootView).GetChildAt(0);

            this.mKeyboardView = activityRootView.FindViewById <KeyboardView>(Droid.Resource.Id.customKeyboard);

            // If the previous line fails, it means the keyboard needs to be created and added
            if (this.mKeyboardView == null)
            {
                this.mKeyboardView =
                    (KeyboardView)activity.LayoutInflater.Inflate(Resource.Layout.customkeyboard, null);
                this.mKeyboardView.Id                   = Resource.Id.customKeyboard;
                this.mKeyboardView.Focusable            = true;
                this.mKeyboardView.FocusableInTouchMode = true;

                this.mKeyboardView.Release += (sender, e) => { };

                var layoutParams = new RelativeLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);
                layoutParams.AddRule(LayoutRules.AlignParentBottom);
                activityRootView.AddView(this.mKeyboardView, layoutParams);
            }
            EditText.SetTextIsSelectable(true);
            // EditText.SetCursorVisible(true);
            this.HideKeyboardView();

            this.mKeyboard = new Keyboard(this.context, Resource.Xml.special_keyboard);

            this.SetCurrentKeyboard();
        }
Ejemplo n.º 4
0
 public override View OnCreateInputView()
 {
     view          = (KeyboardView)LayoutInflater.Inflate(Resource.Layout.keyboardLayout, null);
     keyboard      = new Keyboard(this, Resource.Xml.Qwerty);
     view.Keyboard = keyboard;
     view.OnKeyboardActionListener = this;
     return(view);
 }
Ejemplo n.º 5
0
 public override View OnCreateInputView()
 {
     kv          = (KeyboardView)LayoutInflater.Inflate(Resource.Layout.keyboard, null);
     keyboard    = new Keyboard(this, Resource.Xml.qwerty);
     kv.Keyboard = keyboard;
     kv.OnKeyboardActionListener = this;
     return(kv);
 }
Ejemplo n.º 6
0
        public override void OnBackPressed()
        {
            KeyboardView keyboardView = (KeyboardView)FindViewById <KeyboardView>(Resource.Id.keyboardview);

            if (keyboardView.Visibility == ViewStates.Visible)
            {
                HideHexKeyboard();
            }
            else
            {
                base.OnBackPressed();
            }
        }
Ejemplo n.º 7
0
        public void ShowHexKeyboard(View v)
        {
            var          bottomUp     = AnimationUtils.LoadAnimation(this, Resource.Xml.slideup);
            KeyboardView keyboardView = (KeyboardView)FindViewById <KeyboardView>(Resource.Id.keyboardview);

            keyboardView.StartAnimation(bottomUp);
            keyboardView.Visibility = ViewStates.Visible;
            keyboardView.Enabled    = true;
            if (v != null)
            {
                ((InputMethodManager)GetSystemService(InputMethodService)).HideSoftInputFromWindow(v.WindowToken, 0);
            }
        }
Ejemplo n.º 8
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.º 9
0
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        // Set our view from the "main" layout resource
        SetContentView(Resource.Layout.Main);

        _keyBoard              = new Keyboard(this, Resource.Xml.keyboard);
        _keyboardView          = FindViewById <KeyboardView>(Resource.Id.keyboard_view);
        _keyboardView.Keyboard = _keyBoard;
        _keyboardView.OnKeyboardActionListener = new MyKeyboardListener(this);
        _targetView        = FindViewById <EditText>(Resource.Id.target);
        _targetView.Touch += (sender, args) => {
            var bottomUp = AnimationUtils.LoadAnimation(this, Resource.Animation.slide_up);
            _keyboardView.StartAnimation(bottomUp);
            _keyboardView.Visibility = ViewStates.Visible;
            args.Handled             = true;
        };
    }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
        public FeedbackPage()
            : base(typeof(FeedbackViewModel), typeof(FeedbackContentUI))
        {
            BackgroundColor         = MainStyles.StatusBarColor.FromResources <Color>();
            Content.BackgroundColor = MainStyles.MainBackgroundColor.FromResources <Color>();

            var loadingColor = MainStyles.LoadingColor.FromResources <Color>();

            LoadingActivityIndicator.Color = loadingColor;
            LoadingActivityText.TextColor  = loadingColor;

            var appBar = new TitleBar(this, TitleBar.BarBtnEnum.bbBack)
            {
                BarColor   = MainStyles.StatusBarColor.FromResources <Color>(),
                TitleStyle = LabelStyles.PageTitleStyle.FromResources <Style>(),
                BtnBack    =
                {
                    Source = contentUI.IconBack
                }
            };

            appBar.SetBinding(TitleBar.TitleProperty, "Title");

            var txtNameTitle = new Label
            {
                Style = LabelStyles.FeedbackLabelStyle.FromResources <Style>(),
                Text  = contentUI.TxtName
            };

            _txtName = new Entry
            {
                Style     = LabelStyles.FeedbackEntryStyle.FromResources <Style>(),
                MaxLength = 30
            };
            _txtName.SetBinding(Entry.TextProperty, "Name");
            _txtName.SetBinding(IsEnabledProperty, "IsNotLoading");

            var txtCommentTitle = new Label
            {
                Style = LabelStyles.FeedbackLabelStyle.FromResources <Style>(),
                Text  = contentUI.TxtComment
            };

            _txtComment = new Editor
            {
                Style           = LabelStyles.FeedbackEditorStyle.FromResources <Style>(),
                VerticalOptions = LayoutOptions.FillAndExpand,
                MaxLength       = 1000
            };
            _txtComment.SetBinding(Editor.TextProperty, "Comment");
            _txtComment.SetBinding(IsEnabledProperty, "IsNotLoading");

            var btnSubmit = new ButtonExtended
            {
                Style             = LabelStyles.ButtonStyle.FromResources <Style>(),
                Text              = contentUI.TxtSubmit.ToUpper(),
                HorizontalOptions = LayoutOptions.Center,
                WidthRequest      = 150
            };

            btnSubmit.SetBinding(IsEnabledProperty, "IsValidFeedback");
            btnSubmit.SetBinding(IsVisibleProperty, "IsNotLoading");
            btnSubmit.Clicked += viewModel.BtnSubmit_Clicked;

            var activityIndicator = new ActivityIndicator
            {
                Color             = loadingColor,
                HorizontalOptions = LayoutOptions.Center
            };

            activityIndicator.SetBinding(IsVisibleProperty, "IsSubmitting");
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsSubmitting");

            _layoutFeedback = new KeyboardView
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Star
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    }
                }
            };

            _layoutFeedback.Children.Add(txtNameTitle, 0, 0);
            _layoutFeedback.Children.Add(_txtName, 0, 1);
            _layoutFeedback.Children.Add(txtCommentTitle, 0, 2);
            _layoutFeedback.Children.Add(_txtComment, 0, 3);
            _layoutFeedback.Children.Add(btnSubmit, 0, 4);
            _layoutFeedback.Children.Add(activityIndicator, 0, 5);

            var layoutContainer = new ContentView
            {
                Padding         = 24,
                Content         = _layoutFeedback,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            var safeAreaHelper = new SafeAreaHelper();

            safeAreaHelper.UseSafeArea(this, SafeAreaHelper.CustomSafeAreaFlags.Top);
            safeAreaHelper.UseSafeArea(appBar.BtnBack, SafeAreaHelper.CustomSafeAreaFlags.Left);
            safeAreaHelper.UseSafeArea(layoutContainer, SafeAreaHelper.CustomSafeAreaFlags.Horizontal);

            ContentLayout.Children.Add(appBar);
            ContentLayout.Children.Add(layoutContainer);
        }
Ejemplo n.º 12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            RequestWindowFeature(WindowFeatures.NoTitle);
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.GameViewWithKeyPad);

            board = new Board();



            // Get checkouts
            using (StreamReader sr = new StreamReader(Assets.Open("Checkouts.txt")))
            {
                char[] delim = { ':' };
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    string[] words = line.Split(delim);
                    int      scoreValue;
                    int.TryParse(words[0], out scoreValue);
                    string bestCheckout = words[1];
                    board.Checkouts.Add(scoreValue, bestCheckout);
                }
            }

            using (StreamReader sr = new StreamReader(Assets.Open("twoDartCheckouts.txt")))
            {
                char[] delim = { ':' };
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    string[] words = line.Split(delim);
                    int      scoreValue;
                    int.TryParse(words[0], out scoreValue);
                    string bestCheckout = words[1];
                    board.TwoDartCheckouts.Add(scoreValue, bestCheckout);
                }
            }

            BackArrow = FindViewById <ImageButton>(Resource.Id.backButton);

            player1Name      = FindViewById <TextView>(Resource.Id.player1Name);
            player2Name      = FindViewById <TextView>(Resource.Id.player2Name);
            player1Score     = FindViewById <TextView>(Resource.Id.player1Score);
            player2Score     = FindViewById <TextView>(Resource.Id.player2Score);
            player1Checkout  = FindViewById <TextView>(Resource.Id.player1CheckOut);
            player2Checkout  = FindViewById <TextView>(Resource.Id.player2CheckOut);
            Player1Layout    = FindViewById <LinearLayout>(Resource.Id.player1Details);
            Player2Layout    = FindViewById <LinearLayout>(Resource.Id.player2Details);
            Player1ScoreList = FindViewById <ListView>(Resource.Id.player1ScoreList);
            Player2ScoreList = FindViewById <ListView>(Resource.Id.player2ScoreList);

            ScoreEditText = FindViewById <EditText>(Dartboard.Resource.Id.scoreEditText);
            ScoreEditText.EditorAction += ScoreEditText_EditorAction;
            ScoreEditText.Click        += ScoreEditText_Click;



            Player1.name = Intent.GetStringExtra("p1name");
            Player2.name = Intent.GetStringExtra("p2name");

            if (Intent.HasExtra("gameResumed") && Intent.GetBooleanExtra("gameResumed", false) == true)
            {
                Player1.score = Convert.ToInt32(Intent.GetStringExtra("p1Score"));
                Player2.score = Convert.ToInt32(Intent.GetStringExtra("p2Score"));
                Player1.turn  = Convert.ToBoolean(Intent.GetStringExtra("p1Turn"));
                Player2.turn  = Convert.ToBoolean(Intent.GetStringExtra("p2Turn"));
                legsPlayed    = Convert.ToInt32(Intent.GetStringExtra("legsPlayed"));
                legsToPlay    = Convert.ToInt32(Intent.GetStringExtra("legToPlay"));

                player1Score.Text = Player1.score.ToString();
                player2Score.Text = Player2.score.ToString();

                if (Player1.score <= 170 || Player2.score <= 170)
                {
                    player1Checkout.Text       = GameLogic.GetCheckout(Player1, board);
                    player1Checkout.Visibility = ViewStates.Visible;
                    player2Checkout.Text       = GameLogic.GetCheckout(Player2, board);
                    player2Checkout.Visibility = ViewStates.Visible;
                }
            }
            else
            {
                startScore = Intent.GetIntExtra("startingScore", 101);
                legsToPlay = Intent.GetIntExtra("numLegs", 1);

                player1Score.Text = startScore.ToString();
                player2Score.Text = startScore.ToString();
                Player1.score     = startScore;
                Player2.score     = startScore;
                Player1.turn      = true;
                Player2.turn      = false;
            }

            player1Name.Text = Player1.name;
            player2Name.Text = Player2.name;

            player1Score.TextChanged += Player1Score_TextChanged;
            player2Score.TextChanged += Player2Score_TextChanged;

            if (Player1.turn)
            {
                Player1Layout.SetBackgroundColor(Android.Graphics.Color.Rgb(236, 229, 240));
                Player1Layout.Background.SetAlpha(50);
            }
            else
            {
                Player2Layout.SetBackgroundColor(Android.Graphics.Color.Rgb(236, 229, 240));
                Player2Layout.Background.SetAlpha(50);
            }



            Players.Add(Player1);
            Players.Add(Player2);



            BackArrow.Click += BackArrow_Click;



            // Set checkouts if playing 101
            if (startScore == 101)
            {
                string value;
                board.Checkouts.TryGetValue(101, out value);
                player1Checkout.Text       = value;
                player1Checkout.Visibility = ViewStates.Visible;
                player2Checkout.Text       = value;
                player2Checkout.Visibility = ViewStates.Visible;
            }

            // Set up keyboard
            Keyboard     kbd = new Keyboard(this, Resource.Drawable.dartsNumberPad);
            KeyboardView kbv = FindViewById <KeyboardView>(Resource.Id.customKBD);

            kbv.Keyboard = kbd;
            var myKeyboardListener = new KeyboardListener(this);

            kbv.PreviewEnabled           = false;
            kbv.OnKeyboardActionListener = myKeyboardListener;
            kbv.Key += (sender, e) => {
                long     eventTime = JavaSystem.CurrentTimeMillis();
                KeyEvent ev        = new KeyEvent(eventTime, eventTime, KeyEventActions.Down, e.PrimaryCode, 0, 0, 0, 0, KeyEventFlags.SoftKeyboard | KeyEventFlags.KeepTouchMode);

                if (ev.KeyCode.ToString() == "55001")
                {
                    if (undoEnabled)
                    {
                        if (Player1.turn)
                        {
                            Player2.score    += previousScore;
                            player2Score.Text = Player2.score.ToString();
                        }
                        else
                        {
                            Player1.score    += previousScore;
                            player1Score.Text = Player1.score.ToString();
                        }
                        undoEnabled = false;
                        GameLogic.SwitchPlayer(Player1, Player2, this);
                    }
                    else
                    {
                        this.DispatchKeyEvent(ev);
                    }
                }
                else
                {
                    this.DispatchKeyEvent(ev);
                }
            };



            inputMethodManager = (InputMethodManager)GetSystemService(Context.InputMethodService);
            inputMethodManager.HideSoftInputFromWindow(ScoreEditText.WindowToken, 0);
        }
Ejemplo n.º 13
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            this.Window.SetFlags(WindowManagerFlags.KeepScreenOn, WindowManagerFlags.KeepScreenOn);
            SetContentView(Resource.Layout.Main);

            ListView myview = FindViewById <ListView>(Resource.Id.pingListView);

            myview.Adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, messages);

            interpreter.CANMessageReceived       += CANMessageReceived;
            interpreter.CANMaskSettingReceived   += CANMaskSettingReceived;
            interpreter.CANFilterSettingReceived += CANFilterSettingReceived;

            KeyboardView keyboardView = (KeyboardView)FindViewById <KeyboardView>(Resource.Id.keyboardview);

            keyboardView.Keyboard                 = new Keyboard(this, Resource.Xml.hexkeyboard);
            keyboardView.PreviewEnabled           = false;
            keyboardView.OnKeyboardActionListener = new HexKeyboardListener(this);



            Button button = FindViewById <Button>(Resource.Id.prefsButton);

            button.Click += delegate
            {
                AlertDialog.Builder alert        = new AlertDialog.Builder(this);
                List <string>       descriptions = new List <string>();
                foreach (BluetoothDevice device in BluetoothSerialPort.BondedSerialDevices)
                {
                    descriptions.Add(device.Name + " - " + device.Address);
                }

                alert.SetTitle("Choose SPP device:");
                alert.SetItems(descriptions.ToArray(),
                               async(sender, e) =>
                {
                    string deviceDescription = descriptions[e.Which];
                    string[] descripSplit    = deviceDescription.Split(" - ".ToCharArray());
                    string mac = descripSplit[descripSplit.Length - 1];
                    if (mac != null)
                    {
                        Task serialTask = StartSerial(mac);
                        SavePreferences();
                        await serialTask;
                    }
                });

                alert.SetNegativeButton("Cancel", (senderAlert, args) =>
                {
                    Toast.MakeText(this, "Cancelled!", ToastLength.Short).Show();
                });

                Dialog dialog = alert.Create();
                dialog.Show();
            };

            button        = FindViewById <Button>(Resource.Id.startstopButton);
            button.Click += StartStopButton_Click;

            button        = FindViewById <Button>(Resource.Id.resetMaskFilterButton);
            button.Click += async delegate
            {
                ushort setting = 0x1000;
                await interpreter.SendNewMask(0, setting);

                await interpreter.SendNewMask(1, setting);

                await interpreter.SendNewFilter(0, setting);

                await interpreter.SendNewFilter(1, setting);

                await interpreter.SendNewFilter(2, setting);

                await interpreter.SendNewFilter(3, setting);

                await interpreter.SendNewFilter(4, setting);

                await interpreter.SendNewFilter(5, setting);
            };

            setEditText(Resource.Id.mask1EditText);
            setEditText(Resource.Id.mask2EditText);
            setEditText(Resource.Id.filter1EditText);
            setEditText(Resource.Id.filter2EditText);
            setEditText(Resource.Id.filter3EditText);
            setEditText(Resource.Id.filter4EditText);
            setEditText(Resource.Id.filter5EditText);
            setEditText(Resource.Id.filter6EditText);

            this.Window.SetSoftInputMode(SoftInput.StateAlwaysHidden);

            LoadPreferences();
        }
Ejemplo n.º 14
0
        public VehiclePlateKeyboard(Context context) : base(context)
        {
            var contentView = PutContentView(
                Resource.Layout.keyboard_vehicle_plate);

            mNumbersTextView[0] = contentView.FindViewById <TextView>(
                Resource.Id.keyboard_number_0);
            mNumbersTextView[1] = contentView.FindViewById <TextView>(
                Resource.Id.keyboard_number_1);
            mNumbersTextView[2] = contentView.FindViewById <TextView>(
                Resource.Id.keyboard_number_2);
            mNumbersTextView[3] = contentView.FindViewById <TextView>(
                Resource.Id.keyboard_number_3);
            mNumbersTextView[4] = contentView.FindViewById <TextView>(
                Resource.Id.keyboard_number_4);
            mNumbersTextView[5] = contentView.FindViewById <TextView>(
                Resource.Id.keyboard_number_5);
            mNumbersTextView[6] = contentView.FindViewById <TextView>(
                Resource.Id.keyboard_number_6);

            foreach (var item in mNumbersTextView)
            {
                item.SoundEffectsEnabled = false;
                item.Click += TextViewItemClick;
            }

            mProvinceKeyboard_0 = new Android.InputMethodServices.Keyboard(
                context, Resource.Xml.keyboard_vehicle_province_0);
            mProvinceKeyboard_1 = new Android.InputMethodServices.Keyboard(
                context, Resource.Xml.keyboard_vehicle_province_1);
            mCityCodeKeyboard = new Android.InputMethodServices.Keyboard(
                context, Resource.Xml.keyboard_vehicle_code);
            mNumberKeyboard = new Android.InputMethodServices.Keyboard(
                context, Resource.Xml.keyboard_vehicle_number);
            mNUmberExtraKeyboard = new Android.InputMethodServices.Keyboard(
                context, Resource.Xml.keyboard_vehicle_number_extra);

            mKeyboardView = contentView.FindViewById <KeyboardView>(
                Resource.Id.keyboard_view);

            mKeyboardView.Key += (sender, keyCodes) =>
            {
                int  code     = (int)keyCodes.KeyCodes[0];
                char charCode = (char)keyCodes.PrimaryCode;
                if (400 < code && code < 500)
                {
                    charCode = PROVINCE_CHINESE[code - 400];
                }
                else if (500 < code)
                {
                    charCode = EXTRA_CHINESE[code - 500];
                }
                mSelectedTextView.Text = ((char)charCode).ToString();
                NextNumber();
            };
            mKeyboardView.PreviewEnabled = false;

            mCommitButton = contentView.FindViewById <Button>(
                Resource.Id.keyboard_commit);
            mCommitButton.Click += (s, e) =>
            {
                string number = GetInput(mNumbersTextView);
                if (number.Length == mNumbersTextView.Length)
                {
                    OnFinish(number);
                    Dismiss();
                }
            };
        }