Attachment 'wpfXamlDemo.v1.5.txt'

Download

   1 :Namespace wpfXamlDemo
   2 
   3 ⍝ === VARIABLES ===
   4 
   5     L←⎕av[3+⎕io]
   6 
   7     Copy_b64       ←'iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAaVBMVEX///8AAAC2tra2tra2tra2trb////+/v62trb9/f309PT7+/vExMSurq6Hh4f4+Pj8/Pz5+fnMzMyenp6/zduoqKilpaXNzc2xsbHu7u6Li4vk5OTa2tro6Oj6+vrm5uaMjIympqby8vJPA9lJAAAABnRSTlMAAM8Q7zCjkYU+AAAAiklEQVR4XoXM2Q7CMAxE0bqAk+7s+/7/H4mJMGNXQdzXo5mCiKK2X01nlCpSkbXdspxk4VCLOHBvDvwbYPSWgxu/JQMn5rotMzA8L+d24wAFB+tvzEeFIGDr/0LlrjwEE2D+CxoZ4aoCLASQgau8mQAsb7hqFLp7L28mBSKKPJgS0AdcgO6xtQm8AN3LEZUq6MiXAAAAAElFTkSuQmCC'
   8     Cut_b64        ←'iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAADcElEQVRIiZ2VX2gcVRjFz52d3TYmWW+6q02y1m4bEPOiE6T+K8gWNArFtqB9EIRuUBGKsEbR1zYoiL5UH6uYrAF9KGpWTFFEmLRapW2M26ZNuq3JbksLppvsbqY7O3dm7p3xoV1N3K6Z8Xu6zJzv/L4z93IHruvCdV14rQ9GvqPvfZzJr6Wr+8qenW+VLAdV1+Fxz3pCiGfz9NHTBzva71CuF4veB/KsBLAuFExt3bQRpcXF274/MjFDHQcqce3nAcwBgOTVvKTbcTkg0c5IGIFAY+qvjs9SQqA6rquYptlWf+4ZsKE1WJAlgqBMIEurAeO/5GhAIurGjrBCHBvasjbnGwAAcoAgJEurEnx/6hKVCFE7I2Eleud6LBaL06+98GT1/wMC/yRQp/6gsgS1M9qu9G6+CzMX8zBqtfdX9fgBAAAhBCDAj5OXKEDUrmi70hOL4ufJWVy99mf67Zd3f75S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ICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAH8AAP//AAD//wAA/38AAP9/AAD/fwAA/38AAP9/AAD/fwAA/38AAP8AAAD/gIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAfwAA//8AAP//AAD/fwAA/38AAP9/AAD/fwAA/38AAP9/AAD/fwAA/wAAAP+AgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAAB/AAD//wAA//8AAP9/AAD/fwAA/38AAP9/AAD/fwAA/38AAP9/AAD/AAAA/4CAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAH8AAP//AAD//wAA/38AAP9/AAD/fwAA/38AAP9/AAD/fwAA/38AAP8AAAD/gIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAfwAA//8AAP//AAD/fwAA/38AAP9/AAD/fwAA/38AAP9/AAD/fwAA/wAAAP+AgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAfwAA/38AAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/gIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAAB/f3//nM7//5zO//+czv//nM7//5zO//+czv//v7+//wAAAP+AgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAH9/f/+czv//nM7//5zO//+czv//nM7//5zO//+/v7//AAAA/4CAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAAB/f3//nM7//5zO//+czv//nM7//5zO//+czv//nM7//5zO//+/v7//AAAA/4CAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAf39//5zO//+czv//nM7//5zO//+czv//nM7//5zO//+czv//nM7//7+/v/8AAAD/gIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAH9/f/+czv//nM7//5zO//+czv//nM7//5zO//+czv//nM7//5zO//+czv//nM7//7+/v/8AAAD/gIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAf39//5zO//+czv//nM7//5zO//+czv//nM7//5zO//+czv//nM7//5zO//+czv//v7+//wAAAP+AgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAH9/f/+czv//nM7//5zO//+czv//nM7//5zO//+czv//nM7//5zO//+czv//nM7//5zO//+/v7//AAAA/4CAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAf39//5zO//+czv//nM7//5zO//+czv//nM7//5zO//+czv//nM7//5zO//+czv//nM7//5zO//+/v7//AAAA/4CAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAH9/f/+czv//nM7//5zO//+czv//nM7//5zO//+czv//nM7//5zO//+czv//nM7//5zO//+czv//nM7//7+/v/8AAAD/gIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAf39//5zO//+czv//v7+//7+/v/+czv//nM7//5zO//+czv//nM7//5zO//+czv//nM7//5zO//+czv//v7+//wAAAP+AgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAH9/f/+czv//nM7//7+/v/8AAAD/AAAA/5zO//+czv//nM7//5zO//+czv//nM7//5zO//+czv//nM7//5zO//+/v7//AAAA/4CAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAf39//5zO//+/v7//AAAA/4CAAAB/f3//nM7//5zO//+czv//nM7//5zO//+czv//nM7//5zO//9/f3//nM7//7+/v/8AAAD/gIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAH9/f/+czv//v7+//wAAAP+AgAAAgIAAAH9/f/+czv//nM7//39/f/+czv//nM7//39/f/+czv//v7+//wAAAP+czv//v7+//wAAAP+AgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAf39//39/f/8AAAD/gIAAAICAAACAgAAAf39//5zO//+/v7//AAAA/5zO//+/v7//AAAA/5zO//+/v7//AAAA/5zO//+/v7//AAAA/4CAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAAB/f3//nM7//7+/v/8AAAD/nM7//7+/v/8AAAD/nM7//7+/v/8AAAD/f39//39/f/+AgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAH9/f/+czv//v7+//wAAAP+czv//v7+//wAAAP+czv//v7+//wAAAP+AgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAf39//5zO//+/v7//AAAA/5zO//+/v7//AAAA/39/f/9/f3//gIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAAB/f3//nM7//7+/v/8AAAD/f39//39/f/+AgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAH9/f/+czv//v7+//wAAAP+AgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAf39//5zO//+/v7//AAAA/4CAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAAB/f3//nM7//7+/v/8AAAD/gIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAH9/f/+czv//v7+//wAAAP+AgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAH9/f/9/f3//gIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAAgIAAAICAAACAgAAA///////////+AD///gA///4AP//+AD///gA///8Af///AH///wB///4AP//8AD//+AAf//gAH//wAB//8AAP/+AAD//gAA//wAAP/8IAD/+GAA//jgAP//4AH//+AH///gD///4H///+H////h////4f///+H////z////////8='
  10     Paste_b64      ←'iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAeFBMVEUAAAB7e3ucnJy1tbXOpUrOpVLOrVrnzpz39/f////OrWPn5+fOzs7WtWvWvXuEhITnzqXn1qWUlJRaWlq1nGO9zt6MjIyle0KlhDmljFqlpaXWrWOthEKtlFrW1tbexoTnzpS1hDG1lGOUc0KMYxjv7++9vb3GrXO+vRrUAAAAAXRSTlMAQObYZgAAAKNJREFUeF6NzVcOwyAQRVHTi3tL73X/OwzjeISxiZT7hXT0huRbCSVhV4hQSskDXhOo66pqCSFtp5QK4FwUDXTIiwCqPLfv7nbcbqScgXUxjDKGYAcwY2kGEgGdGZAlmJMGQZAeUpa9EKR04HumuwGkC6DHjFkBKADhYFI5ghBREFBwygPnkcVlz3kchiKn1ndoscCY0b4Z9Jj+a/H7j6aclnwANmEWNaPqN4UAAAAASUVORK5CYII='
  11     Print_b64      ←'iVBORw0KGgoAAAANSUhEUgAAABg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csV9XnDG/aDZ2Wy52ey56vS5lXQewWrORkBi4GKC3b4DevgEiE466iV4mu0mqx+7a8I+7L4XtUh/5ZEA+euTweMW11/3RaDR+JRgcfWnz99f/G2B68pnnl5tMGWsAurp9dHX7Eoqz7KmV8YWByVEQXyZfeG7Xo2+9uc+/5UcPr1t+dWm9oiiH273n/hDrf8ZT0HQzIMec0yX/PvJo7dcefKDqjXi77rn/PRtX8Lad/U+z2TKvYPacb8zU4eDFi691drS/tWJl2SOyLOcAnDvbetcjNff9CVC+c9fmwl3PPt5G9FJGSfudEuhl04MPVO2L/9/ywwfXyJKELEmMjo7s3/rQD1+4719/8Ms4T5Yknnmq9o4fP3zf15J5p042//6Xv3jkQE9355NxXkHB7Ovjdnc9+3jHlWC6IgeSyes91+kPDLqBof977ZXH4nxJlpFkmbHxsTPvvXuor+1c60gg4H87zpdiB/v/uL/qufHw+NHAkL/u8NsHpt2oLkXT5YAGhIk6GInJyYCJ6FTqXvndnvZXfrfnUeAxJkINhBiWZTk7MDjYGDd2od/XaLPZb9Y0bXhoKJDI7o3f/vq3gDFgPNanGmtrRMNG4xI58Ff6S9P/AxzSkKqndbIyAAAAAElFTkSuQmCC'
  14 
  15 
  16     _←⍬
  17     _,←'<Window'
  18     _,←L,'   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"'
  19     _,←L,'   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">'
  20     _,←L,'</Window>'
  21     NewWindow←_
  22 
  23     _←⍬
  24     _,←'<Window'
  25     _,←L,'   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"'
  26     _,←L,'   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"'
  27     _,←L,'   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"'
  28     _,←L,'   Height="200"'
  29     _,←L,'   Width="250"'
  30     _,←L,'   Title="MainWindow"'
  31     _,←L,'   WindowStartupLocation="CenterScreen">'
  32     _,←L,'   <Grid>'
  33     _,←L,'      <Grid.RowDefinitions>'
  34     _,←L,'         <RowDefinition Height="0.5*"/>'
  35     _,←L,'         <RowDefinition Height="0.5*"/>'
  36     _,←L,'      </Grid.RowDefinitions>'
  37     _,←L,'      <TextBox'
  38     _,←L,'         x:Name="textBox1"'
  39     _,←L,'         Width="130"'
  40     _,←L,'         HorizontalAlignment="Center"'
  41     _,←L,'         VerticalAlignment="Center"'
  42     _,←L,'         Text="TextBox"'
  43     _,←L,'         TextAlignment="Center"/>'
  44     _,←L,'      <Button'
  45     _,←L,'         x:Name="button1"'
  46     _,←L,'         Height="40"'
  47     _,←L,'         Width="120"'
  48     _,←L,'         Grid.Row="1"'
  49     _,←L,'         HorizontalAlignment="Center"'
  50     _,←L,'         VerticalAlignment="Center"'
  51     _,←L,'         Content="Click Me !"/>'
  52     _,←L,'   </Grid>'
  53     _,←L,'</Window>'
  54     sample1←_
  55 
  56     _←⍬
  57     _,←'<Window'
  58     _,←L,'   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"'
  59     _,←L,'   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"'
  60     _,←L,'   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"'
  61     _,←L,'   x:Class="WpfApplication3.MainWindow"'
  62     _,←L,'   Height="200"'
  63     _,←L,'   Width="250"'
  64     _,←L,'   Title="MainWindow"'
  65     _,←L,'   WindowStartupLocation="CenterScreen">'
  66     _,←L,'   <Grid>'
  67     _,←L,'      <Grid.RowDefinitions>'
  68     _,←L,'         <RowDefinition Height="0.5*"/>'
  69     _,←L,'         <RowDefinition Height="0.5*"/>'
  70     _,←L,'      </Grid.RowDefinitions>'
  71     _,←L,'      <TextBox'
  72     _,←L,'         x:Name="textBox1"'
  73     _,←L,'         Width="130"'
  74     _,←L,'         HorizontalAlignment="Center"'
  75     _,←L,'         VerticalAlignment="Center"'
  76     _,←L,'         Text="TextBox"'
  77     _,←L,'         TextAlignment="Center"/>'
  78     _,←L,'      <Button'
  79     _,←L,'         x:Name="button1"'
  80     _,←L,'         Click="__Button_Click"'
  81     _,←L,'         Height="40"'
  82     _,←L,'         Width="120"'
  83     _,←L,'         Grid.Row="1"'
  84     _,←L,'         HorizontalAlignment="Center"'
  85     _,←L,'         VerticalAlignment="Center"'
  86     _,←L,'         Content="Click Me !"/>'
  87     _,←L,'   </Grid>'
  88     _,←L,'</Window>'
  89     sample2←_
  90 
  91     _←⍬
  92     _,←'<Window'
  93     _,←L,'  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"'
  94     _,←L,'  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"'
  95     _,←L,'  Width="640"'
  96     _,←L,'  Height="480"'
  97     _,←L,'  Title="PuttingItAllTogether"'
  98     _,←L,'  WindowStartupLocation="CenterScreen">'
  99     _,←L,'  <DockPanel Width="Auto" Height="Auto" LastChildFill="True">'
 100     _,←L,'    <!--Top Menu Area-->'
 101     _,←L,'    <Menu'
 102     _,←L,'      Width="Auto"'
 103     _,←L,'      Height="20"'
 104     _,←L,'      Background="#FFA9D1F4"'
 105     _,←L,'      DockPanel.Dock="Top">'
 106     _,←L,'      <!-- File Menu -->'
 107     _,←L,'      <MenuItem Header="_File">'
 108     _,←L,'        <MenuItem Header="_Cut" Name="mnuCut">'
 109     _,←L,'          <MenuItem.Icon>'
 110     _,←L,'            <Image Name="Cut_b64" Width="16" Height="16"/>'
 111     _,←L,'          </MenuItem.Icon>'
 112     _,←L,'        </MenuItem>'
 113     _,←L,'        <MenuItem Header="_Copy" Name="mnuCopy">'
 114     _,←L,'          <MenuItem.Icon>'
 115     _,←L,'            <Image Name="Copy_b64" Width="16" Height="16"/>'
 116     _,←L,'          </MenuItem.Icon>'
 117     _,←L,'        </MenuItem>'
 118     _,←L,'        <MenuItem Header="_Paste" Name="mnuPaste">'
 119     _,←L,'          <MenuItem.Icon>'
 120     _,←L,'            <Image Name="Paste_b64" Width="16" Height="16"/>'
 121     _,←L,'          </MenuItem.Icon>'
 122     _,←L,'        </MenuItem>'
 123     _,←L,'        <Separator/>'
 124     _,←L,'        <MenuItem Header="_Print" Name="mnuPrint">'
 125     _,←L,'          <MenuItem.Icon>'
 126     _,←L,'            <Image Name="Print_b64" Width="16" Height="16"/>'
 127     _,←L,'          </MenuItem.Icon>'
 128     _,←L,'        </MenuItem>'
 129     _,←L,'        <Separator/>'
 130     _,←L,'        <MenuItem Header="_Quit" Name="mnuQuit">'
 131     _,←L,'          <MenuItem.Icon>'
 132     _,←L,'            <Image Name="Quit_b64" Width="16" Height="16"/>'
 133     _,←L,'          </MenuItem.Icon>'
 134     _,←L,'        </MenuItem>'
 135     _,←L,'      </MenuItem>'
 136     _,←L,'      <!-- About Menu -->'
 137     _,←L,'      <MenuItem Header="_Help">'
 138     _,←L,'        <MenuItem Header="_About" Name="mnuAbout"/>'
 139     _,←L,'      </MenuItem>'
 140     _,←L,'    </Menu>'
 141     _,←L,'    <!--Bottom Status Bar area, declared before middle section,  '
 142     _,←L,'   as I want it to fill entire bottom of Window,  '
 143     _,←L,'   which it wouldn''t if there was a Left docked panel before it -->'
 144     _,←L,'    <StackPanel'
 145     _,←L,'      Width="Auto"'
 146     _,←L,'      Height="31"'
 147     _,←L,'      Background="#FFCAC5C5"'
 148     _,←L,'      DockPanel.Dock="Bottom"'
 149     _,←L,'      Orientation="Horizontal">'
 150     _,←L,'      <Label'
 151     _,←L,'        Name="lStatusBar"'
 152     _,←L,'        Width="200"'
 153     _,←L,'        Height="23"'
 154     _,←L,'        Content="Status Bar Message...."'
 155     _,←L,'        FontFamily="Arial"'
 156     _,←L,'        FontSize="12"/>'
 157     _,←L,'    </StackPanel>'
 158     _,←L,'    <!--Left Main Content area-->'
 159     _,←L,'    <StackPanel'
 160     _,←L,'      Name="buttonPanel"'
 161     _,←L,'      Width="136"'
 162     _,←L,'      Height="Auto"'
 163     _,←L,'      Background="White">'
 164     _,←L,'      <Button'
 165     _,←L,'        Name="btnButton1"'
 166     _,←L,'        Width="Auto"'
 167     _,←L,'        Height="26"'
 168     _,←L,'        Margin="5,5,5,5">'
 169     _,←L,'        <WrapPanel>'
 170     _,←L,'          <Image Name="Settings_b64" Height="16" Width="16"/>'
 171     _,←L,'          <TextBlock Text="Button1" Margin="5,0,0,0"/>'
 172     _,←L,'        </WrapPanel>'
 173     _,←L,'      </Button>'
 174     _,←L,'      <Button'
 175     _,←L,'        Name="btnButton2"'
 176     _,←L,'        Width="126"'
 177     _,←L,'        Height="26"'
 178     _,←L,'        Margin="5,5,5,5"'
 179     _,←L,'        Content="Button2"/>'
 180     _,←L,'      <Button'
 181     _,←L,'        Name="btnButton3"'
 182     _,←L,'        Width="126"'
 183     _,←L,'        Height="26"'
 184     _,←L,'        Margin="5,5,5,5"'
 185     _,←L,'        Content="Button3"/>'
 186     _,←L,'    </StackPanel>'
 187     _,←L,'    <!--Right Main Content area, NOTE HOW this Grid is the last child'
 188     _,←L,'    so takes all the remaining room -->'
 189     _,←L,'    <Grid Width="Auto" Height="Auto" Background="#FFCC9393">'
 190     _,←L,'      <Grid.ColumnDefinitions>'
 191     _,←L,'        <ColumnDefinition Width="*"/>'
 192     _,←L,'        <ColumnDefinition Width="*"/>'
 193     _,←L,'      </Grid.ColumnDefinitions>'
 194     _,←L,'      <Grid.RowDefinitions>'
 195     _,←L,'        <RowDefinition Height="*"/>'
 196     _,←L,'        <RowDefinition Height="*"/>'
 197     _,←L,'      </Grid.RowDefinitions>'
 198     _,←L,'      <Rectangle'
 199     _,←L,'        Grid.Column="0"'
 200     _,←L,'        Grid.Row="0"'
 201     _,←L,'        Margin="10,10,10,10"'
 202     _,←L,'        Fill="Aqua"/>'
 203     _,←L,'      <Rectangle'
 204     _,←L,'        Grid.Column="1"'
 205     _,←L,'        Grid.Row="0"'
 206     _,←L,'        Margin="10,10,10,10"'
 207     _,←L,'        Fill="Aqua"/>'
 208     _,←L,'      <Rectangle'
 209     _,←L,'        Grid.Column="0"'
 210     _,←L,'        Grid.Row="1"'
 211     _,←L,'        Margin="10,10,10,10"'
 212     _,←L,'        Fill="Aqua"/>'
 213     _,←L,'      <Rectangle'
 214     _,←L,'        Grid.Column="1"'
 215     _,←L,'        Grid.Row="1"'
 216     _,←L,'        Margin="10,10,10,10"'
 217     _,←L,'        Fill="Aqua"/>'
 218     _,←L,'    </Grid>'
 219     _,←L,'  </DockPanel>'
 220     _,←L,'</Window>'
 221     sample3←_
 222 
 223     ⎕ex¨ 'L' '_'
 224 
 225 ⍝ === End of variables definition ===
 226 
 227     (⎕IO ⎕ML ⎕WX)←1 3 3
 228 
 229     ∇ cursor←CursorFromBase64String base64String;imageBytes;MS;⎕USING
 230      ⍝ Convert a Base64String to a cursor.
 231      
 232       ⎕USING←'System.IO,mscorlib.dll' 'System,mscorlib.dll' 'System.Windows,WPF/PresentationCore.dll'
 233      
 234      ⍝ Convert Base64 String to byte[]
 235       imageBytes←Convert.FromBase64String(⊂base64String)
 236      
 237      ⍝ Create a new MemoryStream with the byte[]
 238       MS←⎕NEW MemoryStream(⊂imageBytes)
 239      
 240      ⍝ Create the icon
 241       cursor←⎕NEW Input.Cursor MS
 242      
 243      ⍝ Erase the MemoryStream
 244       MS.Close ⋄ MS.Dispose ⋄ MS←⎕NULL
 245 
 246 
 247     ∇ DemoSample3;imgNames
 248      
 249      ⍝ Parse the xaml of the variable sample3
 250       win←FixSimpleXaml sample3
 251      
 252       ⍝ Get the names of all the 'Image' object that has been fixed in rootObj
 253       imgNames←{((⊂'Image')≡¨(⍵.⍎¨(⍵.⎕NL-9)).GetType.Name)/(⍵.⎕NL-9)}win
 254      
 255      ⍝ Set the Source of all the 'Image'. Each 'Image' must have a Base64 variable of the same name.
 256       win{(⍺.⍎⍵).Source←ImageFromBase64String⍎⍵}¨imgNames
 257      
 258      ⍝ Fix manually the Icon of the main window.
 259       win.Icon←ImageFromBase64String Settings_b64
 260      
 261      ⍝ Fix manually the Cursor of the main window.
 262       win.Cursor←CursorFromBase64String HandCursor_b64
 263      
 264      ⍝ Set Routed Events on the whole Window for ClickEvent when a MenuItem or a Button are clicked.
 265       ⎕USING←'System.Windows,WPF/PresentationCore.dll' 'System.Windows.Controls.Primitives,WPF/PresentationFramework.dll'
 266       win.AddHandler(Controls.MenuItem.ClickEvent)(⎕NEW RoutedEventHandler(⎕OR'__EventHandler'))
 267       win.AddHandler(ButtonBase.ClickEvent)(⎕NEW RoutedEventHandler(⎕OR'__EventHandler'))
 268      
 269      ⍝ Show the window.
 270       win.Show
 271 
 272 
 273     ∇ obj DispatchDelegate action;delegate;⎕USING
 274     ⍝ Function to write asynchronously to the UI thread from another thread.
 275     ⍝ The calling thread does not wait for the operation to finish.
 276      
 277     ⍝ obj    = UI Object that you want to write to from another thread
 278     ⍝ action = Line to execute in the UI thread. Use '⋄' to write multiple lines.
 279      
 280       :Trap 0
 281           ⎕USING←'System,System.dll' 'System.Windows.Threading,WPF/WindowsBase.dll'
 282      
 283         ⍝ Create a function (⍙Delegate) with the 'action' to execute in the UI thread.
 284         ⍝ The function will be executed where 'DispatchDelegate' is called and not where
 285         ⍝ 'DispatchDelegate' is located.
 286           delegate←(⎕IO⊃⎕RSI).⎕OR(⎕IO⊃⎕RSI).⎕FX'⍙Delegate'action'⎕EX ''⍙Delegate'''
 287      
 288         ⍝ Get a 'Dispatcher' from the UI object. That way we are sure to have the right UI thread.
 289         ⍝ Use the method '.Invoke' instead of '.BeginInvoke' for synchronous call.
 290           {}obj.Dispatcher.BeginInvoke(DispatcherPriority.Normal(⎕NEW Action delegate))
 291      
 292       :Else
 293           ⎕←'Error DispatchDelegate: ',action
 294      
 295         ⍝ Returns the Last Error
 296           :If 90=⎕EN
 297               ⎕←'EXCEPTION: ',⎕EXCEPTION.Message
 298           :Else
 299               ⎕←(1⊃⎕DM),': ',(2⊃⎕DM)
 300           :EndIf
 301       :End
 302 
 303 
 304     ∇ base64String←FileToBase64String fileName;bytes;⎕USING
 305      ⍝ Converts a file to a Base64 String.
 306      
 307       ⎕USING←'System,mscorlib.dll'
 308      
 309      ⍝ Read the file
 310       bytes←IO.File.ReadAllBytes(⊂,fileName)
 311      
 312      ⍝ Convert to a Base64 string
 313       base64String←Convert.ToBase64String(⊂bytes)
 314 
 315 
 316     ∇ rootObj←FixSimpleXaml xamlString;names;⎕USING
 317      ⍝ Parse simple and correctly formed Xaml that contains only names to fix (no events).
 318      ⍝ Each named element(s) object will be attached to rootObject.
 319      ⍝ You can see the list of attached elements by doing rootObject.⎕NL -9
 320      ⍝ It is recommended to do not name the root object in the xaml (to prevent a recursive call).
 321      ⍝ For 3rd party dll, ⎕USING must be properly initiated before calling this function.
 322      ⍝ For Xaml with event callbacks and error trapping see the function: FixXaml.
 323 
 324      ⍝ xamlString = Vector of Characters representing a XAML string
 325      ⍝ rootObj    = WPF Root Element Object if no error
 326      ⍝            = ⎕NULL if error
 327      
 328       :Trap 0
 329      
 330         ⍝ Parse the simple Xaml and obtain the root element object:
 331           ⎕USING,←⊂'System.Windows.Markup,WPF/PresentationFramework.dll'  ⍝ was ⎕USING←' before
 332           rootObj←XamlReader.Parse(⊂xamlString)
 333      
 334         ⍝ Extract the names beginning with 'x:Name' or 'Name'
 335           names←{{(,⊃0≠⍴¨⍵)/⍵}{1⊃(((⍵[;1]∊⊂'x:Name')∨(⍵[;1]∊⊂'Name'))/⍵[;2]),⊂''}¨(⎕XML ⍵)[;4]}xamlString
 336      
 337         ⍝ Assign the value of each names to the root object:
 338           :If 0≠⍴names
 339               rootObj{⍎'⍺.',⍵,'←⍺.FindName(⊂,⍵)'}¨names
 340           :Else
 341               ⍝ Do nothing, there is no names.
 342           :End
 343      
 344       :Else
 345         ⍝ There is an error.
 346           rootObj←⎕NULL
 347      
 348       :EndTrap
 349 
 350 
 351     ∇ rootObj←FixXaml xamlString;attribs;caller;data;err;event;events;expr;inter;name;names;ref
 352      ⍝ Creates a WPF Object From an APL Character Vector Representing XAML.
 353      ⍝ Each named element(s) object will be attached to rootObject.
 354      ⍝ You can see the list of attached elements by doing rootObject.⎕NL -9
 355      ⍝ The callback functions of events must begin with '__' (ex.: Click="__Button_Click")
 356      ⍝ For 3rd party dll, ⎕USING must be properly initiated before calling this function.
 357      ⍝ If there is an error parsing the Xaml, the function will return ⎕NULL with an explanation of the error.
 358      ⍝ Parts of code is taken from Dyalog.
 359 
 360      ⍝ xamlString = Vector of Characters representing a XAML string
 361      ⍝ rootObj    = WPF Root Element Object if no error
 362      ⍝            = ⎕NULL (explanation of error) if error
 363 
 364      ⍝ If an Element has an event attribute that begins with '__' and is named, it will be fixed.
 365      ⍝ If an Element has an event attribute that begins with '__' and is not named, it will not be fixed and make a warning.
 366      ⍝ If an Element has an event attribute that does not begins with '__', it will make an error and return a ⎕NULL rootObj.
 367      ⍝ Function of an event attribute must be defined in the WS otherwise it will not be fixed and make a warning.
 368      ⍝ Root element with an event must be named, otherwise it is recommended to be nameless.
 369      ⍝ Root element name is removed in all cases. Use the rootObj variable directly to access its properties/methods.
 370      
 371       :Trap 0
 372          ⍝ Check if Valid XML
 373          ⍝ The following line will bug with an explanation if there is a syntax error in xamlString.
 374           ⎕USING∪←⊂'System.Xml,System.Xml.dll'
 375           (⎕NEW XmlDocument).LoadXml(⊂xamlString)
 376      
 377          ⍝ The string is valid XML. Clean-it before 'compiling'.
 378           data←⎕XML xamlString                                               ⍝ Convert the characters to APL representation of Xml
 379           attribs←data[;4]                                                   ⍝ Attributes of all the nodes
 380           names←{1⊃(((⍵[;1]∊⊂'x:Name')∨(⍵[;1]∊⊂'Name'))/⍵[;2]),⊂''}¨attribs  ⍝ Find all 'x:Name' and 'Name' attributes
 381           events←⊃⍪/names{(⊂⍺),((⊂'__')≡¨2↑¨⊃¨⍵[;2])⌿⍵}¨attribs              ⍝ Events are all attributes with values beginning with '__'
 382           data[;4]←{(~(⊂'__')≡¨2↑¨⊃¨⍵[;2])⌿⍵}¨attribs                        ⍝ Remove the events: attribute definition beginning with '__'
 383           data[1;4]←⊂{(~(⊂'x:Class')≡¨7↑¨⊃¨⍵[;1])⌿⍵}⊃data[1;4]               ⍝ Remove the x:Class attribute if present in first node
 384           xamlString←⎕XML data                                               ⍝ Convert the APL representation of Xml to characters
 385       :Else
 386          ⍝ There is an Error. Exit.
 387           →ERROR
 388      
 389       :EndTrap
 390      
 391      ⍝ Obtain the Root Element Object of the clean-up XAML String.
 392      ⍝ You can get an error here if, for example, there is an event that does not begin with '__' and was not remove in Xaml Clean-up.
 393       :Trap 0
 394           ⎕USING∪←⊂'System.Windows.Markup,WPF/PresentationFramework.dll'  ⍝ was ⎕USING←' before
 395           rootObj←XamlReader.Parse(⊂xamlString)
 396      
 397         ⍝ ↓↓↓ Alternative way of doing the same thing.
 398         ⍝ ⎕USING∪ ← '' 'System.IO' 'System.Xml,system.xml.dll' 'System.Windows,WPF/PresentationFramework.dll' 'System.Windows.Markup'
 399         ⍝ rootObj ← XamlReader.Load ⎕NEW XmlTextReader (⎕NEW StringReader (⊂xamlString))
 400      
 401           rootObj.∆Events←events  ⍝ Optional: List the events in the property ∆Events
 402       :Else
 403          ⍝ There is an error. Exit.
 404           →ERROR
 405      
 406       :EndTrap
 407      
 408      ⍝ Fix the events of the rootObj before removing its name:
 409      ⍝ Will bug if the rootObj does not have a name.
 410       :Trap 0
 411           :If 1∊events[;1]∊⊂rootObj.Name                                    ⍝ Check if the rootObj has an event
 412               :For (ref event expr) :In ↓(events[;1]∊⊂rootObj.Name)⌿events  ⍝ Loop through the events
 413                   caller←(1⊃⎕NSI),'.'                                       ⍝ Namespace that is calling this function
 414                   expr←((~'#'∊expr)/caller),expr                            ⍝ Add the namespace of the caller to the name of the event
 415                   ⍎'rootObj.on',event,'←''',expr,''''                       ⍝ Hook-up the event
 416               :EndFor
 417           :EndIf
 418       :Else
 419          ⍝ Do nothing. rootObj does not have a name or events to fix.
 420      
 421       :EndTrap
 422      
 423      ⍝ Create refs to all named child objects
 424       :Trap 0
 425           names←(,⊃0≠⍴¨names)/names                  ⍝ Keep only the not empty names
 426           names←(0=rootObj.⎕NC↑names)/names          ⍝ Only names which do not already have a meaning
 427           names←(~names∊⊂rootObj.Name)/names         ⍝ Remove the name of the rootObj to prevent a recursive entry.
 428           events←(~events[;1]∊⊂rootObj.Name)⌿events  ⍝ Remove the event(s) of the rootObj from the list now that they have been fixed.
 429       :Else
 430          ⍝ Do nothing. The previous 2 lines will bug if rootObj does not have a name.
 431      
 432       :EndTrap
 433      
 434      ⍝ Add a reference of all the named object to the rootObj.
 435      ⍝ FindName will not find the names on certain object (like template),
 436      ⍝  so we need to iterate and Trap the error when the name is not found.
 437       :For name :In names
 438           :Trap 0
 439               ⍎'rootObj.(',name,')←rootObj.FindName ⊂name'
 440      
 441           :Else
 442               ⎕←'FixXaml Warning - Name Not found: ',name
 443      
 444           :EndTrap
 445       :EndFor
 446      
 447      ⍝ Show a Warning for Events that begins with '__' that will not be fixed because they are nameless:
 448       :If 0≠↑⍴inter←(~events[;1]∊names)⌿events
 449           ⎕←(⎕UCS 13),'FixXaml Warning - Following Nameless Event(s) Are Not Fixed:'
 450           ⎕←inter
 451       :End
 452      
 453      ⍝ Hook-up events
 454       events←(events[;1]∊names)⌿events ⍝ Named objects only
 455       caller←(1⊃⎕NSI),'.'              ⍝ Namespace that is calling this function
 456      
 457       :For (ref event expr) :In ↓events
 458           :Trap 0
 459             ⍝ Add the namespace of the caller to the name of the event
 460               expr←((~'#'∊expr)/caller),expr
 461      
 462               :If 0≠⎕NC expr
 463                 ⍝ Callback function exist. Hook-up the event.
 464                   ⍎'rootObj.',ref,'.on',event,'←''',expr,''''
 465               :Else
 466                 ⍝ Callback function does not exist. Show warning and do not fix the event.
 467                   ⎕←'FixXaml Warning - Function ',expr,' does not exist. The Event ''',event,''' of ''',ref,''' is not fixed.'
 468               :End
 469      
 470           :Else
 471             ⍝ There is an error. Exit.
 472               →ERROR
 473      
 474           :EndTrap
 475       :EndFor
 476      
 477       →0  ⍝ rootObj is returned here if there is no error.
 478      
 479      ERROR:
 480       ⍝ Build the Error Message
 481       :If 90≠⎕EN
 482          ⍝ APL Error
 483           err←(1⊃⎕DM),': ',{(' '=1↑⍵)↓((1↓a,0)∨a←' '≠⍵)/⍵}(2⊃⎕DM),(⎕UCS 13)
 484      
 485       :Else
 486        ⍝ .Net Error
 487           :If '(NULL)'≢⍕⎕EXCEPTION
 488            ⍝ Show the value of ⎕EXCEPTION if not (NULL).
 489               err←('EXCEPTION: ',⎕EXCEPTION.Message),(⎕UCS 13)
 490           :Else
 491            ⍝ If ⎕EXCEPTION is (NULL) than the .Message property is empty.
 492               err←'EXCEPTION: Unknown error',(⎕UCS 13)
 493      
 494           :EndIf
 495      
 496       :End
 497      
 498       rootObj←⎕NULL err
 499 
 500 
 501     ∇ winParent←GetWindowParent object
 502      ⍝ Obtain the Windows Parent (Root Object) of a children's element.
 503      
 504       winParent←object
 505      
 506       :While 'System.Windows.Window'≢winParent.GetType.ToString
 507           winParent←winParent.Parent
 508       :EndWhile
 509 
 510 
 511     ∇ bmpimg←ImageFromBase64String base64String;imageBytes;MS;⎕USING
 512      ⍝ Convert a Base64String to a System.Windows.Media.Imaging.BitmapImage.
 513      
 514       ⎕USING←'System.IO,mscorlib.dll' 'System,mscorlib.dll' 'System.Windows.Media.Imaging,WPF/PresentationCore.dll'
 515      
 516      ⍝ Convert Base64 String to byte[] as numbers.
 517       imageBytes←Convert.FromBase64String(⊂base64String)
 518      
 519      ⍝ Create a new MemoryStream with the byte[]
 520       MS←⎕NEW MemoryStream(⊂imageBytes)
 521      
 522      ⍝ Create a BitmapImage Object from the Memory Stream
 523       bmpimg←⎕NEW BitmapImage
 524       bmpimg.BeginInit
 525      ⍝ The .OnLoad CacheOption will load the MemoryStream right now so it can be dispose.
 526      ⍝ That way there is no need to use a WriteableBitmap.
 527       bmpimg.CacheOption←bmpimg.CacheOption.OnLoad
 528       bmpimg.StreamSource←MS
 529       bmpimg.EndInit
 530      
 531 ⍝     ⍝ Create a WriteableBitmap that does not need the MemoryStream to persist
 532 ⍝     ⍝ That way it is possible to erase the MemoryStream after creating the Image
 533 ⍝      bmpimg←⎕NEW WriteableBitmap bmpimg
 534      
 535      ⍝ Erase the MemoryStream
 536       MS.Close ⋄ MS.Dispose ⋄ MS←⎕NULL
 537 
 538 
 539     ∇ ScriptFollowsDispatchDelegate obj;actions;delegate;dtlb;⎕IO;⎕ML;⎕USING
 540     ⍝ Function to write asynchronously to the UI thread from another thread.
 541     ⍝ The calling thread does not wait for the operation to finish.
 542     ⍝ Treat following commented lines in caller as a script.
 543     ⍝ Lines beginning with ⍝∇ are kept
 544     ⍝ Lines beginning with ⍝∇⍝ are stripped out (comments)
 545      
 546     ⍝ obj     = UI Object that you want to write to from another thread
 547     ⍝ actions = Lines to execute in the UI thread.
 548      
 549       (⎕IO ⎕ML)←1 3
 550      
 551       :Trap 0
 552           ⎕USING←'System,System.dll' 'System.Windows.Threading,WPF/WindowsBase.dll'
 553      
 554         ⍝ Create a function (⍙Delegate) with the 'action' to execute in the UI thread.
 555         ⍝ The function will be executed where 'DispatchDelegate' is called and not where
 556         ⍝ 'DispatchDelegate' is located.
 557           dtlb←{⍵{((∨\⍵)∧⌽∨\⌽⍵)/⍺}' '≠⍵}
 558           actions←{{'⍝'=↑⍵:'' ⋄ ' ',dtlb ⍵}¨2↓¨⍵/⍨∧\(⊂'⍝∇')≡¨2↑¨⍵}dtlb¨(1+2⊃⎕LC)↓⎕NR 2⊃⎕XSI
 559           delegate←(⎕IO⊃⎕RSI).⎕OR(⎕IO⊃⎕RSI).⎕FX(⊂'⍙Delegate'),actions,(⊂'⎕EX ''⍙Delegate''')
 560      
 561         ⍝ Get a 'Dispatcher' from the UI object. That way we are sure to have the right UI thread.
 562         ⍝ Use the method '.Invoke' instead of '.BeginInvoke' for synchronous call.
 563           {}obj.Dispatcher.BeginInvoke(DispatcherPriority.Normal(⎕NEW Action delegate))
 564      
 565       :Else
 566           ⎕←'Error ScriptFollowsDispatchDelegate: ',actions
 567      
 568         ⍝ Returns the Last Error
 569           :If 90=⎕EN
 570               ⎕←'EXCEPTION: ',⎕EXCEPTION.Message
 571           :Else
 572               ⎕←(1⊃⎕DM),': ',(2⊃⎕DM)
 573           :EndIf
 574       :End
 575 
 576 
 577     ∇ rootObj←ScrubAndFix xamlString;err;names;nodeNumber;reader;stringReader;writer
 578     ⍝ Function to remove the Class and Events elements of Xaml and fix the resulting Xaml.
 579     ⍝ Each named element(s) object will be attached to rootObject.
 580     ⍝ Root element name is removed in all cases. Use the rootObj directly to access its properties/methods.
 581     ⍝ This function is most usefull when experimenting with Xaml taken directly from the Web but is slower than FixXaml.
 582     ⍝ Inspired from the code of XAMLPAD2009.
 583 
 584     ⍝ XamlString = Vector of Characters representing a XAML string
 585     ⍝ rootObj    = WPF Root Element Object if no error
 586     ⍝            = ⎕NULL (explanation of error) if error
 587      
 588       :Trap 0
 589      
 590           ⎕USING∪←'System.IO' 'System.Windows.Markup,WPF/PresentationFramework.dll' 'System.Xaml,System.Xaml.dll'
 591           stringReader←⎕NEW StringReader(⊂xamlString)
 592           reader←⎕NEW XamlXmlReader(stringReader XamlReader.GetWpfSchemaContext)
 593           writer←⎕NEW XamlObjectWriter(reader.SchemaContext)
 594      
 595           ⎕USING←0⍴⊂''
 596           names←''         ⍝ Initial value of the names to fix.
 597           nodeNumber←0     ⍝ Initial value of the node number.
 598      
 599           :While reader.Read
 600      
 601               :If 'StartObject'≡⍕reader.NodeType
 602                 ⍝ Will increment of 1 each time a new node (with a new object) begins.
 603                   nodeNumber+←1
 604               :End
 605      
 606               :If 'StartMember'≡⍕reader.NodeType
 607               :AndIf reader.Member.Name≡'Class'
 608                   {}reader.Read
 609                   {}reader.Read
 610      
 611               :ElseIf 'StartMember'≡⍕reader.NodeType
 612               :AndIf reader.Member.IsEvent
 613                   {}reader.Read
 614                   {}reader.Read
 615      
 616               :ElseIf 'StartMember'≡⍕reader.NodeType
 617               :AndIf reader.Member.Name≡'Name'
 618                   writer.WriteNode(reader)
 619                   {}reader.Read
 620                   writer.WriteNode(reader)
 621      
 622                 ⍝ Check if reader is on first node
 623                   :If 1≠nodeNumber
 624                     ⍝ reader is not on first node. Keep the name.
 625                       names,←⊂reader.Value
 626                   :Else
 627                     ⍝ reader is on first node. Don't keep the name.
 628                   :End
 629      
 630                   {}reader.Read
 631                   writer.WriteNode(reader)
 632      
 633               :Else
 634                   writer.WriteNode(reader)
 635      
 636               :End
 637      
 638           :EndWhile
 639      
 640           rootObj←writer.Result
 641      
 642          ⍝ Assign the value of each names found to the root object:
 643           :If 0≠⍴names
 644               rootObj{⍎'⍺.',⍵,'←⍺.FindName(⊂,⍵)'}¨names
 645           :Else
 646              ⍝ Do nothing, there is no names.
 647           :End
 648      
 649       :Else
 650         ⍝ Build the Error Message
 651           :If 90≠⎕EN
 652             ⍝ APL Error
 653               err←(1⊃⎕DM),': ',{(' '=1↑⍵)↓((1↓a,0)∨a←' '≠⍵)/⍵}(2⊃⎕DM),(⎕UCS 13)
 654      
 655           :Else
 656              ⍝ .Net Error
 657               :Trap 0
 658                 ⍝ Show the value of ⎕EXCEPTION.Message if not ⎕NULL.
 659                   err←('EXCEPTION: ',⎕EXCEPTION.Message),(⎕UCS 13)
 660               :Else
 661                 ⍝ Sometimes ⎕EXCEPTION is (NULL) and will bug here.
 662                   err←'Exception (NULL): Unknown error',(⎕UCS 13)
 663      
 664               :EndTrap
 665      
 666           :End
 667      
 668           rootObj←⎕NULL err
 669      
 670       :EndTrap
 671 
 672 
 673     ∇ __Button_Click(sender event);rootObject;⎕USING
 674      ⍝ Click Event Handler for the Button
 675      
 676      ⍝ Get the Root Object from the Button object (sender)
 677       rootObject←GetWindowParent sender
 678      
 679      ⍝ Assign the new text to the TextBox.
 680       rootObject.textBox1.Text←'I Was Clicked !'
 681      
 682      ⍝ Change some colors of the TextBox
 683       ⎕USING←'System.Windows.Media,WPF/PresentationCore.dll' 'System.Windows,WPF/PresentationFramework.dll'
 684       rootObject.textBox1.Background←⎕NEW SolidColorBrush(Colors.Yellow)
 685       rootObject.textBox1.BorderBrush←⎕NEW SolidColorBrush(Colors.Red)
 686       rootObject.textBox1.BorderThickness←⎕NEW Thickness 3
 687 
 688 
 689     ∇ __EventHandler(sender event);name
 690      ⍝ Single Event Handler for the Window
 691      
 692      ⍝ Get name of the control that was clicked
 693       name←event.Source.Name
 694      
 695      ⍝ sender is the Root Object in this case because
 696      ⍝ the routed event was attached to it.
 697       sender.lStatusBar.Content←'I Was Clicked: ',name
 698      
 699      ⍝ Select the code to be executed:
 700       :Select name
 701       :Case 'mnuCut'
 702      
 703       :Case 'mnuCopy'
 704      
 705       :Case 'mnuPaste'
 706      
 707       :Case 'mnuPrint'
 708      
 709       :Case 'mnuQuit'
 710      
 711       :Case 'mnuAbout'
 712      
 713       :Case 'btnButton1'
 714      
 715       :Case 'btnButton2'
 716      
 717       :Case 'btnButton3'
 718      
 719       :Else
 720           'Error: Unknow Name'
 721       :EndSelect
 722 
 723 
 724  ⍝ Section BackgroundWorker
 725 
 726     ∇ BackgroundWorkerSample max;xaml
 727  ⍝ If you have an operation that will take a long time to complete, and you do not want to cause delays in your
 728  ⍝ user interface (UI), you can use the BackgroundWorker class from Microsoft to run the operation on another thread.
 729 
 730  ⍝ The BackgroundWorker offers several features which include spawning a background thread, the ability
 731  ⍝ to cancel the background process before it has completed, and the chance to report the progress back to your UI.
 732 
 733  ⍝ For multithread operation with APL it is recommended to wait on the Window on a different thread,
 734  ⍝ that way the thread 0 of the session is not blocked. So the Window will wait on thread 1 and the
 735  ⍝ long calculation will be done on tread 2.
 736 
 737  ⍝ This function will simulate a long calculation with the use of a BackgroundWorker.
 738  ⍝ It is finding all the numbers that are a multiple of 42 between 1 and 'max'
 739  ⍝ Start the demo function by doing: BackgroundWorkerSample& 1000
 740  ⍝ In this case it will find all the multiple of 42 between 1 and 1000.
 741  ⍝ The Spawn operator '&' is telling APL to run the function on another thread (in our case thread no 1)
 742 
 743  ⍝   BackgroundWorkerSample = Main function
 744  ⍝ __btnDoAsynchronousCalculation_Click = Callback of the 'Start' button
 745  ⍝ __btnCancelAsynchronousCalculation_Click = Callback of the 'Cancel' button
 746  ⍝ __worker_DoWork = Does the long calculation on another thread (in our case thread no 2)
 747  ⍝ __worker_ProgressChanged = Change the UI to show the progress. Executed on thread no 1 (UI).
 748  ⍝ __worker_RunWorkerCompleted = Callback when the DoWork callback is finished. Executed on thread no 1 (UI).
 749      
 750  ⍝ Inspired from the following:
 751  ⍝ http://www.wpf-tutorial.com/misc/multi-threading-with-the-backgroundworker/
 752  ⍝ http://www.wpf-tutorial.com/misc/cancelling-the-backgroundworker/
 753  ⍝ http://www.jeremybytes.com/downloads/backgroundworkerinwpf.pdf
 754  ⍝ https://msdn.microsoft.com/fr-fr/library/cc221403(v=vs.95).aspx
 755      
 756       {}2520⌶1 ⍝ Use separate thread for .Net
 757      
 758       ⎕USING←''
 759       ⎕USING,←⊂'System,mscorlib.dll'
 760       ⎕USING,←⊂'System.Threading,mscorlib.dll'
 761       ⎕USING,←⊂'System.ComponentModel,System.dll'
 762       ⎕USING,←⊂'System.Windows,WPF/PresentationFramework.dll'
 763      
 764       xaml←'<Window'
 765       xaml,←' xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"'
 766       xaml,←' xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"'
 767       xaml,←' Height="300"'
 768       xaml,←' Width="375"'
 769       xaml,←' Title="BackgroundWorkerSample">'
 770       xaml,←' <DockPanel Margin="10">'
 771       xaml,←' 	<DockPanel DockPanel.Dock="Top">'
 772       xaml,←'	 	<Button'
 773       xaml,←'	 		Name="btnDoAsynchronousCalculation"'
 774       xaml,←'	 		HorizontalAlignment="Left"'
 775       xaml,←'    Width="150"'
 776       xaml,←'	 		Click="__btnDoAsynchronousCalculation_Click"'
 777       xaml,←'    IsEnabled="True"'
 778       xaml,←'	 		DockPanel.Dock="Left">Start'
 779       xaml,←'	 	</Button>'
 780       xaml,←'	 	<Button'
 781       xaml,←'	 		Name="btnCancel"'
 782       xaml,←'	 		HorizontalAlignment="Right"'
 783       xaml,←'    Width="150"'
 784       xaml,←'	 		Click="__btnCancelAsynchronousCalculation_Click"'
 785       xaml,←'    IsEnabled="False"'
 786       xaml,←'	 		DockPanel.Dock="Right">Cancel'
 787       xaml,←'			</Button>'
 788       xaml,←'		</DockPanel>'
 789       xaml,←'		<ProgressBar Name="pbCalculationProgress" Height="18" DockPanel.Dock="Bottom"/>'
 790       xaml,←'		<ListBox Name="lbResults" Margin="0,10"/>'
 791       xaml,←'	</DockPanel>'
 792       xaml,←'</Window>'
 793      
 794       :If ⎕NULL≡↑win←FixXaml xaml
 795     ⍝ Fixing the Xaml did not work. Show the error and exit.
 796           ⎕←2⊃win
 797      
 798       :Else
 799     ⍝ There is no error.
 800           win.max←max
 801           {}win.ShowDialog
 802      
 803       :EndIf
 804 
 805 
 806     ∇ __btnDoAsynchronousCalculation_Click(sender event)
 807 ⍝ Function using a 'BackgroundWorker' thread to do long calculation or blocking action on another thread.
 808      
 809 ⍝ The ProgressBar and ListBox are reset
 810       win.pbCalculationProgress.Value←0
 811       win.lbResults.Items.Clear
 812      
 813 ⍝ Get a BackgroundWorker object from System.ComponentModel in System.dll
 814       win.worker←⎕NEW BackgroundWorker
 815      
 816 ⍝ The event 'DoWork' occurs when the method 'RunWorkerAsync' is called.
 817 ⍝ The event handler executes on another thread the time-consuming operation.
 818 ⍝ You cannot access the UI thread from this callback.
 819       win.worker.onDoWork←'__worker_DoWork'
 820      
 821 ⍝ The event 'ProgressChanged' occurs when the method 'ReportProgress' is called within the 'DoWork' event function (__worker_DoWork).
 822 ⍝ The 'ProgressChanged' event handler executes on the thread that created the BackgroundWorker (should be the UI thread).
 823       win.worker.WorkerReportsProgress←1   ⍝ Specify that you want the background operation to report progress.
 824       win.worker.onProgressChanged←'__worker_ProgressChanged'
 825      
 826 ⍝ The event 'RunWorkerCompleted' occurs when the DoWork event handler returns.
 827       win.worker.onRunWorkerCompleted←'__worker_RunWorkerCompleted'
 828      
 829 ⍝ Specify you want the background operation to allow cancellation.
 830       win.worker.WorkerSupportsCancellation←1
 831      
 832 ⍝ Starts execution of the background operation by raising the 'DoWork' event asynchronously.
 833 ⍝ The .IsBusy property can be used to check if the worker is already running.
 834       win.worker.RunWorkerAsync win.max
 835      
 836 ⍝ The previous line returns immediately so we can set the properties of the buttons.
 837       win.btnDoAsynchronousCalculation.IsEnabled←0
 838       win.btnCancel.IsEnabled←1
 839 
 840 
 841     ∇ __btnCancelAsynchronousCalculation_Click(sender event)
 842 ⍝ To cancel the calculation execute the method .CancelAsync of the BackgroundWorker
 843 ⍝ This will sets the CancellationPending property to true of the BackgroundWorker
 844 ⍝ The function of the 'DoWork' event should periodically check the CancellationPending property to see if it has been set to true.
 845      
 846 ⍝ event = System.Windows.RoutedEventArgs
 847      
 848       win.worker.CancelAsync
 849 
 850 
 851     ∇ __worker_DoWork(sender event);errorException;errorMessage;i;max;progressPercentage;result
 852 ⍝ Event handler executed on another thread when the method 'RunWorkerAsync' is called on the BackgroundWorker object.
 853 ⍝ If your background operation requires a parameter, call 'RunWorkerAsync' with your parameter.
 854 ⍝ You can extract the parameter from the 'DoWorkEventArgs.Argument' property.
 855 
 856 ⍝ You must be careful not to manipulate any user-interface objects in your 'DoWork' event handler.
 857 ⍝ Instead, communicate to the user interface through 'ProgressChanged' and 'RunWorkerCompleted' events.
 858 
 859 ⍝ event = System.ComponentModel.DoWorkEventArgs
 860      
 861 ⍝ It is recommended to put the calculations executed on this other thread inside a ':Trap' statement
 862 ⍝ and report the error(s) on the UI thread via an 'ArgumentException'.
 863 ⍝ This make it easier to debug and to report the error.
 864      
 865       {}2501⌶0   ⍝ Discard thread on exit
 866      
 867       :Trap 0
 868           max←event.Argument  ⍝ Get the argument of the 'RunWorkerAsync' method.
 869      
 870           result←⍳0
 871      
 872     ⍝ Find all the number divisible by 42 from 1 to 'max'
 873           :For i :In ⍳max
 874      
 875         ⍝ Test if the Cancel button was clicked
 876               :If sender.CancellationPending
 877                   event.Cancel←1
 878                   →END
 879      
 880               :Else
 881             ⍝ No cancellation. Do the next calculation.
 882      
 883                   progressPercentage←Convert.ToInt32(100×i÷max) ⍝ Must be an Int32. (Not coerce by APL)
 884      
 885             ⍝ Do the calculation and report progress on the UI with the '.ReportProgress' method of the BackgroundWorker.
 886                   :If 0=42|i
 887                 ⍝ 'i' is a multiple of 42
 888                       result,←i
 889      
 890                 ⍝ The first argument will be in event.ProgressPercentage (Int32)
 891                 ⍝ The second argument (optional) will be in event.UserState (object)
 892                       sender.ReportProgress(progressPercentage,i)
 893      
 894                   :Else
 895                 ⍝ 'i' is not a multiple of 42
 896                       sender.ReportProgress(progressPercentage)
 897      
 898                   :EndIf
 899               :EndIf
 900      
 901         ⍝ Simulate a long calculation by blocking the thread artificially
 902               Thread.Sleep 10  ⍝ With Thread.Sleep 1 it does not work. APL too fast for Windows ?
 903      
 904           :EndFor
 905      
 906      END:
 907     ⍝ ↓↓↓ This will call the event 'RunWorkerCompleted' with an argument in the .Result property.
 908           event.Result←max result
 909      
 910       :Else
 911      
 912     ⍝ There has been an error. Build the error message
 913           :If 90≠⎕EN
 914         ⍝ APL Error
 915               errorMessage←(1⊃⎕DM),': ',{(' '=1↑⍵)↓((1↓a,0)∨a←' '≠⍵)/⍵}(2⊃⎕DM),(⎕UCS 13)
 916      
 917           :Else
 918         ⍝ .Net Error
 919               :If '(NULL)'≢⍕⎕EXCEPTION
 920             ⍝ Show the value of ⎕EXCEPTION if not (NULL).
 921                   errorMessage←('EXCEPTION: ',⎕EXCEPTION.Message),(⎕UCS 13)
 922               :Else
 923             ⍝ If ⎕EXCEPTION is (NULL) than the .Message property is empty.
 924                   errorMessage←'EXCEPTION: Unknown error',(⎕UCS 13)
 925      
 926               :EndIf
 927           :End
 928      
 929     ⍝ This Exception will terminate the iteration and call the 'RunWorkerCompleted' event.
 930     ⍝ The error can be obtained in the function '__worker_RunWorkerCompleted' that is running on the UI thread.
 931           errorException←⎕NEW ArgumentException(⊂errorMessage)
 932           errorException ⎕SIGNAL 90
 933      
 934       :EndTrap
 935 
 936 
 937     ∇ __worker_ProgressChanged(sender event)
 938 ⍝ Callback function of the event 'ProgressChanged'
 939 ⍝ It is excuted on the thread that created the BackgroundWorker
 940 ⍝ The UI can be access from this function
 941 
 942 ⍝ event = System.ComponentModel.ProgressChangedEventArgs
 943      
 944 ⍝ Get first argument
 945       win.pbCalculationProgress.Value←event.ProgressPercentage
 946      
 947 ⍝ Get second argument of callback if not [Null].
 948       :If '[Null]'≢⍕event.get_UserState
 949           {}win.lbResults.Items.Add(event.UserState)
 950      
 951     ⍝ Position the ListBox at the end.
 952           win.lbResults.ScrollIntoView(win.lbResults.Items[win.lbResults.Items.Count-1])
 953       :EndIf
 954 
 955 
 956     ∇ __worker_RunWorkerCompleted(sender event);max;result
 957 ⍝ This event is raised when the DoWork event handler returns.
 958 ⍝ It is excuted on the thread that created the BackgroundWorker
 959 ⍝ The UI can be access from this function
 960 
 961 ⍝ event = System.ComponentModel.RunWorkerCompletedEventArgs
 962      
 963 ⍝ Check if it was cancelled
 964       :If event.Cancelled
 965           {}MessageBox.Show(⊂'The calculation was Cancel')
 966      
 967 ⍝ Check if there was an error
 968       :ElseIf '[Null]'≢⍕event.get_Error
 969     ⍝ The 'errorMessage' of '__worker_DoWork' is in 'event.Error.Message'
 970           {}MessageBox.Show(⊂event.Error.Message)
 971      
 972       :Else
 973     ⍝ The argument passed by '__worker_DoWork' is in 'event.Result'
 974           (max result)←event.Result
 975           {}MessageBox.Show(⊂'Numbers between 1 and ',(⍕max),' divisible by 42: ',⍕result)
 976      
 977       :EndIf
 978      
 979 ⍝ Setup the UI for another calculation
 980       win.btnDoAsynchronousCalculation.IsEnabled←1
 981       win.btnCancel.IsEnabled←0
 982       win.pbCalculationProgress.Value←0
 983      
 984 ⍝ Clean-up
 985       win.worker.Dispose
 986 
 987 
 988 :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.
  • [get | view] (2015-03-03 02:22:16, 3.6 KB) [[attachment:Sample1.png]]
  • [get | view] (2015-03-08 22:14:08, 41.2 KB) [[attachment:wpfXamlDemo.v1.1.txt]]
  • [get | view] (2015-03-13 18:21:51, 41.5 KB) [[attachment:wpfXamlDemo.v1.2.txt]]
  • [get | view] (2015-04-24 22:54:52, 41.5 KB) [[attachment:wpfXamlDemo.v1.3.txt]]
  • [get | view] (2016-02-11 16:20:05, 41.5 KB) [[attachment:wpfXamlDemo.v1.4.txt]]
  • [get | view] (2017-08-14 03:14:25, 56.3 KB) [[attachment:wpfXamlDemo.v1.5.txt]]
  • [get | view] (2017-10-19 12:20:03, 56.8 KB) [[attachment:wpfXamlDemo.v1.6.txt]]
 All files | Selected Files: delete move to page

You are not allowed to attach a file to this page.