using Microsoft.Extensions.DependencyInjection; using SlnMesnac.Model.AirportApiEntity; using SlnMesnac.Serilog; using SlnMesnac.TouchSocket; using SlnMesnac.WPF.Attribute; using SlnMesnac.WPF.ViewModel; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; 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.Navigation; using System.Windows.Shapes; namespace SlnMesnac.WPF { /// /// Interaction logic for MainWindow.xaml /// /// [RegisterAsSingletonAttribute] public partial class MainWindow : Window { private readonly SerilogHelper _logger; //托盘 NotifyIcon trayIcon; //注册AreaIcon属性,用于托盘的图标 public static readonly DependencyProperty AreaIconProperty = DependencyProperty.Register("AreaIcon", typeof(ImageSource), typeof(MainWindow)); //注册AreaText属性,用于鼠标滑到托盘图标时显示的文字 public static readonly DependencyProperty AreaTextProperty = DependencyProperty.Register("AreaText", typeof(string), typeof(MainWindow)); //注册AreaVisibility属性,用于显示隐藏托盘图标 public static readonly DependencyProperty AreaVisibilityProperty = DependencyProperty.Register("AreaVisibility", typeof(bool), typeof(MainWindow)); //注册AreaMenuItems属性,用于托盘右键在单的列表 public static readonly DependencyProperty AreaMenuItemsProperty = DependencyProperty.Register("AreaMenuItems", typeof(List), typeof(MainWindow), new PropertyMetadata(new List())); public MainWindow() { _logger = App.ServiceProvider.GetRequiredService(); InitializeComponent(); this.DataContext = new MainWindowViewModel(); } private void AddTrayIcon() { if (trayIcon != null) { return; } trayIcon = new NotifyIcon { }; } private void Window_Loaded(object sender, RoutedEventArgs e) { _logger.Info("系统启动!"); } private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { _logger.Info("系统关闭!"); } } }