11// Copyright 2022 Osman Tunçelli. All rights reserved.
22// Use of this source code is governed by GNU General Public License (GPL-2.0) that can be found in the COPYING file.
33
4- using System ;
54using PaintDotNet . PropertySystem ;
5+ using System ;
6+ using System . Drawing ;
7+ using System . IO ;
68
7- namespace PaintDotNet . IndirectUI
9+ namespace PaintDotNet . IndirectUI . Extensions
810{
9- internal static class PropertyControlInfoExtensions
11+ public static class PropertyControlInfoExtensions
1012 {
1113 private static PropertyControlInfo SetPropertyControlValue ( this PropertyControlInfo pci , ControlInfoPropertyNames controlPropertyName , object controlPropertyValue )
1214 {
@@ -20,7 +22,7 @@ private static PropertyControlInfo SetPropertyControlValue(this PropertyControlI
2022 /// <strong>Supported Controls</strong>:
2123 /// <see cref="PropertyControlType.FileChooser" />
2224 /// </remarks>
23- public static PropertyControlInfo AllowAllFiles ( this PropertyControlInfo pci , bool value )
25+ public static PropertyControlInfo AllowAllFiles ( this PropertyControlInfo pci , bool value = true )
2426 => pci . SetPropertyControlValue ( ControlInfoPropertyNames . AllowAllFiles , value ) ;
2527
2628 /// <remarks>
@@ -81,14 +83,14 @@ public static PropertyControlInfo Footnote(this PropertyControlInfo pci, string
8183 /// <strong>Supported Controls</strong>:
8284 /// <see cref="PropertyControlType.TextBox" />
8385 /// </remarks>
84- public static PropertyControlInfo Multiline ( this PropertyControlInfo pci , bool value )
86+ public static PropertyControlInfo Multiline ( this PropertyControlInfo pci , bool value = true )
8587 => pci . SetPropertyControlValue ( ControlInfoPropertyNames . Multiline , value ) ;
8688
8789 /// <remarks>
8890 /// <strong>Supported Controls</strong>:
8991 /// <see cref="PropertyControlType.Slider" /> using <see cref="Int32Property"/> or <see cref="DoubleProperty"/>
9092 /// </remarks>
91- public static PropertyControlInfo RangeWraps ( this PropertyControlInfo pci , bool value )
93+ public static PropertyControlInfo RangeWraps ( this PropertyControlInfo pci , bool value = true )
9294 => pci . SetPropertyControlValue ( ControlInfoPropertyNames . RangeWraps , value ) ;
9395
9496 /// <remarks>
@@ -99,7 +101,7 @@ public static PropertyControlInfo RangeWraps(this PropertyControlInfo pci, bool
99101 /// <see cref="PropertyControlType.RollBallAndSliders" />,
100102 /// <see cref="PropertyControlType.ColorWheel" />
101103 /// </remarks>
102- public static PropertyControlInfo ShowResetButton ( this PropertyControlInfo pci , bool value )
104+ public static PropertyControlInfo ShowResetButton ( this PropertyControlInfo pci , bool value = true )
103105 => pci . SetPropertyControlValue ( ControlInfoPropertyNames . ShowResetButton , value ) ;
104106
105107 /// <remarks>
@@ -139,7 +141,7 @@ public static PropertyControlInfo SliderLargeChangeZ(this PropertyControlInfo pc
139141 /// <strong>Supported Controls</strong>:
140142 /// <see cref="PropertyControlType.Slider" /> using <see cref="Int32Property"/>
141143 /// </remarks>
142- public static PropertyControlInfo SliderShowTickMarks ( this PropertyControlInfo pci , bool value )
144+ public static PropertyControlInfo SliderShowTickMarks ( this PropertyControlInfo pci , bool value = true )
143145 => pci . SetPropertyControlValue ( ControlInfoPropertyNames . SliderShowTickMarks , value ) ;
144146
145147 /// <remarks>
@@ -148,7 +150,7 @@ public static PropertyControlInfo SliderShowTickMarks(this PropertyControlInfo p
148150 /// <see cref="PropertyControlType.PanAndSlider" />,
149151 /// <see cref="PropertyControlType.RollBallAndSliders" />
150152 /// </remarks>
151- public static PropertyControlInfo SliderShowTickMarksX ( this PropertyControlInfo pci , bool value )
153+ public static PropertyControlInfo SliderShowTickMarksX ( this PropertyControlInfo pci , bool value = true )
152154 => pci . SetPropertyControlValue ( ControlInfoPropertyNames . SliderShowTickMarksX , value ) ;
153155
154156 /// <remarks>
@@ -157,15 +159,15 @@ public static PropertyControlInfo SliderShowTickMarksX(this PropertyControlInfo
157159 /// <see cref="PropertyControlType.PanAndSlider" />,
158160 /// <see cref="PropertyControlType.RollBallAndSliders" />
159161 /// </remarks>
160- public static PropertyControlInfo SliderShowTickMarksY ( this PropertyControlInfo pci , bool value )
162+ public static PropertyControlInfo SliderShowTickMarksY ( this PropertyControlInfo pci , bool value = true )
161163 => pci . SetPropertyControlValue ( ControlInfoPropertyNames . SliderShowTickMarksY , value ) ;
162164
163165 /// <remarks>
164166 /// <strong>Supported Controls</strong>:
165167 /// <see cref="PropertyControlType.Slider" /> using <see cref="DoubleVector3Property"/>,
166168 /// <see cref="PropertyControlType.RollBallAndSliders" />
167169 /// </remarks>
168- public static PropertyControlInfo SliderShowTickMarksZ ( this PropertyControlInfo pci , bool value )
170+ public static PropertyControlInfo SliderShowTickMarksZ ( this PropertyControlInfo pci , bool value = true )
169171 => pci . SetPropertyControlValue ( ControlInfoPropertyNames . SliderShowTickMarksZ , value ) ;
170172
171173 /// <remarks>
@@ -207,6 +209,26 @@ public static PropertyControlInfo SliderSmallChangeZ(this PropertyControlInfo pc
207209 public static PropertyControlInfo StaticImageUnderlay ( this PropertyControlInfo pci , ImageResource value )
208210 => pci . SetPropertyControlValue ( ControlInfoPropertyNames . StaticImageUnderlay , value ) ;
209211
212+ /// <remarks>
213+ /// <strong>Supported Controls</strong>:
214+ /// <see cref="DoubleVectorProperty"/>,
215+ /// </remarks>
216+ public static PropertyControlInfo StaticImageUnderlay ( this PropertyControlInfo pci , byte [ ] bytes )
217+ {
218+ using ( var ms = new MemoryStream ( bytes ) )
219+ {
220+ pci . StaticImageUnderlay ( ImageResource . FromImage ( Image . FromStream ( ms ) ) ) ;
221+ }
222+ return pci ;
223+ }
224+
225+ /// <remarks>
226+ /// <strong>Supported Controls</strong>:
227+ /// <see cref="DoubleVectorProperty"/>,
228+ /// </remarks>
229+ public static PropertyControlInfo StaticImageUnderlay ( this PropertyControlInfo pci , string base64string )
230+ => pci . StaticImageUnderlay ( Convert . FromBase64String ( base64string ) ) ;
231+
210232 /// <remarks>
211233 /// <strong>Supported Controls</strong>:
212234 /// <see cref="PropertyControlType.Slider" /> using <see cref="Int32Property"/> or <see cref="DoubleProperty"/>,
@@ -245,7 +267,7 @@ public static PropertyControlInfo UpDownIncrementZ(this PropertyControlInfo pci,
245267 /// <strong>Supported Controls</strong>:
246268 /// <see cref="PropertyControlType.Slider" /> using <see cref="DoubleProperty"/> or <see cref="DoubleVectorProperty"/>
247269 /// </remarks>
248- public static PropertyControlInfo UseExponentialScale ( this PropertyControlInfo pci , bool value )
270+ public static PropertyControlInfo UseExponentialScale ( this PropertyControlInfo pci , bool value = true )
249271 => pci . SetPropertyControlValue ( ControlInfoPropertyNames . UseExponentialScale , value ) ;
250272
251273 public static PropertyControlInfo WindowHelpContent ( this PropertyControlInfo pci , string value )
@@ -254,7 +276,7 @@ public static PropertyControlInfo WindowHelpContent(this PropertyControlInfo pci
254276 public static PropertyControlInfo WindowHelpContentType ( this PropertyControlInfo pci , WindowHelpContentType value )
255277 => pci . SetPropertyControlValue ( ControlInfoPropertyNames . WindowHelpContentType , value ) ;
256278
257- public static PropertyControlInfo WindowIsSizable ( this PropertyControlInfo pci , bool value )
279+ public static PropertyControlInfo WindowIsSizable ( this PropertyControlInfo pci , bool value = true )
258280 => pci . SetPropertyControlValue ( ControlInfoPropertyNames . WindowIsSizable , value ) ;
259281
260282 public static PropertyControlInfo WindowTitle ( this PropertyControlInfo pci , string value )
0 commit comments