コード例 #1
0
ファイル: Overlay.xaml.cs プロジェクト: WildGenie/Watrix
        private void AddDirectionToPoint(Point p, Direction direction)
        {
            switch (direction)
            {
            case Direction.UP:
                p.Y = Math.Max(0, p.Y - 1);
                break;

            case Direction.DOWN:
                p.Y = Math.Min(_matrix.Rows - 1, p.Y + 1);
                break;

            case Direction.LEFT:
                p.X = Math.Max(0, p.X - 1);
                break;

            case Direction.RIGHT:
                p.X = Math.Min(_matrix.Columns - 1, p.X + 1);
                break;
            }
        }
コード例 #2
0
ファイル: Overlay.xaml.cs プロジェクト: WildGenie/Watrix
        private void OnDesktopUpdate(DesktopUpdateMessage msg)
        {
            _timer?.Stop();
            Dispatcher.BeginInvoke((Action) delegate
            {
                if (msg.WithWindow)
                {
                    _matrix.CaptureForegroundWindow();
                }
                Show();
                Topmost     = true;
                var current = new WindowInteropHelper(this).Handle;
                _matrix.PinWindow(current);

                var p = new Point(msg.X, msg.Y);
                AddDirectionToPoint(p, msg.Direction);
                UpdateTiles(p.Y, p.X);
                if (msg.WithWindow)
                {
                    MoveWindow(msg.Direction);
                }
                else
                {
                    MoveDesktop(msg.Direction);
                }

                _timer = new DispatcherTimer
                {
                    Interval = TimeSpan.FromSeconds(0.3)
                };
                _timer.Start();
                _timer.Tick += (sender, _) =>
                {
                    (sender as DispatcherTimer)?.Stop();
                    Hide();
                };

                Debug.WriteLine($"DesktopUpdateMessage: {msg}");
            });
        }