Пример #1
0
 private void LoadSavedState()
 {
     try
     {
         var serializer = new WindowSize.Serializer();
         var text       = XDocument.Load(WindowSize.FileLocation);
         var state      = serializer.Deserialize(text.Root);
         SetWindowSize(state);
     }
     catch (Exception ex)
     {
         Log(ex);
         SetWindowSize(WindowSize.Default);
     }
 }
Пример #2
0
        public void SaveStateToFile()
        {
            try
            {
                var serializer = new WindowSize.Serializer();
                var state      = new WindowSize(WindowState == FormWindowState.Maximized,
                                                Width, Height);

                var doc = new XDocument(serializer.Serialize(state, "root"));
                File.WriteAllText(WindowSize.FileLocation, doc.ToString());
            }
            catch (Exception ex)
            {
                Log(ex);
            }
        }
Пример #3
0
        public void SaveStateToFile()
        {
            try
            {
                var serializer = new WindowSize.Serializer();

                // This is needed because when the form is minimized,
                // the Width and Height have the size of only the title bar.
                var bounds = RestoreBounds;

                var state = new WindowSize(WindowState == FormWindowState.Maximized,
                                           bounds.Width, bounds.Height);

                var doc = new XDocument(serializer.Serialize(state, "root"));
                File.WriteAllText(WindowSize.FileLocation, doc.ToString());
            }
            catch (Exception ex)
            {
                Log(ex);
            }
        }