-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisplayWindow.xaml.cs
More file actions
69 lines (59 loc) · 1.94 KB
/
DisplayWindow.xaml.cs
File metadata and controls
69 lines (59 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Linq;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Media.Imaging;
namespace WpfApp1
{
/// <summary>
/// Interaction logic for DisplayWindow.xaml
/// </summary>
public partial class DisplayWindow : Window
{
public int ImageID;
public string Chemin;
public string ImageName;
public BitmapImage BitmapImageSource;
public DisplayWindow(int ID, string Name, string chemin, BitmapImage BitmapImageToOpen)
{
InitializeComponent();
ImageID = ID;
Chemin = chemin;
ImageName = Name;
BitmapImageSource = BitmapImageToOpen;
MaximizeToSecondaryMonitor(Display);
SetImage();
}
private void SetImage()
{
ImageToDisplay.Source = BitmapImageSource;
}
public void MaximizeToSecondaryMonitor(Window window)
{
// Select Screen
Screen secondaryScreen = Screen.AllScreens.Where(s => !s.Primary).FirstOrDefault();
if (secondaryScreen != null)
{
if (!window.IsLoaded)
window.WindowStartupLocation = WindowStartupLocation.Manual;
// Required to define the Startup Location
System.Drawing.Rectangle workingArea = secondaryScreen.WorkingArea;
window.Left = workingArea.Left;
window.Top = workingArea.Top;
window.Width = workingArea.Width;
window.Height = workingArea.Height;
}
}
public void Maximize(Window window)
{
// If window isn't loaded then maxmizing will result in the window displaying on the primary monitor
if (window.IsLoaded)
{
window.WindowState = WindowState.Maximized;
}
}
private void Display_Closing(object sender, EventArgs e)
{
}
}
}