初始化提交
This commit is contained in:
47
电子展板/MainWindow.xaml.cs
Normal file
47
电子展板/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Media;
|
||||
using System.Xml;
|
||||
|
||||
namespace 电子展板
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
int screenIndex = 0;
|
||||
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());
|
||||
WebServer.Start();
|
||||
}
|
||||
|
||||
public double GetDpiScaleX()
|
||||
{
|
||||
return VisualTreeHelper.GetDpi(this).DpiScaleX;
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
WebServer.Stop();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user