Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DesignerOptionService.cs
Go to the documentation of this file.
4
6
8{
10 [Editor("", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
12 {
14 {
15 private readonly object _target;
16
17 private readonly PropertyDescriptor _property;
18
20
22
23 public override bool IsReadOnly => _property.IsReadOnly;
24
26
27 internal WrappedPropertyDescriptor(PropertyDescriptor property, object target)
28 : base(property.Name, null)
29 {
30 _property = property;
31 _target = target;
32 }
33
34 public override bool CanResetValue(object component)
35 {
37 }
38
39 public override object GetValue(object component)
40 {
42 }
43
44 public override void ResetValue(object component)
45 {
47 }
48
49 public override void SetValue(object component, object value)
50 {
52 }
53
54 public override bool ShouldSerializeValue(object component)
55 {
57 }
58 }
59
61
62 private readonly object _value;
63
65
67
68 public int Count
69 {
70 get
71 {
73 return _children.Count;
74 }
75 }
76
77 public string Name { get; }
78
80
82 {
83 [RequiresUnreferencedCode("The Type of DesignerOptionCollection's value cannot be statically discovered.")]
84 get
85 {
86 if (_properties == null)
87 {
88 ArrayList arrayList;
89 if (_value != null)
90 {
92 arrayList = new ArrayList(properties.Count);
93 foreach (PropertyDescriptor item in properties)
94 {
96 }
97 }
98 else
99 {
100 arrayList = new ArrayList(1);
101 }
103 foreach (DesignerOptionCollection child in _children)
104 {
105 arrayList.AddRange(child.Properties);
106 }
107 PropertyDescriptor[] array = new PropertyDescriptor[arrayList.Count];
108 arrayList.CopyTo(array);
109 _properties = new PropertyDescriptorCollection(array, readOnly: true);
110 }
111 return _properties;
112 }
113 }
114
116 {
117 get
118 {
120 if (index < 0 || index >= _children.Count)
121 {
122 throw new IndexOutOfRangeException("index");
123 }
125 }
126 }
127
128 public DesignerOptionCollection? this[string name]
129 {
130 get
131 {
133 foreach (DesignerOptionCollection child in _children)
134 {
135 if (string.Compare(child.Name, name, ignoreCase: true, CultureInfo.InvariantCulture) == 0)
136 {
137 return child;
138 }
139 }
140 return null;
141 }
142 }
143
144 bool ICollection.IsSynchronized => false;
145
146 object ICollection.SyncRoot => this;
147
148 bool IList.IsFixedSize => true;
149
150 bool IList.IsReadOnly => true;
151
152 object? IList.this[int index]
153 {
154 get
155 {
156 return this[index];
157 }
158 set
159 {
160 throw new NotSupportedException();
161 }
162 }
163
165 {
166 _service = service;
167 Parent = parent;
168 Name = name;
169 _value = value;
170 if (Parent != null)
171 {
172 parent._properties = null;
173 if (Parent._children == null)
174 {
175 Parent._children = new ArrayList(1);
176 }
177 Parent._children.Add(this);
178 }
179 }
180
181 public void CopyTo(Array array, int index)
182 {
185 }
186
187 [MemberNotNull("_children")]
188 private void EnsurePopulated()
189 {
190 if (_children == null)
191 {
193 if (_children == null)
194 {
195 _children = new ArrayList(1);
196 }
197 }
198 }
199
201 {
203 return _children.GetEnumerator();
204 }
205
207 {
209 return _children.IndexOf(value);
210 }
211
213 {
214 if (options._value != null)
215 {
216 return options._value;
217 }
218 foreach (DesignerOptionCollection option in options)
219 {
220 object obj = RecurseFindValue(option);
221 if (obj != null)
222 {
223 return obj;
224 }
225 }
226 return null;
227 }
228
229 public bool ShowDialog()
230 {
231 object obj = RecurseFindValue(this);
232 if (obj == null)
233 {
234 return false;
235 }
236 return _service.ShowDialog(this, obj);
237 }
238
239 int IList.Add(object value)
240 {
241 throw new NotSupportedException();
242 }
243
245 {
246 throw new NotSupportedException();
247 }
248
249 bool IList.Contains(object value)
250 {
252 return _children.Contains(value);
253 }
254
255 int IList.IndexOf(object value)
256 {
258 return _children.IndexOf(value);
259 }
260
261 void IList.Insert(int index, object value)
262 {
263 throw new NotSupportedException();
264 }
265
266 void IList.Remove(object value)
267 {
268 throw new NotSupportedException();
269 }
270
272 {
273 throw new NotSupportedException();
274 }
275 }
276
278 {
280 {
282
283 public override Type ComponentType => _option.GetType();
284
285 public override bool IsReadOnly => true;
286
287 public override Type PropertyType => _option.GetType();
288
290 : base(option.Name, null)
291 {
292 _option = option;
293 }
294
295 public override bool CanResetValue(object component)
296 {
297 return false;
298 }
299
300 public override object GetValue(object component)
301 {
302 return _option;
303 }
304
305 public override void ResetValue(object component)
306 {
307 }
308
309 public override void SetValue(object component, object value)
310 {
311 }
312
313 public override bool ShouldSerializeValue(object component)
314 {
315 return false;
316 }
317 }
318
320 {
321 return true;
322 }
323
324 [RequiresUnreferencedCode("The Type of value cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
326 {
327 PropertyDescriptorCollection propertyDescriptorCollection = new PropertyDescriptorCollection(null);
328 if (!(value is DesignerOptionCollection designerOptionCollection))
329 {
330 return propertyDescriptorCollection;
331 }
332 foreach (DesignerOptionCollection item in designerOptionCollection)
333 {
334 propertyDescriptorCollection.Add(new OptionPropertyDescriptor(item));
335 }
336 foreach (PropertyDescriptor property in designerOptionCollection.Properties)
337 {
338 propertyDescriptorCollection.Add(property);
339 }
340 return propertyDescriptorCollection;
341 }
342
343 public override object ConvertTo(ITypeDescriptorContext cxt, CultureInfo culture, object value, Type destinationType)
344 {
345 if (destinationType == typeof(string))
346 {
348 }
349 return base.ConvertTo(cxt, culture, value, destinationType);
350 }
351 }
352
354
355 public DesignerOptionCollection Options => _options ?? (_options = new DesignerOptionCollection(this, null, string.Empty, null));
356
358 {
359 if (parent == null)
360 {
361 throw new ArgumentNullException("parent");
362 }
363 if (name == null)
364 {
365 throw new ArgumentNullException("name");
366 }
367 if (name.Length == 0)
368 {
369 throw new ArgumentException(System.SR.Format(System.SR.InvalidArgumentValue, "name.Length"), "name");
370 }
371 return new DesignerOptionCollection(this, parent, name, value);
372 }
373
374 [RequiresUnreferencedCode("The Type of DesignerOptionCollection's value cannot be statically discovered.")]
375 private PropertyDescriptor GetOptionProperty(string pageName, string valueName)
376 {
377 if (pageName == null)
378 {
379 throw new ArgumentNullException("pageName");
380 }
381 if (valueName == null)
382 {
383 throw new ArgumentNullException("valueName");
384 }
385 string[] array = pageName.Split('\\');
386 DesignerOptionCollection designerOptionCollection = Options;
387 string[] array2 = array;
388 foreach (string name in array2)
389 {
390 designerOptionCollection = designerOptionCollection[name];
391 if (designerOptionCollection == null)
392 {
393 return null;
394 }
395 }
396 return designerOptionCollection.Properties[valueName];
397 }
398
400 {
401 }
402
403 protected virtual bool ShowDialog(DesignerOptionCollection options, object optionObject)
404 {
405 return false;
406 }
407
408 [RequiresUnreferencedCode("The option value's Type cannot be statically discovered.")]
409 object IDesignerOptionService.GetOptionValue(string pageName, string valueName)
410 {
411 return GetOptionProperty(pageName, valueName)?.GetValue(null);
412 }
413
414 [RequiresUnreferencedCode("The option value's Type cannot be statically discovered.")]
415 void IDesignerOptionService.SetOptionValue(string pageName, string valueName, object value)
416 {
417 GetOptionProperty(pageName, valueName)?.SetValue(null, value);
418 }
419}
virtual IEnumerator GetEnumerator()
virtual int Add(object? value)
virtual bool Contains(object? item)
virtual void CopyTo(Array array)
virtual int IndexOf(object? value)
DesignerOptionCollection(DesignerOptionService service, DesignerOptionCollection parent, string name, object value)
override object ConvertTo(ITypeDescriptorContext cxt, CultureInfo culture, object value, Type destinationType)
override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext cxt, object value, Attribute[] attributes)
virtual void PopulateOptionCollection(DesignerOptionCollection options)
PropertyDescriptor GetOptionProperty(string pageName, string valueName)
DesignerOptionCollection CreateOptionCollection(DesignerOptionCollection parent, string name, object value)
virtual bool ShowDialog(DesignerOptionCollection options, object optionObject)
virtual AttributeCollection Attributes
void SetValue(object? component, object? value)
bool CanResetValue(object component)
bool ShouldSerializeValue(object component)
object? GetValue(object? component)
static PropertyDescriptorCollection GetProperties([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
static CultureInfo InvariantCulture
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string CollectionConverterText
Definition SR.cs:120
static string InvalidArgumentValue
Definition SR.cs:84
Definition SR.cs:7
void RemoveAt(int index)
void Insert(int index, object? value)
int Add(object? value)
bool Contains(object? value)
void Remove(object? value)
int IndexOf(object? value)
void SetOptionValue(string pageName, string valueName, object value)
object? GetOptionValue(string pageName, string valueName)