-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppSettings.cs
251 lines (216 loc) · 9.52 KB
/
AppSettings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
using System.ComponentModel;
using System.Xml.Serialization;
/*
using RuFramework.Config;
namespace RuConfig
{
public partial class Form1 : Form
{
AppSettings appSettings = new AppSettings();
public Form1()
{
InitializeComponent();
// Select the config data path
// ConfigManager.GetAppDataPath(AppDataPath.Local);
// ConfigManager.GetAppDataPath(AppDataPath.Common);
// ConfigManager.GetAppDataPath(AppDataPath.ExePath);
// ConfigManager.GetAppDataPath(AppDataPath.Roaming);
// Default read data = ConfigManager.Read(ConfigManager.GetAppDataPath(AppDataPath.Roaming))
appSettings = ConfigManager.Read(); // default Roaming
}
private void buttonOpen_Click(object sender, EventArgs e)
{
//AppSettingsDialog appSettingsDialog = new AppSettingsDialog(appSettings, AppDataPath.Roaming);
AppSettingsDialog appSettingsDialog = new AppSettingsDialog(appSettings); // default Roaming
appSettingsDialog.propertyGrid.SelectedObject = appSettings;
appSettingsDialog.ShowDialog();
appSettings = appSettingsDialog.AppSettingsOk;
// Property is changed in the program, you must save
ChangeAppSettings();
}
private void ChangeAppSettings()
{
appSettings.MyString = "Property MyString changed";
// ConfigManager.Save(appSettings, AppDataPath.Roaming);
// or
ConfigManager.Save(appSettings); // default Roaming
}
}
}
*/
namespace RuFramework.Config
{
[XmlType(TypeName = "appSettings")]
[Serializable]
public class AppSettings : EventArgs
{
///*
//Standard category translated into the national language
//Action Properties related to available actions.
//Appearance Properties related to how an entity appears.
//Behavior Properties related to how an entity acts.
//Data Properties related to data and data source management.
//Default Properties that are grouped in a default category.
//Design Properties that are available only at design time.
//DragDrop Properties related to drag-and-drop operations.
//Focus Properties related to focus.
//Format Properties related to formatting.
//Key Properties related to the keyboard.
//Layout Properties related to layout.
//Mouse Properties related to the mouse.
//WindowStyle Properties related to the window style of top-level forms.
//*/
//#region Bool as object with Enum-Converter
//// Property Boolean with Enum-Converter
//[Category("Bool as object with Enum-Converter")]
//[Description("Description Unit")]
//[DisplayName("UNIT")]
//[TypeConverter(typeof(EnumConverter))]
//[Browsable(true)]
//public Unit MyUnit { set; get; } = Unit.cm;
//// Property Boolean with Enum-Converter
//[Category("Bool as object with Enum-Converter")]
//[Description("Description Drinker doses")]
//[DisplayName("DRINKER DOSES")]
//[TypeConverter(typeof(DrinkDosesConverter))]
//[Browsable(true)]
//public DrinkDoses MyDoses { set; get; }
//[Category("Boolean as object with True/False Converter")]
//[Description("Description Yes or No")]
//[DisplayName("YES/NO")]
//[TypeConverter(typeof(TrueFalseConverter))]
//[Browsable(true)]
//public bool MyDrinkOrNot { set; get; } = true;
//#endregion
//#region General property
//// Property Boolean
//[Category("General property")]
//[Description("Description Boolean")]
//[DisplayName("BOOLEAN")]
//[Browsable(true)]
//public bool MyBoolean { set; get; } = false;
//// Property Byte
//[Category("General property")]
//[Description("Description Byte")]
//[DisplayName("BYTE")]
//[Browsable(true)]
//public byte MyByte { set; get; } = 30;
//// Property Collection
//[Category("General property")]
//[Description("Description Collection")]
//[DisplayName("COLLECTION")]
//[Browsable(true)]
//// List cannot set default values because, strangely enough, it is always added
//public List<double> MyCollection { set; get; } // new List<double>() { 1.5, 2.6, 3.7 };
//// Property Decimal
//[Category("General property")]
//[Description("Description Decimal")]
//[DisplayName("DECIMAL")]
//[Browsable(true)]
//public decimal MyDecimal { set; get; } = 5;
//// Property Integer
//[Category("General property")]
//[Description("Description Integer")]
//[DisplayName("INTEGER")]
//[Browsable(true)]
//public int MyInteger { set; get; } = 4;
//// Property Point
//[Category("General property")]
//[Description("Description Point")]
//[DisplayName("POINT")]
//[Browsable(true)]
//public Point MyPoint { set; get; } = new Point(10, 15);
//// Property Size
//[Category("General property")]
//[Description("Description Size")]
//[DisplayName("SIZE")]
//[Browsable(true)]
//public Size MySize { set; get; } = new Size(100, 200);
//// Property String
//[Category("General property")]
//[Description("Description String")]
//[DisplayName("STRING")]
//[Browsable(true)]
//public string MyString { set; get; } = "Klaus";
//#endregion
//#region UserType with converter
//// Property Address, UserType
//[Category("UserType with Converter")]
//[Description("Description Address")]
//[DisplayName("ADDRESS")]
//[Browsable(true)]
//[TypeConverterAttribute(typeof(AddressConverter))]
//public Address MyAddress { set; get; } = new Address("Mustermann", "Klaus", "10178", "Berlin", "Hauptstr. 1");
//// Property Lenght, UserType
//[Category("UserType with Converter")]
//[Description("Description Lenght")]
//[DisplayName("LENGTH")]
//[Browsable(true)]
//[TypeConverterAttribute(typeof(LenghtConverter))]
//public Length MyLength { set; get; } = new Length(10, Unit.cm);
//#endregion
//#region With deputy Property
//// Property Color, cannot be serialized
//[Category("With deputy Property")]
//[Description("Description Color")]
//[DisplayName("COLOR")]
//[XmlIgnore]
//public Color MyColor { get; set; } = Color.Red;
//// Property Deputy Color, this is serialized
//[XmlElement("MyColor")]
//[Browsable(false)]
//public string MyColor_Internal
//{
// get { return ColorTranslator.ToHtml(this.MyColor); }
// set { this.MyColor = ColorTranslator.FromHtml(value); }
//}
//#endregion
//#region With UITypeEdotor
//// Property Filename
//[Category("With UITypeEditor")]
//[Description("Description Filename")]
//[DisplayName("Filename")]
//[Editor(typeof(FileSelectorTypeEditor), typeof(UITypeEditor))]
//[Browsable(true)]
//public string MyFileName { set; get; } = @"D:\Temp\Killme.txt";
//// Property Guid
//[Category("With UITypeEditor")]
//[Description("Description Guid")]
//[DisplayName("GUID")]
//[Editor(typeof(GuidUITypeEditor), typeof(System.Drawing.Design.UITypeEditor))]
//[Browsable(true)]
//public string MyGuid { set; get; } = new Guid().ToString();
//// Property Multiline
//[Category("With UITypeEditor")]
//[Description("Description Multiline")]
//[DisplayName("MULTILINE")]
//[Editor(typeof(MultiLineUITypeEditor), typeof(System.Drawing.Design.UITypeEditor))]
//[Browsable(true)]
//public string MyMultiline { set; get; } = "aaaa\nbbbb\ncccc\n";
// Property path, location
[Category("With UITypeEditor")]
[Description("Description Path")]
[DisplayName("FolderPath")]
[Editor(typeof(FolderNameEditorWithRootFolder), typeof(System.Drawing.Design.UITypeEditor))]
[Browsable(true)]
public string MyPath { set; get; } = @"C:\TTD\RectangleData";
[Category("With UITypeEditor")]
[Description("Description Path")]
[DisplayName("InputPath")]
[Editor(typeof(FolderNameEditorWithRootFolder), typeof(System.Drawing.Design.UITypeEditor))]
[Browsable(true)]
public string InputPath { set; get; } = @"C:\TTD\Input";
[Category("With UITypeEditor")]
[Description("Description Path")]
[DisplayName("OutputPath")]
[Editor(typeof(FolderNameEditorWithRootFolder), typeof(System.Drawing.Design.UITypeEditor))]
[Browsable(true)]
public string OutputPath { set; get; } = @"C:\TTD\Output";
[Category("With UITypeEditor")]
[Description("Escala de renderizado de imagen")]
[DisplayName("ScaleRender")]
[Editor(typeof(FolderNameEditorWithRootFolder), typeof(System.Drawing.Design.UITypeEditor))]
[Browsable(true)]
public string scale { set; get; } = "2.0f";
}
}