private void windowDragHere_MouseMove(object sender, MouseEventArgs e)
        {
            if (!drag_here_mode_)
            {
                // drag_hereモードでなければ何もしない
                return;
            }

            Point   screen_location = this.windowDragHere.PointToScreen(e.Location);
            UIntPtr next_window     = ExternalAPI.WindowFromPoint(screen_location.X, screen_location.Y);

            if (next_window == UIntPtr.Zero)
            {
                // nop
                return;
            }

            if (current_window_ == UIntPtr.Zero)
            {
                // 初回実行: どうせDragHereボタンが取得されているはずなので、一回は無視
                current_window_ = next_window;
            }

            if (next_window == current_window_)
            {
                // 対象ウィンドウが変わっていなければ何も描画する必要はない
                return;
            }

            // ウィンドウが異なる場合、描画していたウィンドウをアップデートして描画内容を消しておく
            ClearCurrentWindow();

            // 現在処理中のウィンドウを更新
            current_window_   = next_window;
            current_dc_       = ExternalAPI.GetDC(current_window_);
            current_graphics_ = System.Drawing.Graphics.FromHdc(current_dc_);

            // 描画
            ExternalAPI.RECT current_rect;
            ExternalAPI.GetClientRect(current_window_, out current_rect);
            current_graphics_.DrawRectangle(orange_pen_,
                                            current_rect.left,
                                            current_rect.top,
                                            current_rect.right - current_rect.left,
                                            current_rect.bottom - current_rect.top);
        }
示例#2
0
        /// @brief マルチモニタを考慮してウィンドウ領域を求める
        public static Rectangle GetWindowRectangle(UIntPtr window)
        {
            Rectangle window_rectangle = new Rectangle(0, 0, 0, 0);

            if (window == ExternalAPI.GetDesktopWindow())
            {
                window_rectangle = SystemInformation.VirtualScreen;
            }
            else if (ExternalAPI.IsWindow(window))
            {
                ExternalAPI.RECT window_rect;
                ExternalAPI.GetClientRect(window, out window_rect);
                window_rectangle.X      = window_rect.left;
                window_rectangle.Y      = window_rect.top;
                window_rectangle.Width  = window_rect.right - window_rect.left;
                window_rectangle.Height = window_rect.bottom - window_rect.top;
            }
            return(window_rectangle);
        }
 void ClearCurrentWindow()
 {
     // 描画内容を消しておく
     if (current_window_ != UIntPtr.Zero)
     {
         ExternalAPI.RECT current_rect;
         ExternalAPI.GetClientRect(current_window_, out current_rect);
         ExternalAPI.InvalidateRect(current_window_, ref current_rect, true);
     }
     // Graphicsを破棄
     if (current_graphics_ != null)
     {
         current_graphics_.Dispose();
         current_graphics_ = null;
     }
     // DCを破棄
     if (current_dc_ != IntPtr.Zero)
     {
         ExternalAPI.ReleaseDC(current_window_, current_dc_);
         current_dc_ = IntPtr.Zero;
     }
 }
 public void SetWindowFromPoint(int screen_x, int screen_y) {
   UIntPtr window = ExternalAPI.WindowFromPoint(screen_x, screen_y);
   ((viewmodel.LayoutParameter)layout_parameters_.Current).SetWindow(window);
 }