完善功能

This commit is contained in:
2025-09-22 14:30:54 +08:00
parent fde5919d99
commit 365cd2397a
31 changed files with 1849 additions and 467 deletions

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Media;
using .Base;
namespace .ViewModels
{
public class MainWindowViewModel : ViewModelBase
{
private Window window;
public DelegateCommand<Window> LoadedCommand { get; set; }
public DelegateCommand<CancelEventArgs> WindowClosingCommand { get; set; }
public MainWindowViewModel()
{
LoadedCommand = new DelegateCommand<Window>(Loaded);
WindowClosingCommand = new DelegateCommand<CancelEventArgs>(WindowClosing);
}
private void Loaded(Window window)
{
this.window = window;
int screenIndex = 0;
this.window.Left = (int)(Screen.AllScreens[screenIndex].Bounds.Left / GetDpiScaleX());
this.window.Top = (int)(Screen.AllScreens[screenIndex].Bounds.Top / GetDpiScaleX());
this.window.Width = (int)(Screen.AllScreens[screenIndex].Bounds.Width / GetDpiScaleX());
this.window.Height = (int)(Screen.AllScreens[screenIndex].Bounds.Height / GetDpiScaleX());
WebServer.Start();
}
private void WindowClosing(CancelEventArgs args)
{
WebServer.Stop();
Environment.Exit(0);
}
public double GetDpiScaleX()
{
return VisualTreeHelper.GetDpi(this.window).DpiScaleX;
}
}
}