Ejemplo n.º 1
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
 {
     switch (connectionId)
     {
     case 1:
         this.exit = ((UsingKeyboard.KeyButton)(target));
         return;
     }
     this._contentLoaded = true;
 }
Ejemplo n.º 2
0
        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Protected

        #region 키 업데이트하기 - UpdateKeys(panel)

        /// <summary>
        /// 키 업데이트하기
        /// </summary>
        /// <param name="panel">패널</param>
        protected void UpdateKeys(Panel panel)
        {
            foreach (UIElement child in panel.Children)
            {
                if (child is Panel)
                {
                    Panel content = child as Panel;

                    UpdateKeys(content);
                }
                else if (child is KeyButton)
                {
                    KeyButton keyButton = child as KeyButton;

                    keyButton.UpdateKey(IsPressedShift, IsPressedCapsLock, IsPressedHangul);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 후킹 마우스 클릭시 처리하기
        /// </summary>
        /// <param name="point">포인트</param>
        /// <param name="message">메시지</param>
        private void Hook_MouseClick(POINT point, MouseMessage message)
        {
            Point screenPoint = PointFromScreen(new Point(point.X, point.Y));

            KeyButton keyButton = VisualElementHelper.TryFindFromPoint <KeyButton>(this, screenPoint);

            if (keyButton == null)
            {
                return;
            }

            VirtualKeyCode keyCode = keyButton.KeyCode;

            if (message == MouseMessage.WM_LBUTTONDOWN)
            {
                this.previusKeyButton = keyButton;

                keyButton.IsPressed = true;

                if (keyButton.ClickMode == ClickMode.Press)
                {
                    keyButton.RaiseEvent(new RoutedEventArgs(KeyButton.ClickEvent));
                }
            }
            else if (message == MouseMessage.WM_LBUTTONUP)
            {
                if (keyCode != VirtualKeyCode.CAPITAL && keyCode != VirtualKeyCode.SHIFT)
                {
                    if (this.previusKeyButton != null)
                    {
                        this.previusKeyButton.IsPressed = false;

                        this.previusKeyButton = null;
                    }

                    keyButton.IsPressed = false;
                }

                if (keyButton.ClickMode == ClickMode.Release)
                {
                    keyButton.RaiseEvent(new RoutedEventArgs(KeyButton.ClickEvent));
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 키 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void KeyButton_Click(object sender, RoutedEventArgs e)
        {
            KeyButton keyButton = e.OriginalSource as KeyButton;

            if (keyButton == null || (IsEnableHook && keyButton.IsStylusCaptured))
            {
                return;
            }

            this.keyPressed = true;

            if (keyButton.KeyCode == VirtualKeyCode.CAPITAL)
            {
                IsPressedCapsLock = !IsPressedCapsLock;

                //Simulator.Keyboard.KeyPress(keyButton.KeyCode);
            }
            else if (keyButton.KeyCode == VirtualKeyCode.SHIFT)
            {
                IsPressedShift = !IsPressedShift;

                if (IsPressedShift)
                {
                    Simulator.Keyboard.KeyDown(keyButton.KeyCode);
                    keyButton.Background = new SolidColorBrush(Color.FromArgb(0xFF, 91, 165, 37));
                }
                else
                {
                    Simulator.Keyboard.KeyUp(keyButton.KeyCode);
                    keyButton.Background = Brushes.RoyalBlue;
                }
            }
            else if (keyButton.KeyCode == VirtualKeyCode.HANGUL)
            {
                IsPressedHangul = !IsPressedHangul;

                Simulator.Keyboard.KeyPress(keyButton.KeyCode);
            }
            else if (keyButton.KeyCode == VirtualKeyCode.CLEAR)
            {
                if (Keyboard.FocusedElement is TextBox)
                {
                    TextBox textBox = Keyboard.FocusedElement as TextBox;
                    textBox.Text = string.Empty;
                }
            }
            else if (keyButton.Name == "exit")
            {
                TextBox textBox = Keyboard.FocusedElement as TextBox;
                textBox.Text = string.Empty;
                Window.GetWindow(this).Close();
            }
            else if (keyButton.KeyCode == VirtualKeyCode.RETURN)
            {
                if (Keyboard.FocusedElement is TextBox)
                {
                    //ReturnString();

                    Window.GetWindow(this).Close();
                    //TextBox textBox = Keyboard.FocusedElement as TextBox;

                    //InputString = textBox.Text;
                    //if (!InputString.Equals(string.Empty))
                    //{
                    //    BindingExpression expression = textBox.GetBindingExpression(TextBox.TextProperty);
                    //    expression?.UpdateSource();

                    //    Window.GetWindow(this).Close();
                    //}
                }
            }
            else
            {
                Simulator.Keyboard.KeyPress(keyButton.KeyCode);

                //if (IsPressedShift)
                //{
                //    IsPressedShift = false;
                //    Simulator.Keyboard.KeyPress(keyButton.KeyCode);
                //    Simulator.Keyboard.KeyUp(VirtualKeyCode.SHIFT);
                //}
                //else
                //{
                //    Simulator.Keyboard.KeyPress(keyButton.KeyCode);
                //}
            }

            UpdateKeys();

            RaiseEvent(new RoutedEventArgs(VirtualKeyDownEvent, keyButton.KeyCode));

            this.keyPressed = false;
        }