func init // adds using namespace sys.add_use('System.Windows.Forms') // initialize instance sys.add_object(this.codename, 'System.Windows.Forms.Timer') // initialize autostop if(not isdef("AutoStop")) sys.add_var('auto', 1) end // initialize properties sys.set_typed_field(104, 'Enabled') sys.set_field('Interval') sys.set_typed_field(20, 'Tag') if(isdef("IgnoreOverCall")) sys.add_var('timer_running', 'bool') end // makes implementation methods for properties sys._prop_init('AutoStop', 0, 1, 1) sys._prop_init('Enabled', 1, 1, 104) sys._prop_init('Interval', 1, 1, 1) sys._prop_init('Tag', 1, 1, 0) // makes implementation of methods as properties sys._mtd_as_prop_init('Timer') // initialize events if(linked('onTick')) a = block.reggen().inc().inc().inc() b = block.reggen().inc().inc().inc() c = block.reggen().inc().inc().inc() if(not isdef("AutoStop")) a.println(this.auto, '--;') .println('if(', this.auto, ' == 0) {').inc() .println(this.codename, '.Stop();') .dec().println('}') end if(isdef("IgnoreOverCall")) b.println(this.timer_running, ' = false;') c.println('if (', this.timer_running, ') return;') .println(this.timer_running, ' = true;') if(not a.empty()) c.copyhere(a) end end sys.event_imp('onTick', '', '', '', '', c, b) sys.event_add('onTick') block.delete(a) block.delete(b) block.delete(c) end // initialize common events and properties include("Component-init") // autostart if(not isdef("Enabled")) startTimer(blk_init) end end func doStart() this.startTimer(blk) end func doStop() blk.println(this.codename, '.Stop();') event('onStop') end func startTimer(b) if(not isdef("AutoStop")) b.println(this.auto + ' = ' + this.props("AutoStop").value + ';') end b.println(this.codename + '.Start();') end