/*////////// SCRIPT: SaveFile Reminder v1.5 //////////*/ /*////////// WRITTEN BY: Branko Zivkovic //////////*/ /*////////// EMAIL: barigazy@hotmail.com //////////*/ macroScript SFR category:"bgaTools" buttonText:"S • F • R" toolTip:"SaveFile Reminder v1.5" Icon:#("SubObjectIcons",29) ( global timeSpan = dotNetClass "System.Timespan", msAppSDK = dotNetClass "ManagedServices.AppSDK", \ dateTime = dotNetClass "System.DateTime", notifier = dotnetobject "System.Timers.Timer", isOn = false fn defNotifier n = ( n.autoreset = on ; n.enabled = off dotNet.addEventHandler n "Elapsed" \ ( fn elapse s e = if msAppSDK.IsSaveRequired() do ( s.stop() ; (msAppSDK.CheckForSave()) ; format "Saved at %\n" (dateTime.Now.ToShortTimeString()) ; s.start() ) ) dotNet.setLifetimeControl n #dotnet ) global sfrRoll = rollout sfrRoll "Dialog" ( spinner spn_nt "notifying time [minutes] :" pos:[5,5] fieldwidth:40 type:#integer range:[1,1440,5] on sfrRoll open do ( defNotifier notifier ; notifier.Enabled = not (autosave.Enable = on)) on sfrRoll close do if isOn do ( notifier.interval = (timeSpan.FromMinutes(spn_nt.value)).TotalMilliseconds as integer notifier.Enabled = not (autosave.Enable = off) ) ) fn preRender n = (n.Enabled = off ; format "Render started at %\n" (dateTime.Now.ToShortTimeString())) fn postRender n = (n.Enabled = on ; format "Render finished at %\n" (dateTime.Now.ToShortTimeString())) fn destroySFR = try(destroydialog sfrRoll) catch() fn showSFR = (destroySFR() ; createdialog sfrRoll 180 25 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)) on isChecked return isOn on execute do ( isOn = not isOn if not isOn then (notifier.Enabled = not (autosave.Enable = off) ; callbacks.removescripts id:#disable_notification) else ( showSFR() callbacks.removescripts id:#disable_notification callbacks.addscript #preRender "sfrTool.preRender sfrTool.notifier" id:#disable_notification callbacks.addscript #postRender "sfrTool.postRender sfrTool.notifier" id:#disable_notification ) ) )