using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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.Navigation;
using System.Windows.Shapes;
namespace WpfApplication1
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow() //按照配置文件吧窗口初始化
{
InitializeComponent();
this.WindowState = Properties.Settings.Default.MainWindowState; //给窗口赋值配置文件的内容
Rect rect = Properties.Settings.Default.MainWindowRect; //描述一个矩形宽度,高度和未知的类
this.Top = rect.Top;
this.Left = rect.Left;
this.Width = rect.Width;
this.Height = rect.Height;
}
//点击关闭时在配置文件里记录关闭的位置
private void Window_Closing_1(object sender, System.ComponentModel.CancelEventArgs e)
{
Properties.Settings.Default.MainWindowState = this.WindowState;
Properties.Settings.Default.MainWindowRect = this.RestoreBounds;
Properties.Settings.Default.Save();
//e.Cancel = true;
if (w!=null)
{
w.Close();
}
}
Window1 w;
private void Button_Click_1(object sender, RoutedEventArgs e) //点击打开新窗口
{
if (w == null)
{
w = new Window1();
w.Show();
}
else
{
w.Show();
}
}
private void Button_Click_2(object sender, RoutedEventArgs e) //点击隐藏新窗口
{
if (w!=null)
{
w.Hide();
}
}
}
}