using CCDCountWpf.Language; using CCDCountWpf.WpfFrom; 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.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; using System.Windows.Threading; namespace CCDCountWpf { /// /// StartWindow.xaml 的交互逻辑 /// public partial class StartWindow : Window { private DispatcherTimer _timer; public StartWindow() { InitializeComponent(); DataContext = ShowMessageBus.ShowBinding; SetupFullScreen(); InitTimer(); } private void InitTimer() { _timer = new DispatcherTimer(); _timer.Interval = TimeSpan.FromSeconds(0.5); _timer.Tick += Timer_Tick; _timer.Start(); } private void SetupFullScreen() { // 隐藏标题栏和边框 this.WindowStyle = WindowStyle.None; // 禁止调整大小 this.ResizeMode = ResizeMode.NoResize; // 设置为最顶层窗口 //this.Topmost = true; // 最大化窗口 this.WindowState = WindowState.Maximized; // 隐藏任务栏(可选) this.Top = 0; this.Left = 0; this.Width = SystemParameters.PrimaryScreenWidth; this.Height = SystemParameters.PrimaryScreenHeight; } private void LoginInBtd_Loaded(object sender, RoutedEventArgs e) { if(MessageBus.NowLoginUserMessage==null) { LoginInBtd.Visibility = Visibility.Visible; EnterSystemBtn.Visibility = Visibility.Collapsed; } else { LoginInBtd.Visibility = Visibility.Collapsed; EnterSystemBtn.Visibility = Visibility.Visible; } } private void LoginInBtd_Click(object sender, RoutedEventArgs e) { UserLoginWindow userLoginWindow = new UserLoginWindow(); // 设置窗口启动位置为手动 userLoginWindow.WindowStartupLocation = WindowStartupLocation.Manual; // 水平居中 userLoginWindow.Left = (SystemParameters.PrimaryScreenWidth - userLoginWindow.Width) / 2; // 垂直靠上(例如屏幕高度的 10% 位置) userLoginWindow.Top = SystemParameters.PrimaryScreenHeight * 0.1; userLoginWindow.ShowDialog(); if (MessageBus.NowLoginUserMessage == null) { LoginInBtd.Visibility = Visibility.Visible; EnterSystemBtn.Visibility = Visibility.Collapsed; } else { LoginInBtd.Visibility = Visibility.Collapsed; EnterSystemBtn.Visibility = Visibility.Visible; } } private async void EnterSystemBtn_Click(object sender, RoutedEventArgs e) { var loadwin = new LoadingWindow { Owner = this }; loadwin.WindowStartupLocation = WindowStartupLocation.CenterScreen; loadwin.Show(); try { await Dispatcher.InvokeAsync(() => { MainWindow mainWindow = new MainWindow(); mainWindow.Show(); this.Close(); }); } finally { await Dispatcher.InvokeAsync(() => { loadwin.Close(); }); } } private void SystemExit_Click(object sender, RoutedEventArgs e) { if(_timer != null) { _timer.Stop(); _timer.Tick -= Timer_Tick; _timer = null; } this.Close(); Environment.Exit(0); } private void Timer_Tick(object sender,EventArgs e) { ShowMessageBus.ShowBinding.ShowTimer = DateTime.Now.ToString("HH:mm:ss"); } private void SwitchLanguage_Click(object sender, RoutedEventArgs e) { MessageBus.LanguageIndex++; LanguageManager.ChangeLanguage(LanguageManager.LanguageList[MessageBus.LanguageIndex % LanguageManager.LanguageList.Count]); } } }