Attachment 'sfDoubleTextBox.v1.0.txt'
Download 1 :Namespace sfDoubleTextBox
2
3 ⍝ === VARIABLES ===
4
5 L←⎕av[3+⎕io]
6 _←⍬
7 _,←'<ToolTip x:Name="tooltip" Placement="Top" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">'
8 _,←L,'<Grid Height="60" Width="222" UseLayoutRounding="True">'
9 _,←L,' <Grid.Resources>'
10 _,←L,' <ResourceDictionary>'
11 _,←L,' <SolidColorBrush x:Key="Brush1" Color="#FF010101">'
12 _,←L,' </SolidColorBrush>'
13 _,←L,' <DrawingBrush x:Key="Warning_Icon" Stretch="Uniform">'
14 _,←L,' <DrawingBrush.Drawing>'
15 _,←L,' <DrawingGroup>'
16 _,←L,' <DrawingGroup Transform="1,0,0,1,-55.8940696716309,-15.1816902160645">'
17 _,←L,' <DrawingGroup Transform="1,0,0,1,54.9428482055664,205.567092895508">'
18 _,←L,' <DrawingGroup Transform="1,0,0,1,-495.6494140625,-311.927703857422">'
19 _,←L,' <GeometryDrawing Brush="#FFFDEE1C" Geometry="F1M554.728,121.842C552.848,122.133,551.195,123.244,550.249,124.890L497.615,216.078C496.514,217.992 496.497,220.381 497.615,222.307 498.733,224.240 500.813,225.451 503.063,225.449L608.331,225.449C610.581,225.451 612.661,224.240 613.780,222.307 614.897,220.377 614.880,217.992 613.780,216.078L561.144,124.890C559.851,122.636,557.288,121.440,554.728,121.842z">'
20 _,←L,' </GeometryDrawing>'
21 _,←L,' <GeometryDrawing Brush="{StaticResource Brush1}" Geometry="F1M555.212,124.416C554.194,124.574,553.327,125.187,552.837,126.041L499.837,217.853C499.257,218.864 499.255,220.161 499.837,221.165 500.429,222.185 501.522,222.853 502.712,222.853L608.712,222.853C609.901,222.853 610.995,222.185 611.587,221.165 612.169,220.159 612.167,218.862 611.587,217.853L558.587,126.041C557.905,124.856,556.591,124.200,555.212,124.416z M555.712,134.978L600.712,214.229 510.650,214.229 555.712,134.978z">'
22 _,←L,' </GeometryDrawing>'
23 _,←L,' </DrawingGroup>'
24 _,←L,' </DrawingGroup>'
25 _,←L,' <DrawingGroup Transform="0.414274990558624,0,0,0.414274990558624,310.556701660156,217.852905273438">'
26 _,←L,' <GeometryDrawing Brush="{StaticResource Brush1}" Geometry="F1M-463.544,-288.905C-463.544,-282.611 -468.645,-277.512 -474.944,-277.512 -481.233,-277.512 -486.337,-282.611 -486.337,-288.905 -486.337,-295.201 -481.233,-300.300 -474.944,-300.300 -468.645,-300.300 -463.544,-295.201 -463.544,-288.905z">'
27 _,←L,' <GeometryDrawing.Pen>'
28 _,←L,' <Pen Brush="{StaticResource Brush1}" DashCap="Round" EndLineCap="Round" MiterLimit="4" StartLineCap="Round" Thickness="4">'
29 _,←L,' </Pen>'
30 _,←L,' </GeometryDrawing.Pen>'
31 _,←L,' </GeometryDrawing>'
32 _,←L,' <GeometryDrawing Brush="{StaticResource Brush1}" Geometry="F1M-479.300,-394.850L-470.309,-394.850C-465.743,-394.850,-462.073,-389.294,-462.073,-382.392L-465.915,-325.287C-465.915,-318.385,-469.588,-312.826,-474.150,-312.826L-475.451,-312.826C-480.017,-312.826,-483.690,-318.384,-483.690,-325.287L-487.536,-382.392C-487.536,-389.294,-483.861,-394.850,-479.300,-394.850z">'
33 _,←L,' <GeometryDrawing.Pen>'
34 _,←L,' <Pen Brush="{StaticResource Brush1}" DashCap="Round" EndLineCap="Round" MiterLimit="4" StartLineCap="Round" Thickness="3.796">'
35 _,←L,' </Pen>'
36 _,←L,' </GeometryDrawing.Pen>'
37 _,←L,' </GeometryDrawing>'
38 _,←L,' </DrawingGroup>'
39 _,←L,' </DrawingGroup>'
40 _,←L,' </DrawingGroup>'
41 _,←L,' </DrawingBrush.Drawing>'
42 _,←L,' </DrawingBrush>'
43 _,←L,' </ResourceDictionary>'
44 _,←L,' </Grid.Resources>'
45 _,←L,' <Grid.RowDefinitions>'
46 _,←L,' <RowDefinition Height="23"/>'
47 _,←L,' <RowDefinition/>'
48 _,←L,' </Grid.RowDefinitions>'
49 _,←L,' <Grid.ColumnDefinitions>'
50 _,←L,' <ColumnDefinition Width="0.25*"/>'
51 _,←L,' <ColumnDefinition Width="0.75*"/>'
52 _,←L,' </Grid.ColumnDefinitions>'
53 _,←L,' <Label x:Name="header" Grid.ColumnSpan="2" Background="Blue" Content="Warning !" FontWeight="Bold" Foreground="White" TextOptions.TextFormattingMode="Display" VerticalContentAlignment="Center"/>'
54 _,←L,' <Label x:Name="warning" Grid.Column="1" Grid.Row="1" Content="TextBlock" VerticalContentAlignment="Center"/>'
55 _,←L,' <Viewbox Grid.Row="1" VerticalAlignment="Bottom"/>'
56 _,←L,' <Border Grid.Row="1" Margin="3" Background="{DynamicResource Warning_Icon}"/>'
57 _,←L,'</Grid>'
58 _,←L,'</ToolTip>'
59 Warning_ToolTip_xaml←_
60
61 _←⍬
62 _,←'<Window'
63 _,←L,' xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"'
64 _,←L,' xmlns:d="http://schemas.microsoft.com/expression/blend/2008"'
65 _,←L,' xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"'
66 _,←L,' xmlns:sf="http://schemas.syncfusion.com/wpf"'
67 _,←L,' xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"'
68 _,←L,' Height="390"'
69 _,←L,' Width="550"'
70 _,←L,' Title="DoubleText Box Demo 1">'
71 _,←L,' <Grid x:Name="LayoutRoot">'
72 _,←L,' <Grid.RowDefinitions>'
73 _,←L,' <RowDefinition Height="0.16*"/>'
74 _,←L,' <RowDefinition Height="0.28*"/>'
75 _,←L,' <RowDefinition Height="0.28*"/>'
76 _,←L,' <RowDefinition Height="0.28*"/>'
77 _,←L,' </Grid.RowDefinitions>'
78 _,←L,' <Grid.ColumnDefinitions>'
79 _,←L,' <ColumnDefinition Width="0.5*"/>'
80 _,←L,' <ColumnDefinition Width="0.5*"/>'
81 _,←L,' </Grid.ColumnDefinitions>'
82 _,←L,' <Label'
83 _,←L,' Margin="0,10"'
84 _,←L,' Content="Fill the following details:"'
85 _,←L,' FontSize="14"'
86 _,←L,' FontWeight="Bold"/>'
87 _,←L,' <Label'
88 _,←L,' Height="24"'
89 _,←L,' Grid.Row="1"'
90 _,←L,' HorizontalAlignment="Right"'
91 _,←L,' Margin="0,0,10,0"'
92 _,←L,' VerticalAlignment="Center"'
93 _,←L,' Content="Enter your age [1-100]:"'
94 _,←L,' HorizontalContentAlignment="Right"'
95 _,←L,' VerticalContentAlignment="Center"/>'
96 _,←L,' <sf:DoubleTextBox'
97 _,←L,' x:Name="doubleTextBox1"'
98 _,←L,' Height="24"'
99 _,←L,' Width="64"'
100 _,←L,' Grid.Column="1"'
101 _,←L,' Grid.Row="1"'
102 _,←L,' HorizontalAlignment="Left"'
103 _,←L,' MaxValidation="OnLostFocus"'
104 _,←L,' MaxValue="100"'
105 _,←L,' MinValidation="OnLostFocus"'
106 _,←L,' MinValue="1"'
107 _,←L,' NumberDecimalDigits="0"/>'
108 _,←L,' <Label'
109 _,←L,' Height="24"'
110 _,←L,' Grid.Row="2"'
111 _,←L,' HorizontalAlignment="Right"'
112 _,←L,' Margin="0,0,10,0"'
113 _,←L,' VerticalAlignment="Center"'
114 _,←L,' Content="Enter your year of birth [1900-2100]:"'
115 _,←L,' HorizontalContentAlignment="Right"'
116 _,←L,' VerticalContentAlignment="Center"/>'
117 _,←L,' <sf:DoubleTextBox'
118 _,←L,' x:Name="doubleTextBox2"'
119 _,←L,' Height="24"'
120 _,←L,' Width="64"'
121 _,←L,' Grid.Column="1"'
122 _,←L,' Grid.Row="2"'
123 _,←L,' HorizontalAlignment="Left"'
124 _,←L,' Margin="0"'
125 _,←L,' VerticalAlignment="Center"'
126 _,←L,' MaxValidation="OnLostFocus"'
127 _,←L,' MaxValue="2100"'
128 _,←L,' MinValidation="OnLostFocus"'
129 _,←L,' MinValue="1900"'
130 _,←L,' NumberDecimalDigits="0"/>'
131 _,←L,' <Button'
132 _,←L,' x:Name="buttonCancel"'
133 _,←L,' Height="35"'
134 _,←L,' Width="168"'
135 _,←L,' Grid.Row="3"'
136 _,←L,' HorizontalAlignment="Center"'
137 _,←L,' VerticalAlignment="Center"'
138 _,←L,' Content="Cancel"'
139 _,←L,' IsCancel="True"/>'
140 _,←L,' <Button'
141 _,←L,' x:Name="buttonOk"'
142 _,←L,' Height="36"'
143 _,←L,' Width="168"'
144 _,←L,' Grid.Column="1"'
145 _,←L,' Grid.Row="3"'
146 _,←L,' HorizontalAlignment="Center"'
147 _,←L,' Margin="0"'
148 _,←L,' Content="OK"'
149 _,←L,' HorizontalContentAlignment="Center"'
150 _,←L,' IsDefault="True"/>'
151 _,←L,' </Grid>'
152 _,←L,'</Window>'
153 sfDoubleTextBoxDemo1_xaml←_
154
155 ⎕ex¨ 'L' '_'
156
157 ⍝ === End of variables definition ===
158
159 (⎕IO ⎕ML ⎕WX)←1 3 3
160
161 ∇ DemoDoubleTextBox1;sfDir;⎕USING
162 ⍝ Demo of DataValidation on Lost Focus for a Syncfusion DoubleTextBox using their MinValue and MaxValue properties.
163
164 sfDir ← 'Syncfusion/4.5/' ⍝ Location of the Syncfusion librairies
165
166 ⎕USING ← 'System.Windows.Controls,WPF/PresentationFramework.dll'
167 ⎕USING,← ⊂'Syncfusion.Windows.Shared,',sfDir,'Syncfusion.Shared.Wpf.dll'
168 :Trap 0
169 {}DoubleTextBox ⍝ Syncfusion DoubleTextBox object should be available.
170 :Else
171 ⎕←'DemoDoubleTextBox: Error loading the assembly Syncfusion.Shared.Wpf.dll.'
172 →0
173 :End
174
175 ⍝ Compile the Xaml:
176 sfDoubleTextBoxDemo_obj←FixSimpleXaml sfDoubleTextBoxDemo1_xaml
177
178 ⍝ Attach manually the events:
179 sfDoubleTextBoxDemo_obj.doubleTextBox1.onValueChanged ← '_DoubleTextBox_ValueChangedEvent'
180 sfDoubleTextBoxDemo_obj.doubleTextBox2.onValueChanged ← '_DoubleTextBox_ValueChangedEvent'
181 sfDoubleTextBoxDemo_obj.buttonCancel.onClick ← '_ButtonCancel_ClickEvent'
182 sfDoubleTextBoxDemo_obj.buttonOk.onClick ← '_ButtonOk_ClickEvent'
183
184 ⍝ Show the window:
185 sfDoubleTextBoxDemo_obj.Show
186 ∇
187
188 ∇ rootObject←FixSimpleXaml xaml;names;⎕USING
189 ⍝ Parse simple Xaml that contains only names to fix.
190
191 ⍝ Parse the simple Xaml and obtain the root object:
192 ⎕USING ← 'System.Windows.Markup,WPF/PresentationFramework.dll'
193 rootObject ← XamlReader.Parse(⊂xaml)
194
195 ⍝ Extract the names beginning with 'x:Name':
196 names ← {{(,⊃0≠⍴¨⍵)/⍵}{1⊃((⍵[;1]∊⊂'x:Name')/⍵[;2]),⊂''}¨(⎕XML ⍵)[;4]}xaml
197
198 ⍝ Assign the value of each names to the root object:
199 rootObject {⍎'⍺.',⍵,'←⍺.FindName(⊂⍵)'} ¨names
200 ∇
201
202 ∇ _ButtonCancel_ClickEvent(sender event)
203 ⍝ Click Event Handler for the Cancel Button.
204
205 ⍝ Close the Parent Window.
206 sfDoubleTextBoxDemo_obj.Close
207 ∇
208
209 ∇ _ButtonOk_ClickEvent(sender event)
210 ⍝ Click Event Handler for the OK Button.
211
212 ⍝ Show the validated values of the form.
213 ⎕ ← sfDoubleTextBoxDemo_obj.(doubleTextBox1 doubleTextBox2).Value
214
215 ⍝ Close the Parent Window.
216 sfDoubleTextBoxDemo_obj.Close
217 ∇
218
219 ∇ _DoubleTextBox_ValueChangedEvent(sender event);maxValue;message;minValue;value;⎕USING
220 ⍝ ValueChanged Event Handler OnLostFocus for a Syncfusion DoubleTextBox.
221 ⍝ It Will Show a ToolTip if the Value of the DoubleTextBox Exceed the Maximum or the Minimum Value Range.
222 ⍝
223 ⍝ sender = Syncfusion.Windows.Shared.DoubleTextBox
224 ⍝ event = System.Windows.DependencyPropertyChangedEventArgs
225
226 (value minValue maxValue) ← sender.(Value MinValue MaxValue)
227
228 :If (value≤maxValue)∧(value≥minValue)
229 ⍝ The Value is Within the Maximum and Minimum Value Range.
230 ⍝ Remove Any Visible ToolTip and Reset the Background and Foreground Property to Default Value.
231 :Trap 0
232 sender.ToolTip.IsOpen ← 0
233
234 ⍝ Reset the Background, Foreground and ToolTip properties of sender to it's default value.
235 ⎕USING ← 'System.Windows.Controls,WPF/PresentationFramework.dll'
236 sender.ClearValue¨TextBox.(BackgroundProperty ForegroundProperty ToolTipProperty)
237 :Else
238 ⍝ Error because there is no ToolTip define for the sender. Do nothing.
239
240 :EndTrap
241
242 :Else
243 ⍝ The Value is Not Within the Maximum and Minimum Value Range.
244 ⍝ Prepare the Warning Message:
245 :If value<minValue
246
247 message ← ('¯'⎕R'-')'The Value is Too Small.',(⎕UCS 13),'It Must be Greater Than ',(⍕minValue),'.'
248
249 :ElseIf value>maxValue
250
251 message ← ('¯'⎕R'-')'The Value is Too Large.',(⎕UCS 13),'It Must be Smaller Than ',(⍕maxValue),'.'
252
253 :EndIf
254
255 ⍝ Show a ToolTip with the Warning Message.
256 :Trap 0
257 ⍝ Will bug if empty. If there is already a ToolTip, reuse it.
258 sender.ToolTip.(FindName⊂'warning').Content ← message
259
260 :Else
261 ⍝ No ToolTip. Create it for the first time.
262 ⎕USING ← 'System.Windows.Markup,WPF/PresentationFramework.dll'
263 sender.ToolTip ← XamlReader.Parse(⊂Warning_ToolTip_xaml)
264 sender.ToolTip.(FindName⊂'tooltip').PlacementTarget ← sender
265 sender.ToolTip.(FindName⊂'warning').Content ← message
266
267 :EndTrap
268
269 ⍝ Force the ToolTip to Show and to stay visible.
270 sender.ToolTip.(IsOpen StaysOpen) ← 1
271
272 ⍝ Change the Foreground and Background color of sender to indicate that there is a warning tooltip.
273 ⎕USING ← 'System.Windows.Media,WPF/PresentationCore.dll'
274 sender.(Background Foreground) ← ⎕NEW¨SolidColorBrush,¨(Colors.Red)(Colors.White)
275 :End
276 ∇
277
278 :EndNamespace
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.