cs代码
using System;using System.Collections.Generic;using System.Linq;using System.Net;using System.Windows;using System.Windows.Controls;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Animation;using System.Windows.Shapes;using System.Windows.Threading;namespace FullScreen{ public partial class MainPage : UserControl { Analytics myAnalytics; public MainPage() { InitializeComponent(); Loaded += new RoutedEventHandler(MainPage_Loaded); Application.Current.Host.Content.FullScreenChanged += new EventHandler(Content_FullScreenChanged); } void MainPage_Loaded(object sender, RoutedEventArgs e) { myAnalytics = new Analytics(); DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(1); timer.Tick += new EventHandler(timer_Tick); timer.Start(); } void timer_Tick(object sender, EventArgs e) { txtCPULoad.Text = myAnalytics.AverageProcessorLoad.ToString(); txtSLCPULoad.Text = myAnalytics.AverageProcessLoad.ToString(); } void Content_FullScreenChanged(object sender, EventArgs e) { var content = Application.Current.Host.Content; if (content.IsFullScreen) { btnFull.Background = new SolidColorBrush(Colors.Yellow); LayoutRoot.Background = new SolidColorBrush(Colors.Yellow); } else { btnFull.Background = new SolidColorBrush(Colors.Red); LayoutRoot.Background = new SolidColorBrush(Colors.Red); } } private void btnFull_Click(object sender, RoutedEventArgs e) { var content = Application.Current.Host.Content; if (!content.IsFullScreen) { content.IsFullScreen = !content.IsFullScreen; btnFull.Content = "还原"; } else { content.IsFullScreen = !content.IsFullScreen; btnFull.Content = "全屏"; } } }}