public void AdjustWindow() { //读取窗体设置 WindowConfig cj = new WindowConfig(this.GetType().Name); Rect rect; (rect, WinState) = cj.GetValue(); if (rect.X != -1 && rect.Y != -1) { this.WindowState = WindowState.Normal; this.Left = rect.X > 0 ? rect.X : 0; this.Top = rect.Y > 0 ? rect.Y : 0; this.Height = rect.Height <= SystemParameters.PrimaryScreenHeight ? rect.Height : SystemParameters.PrimaryScreenHeight / 2; this.Width = rect.Width <= SystemParameters.PrimaryScreenWidth ? rect.Width : SystemParameters.PrimaryScreenWidth / 2; if (this.Width == SystemParameters.WorkArea.Width | this.Height == SystemParameters.WorkArea.Height) { WinState = JvedioWindowState.Maximized; } } else { WinState = JvedioWindowState.Normal; this.WindowStartupLocation = WindowStartupLocation.CenterScreen; } }
/// <summary> /// 调整窗体状态 /// </summary> private void AdjustWindow() { //读取窗体设置 WindowConfig cj = new WindowConfig(this.GetType().Name); WindowProperty windowProperty = cj.Read(); Rect rect = new Rect() { Location = windowProperty.Location, Size = windowProperty.Size }; WinState = windowProperty.WinState; //读到属性值 if (WinState == JvedioWindowState.FullScreen) { this.WindowState = WindowState.Maximized; } else if (WinState == JvedioWindowState.None) { WinState = 0; this.WindowStartupLocation = WindowStartupLocation.CenterScreen; } else { this.Left = rect.X >= 0 ? rect.X : 0; this.Top = rect.Y >= 0 ? rect.Y : 0; this.Height = rect.Height > 100 ? rect.Height : 100; this.Width = rect.Width > 100 ? rect.Width : 100; if (this.Width == SystemParameters.WorkArea.Width | this.Height == SystemParameters.WorkArea.Height) { WinState = JvedioWindowState.Maximized; } } HideMargin(); }
/// <summary> /// 保存窗口状态 /// </summary> private void SaveWindow() { if (this.WindowState != WindowState.Minimized) { if (this.WindowState == WindowState.Normal) { WinState = JvedioWindowState.Normal; } else if (this.WindowState == WindowState.Maximized) { WinState = JvedioWindowState.FullScreen; } if (this.Width == SystemParameters.WorkArea.Width & this.Height == SystemParameters.WorkArea.Height) { WinState = JvedioWindowState.Maximized; } WindowConfig cj = new WindowConfig(this.GetType().Name); cj.Save(new WindowProperty() { Location = new Point(this.Left, this.Top), Size = new Size(this.Width, this.Height), WinState = WinState }); } }
private void Button_Click_1(object sender, RoutedEventArgs e) { WindowConfig windowConfig = new WindowConfig("Main"); windowConfig.Save(new WindowProperty() { Location = new Point(123, 456), Size = new Size(789, 777), WinState = StaticVariable.JvedioWindowState.FullScreen }); WindowProperty windowProperty = windowConfig.Read(); Console.WriteLine(123); }
private void SaveWindow() { if (this.WindowState != WindowState.Minimized) { if (this.WindowState == WindowState.Normal) { WinState = JvedioWindowState.Normal; } else if (this.WindowState == WindowState.Maximized) { WinState = JvedioWindowState.FullScreen; } else if (this.Width == SystemParameters.WorkArea.Width & this.Height == SystemParameters.WorkArea.Height) { WinState = JvedioWindowState.Maximized; } WindowConfig cj = new WindowConfig(this.GetType().Name); Rect rect = new Rect(this.Left, this.Top, this.Width, this.Height); cj.Save(rect, WinState); } }
private void AdjustWindow() { //读取窗体设置 WindowConfig cj = new WindowConfig(this.GetType().Name); Rect rect; (rect, WinState) = cj.GetValue(); if (rect.X != -1 && rect.Y != -1) { //读到属性值 if (WinState == JvedioWindowState.Maximized) { MaxWindow(this, new MouseButtonEventArgs(InputManager.Current.PrimaryMouseDevice, 0, MouseButton.Left)); } else { this.WindowState = WindowState.Normal; this.Left = rect.X > 0 ? rect.X : 0; this.Top = rect.Y > 0 ? rect.Y : 0; this.Height = rect.Height > 100 ? rect.Height : 100; this.Width = rect.Width > 100 ? rect.Width : 100; if (this.Width == SystemParameters.WorkArea.Width | this.Height == SystemParameters.WorkArea.Height) { WinState = JvedioWindowState.Maximized; } } } else { WinState = JvedioWindowState.Normal; this.WindowStartupLocation = WindowStartupLocation.CenterScreen; } HideMargin(); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { StopDownLoad(); if (this.WindowState != WindowState.Minimized) { if (this.WindowState == WindowState.Normal) { WinState = JvedioWindowState.Normal; } else if (this.WindowState == WindowState.Maximized) { WinState = JvedioWindowState.FullScreen; } else if (this.Width == SystemParameters.WorkArea.Width & this.Height == SystemParameters.WorkArea.Height) { WinState = JvedioWindowState.Maximized; } WindowConfig cj = new WindowConfig(this.GetType().Name); Rect rect = new Rect(this.Left, this.Top, this.Width, this.Height); cj.Save(rect, WinState); } }