protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName == CustomReturnEntry.ReturnTypeProperty.PropertyName)
            {
                var customEntry = sender as CustomReturnEntry;

                if (Control != null && customEntry != null)
                {
                    Control.ImeOptions = KeyboardHelpers.GetKeyboardButtonType(customEntry.ReturnType);
                }
            }
            else if (e.PropertyName == CustomReturnEntry.SelectAllOnFocusProperty.PropertyName)
            {
                var customEntry = sender as CustomReturnEntry;

                if (Control != null && customEntry != null)
                {
                    Control.SetSelectAllOnFocus(customEntry.SelectAllOnFocus);
                }
            }
            else if (e.PropertyName == CustomReturnEntry.ErrorMessageProperty.PropertyName)
            {
                var customEntry = sender as CustomReturnEntry;

                if (Control != null && customEntry != null)
                {
                    var icon = this.Context.GetDrawable(Resource.Drawable.entry_error_hint);
                    icon.SetBounds(0, 0, icon.IntrinsicWidth, icon.IntrinsicHeight);

                    Control.SetError(customEntry.ErrorMessage, icon);
                }
            }
        }
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            var customEntry = Element as CustomReturnEntry;


            if (Control != null && customEntry != null)
            {
                Control.ImeOptions = KeyboardHelpers.GetKeyboardButtonType(customEntry.ReturnType);

                //Control.FocusChange += (sender, args) =>
                //{
                //    if (args.HasFocus)
                //    {
                //        if (!string.IsNullOrEmpty(Control.Text))
                //        {
                //            Control.SetSelection(Control.Text.Length);
                //        }
                //    }
                //};


                //Control.FocusChange += Control_FocusChange;

                Control.EditorAction += Control_EditorAction;
                //Control.EditorAction += (object sender, TextView.EditorActionEventArgs args) =>
                //{
                //    if (args?.Event?.KeyCode == Keycode.Enter)
                //        return;

                //    var dtNow = DateTime.Now;
                //    bool shouldTriggerEvent = false;
                //    if(_lastEnterKeyPressed == null)
                //    {

                //        shouldTriggerEvent = true;
                //    }
                //    else
                //    {
                //        TimeSpan ts = dtNow - _lastEnterKeyPressed.Value;
                //        if(ts.TotalMilliseconds > 100)
                //        {
                //            shouldTriggerEvent = true;
                //        }
                //    }
                //    _lastEnterKeyPressed = dtNow;

                //    if (shouldTriggerEvent)
                //    {
                //        customEntry.ReturnCommand?.Execute(null);
                //        customEntry.OnRetrunKeyPress();
                //    }

                //};
            }
        }
 protected override (bool shouldExecute, bool isIlluminated) OnPress()
 {
     // only works if you also send the USB Keyboard scan code
     KeyboardHelpers.SendKeyPress(KeyCode.MEDIA_PLAY_PAUSE, 0xe8);
     return(false, true);
 }
        private bool SearchInGameState(out long debugRectAddr)
        {
            var  debugRectAddresses = new LinkedList <long>();
            byte debugValue         = 2;

            foreach (var section in MemorySectionsProcessor.Instance.Sections)
            {
                if (section.Category != SectionCategory.HEAP)
                {
                    continue;
                }

                var sectionSize  = section.Size.ToInt32();
                var sectionBytes = Memory.Instance.ReadBytes(section.Begin.ToInt64(), sectionSize);

                for (var i = 0; i < sectionBytes.Length; i++)
                {
                    if (sectionBytes[i] == debugValue)
                    {
                        debugRectAddresses.AddLast(section.Begin.ToInt64() + i);
                    }
                }
            }

            FocusWindow();

            while (debugRectAddresses.Count > 1)
            {
                debugValue++;

                if (debugValue == 3)
                {
                    debugValue = 0;
                }

                FocusWindow();
                KeyboardHelpers.KeyPress(Keys.F1);

                var currentNode = debugRectAddresses.Last;

                while (currentNode != null)
                {
                    var previous = currentNode.Previous;

                    if (Memory.Instance.ReadByte(currentNode.Value) != debugValue)
                    {
                        debugRectAddresses.Remove(currentNode);
                    }

                    currentNode = previous;
                }
            }

            if (debugRectAddresses.Count == 1)
            {
                debugRectAddr = debugRectAddresses.First.Value;
                return(true);
            }

            debugRectAddr = 0;
            return(false);
        }