Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 56 lines (44 sloc) 1.745 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
require 'rho/rhocontroller'

class SignatureUtilController < Rho::RhoController
  @layout = :simplelayout
  
  def index
    puts "Signature index controller"
    @signatures = SignatureUtil.find(:all)
    render :back => '/app'
  end

  def new
    imgFormat = System::get_property('platform') == 'WINDOWS' ? "bmp" : "jpg"
    
    Rho::SignatureCapture.take(url_for( :action => :signature_callback), { :imageFormat => imgFormat, :penColor => 0xff0000, :penWidth=>5, :border => true, :bgColor => 0x00ff00,
        :fileName => File.join( Rho::Application.databaseBlobFolder(), "/Image_" + Time.now.to_i.to_s() ) })
        
    redirect :action => :index
  end

  def delete
    @signature = SignatureUtil.find(@params['id'])
    @signature.destroy
    redirect :action => :index
  end

  def signature_callback
    puts "@params : #{@params}"
    if @params['status'] == 'ok'
      #create signature record in the DB
      signature = SignatureUtil.new({'signature_uri'=> Rho::Application.relativeDatabaseBlobFilePath(@params['signature_uri'])})
      signature.save
      puts "new Signature object: " + signature.inspect
    end
    WebView.navigate( url_for :action => :index )
    #WebView::refresh
    #reply on the callback
    #render :action => :ok, :layout => false
    ""
  end

  def inline_capture
    Rho::SignatureCapture.visible(true, :penColor => 0xff0000, :penWidth=>1, :border => true, :bgColor => 0x00ff00,
        :fileName => File.join( Rho::Application.databaseBlobFolder(), "/Image_" + Time.now.to_i.to_s() ) )
  end

  def do_capture
    Rho::SignatureCapture.capture(url_for( :action => :signature_callback))
  end
  
  def clear_capture
    Rho::SignatureCapture.clear()
  end
  
end
Something went wrong with that request. Please try again.