WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: stanl on January 03, 2021, 05:52:18 AM

Title: XAML - 1 and Done
Post by: stanl on January 03, 2021, 05:52:18 AM
Attached is a simple XAML file to support the script below. Based on a discussion of XAML that re-focused Jim's Rich Text Control thread I want to clear up the main issue with XAML - WB.
Running the script with the attached file will bring up a window with a series of buttons. There is also a lame effort to itemize the Buttons as I need more practice with XPath as it has been years since I have played with it :o .


The ask would be: is there a way to process a click event on any of the buttons?
Code (WINBATCH) Select


;CLR  - test XAML Buttons
cXAML = dirscript():"testbutton.xaml"
If ! FileExist(cXAML) Then Terminate(@TRUE,"XAML File Not Found",cXAML)
XAML = FileGet(cXAML)
Message("",XAML)
_True = ObjectType('BOOL',1)
_False = ObjectType('BOOL',0)
ObjectClrOption('useany','System')
ObjectCLrOPtion('useany','PresentationFramework')
ObjectCLrOPtion('useany','PresentationCore')
ObjectClrOption('useany','System.Xml')
oDOc =  ObjectClrNew('System.Xml.XmlDocument')
oDoc.LoadXml(XAML)
oXML = ObjectClrNew('System.Xml.XmlNodeReader',oDoc)


;create list pair to identify Buttons
;====================================================================================================
blist =""
elements = oDoc.GetElementsByTagName("Button")
n = elements.Count
For i = 0 To n-1
   n1 = elements.Item(i).Attributes.Count
   att = ""
   For j=0 To n1-1
      att = att:elements.Item(i).Attributes.Item(j).Name:"="
      att = att:elements.Item(i).Attributes.Item(j).Value:","
   Next
   blist = blist:strsub(att,1,strlen(att)-1):@LF
Next
Message("XAML Buttons",blist)
;====================================================================================================


;Load Xaml
oXamlReader = ObjectClrNew('System.Windows.Markup.XamlReader')
oWin = oXamlReader.Load(oXML)
oWin = ObjectClrType( 'System.Windows.Window', oWin )
;Display Window for 5 seconds then close
;otherwise oWin.ShowDialog() will keep Window Open
oWin.Show()
TimeDelay(5)
oWin.Close()


Exit
;====================================================================================================


Title: Re: XAML - 1 and Done
Post by: td on January 03, 2021, 08:29:46 AM
As has been mentioned multiple times before and as far as I know, the answer to your question is "No". At least, that is the case without writing and compiling some C# or other MSFT extended language.  The technical explanation for this goes beyond the scope of this forum.
Title: Re: XAML - 1 and Done
Post by: stanl on January 03, 2021, 01:31:42 PM
Asked and answered.
Title: Re: XAML - 1 and Done
Post by: td on January 04, 2021, 08:35:33 AM
Thanks for taking the time to write a script that demonstrates creating a UI with MSFT's dotNet support for AXML.
Title: Re: XAML - 1 and Done
Post by: stanl on January 04, 2021, 01:41:52 PM
Just as a side note. I create a GUI with WinForms and compile with PS. Attached is not much. 4 buttons, click first 3 they change colors, last one exists, but I can access the click event. Now, to execute any of the fist 3 clicks in WB code would take minutes, in PS a lot longer as there is so much extra stuff I could easily do with WB. Kinda want the best of both worlds....


Attached may throw an initial warning as it an exe.
Title: Re: XAML - 1 and Done
Post by: td on January 05, 2021, 10:20:10 AM
MSFT is starting to push their "Fluent Design" UI. How much is marketing and how much is actual changes to the basic set of Windows widgets that have become familiar to Windows users over the years will help determine the direction of WIL/WinBath's  scriptable UI.  The coming fall release of Windows 10 update may help clarify their direction and the direction of WinBatch.
Title: Re: XAML - 1 and Done
Post by: stanl on January 05, 2021, 01:08:34 PM
Quote from: td on January 05, 2021, 10:20:10 AM
  The coming fall release of Windows 10 update may help clarify their direction and the direction of WinBatch.


at which point you can sign me up :)