###############################################################################
#
# example1.tcl --
#
# Copyright (c) 2007-2012 by Joe Mistachkin.  All rights reserved.
#
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: $
#
###############################################################################

package require Tk
package require Garuda

wm withdraw .

if {![info exists i]} then { set i 0 }; incr i

set toplevel [toplevel .example$i]
bind $toplevel <F2> {console show}

set script {
  #
  # NOTE: This script can use any of the commands provided by
  #       Eagle (e.g. [object invoke] to invoke .NET Framework
  #       objects).
  #
  proc handleClickEvent { sender e } {
    if {[tcl ready]} then {
      msgBox [appendArgs "Tcl version is: " \
          [tcl eval [tcl master] info patchlevel] \n \
          "Eagle version is: " [info engine patchlevel]] About
    } else {
      msgBox "Tcl is not ready." About
    }
  }

  object load -import System.Windows.Forms
  interp alias {} msgBox {} object invoke MessageBox Show

  set form [object create -alias Form]
  $form Text WinForm; $form Show

  set button [object create -alias Button]

  $button Left [expr {([$form ClientSize.Width] - [$button Width]) / 2}]
  $button Top [expr {([$form ClientSize.Height] - [$button Height]) / 2}]

  $button Text "Click Here"
  $button add_Click handleClickEvent

  object invoke $form.Controls Add $button
}

set button [button $toplevel.run -text "Click Here" \
    -command [list eagle $script]]

pack $button -padx 20 -pady 20 -ipadx 10 -ipady 10
