Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require("CLRPackage")
- --
- import("PresentationFramework")
- import("PresentationBase")
- import("PresentationCore")
- import("System.Windows")
- import("System.Windows.Controls")
- import("System.Windows.Markup")
- import("System.Windows.Media")
- import("System.Reflection")
- import("System.Xml")
- import("System.IO")
- --
- dynxaml11 = {}
- --
- function dynxaml11.ctor()
- local this = Window()
- local button, rd
- local xaml = [[
- <Page
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
- <Page.Resources>
- <ResourceDictionary>
- <ResourceDictionary.MergedDictionaries>
- <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
- <SolidColorBrush x:Key="brush" Color="Red" />
- </ResourceDictionary>
- </ResourceDictionary.MergedDictionaries>
- </ResourceDictionary>
- </Page.Resources>
- <Button x:Name="button" Content="Click Me" Height="100" Width="100"
- Background="{DynamicResource brush}" />
- </Page>
- ]]
- local function button_Click( sender, e )
- end
- local function LoadXAML()
- -- local fn = [[C:\Tony Gomez\Wlua\WpfTests\rd1.xaml]]
- -- local fs = FileStream( fn, FileMode.Open )
- -- rd = XamlReader.Load( fs )
- -- this.Resources = rd
- this.Resources.Source = Uri( [[C:\Tony Gomez\Wlua\WpfTests\rd1.xaml]] )
- local mysr = StringReader( xaml )
- local xmlReader = XmlTextReader( mysr )
- local content = XamlReader.Load( xmlReader )
- button = LogicalTreeHelper.FindLogicalNode( content, "button" )
- return content
- end
- local function InitializeComponent()
- this.Width = 300
- this.Height = 175
- this.Title = "Resource Test"
- this.WindowStartupLocation = WindowStartupLocation.CenterScreen
- this.Topmost = true
- this.Content = LoadXAML()
- button.Click:Add( button_Click )
- end
- InitializeComponent()
- return this
- end
- --
- setmetatable( dynxaml11, { __call = function( _, ... ) return dynxaml11.ctor( ... ) end } )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement