示例#1
0
        private void OnMouseMove(MouseHook.MouseEventArgs32 e)
        {
            User32.POINT ptCurr = e.MessageData.pt;
            if (ptCurr.Equals(_prev))
            {
                //Debug.WriteLine("SKIP => Mouse Position:{0}", _prev);
                return; //already been there
            }

            User32.POINT ptPrev = _prev;
            _prev = e.MessageData.pt;

            if (IsButtonDown || _screens.Count == 1 || !MouseHook.Hook.Enabled)
            {
                return; //ignore dragging or if one sceen only or if not enabled
            }
            int screenSrcIndex = WpfScreen.ScreenIndexFromPoint(ptPrev.X, ptPrev.Y, _screens);

            if (screenSrcIndex < 0) //point out of screens
            {
                return;
            }

            int screenDstIndex = WpfScreen.ScreenIndexFromPoint(ptCurr.X, ptCurr.Y, _screens);

            if (screenSrcIndex == screenDstIndex)
            {
                return;
            }

            User32.POINT ptCorrected = CorrectIntoOtherScreenProportionally(ptPrev, ptCurr, screenSrcIndex);
            if (ptCorrected.X != 0 || ptCorrected.Y != 0)
            {
                _prev = ptCorrected; //already handled
                User32.SetCursorPos(ptCorrected.X, ptCorrected.Y);
            }
        }
        private void InitializeComponent(WindowStartupLocation startupLocation, Point location)
        {
            this.DataContext = this;

            InitializeComponent();

            this.WindowStartupLocation = startupLocation;

            this.Draggable(true);

            if (startupLocation == WindowStartupLocation.Manual)
            {
                int screenIdx = WpfScreen.ScreenIndexFromPoint(location.X, location.Y);
                if (screenIdx >= 0)
                {
                    this.Left = location.X;
                    this.Top  = location.Y;
                }
                else //show on first visible screen
                {
                    WpfScreen screen = WpfScreen.AllScreens()[0];
                    this.Left = screen.DeviceBounds.Left + 100;
                    this.Top  = screen.DeviceBounds.Top + 100;
                }
            }

            m_Timer.Interval = TimeSpan.FromMilliseconds(100);
            m_Timer.Tick    += Timer_Tick;

            m_Timer.Start();
            _timer_count = 0;

            _progress.ProgressTheme = GradientProgressBar.TicksTheme.GetBase100Theme();
            _progress.Maximum       = 100;
            _progress.TickColor     = Brushes.Navy;
        }