RollingGauge


Or cyclometer - aim is to display a counter that increments every second.



XAML


∇  xaml←RollingGaugeXAML
⍝ XAML for the RollingGauge 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:RollingGauge Name="rg" Height="50"'
 xaml,←⊂'            SegmentCount="4" Unit="Count:" UnitPosition="Start"'
 xaml,←⊂'            >'
 xaml,←⊂'        </sfg:RollingGauge>'
 xaml,←⊂'        <Button Name="btnStop" Content="Stop"/>'
 xaml,←⊂'    </StackPanel>'
 xaml,←⊂'</Window>'


Code


∇ RollingGauge;⎕IO;⎕ML;xaml;⎕USING
⍝ Simple RollingGauge example
 ⎕IO ⎕ML←0 3
 xaml←RollingGaugeXAML
 #.window←#.UTIL.WPF.LoadXaml xaml(⊂'SyncGauge')
 window_rg window_btnStop←{window.FindName⊂⍵}¨'rg' 'btnStop'
 window_btnStop.onClick←'RollingGaugeStop'
 ⎕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←'#.RollingGaugeIncrement'
 #.timer.Start
 window_rg.Value←,'0'
 #.window.Show


Notice here that for some reason it is necessary to offer Value in character form rather than number (see also the rigmarole in RollingGaugeIncrement).

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


∇ RollingGaugeIncrement w;⎕IO;⎕ML;value
⍝ Increment RollingGauge
 ⎕IO ⎕ML←0 3
 #.window_rg.Value←⍕1+⍎window_rg.Value


∇ RollingGaugeStop w;⎕IO;⎕ML
⍝ Stop the RollingGauge 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

RollingGauge

Unresolved Issues

More control over appearance.