$LOAD_PATH << './lib'
require 'wx'
require 'win32ole'
require '__wxautoload'
require 'dl/win32'


module Rumix
	module Util
		module_function
		
		def run(cmd)
			@wsh.Run(cmd)
		end
		
		def run_on_ckw(cmd)
			run(%Q|start d:\\nyaos\\ckw.exe -e d:\\nyaos\\nyaos.exe|)
		end
	end
	
	include Util

	class App < Wx::App
	  private
	
	  def on_init
			"app initialize start."
		
	    Wx::XmlResource.get.load('rumix.xrc')
		  MainFrame.new.show
				
			
			return(!ARGV.include?('--test-run'))
	  end
	end
	
	class MainFrame < Wx::Frame
		
		def initialize
			super
			
			@wsh = WIN32OLE.new("Wscript.Shell")
			#@send_message = Win32API.new("user32", "SendMessage",['L']*4,'L')
			
			Wx::XmlResource.get.load_frame_subclass(self, nil, 'FrmMain')
			evt_button(find_window_by_name('BtnGemManager')) do
				GemManagerDialog.new.show_modal
			end
		end
	end
	
	class ProgressDialog < Wx::Dialog
		
		def initialize
			super
			
			Wx::XmlResource.get.load_dialog_subclass(self, nil, 'ProgressDialog')
			
			evt_button(find_window_by_name('BtnCancel')) do
				end_modal(0)
			end
			
			find_window_by_name('LblProcess').label = 'gemの情報を読み込み中です...'
		end
	end

	
	class GemManagerDialog < Wx::Dialog
		
		def initialize
			super
			
			Wx::XmlResource.get.load_dialog_subclass(self, nil, 'GemManagerDialog')
			
			

			
			@remote_page = find_window_by_name('notebook').get_page(1)
			@remote_list = @remote_page.find_window_by_name('LstGem')
			evt_listbox(@remote_list) do |evt|
				dlg = ProgressDialog.new
				dlg.show_modal
			end
			

		end
	end
end



Rumix::App.new.main_loop
