bovender framework
C# framework that implements MVVM and more
WindowSettings.cs
1 /* WindowSettings.cs
2  * part of Daniel's XL Toolbox NG
3  *
4  * Copyright 2014-2018 Daniel Kraus
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 using System.Configuration;
19 using System.Windows;
20 
21 namespace Bovender.Mvvm.Views.Settings
22 {
23  public class WindowSettings : ApplicationSettingsBase
24  {
25  #region Constructor
26 
27  public WindowSettings(Window window) : base(window.ToString()) { }
28 
29  #endregion
30 
31  #region Properties
32 
36  [UserScopedSetting]
37  public Rect Rect
38  {
39  get
40  {
41  // Cannot return this["Rect"] as Rect
42  // because Rect is not nullable
43  object obj = this["Rect"];
44  if (obj == null) {
45  return Rect.Empty;
46  }
47  else {
48  return (Rect)obj;
49  }
50  }
51  set
52  {
53  this["Rect"] = value;
54  }
55  }
56 
57  [UserScopedSetting]
58  public System.Windows.WindowState State
59  {
60  get
61  {
62  object obj = this["State"];
63  if (obj == null)
64  {
65  return System.Windows.WindowState.Normal;
66  }
67  else
68  {
69  return (System.Windows.WindowState)obj;
70  }
71  }
72  set
73  {
74  this["State"] = value;
75  }
76  }
77 
78  [UserScopedSetting]
79  public System.Windows.Forms.Screen Screen
80  {
81  get
82  {
83  return (System.Windows.Forms.Screen)this["Screen"];
84  }
85  set
86  {
87  this["Screen"] = value;
88  }
89  }
90 
91  #endregion
92 
93  }
94 }