Running a translucent window over multiple screens when moving a rectangle in real time

I have a small application that shows a translucent window on the entire desktop. The window does not appear on the taskbar and does not have a title

In this window, the user can drag the rectangle with the mouse. When the mouse button is released, a screenshot is taken from this area. (Something like a trimmer in windows 7)

To achieve this, the window contains a RectangleGeometry.

Now, in the CompositionTarget.Rendering event, the rectangle in which the place where the mouse was located when the mouse was pointed is also sized to cover the area to the current position of the mouse.

This works very well as long as only one monitor is connected. When a second higher resolution monitor is connected, performance drops dramatically.

Laptop display resolution is 1600x1200

The display that is connected has 1900x1200

Also, when connecting the display, he changed the main screen to a new one

Here is the window definition

<Window x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525"
        AllowsTransparency="True" Background="Transparent" WindowStyle="None" >

the geometry definition
<Path Fill="Black" Opacity="0.4" Stroke="Red" StrokeThickness="3">
   <Path.Data>
       <RectangleGeometry  x:Name="Inner" Rect="105,5,90,90"/>
   </Path.Data>
</Path>

Here is the piece of code that moves the rectangle

System.Windows.Rect location = new System.Windows.Rect(this.DragStart.X, this.DragStart.Y, width, height);

this.Inner.Rect = rect;

Does anyone have an idea on how to improve performance? Is it "normal" that performance drops significantly at higher resolutions with multiple displays?

+3
source share
1 answer

-, , CompositionTarget.Rendering - - , - ...

, 3-4 1920x1200. ( ) .

, win XP span win7 NVIDIA ( ).

, AllowsTransparency - , !

- ( WPF win XP, NVIDIA Quadro).

+2

Source: https://habr.com/ru/post/1790391/


All Articles