Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for dialogboxes_systemtraymessage.cs

(view source code of dialogboxes_systemtraymessage.cs as plain text)

  1. namespace RobvanderWoude
  2. {
  3. 	[System.Runtime.InteropServices.Guid( "96D1A611-39B2-4039-AEDA-C9DC88FFB031" )]
  4. 	public interface SystemTrayMessage_Interface
  5. 	{
  6. 		[System.Runtime.InteropServices.DispId( 1 )]
  7. 		void CheckUpdate( );
  8.  
  9. 		[System.Runtime.InteropServices.DispId( 2 )]
  10. 		string Credits( );
  11.  
  12. 		[System.Runtime.InteropServices.DispId( 3 )]
  13. 		string Help( int html = 0 );
  14.  
  15. 		[System.Runtime.InteropServices.DispId( 4 )]
  16. 		string ListProperties( );
  17.  
  18. 		[System.Runtime.InteropServices.DispId( 5 )]
  19. 		string ListToolTipIcons( );
  20.  
  21. 		[System.Runtime.InteropServices.DispId( 6 )]
  22. 		string SampleCode( );
  23.  
  24. 		[System.Runtime.InteropServices.DispId( 7 )]
  25. 		void Show( );
  26. 	}
  27.  
  28.  
  29. 	[System.Runtime.InteropServices.Guid( "F80187E9-E178-4B7B-87EB-EEE1386FF0E1" ), System.Runtime.InteropServices.InterfaceType( System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIDispatch )]
  30. 	public interface SystemTrayMessage_Events
  31. 	{
  32. 	}
  33.  
  34.  
  35. 	[System.Runtime.InteropServices.Guid( "C7484303-39FC-4C47-8736-02E3E341BDD5" ), System.Runtime.InteropServices.ClassInterface( System.Runtime.InteropServices.ClassInterfaceType.AutoDual ), System.Runtime.InteropServices.ComSourceInterfaces( typeof( SystemTrayMessage_Events ) )]
  36. 	public class SystemTrayMessage : SystemTrayMessage_Interface
  37. 	{
  38. 		#region Default Values
  39.  
  40. 		const string defaulticonfile = "shell32.dll";
  41. 		const int defaulticonindex = 277;
  42. 		const int defaulttimeout = 10;
  43. 		const System.Windows.Forms.ToolTipIcon defaulttooltipicon = System.Windows.Forms.ToolTipIcon.Info;
  44. 		static readonly string defaulttitle = string.Format( "{0},  Version {1}", Global.Common.ProgramInfo.FileName, Global.Common.ProgramInfo.FileVersion );
  45. 		static readonly string[] searchpath = System.Environment.GetEnvironmentVariable( "PATH" ).Split( new char[] { ';' }, System.StringSplitOptions.RemoveEmptyEntries );
  46.  
  47. 		#endregion Default Values
  48.  
  49.  
  50. 		static System.Windows.Forms.NotifyIcon notifyicon;
  51. 		static System.Drawing.Icon systrayicon;
  52.  
  53.  
  54. 		#region Methods
  55.  
  56. 		public void CheckUpdate( )
  57. 		{
  58. 			Global.Common.ProgramInfo.CheckUpdate( );
  59. 		}
  60.  
  61.  
  62. 		public string Credits( )
  63. 		{
  64. 			return Global.Common.Credits( );
  65. 		}
  66.  
  67.  
  68. 		public string Help( int html = 0 )
  69. 		{
  70. 			int col1width = 0;
  71. 			int col2width = 0;
  72. 			int col3width = 0;
  73. 			int col4width = 0;
  74. 			int col5width = 0;
  75. 			string help = string.Empty;
  76. 			string linetemplate = string.Empty;
  77. 			string separatorline = string.Empty;
  78.  
  79. 			if ( html == 1 )
  80. 			{
  81. 				help += "<h1>Help for SystemTrayMessage class</h1>\n\n";
  82. 				help += "<p>Present an icon in the notification area (system tray) with an optional tooltip balloon, and return whether the icon or tooltip were clicked</p>\n\n";
  83. 				help += "<h2>COM ProgID: RobvanderWoude.SystemTrayMessage</h2>\n\n";
  84. 			}
  85. 			else
  86. 			{
  87. 				help += "Help for SystemTrayMessage class\n";
  88. 				help += new string( '\u2500', help.Length ) + "\n\n";
  89. 				help += "Present an icon in the notification area (system tray) with an optional tooltip balloon, and return whether the icon or tooltip were clicked\n\n\n";
  90. 				help += "COM ProgID: RobvanderWoude.SystemTrayMessage\n\n\n";
  91. 			}
  92.  
  93.  
  94. 			#region Properties
  95.  
  96. 			if ( html == 1 )
  97. 			{
  98. 				separatorline = string.Empty;
  99. 				linetemplate = "<tr>\n\t<td>{0}</td>\n\t<td>{1}</td>\n\t<td>{2}</td>\n\t<td>{3}</td>\n\t<td>{4}</td>\n</tr>\n";
  100.  
  101. 				help += "<table>\n";
  102. 				help += "<tr>\n";
  103. 				help += "\t<th colspan=\"5\">Properties (Note that all properties are string or integer, no booleans, objects or arrays)</th>\n";
  104. 				help += "</tr>\n";
  105.  
  106. 				help += "<tr>\n";
  107. 				help += "\t<th>Property Name</th>\n";
  108. 				help += "\t<th>Description</th>\n";
  109. 				help += "\t<th>Mandatory</th>\n";
  110. 				help += "\t<th>Read-Only</th>\n";
  111. 				help += "\t<th>Default (Allowed) Values</th>\n";
  112. 				help += "</tr>\n";
  113. 			}
  114. 			else
  115. 			{
  116. 				col1width = 16;
  117. 				col2width = 50;
  118. 				col3width = 9;
  119. 				col4width = 9;
  120. 				col5width = 44;
  121.  
  122. 				separatorline = "\u251C" + new string( '\u2500', 2 + col1width ) + "\u253C" + new string( '\u2500', 2 + col2width ) + "\u253C" + new string( '\u2500', 2 + col3width ) + "\u253C" + new string( '\u2500', 2 + col4width ) + "\u253C" + new string( '\u2500', 2 + col5width ) + "\u2524\n";
  123. 				linetemplate = "\u2502 {0,-" + col1width.ToString( ) + "} \u2502 {1,-" + col2width.ToString( ) + "} \u2502 {2,-" + col3width.ToString( ) + "} \u2502 {3,-" + col4width.ToString( ) + "} \u2502 {4,-" + col5width.ToString( ) + "} \u2502\n";
  124.  
  125. 				help += "\u250C" + new string( '\u2500', 14 + col1width + col2width + col3width + col4width + col5width ) + "\u2510\n";
  126. 				help += "\u2502" + new string( ' ', 14 + col1width + col2width + col3width + col4width + col5width ) + "\u2502\n";
  127. 				help += string.Format( "\u2502 {0,-" + ( 12 + col1width + col2width + col3width + col4width + col5width ).ToString( ) + "} \u2502\n", "Properties        (Note that all properties are string or integer, no booleans, objects or arrays)" );
  128. 				help += "\u2502" + new string( ' ', 14 + col1width + col2width + col3width + col4width + col5width ) + "\u2502\n";
  129. 				help += "\u255E" + new string( '\u2550', 2 + col1width ) + "\u2564" + new string( '\u2550', 2 + col2width ) + "\u2564" + new string( '\u2550', 2 + col3width ) + "\u2564" + new string( '\u2550', 2 + col4width ) + "\u2564" + new string( '\u2550', 2 + col5width ) + "\u2561\n";
  130. 				help += string.Format( linetemplate, "Property Name", "Description", "Mandatory", "Read-Only", "Default (Allowed) Values" );
  131. 				help += "\u255E" + new string( '\u2550', 2 + col1width ) + "\u256A" + new string( '\u2550', 2 + col2width ) + "\u256A" + new string( '\u2550', 2 + col3width ) + "\u256A" + new string( '\u2550', 2 + col4width ) + "\u256A" + new string( '\u2550', 2 + col5width ) + "\u2561\n";
  132. 			}
  133.  
  134. 			help += HelpTableRow( linetemplate, "balloonclicked", "Will be 1 (true) if wait is 1 (true) and the tooltip balloon was clicked before timeout elapsed (0=false; 1=true)", "N/A", "YES", "", html );
  135. 			help += separatorline;
  136.  
  137. 			help += HelpTableRow( linetemplate, "debuginfo", Global.Common.Help.debuginfo, "N/A", "YES", "", html );
  138. 			help += separatorline;
  139.  
  140. 			help += HelpTableRow( linetemplate, "errors", Global.Common.Help.errors, "N/A", "YES", "", html );
  141. 			help += separatorline;
  142.  
  143. 			help += HelpTableRow( linetemplate, "escapemessage", "Interpret \\n as newline and \\t as tab in message (0=false; 1=true)", "no", "no", "1", html );
  144. 			help += separatorline;
  145.  
  146. 			help += HelpTableRow( linetemplate, "iconfile", "Either an icon file (*.ico) or an icon library (*.dll or *.exe) containing the icon to be used in notification area", "no", "no", string.Format( "icon #{0} in {1}", defaulticonindex, defaulticonfile ), html );
  147. 			help += separatorline;
  148.  
  149. 			help += HelpTableRow( linetemplate, "iconindex", "Index of icon in icon library iconfile", "no", "no", string.Format( "{0} if iconfile is {1}", defaulticonindex, defaulticonfile ), html );
  150. 			help += separatorline;
  151.  
  152. 			help += HelpTableRow( linetemplate, "message", "Tooltip message (if empty, no tooltip is shown)", "no", "no", "", html );
  153. 			help += separatorline;
  154.  
  155. 			help += HelpTableRow( linetemplate, "timeout", Global.Common.Help.timeout, "no", "no", defaulttimeout.ToString( ), html );
  156. 			help += separatorline;
  157.  
  158. 			help += HelpTableRow( linetemplate, "title", Global.Common.Help.title, "no", "no", defaulttitle, html );
  159. 			help += separatorline;
  160.  
  161. 			help += HelpTableRow( linetemplate, "tooltipicon", "Icon shown in the tooltip balloon (use ListToolTipIcons( ) for a list of available icons)", "no", "no", string.Format( "{0} ({1})", defaulttooltipicon.ToString( ), ListToolTipIcons( ).Replace( ";", ", " ) + ")" ), html );
  162. 			help += separatorline;
  163.  
  164. 			help += HelpTableRow( linetemplate, "Version", Global.Common.Help.version, "N/A", "YES", "", html );
  165. 			help += separatorline;
  166.  
  167. 			help += HelpTableRow( linetemplate, "wait", "Wait for timeout to elapse       (0=false; 1=true)\n(if 1, script will wait until either tooltip balloon is clicked or timeout elapses, if 0 script will continue without waiting, but \"balloonclicked\" status will not be available)", "", "", "1", html );
  168.  
  169. 			if ( html == 1 )
  170. 			{
  171. 				help += "</table>\n\n\n";
  172. 			}
  173. 			else
  174. 			{
  175. 				help += "\u2514" + new string( '\u2500', 2 + col1width ) + "\u2534" + new string( '\u2500', 2 + col2width ) + "\u2534" + new string( '\u2500', 2 + col3width ) + "\u2534" + new string( '\u2500', 2 + col4width ) + "\u2534" + new string( '\u2500', 2 + col5width ) + "\u2518\n\n\n";
  176. 			}
  177.  
  178. 			#endregion Properties
  179.  
  180.  
  181. 			#region Methods
  182.  
  183. 			if ( html == 1 )
  184. 			{
  185. 				separatorline = string.Empty;
  186. 				linetemplate = "<tr>\n\t<td>{0}</td>\n\t<td>{1}</td>\n\t<td>{2}</td>\n</tr>\n";
  187.  
  188. 				help += "<table>\n";
  189. 				help += "<tr>\n";
  190. 				help += "\t<th colspan=\"3\">Methods</th>\n";
  191. 				help += "</tr>\n";
  192.  
  193. 				help += "<tr>\n";
  194. 				help += "\t<th>Method Name</th>\n";
  195. 				help += "\t<th>Description</th>\n";
  196. 				help += "\t<th>Requirements</th>\n";
  197. 				help += "</tr>\n";
  198. 			}
  199. 			else
  200. 			{
  201. 				col1width = 16;
  202. 				col2width = 74;
  203. 				col3width = 44;
  204.  
  205. 				separatorline = "\u251C" + new string( '\u2500', 2 + col1width ) + "\u253C" + new string( '\u2500', 2 + col2width ) + "\u253C" + new string( '\u2500', 2 + col3width ) + "\u2524\n";
  206. 				linetemplate = "\u2502 {0,-" + col1width.ToString( ) + "} \u2502 {1,-" + col2width.ToString( ) + "} \u2502 {2,-" + col3width.ToString( ) + "} \u2502\n";
  207.  
  208. 				help += "\u250C" + new string( '\u2500', 8 + col1width + col2width + col3width ) + "\u2510\n";
  209. 				help += "\u2502" + new string( ' ', 8 + col1width + col2width + col3width ) + "\u2502\n";
  210. 				help += string.Format( "\u2502 {0,-" + ( 6 + col1width + col2width + col3width ).ToString( ) + "} \u2502\n", "Methods" );
  211. 				help += "\u2502" + new string( ' ', 8 + col1width + col2width + col3width ) + "\u2502\n";
  212. 				help += "\u255E" + new string( '\u2550', 2 + col1width ) + "\u2564" + new string( '\u2550', 2 + col2width ) + "\u2564" + new string( '\u2550', 2 + col3width ) + "\u2561\n";
  213. 				help += string.Format( linetemplate, "Method Name", "Description", "Requirements" );
  214. 				help += "\u255E" + new string( '\u2550', 2 + col1width ) + "\u256A" + new string( '\u2550', 2 + col2width ) + "\u256A" + new string( '\u2550', 2 + col3width ) + "\u2561\n";
  215. 			}
  216.  
  217. 			help += HelpTableRow( linetemplate, "CheckUpdate", Global.Common.Help._checkupdate, "", html );
  218. 			help += separatorline;
  219.  
  220. 			help += HelpTableRow( linetemplate, "Credits", Global.Common.Help._credits, "", html );
  221. 			help += separatorline;
  222.  
  223. 			help += HelpTableRow( linetemplate, "Help", Global.Common.Help._help, "", html );
  224. 			help += separatorline;
  225.  
  226. 			help += HelpTableRow( linetemplate, "ListProperties", Global.Common.Help._listproperties, "", html );
  227. 			help += separatorline;
  228.  
  229. 			help += HelpTableRow( linetemplate, "ListToolTipIcons", "Return a semicolon-separated list of available icons", "", html );
  230. 			help += separatorline;
  231.  
  232. 			help += HelpTableRow( linetemplate, "SampleCode", Global.Common.Help._samplecode, "", html );
  233. 			help += separatorline;
  234.  
  235. 			help += HelpTableRow( linetemplate, "Show", "Presents an icon in the notification area (system tray) with an optional tooltip balloon; if the program is set to continue without waiting, then that's all; if the program is set to wait for the timeout to elapse, clicking the tooltip balloon sets \"balloonclicked\" property and aborts the program.", "", html );
  236.  
  237. 			if ( html == 1 )
  238. 			{
  239. 				help += "</table>\n\n\n";
  240. 			}
  241. 			else
  242. 			{
  243. 				help += "\u2514" + new string( '\u2500', 2 + col1width ) + "\u2534" + new string( '\u2500', 2 + col2width ) + "\u2534" + new string( '\u2500', 2 + col3width ) + "\u2518\n\n\n";
  244. 			}
  245.  
  246. 			#endregion Methods
  247.  
  248.  
  249. 			#region Example
  250.  
  251. 			if ( html == 1 )
  252. 			{
  253. 				help += "<h2>VBScript usage example:</h2>\n\n<pre>";
  254. 			}
  255. 			else
  256. 			{
  257. 				help += "VBScript usage example:\n";
  258. 				help += new string( '\u2500', 23 ) + "\n\n";
  259. 			}
  260.  
  261. 			help += SampleCode( );
  262.  
  263. 			if ( html == 1 )
  264. 			{
  265. 				help += "</pre>";
  266. 			}
  267.  
  268. 			help += "\n\n";
  269.  
  270. 			#endregion Example
  271.  
  272.  
  273. 			help = help.Replace( "\n", System.Environment.NewLine );
  274. 			return help;
  275. 		}
  276.  
  277.  
  278. 		private string HelpTableRow( string template, string col1text, string col2text, string col3text, int html )
  279. 		{
  280. 			if ( html == 1 )
  281. 			{
  282. 				return Global.Common.Help.HelpTableRowHTML( col1text, col2text, col3text );
  283. 			}
  284. 			else
  285. 			{
  286. 				return Global.Common.Help.HelpTableRowText( template, col1text, col2text, col3text, "", "" );
  287. 			}
  288. 		}
  289.  
  290.  
  291. 		private string HelpTableRow( string template, string col1text, string col2text, string col3text, string col4text, string col5text, int html )
  292. 		{
  293. 			if ( html == 1 )
  294. 			{
  295. 				return Global.Common.Help.HelpTableRowHTML( col1text, col2text, col3text, col4text, col5text );
  296. 			}
  297. 			else
  298. 			{
  299. 				return Global.Common.Help.HelpTableRowText( template, col1text, col2text, col3text, col4text, col5text );
  300. 			}
  301. 		}
  302.  
  303.  
  304. 		public string ListProperties( )
  305. 		{
  306. 			return Global.Common.Lists.Properties( this );
  307. 		}
  308.  
  309.  
  310. 		public string ListToolTipIcons( )
  311. 		{
  312. 			return Global.Common.Lists.ToolTipIcons( );
  313. 		}
  314.  
  315.  
  316. 		public string SampleCode( )
  317. 		{
  318. 			string code = string.Empty;
  319.  
  320. 			code += "Set objSystemTrayMessage = CreateObject( \"RobvanderWoude.SystemTrayMessage\" )\n\n";
  321. 			code += "With objSystemTrayMessage\n";
  322. 			code += "\t.message = \"It is time for your daily backup.\" & vbCrLf & \"Please save and close all documents,\" & vbCrLf & \"and click this message when ready.\"\n";
  323. 			code += "\t.title = \"Backup Time\"\n";
  324. 			code += "\t.timeout = 1800\n";
  325. 			code += "\t.wait = 1\n";
  326. 			code += "\tWScript.Echo .ListProperties( )\n";
  327. 			code += "\tWScript.Echo\n";
  328. 			code += "\t.Show\n";
  329. 			code += "\tIf .balloonclicked Then\n";
  330. 			code += "\t\tWScript.Echo \"You clicked the tooltip balloon before the timeout elapsed\"\n";
  331. 			code += "\tEnd If\n";
  332. 			code += "End With\n\n";
  333. 			code += "Set objSystemTrayMessage = Nothing";
  334.  
  335. 			return code;
  336. 		}
  337.  
  338.  
  339. 		public void Show( )
  340. 		{
  341. 			if ( iconext == ".dll" )
  342. 			{
  343. 				systrayicon = Global.IconExtractor.Extract( iconfile, iconindex, true );
  344. 			}
  345. 			else
  346. 			{
  347. 				systrayicon = new System.Drawing.Icon( iconfile );
  348. 			}
  349. 			notifyicon = new System.Windows.Forms.NotifyIcon( );
  350. 			notifyicon.Icon = systrayicon;
  351. 			notifyicon.Visible = true;
  352. 			if ( !string.IsNullOrWhiteSpace( message ) )
  353. 			{
  354. 				if ( _escapemessage )
  355. 				{
  356. 					message = System.Text.RegularExpressions.Regex.Replace( message, @"(?<!\\)\\n", "\n" );
  357. 					message = System.Text.RegularExpressions.Regex.Replace( message, @"(?<!\\)\\t", "\t" );
  358. 					message = System.Text.RegularExpressions.Regex.Replace( message, @"\\", @"\" );
  359. 				}
  360. 				if ( _wait )
  361. 				{
  362. 					// Wait for the icon/message to be clicked
  363. 					notifyicon.BalloonTipClicked += ( object sender, System.EventArgs e ) => { _balloonclicked = true; };
  364. 					notifyicon.BalloonTipClosed += ( object sender, System.EventArgs e ) => { _balloonclicked = true; };
  365. 				}
  366. 				notifyicon.ShowBalloonTip( _timeout, title, message, _tooltipicon );
  367. 			}
  368.  
  369. 			if ( _wait )
  370. 			{
  371. 				_balloonclicked = false;
  372. 				while ( _timeout > 0 && !_balloonclicked )
  373. 				{
  374. 					System.Threading.Thread.Sleep( 100 );
  375. 					System.Windows.Forms.Application.DoEvents( );
  376. 					_timeout -= 100;
  377. 				}
  378. 				notifyicon.Visible = false;
  379. 				notifyicon.Dispose( );
  380. 			}
  381. 		}
  382.  
  383. 		#endregion Methods
  384.  
  385.  
  386. 		#region Properties
  387.  
  388. 		private static bool _balloonclicked = false;
  389. 		[System.Runtime.InteropServices.ComVisible( true )]
  390. 		public int balloonclicked
  391. 		{
  392. 			get
  393. 			{
  394. 				return ( _balloonclicked ? 1 : 0 );
  395. 			}
  396. 		}
  397.  
  398.  
  399. 		private static System.Collections.Generic.List<string> _debuginfo = new System.Collections.Generic.List<string>( );
  400. 		[System.Runtime.InteropServices.ComVisible( true )]
  401. 		public string debuginfo
  402. 		{
  403. 			get
  404. 			{
  405. 				return string.Join( "\n", _debuginfo.ToArray( ) );
  406. 			}
  407. 		}
  408.  
  409.  
  410. 		private static System.Collections.Generic.List<string> _errors = new System.Collections.Generic.List<string>( );
  411. 		[System.Runtime.InteropServices.ComVisible( true )]
  412. 		public string errors
  413. 		{
  414. 			get
  415. 			{
  416. 				return string.Join( "\n", _errors.ToArray( ) );
  417. 			}
  418. 		}
  419.  
  420.  
  421. 		private static bool _escapemessage = true;
  422. 		[System.Runtime.InteropServices.ComVisible( true )]
  423. 		public int escapemessage
  424. 		{
  425. 			get
  426. 			{
  427. 				return ( _escapemessage ? 1 : 0 );
  428. 			}
  429. 			set
  430. 			{
  431. 				_escapemessage = ( value == 1 );
  432. 			}
  433. 		}
  434.  
  435.  
  436. 		private static string _iconfile = defaulticonfile;
  437. 		[System.Runtime.InteropServices.ComVisible( true )]
  438. 		public string iconfile
  439. 		{
  440. 			get
  441. 			{
  442. 				return _iconfile;
  443. 			}
  444. 			set
  445. 			{
  446. 				if ( System.IO.File.Exists( value ) )
  447. 				{
  448. 					_iconfile = System.IO.Path.GetFullPath( value );
  449. 				}
  450. 				else if ( iconext == ".dll" || iconext == ".exe" )
  451. 				{
  452. 					foreach ( string folder in searchpath )
  453. 					{
  454. 						if ( System.IO.File.Exists( System.IO.Path.Combine( folder, value ) ) )
  455. 						{
  456. 							_iconfile = System.IO.Path.Combine( folder, value );
  457. 							break;
  458. 						}
  459. 					}
  460. 					if ( !System.IO.File.Exists( _iconfile ) )
  461. 					{
  462. 						_debuginfo.Add( timestamp + "Invalid path to icon file or library, using default icon file \"" + defaulticonfile + "\" and index " + defaulticonindex + " instead" );
  463. 						_errors.Add( Global.Common.TimeStamp( ) + "Invalid path to icon file or library, using default icon file \"" + defaulticonfile + "\" and index " + defaulticonindex + " instead" );
  464. 						_iconfile = defaulticonfile;
  465. 						_iconindex = defaulticonindex;
  466. 					}
  467. 				}
  468. 				if ( iconfile.EndsWith( "shell32.dll", System.StringComparison.InvariantCultureIgnoreCase ) )
  469. 				{
  470. 					iconindex = iconindex.LimitToRange( 1, 305 );
  471. 				}
  472. 			}
  473. 		}
  474. 		[System.Runtime.InteropServices.ComVisible( false )]
  475. 		private static string iconext
  476. 		{
  477. 			get
  478. 			{
  479. 				return System.IO.Path.GetExtension( _iconfile ).ToLower( );
  480. 			}
  481. 		}
  482.  
  483.  
  484. 		private static int _iconindex = defaulticonindex;
  485. 		[System.Runtime.InteropServices.ComVisible( true )]
  486. 		public int iconindex
  487. 		{
  488. 			get
  489. 			{
  490. 				return _iconindex;
  491. 			}
  492. 			set
  493. 			{
  494. 				if ( _iconfile.EndsWith( "shell32.dll", System.StringComparison.InvariantCultureIgnoreCase ) )
  495. 				{
  496. 					_iconindex = value.LimitToRange( 1, 305 );
  497. 				}
  498. 				else
  499. 				{
  500. 					_iconindex = value;
  501. 				}
  502. 			}
  503. 		}
  504.  
  505.  
  506. 		private static string _message = string.Empty;
  507. 		[System.Runtime.InteropServices.ComVisible( true )]
  508. 		public string message
  509. 		{
  510. 			get
  511. 			{
  512. 				return _message;
  513. 			}
  514. 			set
  515. 			{
  516. 				_message = value.Trim( );
  517. 			}
  518. 		}
  519.  
  520.  
  521. 		private static int _timeout = defaulttimeout * 1000;
  522. 		[System.Runtime.InteropServices.ComVisible( true )]
  523. 		public int timeout
  524. 		{
  525. 			get
  526. 			{
  527. 				return _timeout / 1000;
  528. 			}
  529. 			set
  530. 			{
  531. 				if ( value < 1 )
  532. 				{
  533. 					_debuginfo.Add( timestamp + "Cannot set timeout to a value less than 1 second, using the minimum of 1 second" );
  534. 					_timeout = 1000;
  535. 				}
  536. 				else
  537. 				{
  538. 					_timeout = value * 1000;
  539. 				}
  540. 			}
  541. 		}
  542.  
  543.  
  544. 		public static string timestamp => Global.Common.TimeStamp( );
  545.  
  546.  
  547. 		private static string _title = defaulttitle;
  548. 		[System.Runtime.InteropServices.ComVisible( true )]
  549. 		public string title
  550. 		{
  551. 			get
  552. 			{
  553. 				return _title;
  554. 			}
  555. 			set
  556. 			{
  557. 				if ( string.IsNullOrWhiteSpace( value ) )
  558. 				{
  559. 					_title = defaulttitle;
  560. 				}
  561. 				else
  562. 				{
  563. 					_title = value.Trim( );
  564. 				}
  565. 			}
  566. 		}
  567.  
  568.  
  569. 		private static System.Windows.Forms.ToolTipIcon _tooltipicon = defaulttooltipicon;
  570. 		[System.Runtime.InteropServices.ComVisible( true )]
  571. 		public string tooltipicon
  572. 		{
  573. 			get
  574. 			{
  575. 				return _tooltipicon.ToString( );
  576. 			}
  577. 			set
  578. 			{
  579. 				if ( !System.Enum.TryParse( value, true, out _tooltipicon ) )
  580. 				{
  581. 					_tooltipicon = defaulttooltipicon;
  582. 				}
  583. 			}
  584. 		}
  585.  
  586.  
  587. 		[System.Runtime.InteropServices.ComVisible( true )]
  588. 		public string Version
  589. 		{
  590. 			get
  591. 			{
  592. 				return Global.Common.ProgramInfo.FileVersion;
  593. 			}
  594. 		}
  595.  
  596.  
  597. 		private static bool _wait = true;
  598. 		[System.Runtime.InteropServices.ComVisible( true )]
  599. 		public int wait
  600. 		{
  601. 			get
  602. 			{
  603. 				return ( _wait ? 1 : 0 );
  604. 			}
  605. 			set
  606. 			{
  607. 				_wait = ( value == 1 );
  608. 			}
  609. 		}
  610.  
  611. 		#endregion Properties
  612. 	}
  613. }
  614.  

page last modified: 2024-04-16; loaded in 0.0387 seconds