Exemplo n.º 1
0
        /// <summary>
        /// 후킹 이용 가능 여부 속성 변경시 콜백 처리하기
        /// </summary>
        /// <param name="d">의존 객체</param>
        /// <param name="e">이벤트 인자</param>
        private static void IsEnableHookPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            VirtualKeyboard virtualKeyboard = d as VirtualKeyboard;

            if ((bool)e.NewValue)
            {
                virtualKeyboard.UpdateHookData();

                HookingHelper.UseGlobal = virtualKeyboard.UseGlobal;

                HookingHelper.MouseClick += virtualKeyboard.Hook_MouseClick;
                HookingHelper.KeyClick   += virtualKeyboard.Hook_KeyClick;

                HookingHelper.Start();
            }
            else
            {
                HookingHelper.MouseClick -= virtualKeyboard.Hook_MouseClick;
                HookingHelper.KeyClick   -= virtualKeyboard.Hook_KeyClick;

                HookingHelper.Stop();
            }
        }
Exemplo n.º 2
0
        ////////////////////////////////////////////////////////////////////////////////////////// Private
        //////////////////////////////////////////////////////////////////////////////// Event

        #region 사용자 컨트롤 로드시 처리하기 - UserControl_Loaded(sender, e)

        /// <summary>
        /// 사용자 컨트롤 로드시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }

            RenderTransform = new TranslateTransform();

            AddHandler(KeyButton.ClickEvent, (RoutedEventHandler)KeyButton_Click);

            if (IsEnableHook)
            {
                UpdateHookData();

                HookingHelper.KeyClick += Hook_KeyClick;

                HookingHelper.UseGlobal = UseGlobal;

                HookingHelper.Start();
            }

            Application.Current.MainWindow.Closed += (sender2, e2) => HookingHelper.Stop();
        }