/** * Window_Closing */ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { // operations Operations.GetInstance().Final(); // window WindowConfig config = WindowConfig.GetInstance(); WindowConfigValues values = config.GetValues(); if (WindowState == WindowState.Normal) { values.WindowX = Left; values.WindowY = Top; values.WindowWidth = ActualWidth; values.WindowHeight = ActualHeight; values.WindowMaximized = false; } else if (WindowState == WindowState.Maximized) { values.WindowMaximized = true; } else { values.WindowMaximized = false; } }
/** * Init */ public void Init() { int number = 1; string basePath = ApplicationPaths.GetApplicationPath(); for (;;) { controlPath = basePath + "\\fmps_config_" + number; FileInfo control = new FileInfo(controlPath); if (control.Exists == false) { control.Create().Close(); break; } number++; } configPath = basePath + "\\fmps_config_" + number + ".xml"; FileInfo config = new FileInfo(configPath); if (config.Exists == true) { StreamReader reader = new StreamReader(configPath, new UTF8Encoding(false)); XmlSerializer serializer = new XmlSerializer(typeof(WindowConfigValues)); values = (WindowConfigValues)serializer.Deserialize(reader); reader.Close(); } }
/** * Window_Initialized */ private void Window_Initialized(object sender, EventArgs e) { // window WindowConfig config = WindowConfig.GetInstance(); WindowConfigValues values = config.GetValues(); Left = values.WindowX; Top = values.WindowY; Width = values.WindowWidth; Height = values.WindowHeight; if (values.WindowMaximized == true) { WindowState = WindowState.Maximized; } // operations Operations.GetInstance().Init(); }