初始化提交
This commit is contained in:
59
电子展板/MainWindow2.xaml.cs
Normal file
59
电子展板/MainWindow2.xaml.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace 电子展板
|
||||
{
|
||||
/// <summary>
|
||||
/// MainWindow2.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MainWindow2 : Window
|
||||
{
|
||||
public MainWindow2()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Screen[] screens = Screen.AllScreens;
|
||||
if (screens.Length > 1)
|
||||
{
|
||||
int screenIndex = 1;
|
||||
this.Left = (int)(Screen.AllScreens[screenIndex].Bounds.Left / GetDpiScaleX());
|
||||
this.Top = (int)(Screen.AllScreens[screenIndex].Bounds.Top / GetDpiScaleX());
|
||||
this.Width = (int)(Screen.AllScreens[screenIndex].Bounds.Width / GetDpiScaleX());
|
||||
this.Height = (int)(Screen.AllScreens[screenIndex].Bounds.Height / GetDpiScaleX());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public double GetDpiScaleX()
|
||||
{
|
||||
return VisualTreeHelper.GetDpi(this).DpiScaleX;
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
WebServer.Stop();
|
||||
Screen[] screens = Screen.AllScreens;
|
||||
if (screens.Length > 1)
|
||||
{
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user