Size: 2410
Comment:
|
Size: 10272
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 3: | Line 3: |
UNDER CONSTRUCTION |
|
Line 6: | Line 4: |
wpfXamlEditor is a Xaml editor for an APL variable in a workspace or for a file on disk. The user command is able to show the Xaml in color with folding, print it, reorganize it so it is more readable according to some settings set by the user. It is inspired by the work of Robby Ingebretsen of '''Kaxaml''' ([[http://www.Kaxaml.com||target='_blank']]). It is particularly valuable to the users that like to keep their Xaml in the workspace. With `XamlEditor` they have a tool to maintain it without effort. | `XamlEditor` is a Xaml editor for an APL variable or for a file on disk. This Dyalog APL user command is able to show the Xaml in color with folding, print it, reorganize it so it is more readable according to some settings set by the user. It is inspired by the work of Robby Ingebretsen of '''Kaxaml''' ([[http://www.Kaxaml.com||target='_blank']]). It is particularly valuable for APLers that like to keep their Xaml in the workspace. With `XamlEditor` they have a tool to maintain it without effort. |
Line 9: | Line 7: |
Once installed the user command can be invoke by typing `]XamlEditor` (casing is not important, no argument). The following start-up screen should appear:<<BR>><<BR>> | Once installed the user command can be invoke by typing `]XamlEditor` (casing is not important, no argument). The following start-up screen will appear:<<BR>><<BR>> |
Line 14: | Line 12: |
||{{attachment:Scrubber24.png || width=24}} || Scrub the Xaml According to Settings ||{{attachment:Delete24.png || width=24}} || Delete the Selected Text || | ||{{attachment:Scrubber24.png || width=24}} || Rewrite the Xaml According to the Settings (Scrub) ||{{attachment:Delete24.png || width=24}} || Delete the Selected Text || |
Line 22: | Line 20: |
== Installation == 1. Download the file [[attachment:wpfXamlEditor.1.0.zip]]. It contains the Dyalog user command file `wpfXamlEditor.dyalog` and a dll named `ICSharpCode.AvalonEdit.dll` 1. Copy the file `wpfXamlEditor.dyalog` to your user command directory (for advice how to organize your User Commands see [[UserCommands/WhereShouldTheyGo||target='_blank']]). 1. Copy the file `ICSharpCode.AvalonEdit.dll` to the same directory as your `dyalog.exe` file (as shown by `+2 ⎕NQ'.' 'GetEnvironment' 'Dyalog'`). You may need administrator privileges for copying the file. That dll is free of charge and was written by Daniel Grunwald. It can be downloaded from [[http://www.codeproject.com/Articles/42490/Using-AvalonEdit-WPF-Text-Editor|CodeProject|target='_blank']] or from [[http://avalonedit.net/|AvalonEdit|target='_blank']] but is included in the zip file for commodity. == Detailed Explanations == ||{{attachment:Exec32.png || width=24}}|| Execute the Xaml and Show the Result in a Separate Window || The Xaml will be parsed and show in a separate window. If the root element of the Xaml is not a window it will be made the content of a new window. The x:Class attribute will be removed if present. All the events will be removed before parsing the Xaml by the function `ScrubAndFix`. It does not rely on a prefix to removed the events. <<SeeSaw(section="ScrubAndFix", toshow="(<<Show ScrubAndFix>>)", tohide="(<<Hide ScrubAndFix>>)", bg="#FEE1A5", speed="Slow")>> {{{{#!wiki seesaw/ScrubAndFix/ScrubAndFix/hide {{{ ∇ rootObj←ScrubAndFix xamlString;err;reader;stringReader;writer;⎕USING ⍝ Function to remove the Class and Events elements of Xaml and fix the resulting Xaml. ⍝ This function is most usefull when experimenting with Xaml taken directly from the Web but is slower than FixXaml. ⍝ Inspired from the code of XAMLPAD2009. ⍝ ⍝ XamlString = Vector of Characters representing a XAML string ⍝ rootObj = WPF Root Element Object if no error ⍝ = ⎕NULL (explanation of error) if error :Trap 0 ⎕USING←'System.IO' 'System.Windows.Markup,WPF/PresentationFramework.dll' 'System.Xaml,System.Xaml.dll' stringReader←⎕NEW StringReader(⊂xamlString) reader←⎕NEW XamlXmlReader(stringReader XamlReader.GetWpfSchemaContext) writer←⎕NEW XamlObjectWriter(reader.SchemaContext) ⎕USING←0⍴⊂'' ⍝ Don't need it anymore :While reader.Read :If 'StartMember'≡⍕reader.NodeType :AndIf reader.Member.Name≡'Class' ⍝ Skip the x:Class attribute {}reader.Read {}reader.Read :ElseIf 'StartMember'≡⍕reader.NodeType :AndIf reader.Member.IsEvent ⍝ Skip the Event member {}reader.Read {}reader.Read :Else ⍝ Keep the other nodes writer.WriteNode(reader) :End :EndWhile ⍝ The following line will return the root object rootObj←writer.Result :Else ⍝ Build the Error Message :If 90≠⎕EN ⍝ APL Error err←(1⊃⎕DM),': ',{(' '=1↑⍵)↓((1↓a,0)∨a←' '≠⍵)/⍵}(2⊃⎕DM),(⎕UCS 13) :Else ⍝ .Net Error :Trap 0 ⍝ Show the value of ⎕EXCEPTION.Message if not ⎕NULL. err←('EXCEPTION: ',⎕EXCEPTION.Message),(⎕UCS 13) :Else ⍝ Sometimes ⎕EXCEPTION is (NULL) and will bug here. err←'Exception (NULL): Unknown error',(⎕UCS 13) :EndTrap :End rootObj←⎕NULL err :EndTrap ∇ }}} }}}} <<BR>> ||{{attachment:Scrubber24.png || width=24}} || Rewrite the Xaml According to the Settings (Scrub) || Will rewrite the Xaml according to the Settings. The most important Settings is '''Attribute Tolerance''', it allows you to define up to how many attributes there could be on one line of Xaml. Past that number all the attributes are written on a separate line. <<BR>><<BR>> ||{{attachment:OpenObject24.png || width=24}} || Open a Dialog Box to Select a Xaml Variable in the WS || ||{{attachment:SaveObject24.png || width=24}} || Open a Dialog Box to Save the Xaml as a Variable in the WS || The dialog box contains a tree element where each branch is a namespace that has a character variable that responded positive to the following test: `'><'≡¯2↑1⌽variableName~⎕UCS 32 10 13 9` (first and last character is '<>' after removing the space,LF,NL,HT characters). Note that variables of scripted namespace will not be permanently changed by `XamlEditor`. <<BR>><<BR>> ||{{attachment:Open24.png || width=24}} || Open a Dialog Box to Select a File on Disk || ||{{attachment:Save24.png || width=24}} || Open a Dialog Box to Save the Xaml to a File || A standard `OpenFileDialog` and `SaveFileDialog` are used to select and save the file. <<BR>><<BR>> ||{{attachment:Print32.png || width=24}} || Print All the Xaml || ||{{attachment:PrintPreview32.png || width=24}} || Print Preview All the Xaml || Will take the Xaml to a `FlowDocument` where it can be preview or print directly. <<BR>><<BR>> ||{{attachment:Comments24.png || width=24}} || Make Selected Text a Comment || The following rules applied to this button when clicked: 1. If nothing is selected it will insert `'<!-- -->'` at the caret. 1. If the selection is positive to the test: `' --><!-- '≡9↑¯4⌽selectedText`, the comments are removed. 1. Otherwise it will insert: `'<!-- ',selectedText,' -->'` <<BR>> ||{{attachment:Settings24.png || width=24}} || Choose the Settings when Scrubbing || The settings for scrubbing are saved in a xml file named `XED.Settings.xml`. The file will be created automatically with default values the first time the user command runs. It will be located next to the `wpfXamlEditor.dyalog` file or in the `AppData` directory depending on the Windows version and security. The data of the file looks like this:<<BR>> {{{#!highlight xml <Settings> <EditorFont>APL385 Unicode</EditorFont> <EditorFontSize>14</EditorFontSize> <ReducePrecision>1</ReducePrecision> <Precision>3</Precision> <AttributeCounteTolerance>3</AttributeCounteTolerance> <ReorderAttributes>1</ReorderAttributes> <RemoveCommonDefaultValues>0</RemoveCommonDefaultValues> <ConvertTabsToSpaces>1</ConvertTabsToSpaces> <SpaceCount>3</SpaceCount> </Settings> }}} <<BR>>It is used to build the Settings window.<<BR>> {{attachment:Settings.png || width=243}} || '''Item''' || '''Description''' || || Font: || Font used by Xaml Editor || || Font Size: || Size of the font used by Xaml Editor || || Numeric Precision: || Reduce the Precision of Large Numbers to a Maximum of this Number of Digits Beyond the Decimal Point || || Attribute Tolerance: || If More Than This Number of Attributes are Defined on an Element, Scrubber Will Move Each Attribute onto its Own Line || || Reorder Attributes by Importance || Scrubber Will Reorder Attributes on a Given Element According to a Predetermined Set of Rules About Which Attributes Are Most Important || || Remove Common Default Values || Scrubber Will Remove Common Properties Which Are Being Set to Their Default Values || || Indent Using Spaces || If This is Checked, Scrubber Will Indent Using Spaces Instead of Tabs || == Version Information == ||Original author: ||Pierre Gilbert || ||Responsible: ||PierreGilbert || ||Email: || <<MailTo(apgil AT SPAMFREE videotron DOT ca)>> || ---- CategoryDyalogWpfUtilities CategoryDyalog |
wpfXamlEditor
Overview
XamlEditor is a Xaml editor for an APL variable or for a file on disk. This Dyalog APL user command is able to show the Xaml in color with folding, print it, reorganize it so it is more readable according to some settings set by the user. It is inspired by the work of Robby Ingebretsen of Kaxaml (http://www.Kaxaml.com). It is particularly valuable for APLers that like to keep their Xaml in the workspace. With XamlEditor they have a tool to maintain it without effort.
Usage
Once installed the user command can be invoke by typing ]XamlEditor (casing is not important, no argument). The following start-up screen will appear:
Here is a short description for each buttons:
Button |
Explanation |
Button |
Explanation |
Execute the Xaml and Show the Result in a Separate Window |
|
Select All the Xaml |
|
|
Rewrite the Xaml According to the Settings (Scrub) |
|
Delete the Selected Text |
|
Open a Dialog Box to Select a Xaml Variable in the WS |
|
Clear the Clipboard |
|
Open a Dialog Box to Save the Xaml as a Variable in the WS |
|
Undo Last Operation |
|
Open a Dialog Box to Select a File on Disk |
|
Redo Previous Operation |
|
Open a Dialog Box to Save the Xaml to a File |
|
Print All the Xaml |
|
Cut the Selected Text to The Clipboard |
|
Print Preview All the Xaml |
|
Copy the Selected Text to the Clipboard |
|
Make Selected Text a Comment |
|
Paste the Text From the clipboard |
|
Choose the Settings when Scrubbing |
Installation
Download the file wpfXamlEditor.1.0.zip. It contains the Dyalog user command file wpfXamlEditor.dyalog and a dll named ICSharpCode.AvalonEdit.dll
Copy the file wpfXamlEditor.dyalog to your user command directory (for advice how to organize your User Commands see UserCommands/WhereShouldTheyGo).
Copy the file ICSharpCode.AvalonEdit.dll to the same directory as your dyalog.exe file (as shown by +2 ⎕NQ'.' 'GetEnvironment' 'Dyalog'). You may need administrator privileges for copying the file. That dll is free of charge and was written by Daniel Grunwald. It can be downloaded from CodeProject or from AvalonEdit but is included in the zip file for commodity.
Detailed Explanations
Execute the Xaml and Show the Result in a Separate Window |
The Xaml will be parsed and show in a separate window. If the root element of the Xaml is not a window it will be made the content of a new window. The x:Class attribute will be removed if present. All the events will be removed before parsing the Xaml by the function ScrubAndFix. It does not rely on a prefix to removed the events. ( Show ScrubAndFix )
|
Rewrite the Xaml According to the Settings (Scrub) |
Will rewrite the Xaml according to the Settings. The most important Settings is Attribute Tolerance, it allows you to define up to how many attributes there could be on one line of Xaml. Past that number all the attributes are written on a separate line.
|
Open a Dialog Box to Select a Xaml Variable in the WS |
|
Open a Dialog Box to Save the Xaml as a Variable in the WS |
The dialog box contains a tree element where each branch is a namespace that has a character variable that responded positive to the following test: '><'≡¯2↑1⌽variableName~⎕UCS 32 10 13 9 (first and last character is '<>' after removing the space,LF,NL,HT characters). Note that variables of scripted namespace will not be permanently changed by XamlEditor.
|
Open a Dialog Box to Select a File on Disk |
|
Open a Dialog Box to Save the Xaml to a File |
A standard OpenFileDialog and SaveFileDialog are used to select and save the file.
|
Print All the Xaml |
|
Print Preview All the Xaml |
Will take the Xaml to a FlowDocument where it can be preview or print directly.
|
Make Selected Text a Comment |
The following rules applied to this button when clicked:
If nothing is selected it will insert '<!-- -->' at the caret.
If the selection is positive to the test: ' --><!-- '≡9↑¯4⌽selectedText, the comments are removed.
Otherwise it will insert: '<!-- ',selectedText,' -->'
|
Choose the Settings when Scrubbing |
The settings for scrubbing are saved in a xml file named XED.Settings.xml. The file will be created automatically with default values the first time the user command runs. It will be located next to the wpfXamlEditor.dyalog file or in the AppData directory depending on the Windows version and security. The data of the file looks like this:
1 <Settings>
2 <EditorFont>APL385 Unicode</EditorFont>
3 <EditorFontSize>14</EditorFontSize>
4 <ReducePrecision>1</ReducePrecision>
5 <Precision>3</Precision>
6 <AttributeCounteTolerance>3</AttributeCounteTolerance>
7 <ReorderAttributes>1</ReorderAttributes>
8 <RemoveCommonDefaultValues>0</RemoveCommonDefaultValues>
9 <ConvertTabsToSpaces>1</ConvertTabsToSpaces>
10 <SpaceCount>3</SpaceCount>
11 </Settings>
It is used to build the Settings window.
Item |
Description |
Font: |
Font used by Xaml Editor |
Font Size: |
Size of the font used by Xaml Editor |
Numeric Precision: |
Reduce the Precision of Large Numbers to a Maximum of this Number of Digits Beyond the Decimal Point |
Attribute Tolerance: |
If More Than This Number of Attributes are Defined on an Element, Scrubber Will Move Each Attribute onto its Own Line |
Reorder Attributes by Importance |
Scrubber Will Reorder Attributes on a Given Element According to a Predetermined Set of Rules About Which Attributes Are Most Important |
Remove Common Default Values |
Scrubber Will Remove Common Properties Which Are Being Set to Their Default Values |
Indent Using Spaces |
If This is Checked, Scrubber Will Indent Using Spaces Instead of Tabs |
Version Information
Original author: |
Pierre Gilbert |
Responsible: |
|
Email: |
<apgil AT SPAMFREE videotron DOT ca> |