[Ironruby-core] silverlight.rb
Randall Sutton
randallsutton at gmail.com
Wed Feb 10 19:07:19 EST 2010
I ended up just taking the idea and making my own version.
class Wpf
def self.create(t,args={},&b)
# create an instance of the class
obj = t.new
# assign all the args
args.each_pair do |k,v|
obj.send("#{k.to_s}=",v)
end
# define the add method if it doesn't have one
if !(obj.respond_to? :add) && (obj.respond_to? :children)
obj.instance_eval('def add(t,args={},&b); obj = Wpf.create(t,args,&b); self.children.add(obj); obj; end;')
end
# call the create method if there is one
if obj.respond_to? :create
obj.create
end
# execute the block against the instance
obj.instance_eval(&b)
obj
end
end
Not as complex as the other, so I might be missing something. So far this has worked great and I added ability to have a create method so if you are constructing a class that inherits from a control you could do some initialization before the block is executed.
Thanks,
Randall
On Jan 20, 2010, at 1:21 AM, Jimmy Schementi wrote:
> Silverlight.rb has actually been embedded in the Microsoft.Scripting.Silverlight.dll (as init.rb) and is loaded automatically, but I didn't include Wpf.build, so the version you have in the photoviewer app is the latest, so use at your own risk. It could possibly be added for the final release, or put in an external helper file. Let me know if it works for you currently.
>
> ~Jimmy
>
>
>> -----Original Message-----
>> From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-
>> bounces at rubyforge.org] On Behalf Of Randall Sutton
>> Sent: Wednesday, January 13, 2010 10:42 AM
>> To: ironruby-core at rubyforge.org
>> Subject: [Ironruby-core] silverlight.rb
>>
>> I would like to use the Wpf.build method contained in the silverlight.rb
>> file. Currently I can only find this file in the photoviewer app from 2008
>> for what looks like Silverlight 2. Is there an updated version of this file?
>> I noticed it isn't contained in the 1.0RC1 download.
>>
>> Thanks,
>> Randall
>> _______________________________________________
>> Ironruby-core mailing list
>> Ironruby-core at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/ironruby-core
>
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
More information about the Ironruby-core
mailing list