Skip to content

Instantly share code, notes, and snippets.

@mattpodwysocki
Created August 6, 2010 04:37
Show Gist options
  • Save mattpodwysocki/510841 to your computer and use it in GitHub Desktop.
Save mattpodwysocki/510841 to your computer and use it in GitHub Desktop.
load_assembly 'System.Core'
load_assembly 'WindowsBase'
load_assembly 'PresentationCore'
load_assembly 'PresentationFramework'
load_assembly 'System.Xaml'
load_assembly 'System.CoreEx'
load_assembly 'System.Reactive'
include System
include System::Linq
include System::Windows
include System::Windows::Controls
using_clr_extensions System
using_clr_extensions System::Linq
class RubyWindow < Window
attr_reader :textbox, :listbox
def initialize
self.Title = 'Hello Ruby!'
stackpanel = StackPanel.new
@textbox = TextBox.new
@listbox = ListBox.new
stackpanel.children.add(@textbox)
stackpanel.children.add(@listbox)
self.content = stackpanel
@textbox_changed = Observable.method(:from_event).of(TextChangedEventArgs).call(@textbox, 'TextChanged')
@textbox_changed.
select(lambda { |event| event.sender.text }).
throttle(TimeSpan.from_seconds(1)).
distinct_until_changed().
observe_on_dispatcher().
subscribe(
lambda do |text|
@listbox.items.add(text)
end)
end
end
window = RubyWindow.new
application = Application.new
application.run(window)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment