Beispiel #1
0
        private void InputSystemOnKeyChange(Input.IInput obj)
        {
            Dispatcher.Invoke(() => {
                SetBlock(_elmGrid[(int)(Math.Round(obj.BlockPos.X + 1)), (int)(Math.Round(-obj.BlockPos.Y + 1))]);

                if (Math.Abs(obj.CharPos.X) > 0.1f || Math.Abs(obj.CharPos.Y) > 0.1f)
                {
                    var c = _activeElement.GetStr((int)obj.CharPos.X, (int)-obj.CharPos.Y);
                    OnKey?.Invoke(c);
                }
            });
        }
        public async Task <IVidResult> GetVid(IYouTubeLiveServer server, Input.IInput input)
        {
            if (input is Input.Vid vid)
            {
                return(new VidResult {
                    Vid = vid.Raw
                });
            }
            else if (input is WatchUrl watchUrl)
            {
                return(new VidResult {
                    Vid = watchUrl.Vid
                });
            }
            else if (input is Input.ChannelUrl channelUrl)
            {
                var channelId = channelUrl.ChannelId;
                return(await GetResultFromChannelId(server, channelId));
            }
            else if (input is Input.UserUrl userUrl)
            {
                var userId    = userUrl.UserId;
                var channelId = await GetChannelIdFromUserId(server, userId);

                return(await GetResultFromChannelId(server, channelId));
            }
            else if (input is Input.CustomChannelUrl customChannelUrl)
            {
                var(channelId, _) = await TryGetChannelIdFromCustomChannel(server, customChannelUrl.Raw);

                return(await GetResultFromChannelId(server, channelId));
            }
            else if (input is Input.StudioUrl studioUrl)
            {
                return(new VidResult {
                    Vid = studioUrl.Vid
                });
            }
            return(new NoVidResult());
        }
        private void InputSystemOnKeyChange(Input.IInput input)
        {
            if (input.OpenClose && _isEnabled == false)
            {
                input.Enable();
                Show();
                _isEnabled = true;
            }
            else if (_isEnabled == false)
            {
                return;
            }

            else if (input.OpenClose && _isEnabled)
            {
                input.Disable();
                Hide();
                Reset();
                InvalidateVisual();
                _isEnabled = false;
                return;
            }

            if (input.Delete)
            {
                if (_caretIndex > 0 && TextBox.Text.Length > 0)
                {
                    CaretIndex--;
                    RemoveText();
                }
                SendKey("{BS}");
            }

            if (input.Space)
            {
                InsertText(" ");
            }

            if (input.Enter)
            {
                TextBox.Text = TextBox.Text.Substring(_caretIndex);
                CaretIndex   = 0;
                SendKey("{ENTER}");
            }

            if (input.MoveLeft)
            {
                CaretIndex--;
                SendKey("{LEFT}");
            }
            else if (input.MoveRight)
            {
                CaretIndex++;
                SendKey("{RIGHT}");
            }


            if (input.ChangeSymbols)
            {
                InputControl.SwitchSymbols();
            }
            else if (input.ChangeCase)
            {
                InputControl.SwitchUppercase();
            }
            else
            {
                InputControl.SwitchLowercase();
            }
        }
 private void OpenCloseHandle(Input.IInput obj)
 {
     Dispatcher.Invoke(() => {
         InputSystemOnKeyChange(obj);
     });
 }