예제 #1
0
        public void ProcessInputTest()
        {
            var textStream        = new TextStreamModel();
            var keyboardViewModel = new KeyboardViewModel(textStream);
            var target            = new TextStreamViewModel(textStream)
            {
                Text = "BEIRUT"
            };
            const string inputText = "B";

            target.ProcessInput(inputText);
            Assert.AreEqual(1, target.CharacterIndex);
        }
예제 #2
0
        /// <summary>
        /// Definitely a lot easier to handle events in code behind
        /// </summary>
        /// <param name="input"></param>
        private void HandleInput(string input)
        {
            TextStreamViewModel vm = this.DataContext as TextStreamViewModel;

            if (vm == null)
            {
                Debug.Assert(false, "Viewmodel should never be null. Check DataContext data type");
                return;
            }

            vm.ProcessInput(input);
            this.TextBox.Select(vm.CharacterIndex, 1);
            this.TextBox.Focus();
        }