WPF Canvas с использованием всех экрановC#

Место общения программистов C#
Anonymous
WPF Canvas с использованием всех экранов

Сообщение Anonymous »

На моих мониторах установлены следующие настройки:
Изображение

Я работаю над приложением для создания снимков экрана с помощью C# - WPF, и когда я пытаюсь разместить холст на мониторе 3, он все равно загружается в основных окнах (монитор 2). >
Я попробовал Canvas.SetLeft и Canvas.SetTop, используя VirtualScreen.Left и VirtualScreen.Top (значения в порядке, те же значения для той же ситуации в другом приложении на Java), но это не сработало.
private void InitializeEditor()
{
var left = System.Windows.Forms.SystemInformation.VirtualScreen.Left;
var top = System.Windows.Forms.SystemInformation.VirtualScreen.Top;
var width = System.Windows.Forms.SystemInformation.VirtualScreen.Width;
var height = System.Windows.Forms.SystemInformation.VirtualScreen.Height;

MainCanvas = new Canvas();
MainCanvas.Background = Brushes.Black;
Content = MainCanvas;

MainImage = new Image();
Canvas.SetLeft(MainImage, 0);
Canvas.SetTop(MainImage, 0);
//Canvas.SetLeft(MainImage, left);
//Canvas.SetTop(MainImage, top);

SecondImage = new Image();

Canvas.SetLeft(SecondImage, 0);
Canvas.SetTop(SecondImage, 0);
//Canvas.SetLeft(SecondImage, left);
//Canvas.SetTop(SecondImage, top);
SecondImage.Opacity = 0.6;

SelectedArea = new();
screenshotAreaPickingState = new(this);
screenshotAreaMovingState = new(this);

freePenDrawingState = new FreePenDrawingState(MainCanvas);
lineState = new LineDrawingState(MainCanvas);
rectangleState = new RectangleDrawingState(MainCanvas, this);
arrowDrawingState = new ArrowDrawingState(MainCanvas);
textDrawingState = new TextDrawingState(MainCanvas);

var grid = new Grid();

if (this.Content != MainCanvas)
{
grid.Children.Add(MainCanvas);
}

CreateRectMenu();

}

Также пробовал менять свойства Windows, но тоже не помогло
this.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual;
this.Left = System.Windows.Forms.SystemInformation.VirtualScreen.Left;
this.Top = System.Windows.Forms.SystemInformation.VirtualScreen.Top;
this.Width = System.Windows.Forms.SystemInformation.VirtualScreen.Width;
this.Height = System.Windows.Forms.SystemInformation.VirtualScreen.Height;
this.WindowStyle = WindowStyle.None;
this.WindowState = WindowState.Minimized;
this.Visibility = Visibility.Hidden;
this.Topmost = true;


Подробнее здесь: https://stackoverflow.com/questions/788 ... ll-screens

Вернуться в «C#»