ColorPicker


Aim is to allow the user to pick a colour visually (specifying the input values and returning a result in the ARGB convention)



XAML


∇  xaml←ColorPickerXAML
⍝ XAML for the ColorPicker 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:sfcolpick="clr-namespace:Syncfusion.Windows.Shared;assembly=SyncFusion.Shared.WPF"'
 xaml,←⊂'    SizeToContent="WidthandHeight" >'
 xaml,←⊂'    <StackPanel>'
 xaml,←⊂'        <sfcolpick:ColorPicker Name="colpick"'
 xaml,←⊂'        IsGradientPropertyEnabled="False" VisualizationStyle="RGB">'
 xaml,←⊂'        </sfcolpick:ColorPicker>'
 xaml,←⊂'    </StackPanel>'
 xaml,←⊂'</Window>'


Code


∇  z←ColorPicker w;⎕IO;⎕ML;xaml;⎕USING
⍝ Simple ColorPicker example
 ⎕IO ⎕ML←0 3
 xaml←ColorPickerXAML
 window←#.UTIL.WPF.LoadXaml xaml(⊂'SyncTools')
 window_colorpicker←window.FindName⊂'colpick'
 ⎕USING←#.UTIL.WPF.Using''
 window_colorpicker.Color←Color.FromArgb w
 {}window.ShowDialog
 z←window_colorpicker.Color.(A R G B)


Limitations of Windows snipping (or my lack of mastery) means that the display above doesn't show the dropped display which appears when the user clicks on the selection button.

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

Thanks to Pierre Gilbert for the simplification which makes this example work correctly with the most recent (January 2015) version of the Syncfusion libraries supplied by Dyalog.

Operation


     #.ColorPicker.ColorPicker 100 255 0 0      
100 255 255 0 

Unresolved Issues

Hue-saturation-brightness (bizarrely called HSV by SyncFusion) as an option.

Gradient mode