DigitalGauge


The aim here is to display a digital gauge in a window and have it show the current date/time - incrementing once a second



XAML


∇  xaml←DigitalGaugeXAML
⍝ XAML for the DigitalGauge example
 xaml←⊂'<Window'
 xaml,←⊂'    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"'
 xaml,←⊂'    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"'
 xaml,←⊂'    xmlns:sfg="clr-namespace:Syncfusion.Windows.Gauge;assembly=Syncfusion.Gauge.WPF"'
 xaml,←⊂'    SizeToContent="WidthandHeight" Name="gaugewindow">'
 xaml,←⊂'    <StackPanel>'
 xaml,←⊂'        <sfg:DigitalGauge Height="50" Width="500" Name="dg"'
 xaml,←⊂'            CharacterType="SegmentFourteen" HorizontalContentAlignment="Center"'
 xaml,←⊂'            >'
 xaml,←⊂'        </sfg:DigitalGauge>'
 xaml,←⊂'        <Button Name="btnStop" Content="Stop"/>'
 xaml,←⊂'    </StackPanel>'
 xaml,←⊂'</Window>'


Code


∇ DigitalGauge;⎕IO;⎕ML;xaml;⎕USING
⍝ Simple DigitalGauge example
 ⎕IO ⎕ML←0 3
 xaml←DigitalGaugeXAML
 #.window←#.UTIL.WPF.LoadXaml xaml(⊂'SyncGauge')
 window_dg window_btnStop←{window.FindName⊂⍵}¨'dg' 'btnStop'
 window_btnStop.onClick←'DigitalGaugeStop'
 ⎕USING←'System,mscorlib.dll' 'System.Windows.Threading,WindowsBase.dll' 'System.Windows.Media,presentationcore.dll'
 #.timer←⎕NEW DispatcherTimer
 #.timer.Interval←⎕NEW TimeSpan(0 0 1)
 #.timer.onTick←'#.DigitalGaugeIncrement'
 #.timer.Start
 #.window.Show


The hocus-pocus to define and start the Timer should really hide away inside another function.

∇ DigitalGaugeIncrement w;⎕IO;⎕ML;ts;⎕USING
⍝ Increment pointer
 ⎕IO ⎕ML←0 3
 ⎕USING←,⊂'System'
 ts←⎕NEW DateTime(6↑⎕TS)
 window_dg.(CharacterCount Value)←{(≢⍵)⍵}⍕ts


∇ DigitalGaugeStop w;⎕IO;⎕ML
⍝ Stop the DigitalGauge and close the window
 ⎕IO ⎕ML←0 3
 #.timer.Stop
 #.window.Close


Notice also the untidiness (in terms of global variables) which is endemic to WPF-based code, especially when using Show rather than ShowDialog.

The 'SyncGauge' argument to #.UTIL.LoadXAML has the effect of adding 'Syncfusion.Windows.Gauge,Syncfusion/4.5/Syncfusion.Gauge.WPF.dll' to the ⎕USING list of LoadXAML


Operation

DigitalGauge

Unresolved Issues

More control over appearance.