Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for dialogboxes_multiplechoicebox.cs

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

  1. using System.Linq;
  2.  
  3.  
  4. namespace RobvanderWoude
  5. {
  6. 	[System.Runtime.InteropServices.Guid( "72983C46-4D1F-47F7-AE13-C69B1EA3D56E" )]
  7. 	public interface MultipleChoiceBox_Interface
  8. 	{
  9. 		[System.Runtime.InteropServices.DispId( 1 )]
  10. 		void CheckUpdate( );
  11.  
  12. 		[System.Runtime.InteropServices.DispId( 2 )]
  13. 		string Credits( );
  14.  
  15. 		[System.Runtime.InteropServices.DispId( 3 )]
  16. 		string Help( int html = 0 );
  17.  
  18. 		[System.Runtime.InteropServices.DispId( 4 )]
  19. 		string ListProperties( );
  20.  
  21. 		[System.Runtime.InteropServices.DispId( 5 )]
  22. 		string SampleCode( );
  23.  
  24. 		[System.Runtime.InteropServices.DispId( 6 )]
  25. 		void Show( );
  26. 	}
  27.  
  28.  
  29. 	[System.Runtime.InteropServices.Guid( "7569FB42-3E00-45E5-ADCA-67E231D51CDE" ), System.Runtime.InteropServices.InterfaceType( System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIDispatch )]
  30. 	public interface MultipleChoiceBox_Events
  31. 	{
  32. 	}
  33.  
  34.  
  35. 	[System.Runtime.InteropServices.Guid( "5FF30751-2030-437A-935C-44AE1E366FFC" ), System.Runtime.InteropServices.ClassInterface( System.Runtime.InteropServices.ClassInterfaceType.AutoDual ), System.Runtime.InteropServices.ComSourceInterfaces( typeof( MultipleChoiceBox_Events ) )]
  36. 	public class MultipleChoiceBox : MultipleChoiceBox_Interface
  37. 	{
  38. 		#region Default Values
  39.  
  40. 		const string defaultcaptioncancel = "Cancel";
  41. 		const string defaultcaptionok = "OK";
  42. 		static readonly System.Drawing.FontFamily defaultfontfamily = System.Drawing.FontFamily.GenericSansSerif;
  43. 		const float defaultfontsize = 10;
  44. 		static readonly string defaulttitle = string.Format( "{0},  Version {1}", Global.Common.ProgramInfo.FileName, Global.Common.ProgramInfo.FileVersion );
  45. 		const int defaultwindowheight = 90;
  46. 		const int defaultwindowwidth = 200;
  47. 		const float minimumfontsize = 6;
  48. 		const float maximumfontsize = 48;
  49.  
  50. 		#endregion Default Values
  51.  
  52.  
  53. 		#region Controls
  54.  
  55. 		static System.Timers.Timer timer;
  56. 		static System.Windows.Forms.Form multiplechoiceform;
  57. 		static System.Windows.Forms.GroupBox groupbox;
  58.  
  59. 		#endregion Controls
  60.  
  61.  
  62. 		#region Methods
  63.  
  64. 		public void CheckUpdate( )
  65. 		{
  66. 			Global.Common.ProgramInfo.CheckUpdate( );
  67. 		}
  68.  
  69.  
  70. 		public string Credits( )
  71. 		{
  72. 			return Global.Common.Credits( );
  73. 		}
  74.  
  75.  
  76. 		public string Help( int html = 0 )
  77. 		{
  78. 			int col1width = 0;
  79. 			int col2width = 0;
  80. 			int col3width = 0;
  81. 			int col4width = 0;
  82. 			int col5width = 0;
  83. 			string help = string.Empty;
  84. 			string linetemplate = string.Empty;
  85. 			string separatorline = string.Empty;
  86.  
  87. 			if ( html == 1 )
  88. 			{
  89. 				help += "<h1>Help for MultipleChoiceBox class</h1>\n\n";
  90. 				help += "<p>Present a dialog with a group of checkboxes, and return the selected items</p>\n\n";
  91. 				help += "<h2>COM ProgID: RobvanderWoude.MultipleChoiceBox</h2>\n\n";
  92. 			}
  93. 			else
  94. 			{
  95. 				help += "Help for MultipleChoiceBox class\n";
  96. 				help += new string( '\u2500', help.Length ) + "\n\n";
  97. 				help += "Present a dialog with a group of checkboxes, and return the selected items\n\n\n";
  98. 				help += "COM ProgID: RobvanderWoude.MultipleChoiceBox\n\n\n";
  99. 			}
  100.  
  101.  
  102. 			#region Properties
  103.  
  104. 			if ( html == 1 )
  105. 			{
  106. 				separatorline = string.Empty;
  107. 				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";
  108.  
  109. 				help += "<table>\n";
  110. 				help += "<tr>\n";
  111. 				help += "\t<th colspan=\"5\">Properties (Note that all properties are string or integer, no booleans, objects or arrays)</th>\n";
  112. 				help += "</tr>\n";
  113.  
  114. 				help += "<tr>\n";
  115. 				help += "\t<th>Property Name</th>\n";
  116. 				help += "\t<th>Description</th>\n";
  117. 				help += "\t<th>Mandatory</th>\n";
  118. 				help += "\t<th>Read-Only</th>\n";
  119. 				help += "\t<th>Default (Allowed) Values</th>\n";
  120. 				help += "</tr>\n";
  121. 			}
  122. 			else
  123. 			{
  124. 				col1width = 18;
  125. 				col2width = 50;
  126. 				col3width = 9;
  127. 				col4width = 9;
  128. 				col5width = 42;
  129.  
  130. 				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";
  131. 				linetemplate = "\u2502 {0,-" + col1width.ToString( ) + "} \u2502 {1,-" + col2width.ToString( ) + "} \u2502 {2,-" + col3width.ToString( ) + "} \u2502 {3,-" + col4width.ToString( ) + "} \u2502 {4,-" + col5width.ToString( ) + "} \u2502\n";
  132.  
  133. 				help += "\u250C" + new string( '\u2500', 14 + col1width + col2width + col3width + col4width + col5width ) + "\u2510\n";
  134. 				help += "\u2502" + new string( ' ', 14 + col1width + col2width + col3width + col4width + col5width ) + "\u2502\n";
  135. 				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)" );
  136. 				help += "\u2502" + new string( ' ', 14 + col1width + col2width + col3width + col4width + col5width ) + "\u2502\n";
  137. 				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";
  138. 				help += string.Format( linetemplate, "Property Name", "Description", "Mandatory", "Read-Only", "Default (Allowed) Values" );
  139. 				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";
  140. 			}
  141.  
  142. 			help += HelpTableRow( linetemplate, "captioncancel", Global.Common.Help.captioncancel, "no", "no", defaultcaptioncancel, html );
  143. 			help += separatorline;
  144.  
  145. 			help += HelpTableRow( linetemplate, "captionok", Global.Common.Help.captionok, "no", "no", defaultcaptionok, html );
  146. 			help += separatorline;
  147.  
  148. 			help += HelpTableRow( linetemplate, "columns", "The number of columns", "no", "no", "", html );
  149. 			help += separatorline;
  150.  
  151. 			help += HelpTableRow( linetemplate, "debuginfo", Global.Common.Help.debuginfo, "N/A", "YES", "", html );
  152. 			help += separatorline;
  153.  
  154. 			help += HelpTableRow( linetemplate, "defaultindex", "The index of the preselected item in the list", "no", "no", "", html );
  155. 			help += separatorline;
  156.  
  157. 			help += HelpTableRow( linetemplate, "errors", Global.Common.Help.errors, "N/A", "YES", "", html );
  158. 			help += separatorline;
  159.  
  160. 			help += HelpTableRow( linetemplate, "fontfamily", Global.Common.Help.fontfamily, "no", "no", defaultfontfamily.Name, html );
  161. 			help += separatorline;
  162.  
  163. 			help += HelpTableRow( linetemplate, "fontsize", Global.Common.Help.fontsize, "no", "no", string.Format( "{0} ({1}..{2})", defaultfontsize, minimumfontsize, maximumfontsize ), html );
  164. 			help += separatorline;
  165.  
  166. 			help += HelpTableRow( linetemplate, "left", Global.Common.Help.left, "no", "no", "Centered (0..screenwidth-windowwidth)", html );
  167. 			help += separatorline;
  168.  
  169. 			if ( html == 1 )
  170. 			{
  171. 				string template = "<tr>\n\t<td>{0}</td>\n\t<td>{1}</td>\n\t<td colspan=\"2\" style=\"vertical-align: middle;\">{2}</td>\n\t<td>{3}</td>\n\t<td colspan=\"2\" style=\"vertical-align: middle;\">{4}</td>\n</tr>\n";
  172. 				help += string.Format( template, "list", "Semicolon-separated list of items", "* YES", "no", "* Set either \"list\" or \"listfile\" property" );
  173. 				template = "<tr>\n\t<td>{0}</td>\n\t<td>{1}</td>\n\t<td>{2}</td>\n</tr>\n";
  174. 				help += string.Format( template, "listfile", "Path to file containing list", "no" );
  175. 			}
  176. 			else
  177. 			{
  178. 				help += HelpTableRow( linetemplate, "list", "Semicolon-separated list of items", "", "no", "", html );
  179. 				help += "\u251C" + new string( '\u2500', 2 + col1width ) + "\u253C" + new string( '\u2500', 2 + col2width ) + "\u2524 " + string.Format( "{0,-" + col3width + "}", "* YES" ) + " \u251C" + new string( '\u2500', 2 + col4width ) + "\u2524 " + string.Format( "{0,-" + col5width + "}", "* Set either \"list\" or \"listfile\" property" ) + " \u2502\n";
  180. 				help += HelpTableRow( linetemplate, "listfile", "Path to file containing list", "", "no", new string( ' ', 6 ) + new string( '\u2550', 6 ) + new string( ' ', 8 ) + new string( '\u2550', 2 ), html );
  181. 			}
  182. 			help += separatorline;
  183.  
  184. 			help += HelpTableRow( linetemplate, "literal", Global.Common.Help.literal, "no", "no", "0: interpret \"\\t\" as tab and \"\\n\" as newline", html );
  185. 			help += separatorline;
  186.  
  187. 			help += HelpTableRow( linetemplate, "localizecaptions", Global.Common.Help.localizecaptions, "no", "no", "0: English captions", html );
  188. 			help += separatorline;
  189.  
  190. 			help += HelpTableRow( linetemplate, "modal", Global.Common.Help.modal, "no", "no", "1: always on top", html );
  191. 			help += separatorline;
  192.  
  193. 			help += HelpTableRow( linetemplate, "prompt", Global.Common.Help.prompt, "no", "no", "No prompt", html );
  194. 			help += separatorline;
  195.  
  196. 			help += HelpTableRow( linetemplate, "selectedindex", "Index of last selected radio button item", "N/A", "YES", "", html );
  197. 			help += separatorline;
  198.  
  199. 			help += HelpTableRow( linetemplate, "selecteditem", "Text of last selected radio button item", "N/A", "YES", "", html );
  200. 			help += separatorline;
  201.  
  202. 			help += HelpTableRow( linetemplate, "timeout", Global.Common.Help.timeout, "no", "no", "0: no timeout", html );
  203. 			help += separatorline;
  204.  
  205. 			help += HelpTableRow( linetemplate, "timeoutelapsed", Global.Common.Help.timeoutelapsed, "N/A", "YES", "", html );
  206. 			help += separatorline;
  207.  
  208. 			help += HelpTableRow( linetemplate, "title", Global.Common.Help.title, "no", "no", defaulttitle, html );
  209. 			help += separatorline;
  210.  
  211. 			help += HelpTableRow( linetemplate, "top", Global.Common.Help.top, "no", "no", "Centered (0..screenheight-windowheight)", html );
  212. 			help += separatorline;
  213.  
  214. 			help += HelpTableRow( linetemplate, "Version", Global.Common.Help.version, "", html );
  215. 			help += separatorline;
  216.  
  217. 			help += HelpTableRow( linetemplate, "windowheight", "Height of dialog window", "no", "no", string.Format( "{0} ({0}..screenheight)", defaultwindowheight ), html );
  218. 			help += separatorline;
  219.  
  220. 			help += HelpTableRow( linetemplate, "windowwidth", "Width of dialog window", "no", "no", string.Format( "{0} ({0}..screenwidth)", defaultwindowwidth ), html );
  221.  
  222. 			if ( html == 1 )
  223. 			{
  224. 				help += "</table>\n\n\n";
  225. 			}
  226. 			else
  227. 			{
  228. 				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";
  229. 			}
  230.  
  231. 			#endregion Properties
  232.  
  233.  
  234. 			#region Methods
  235.  
  236. 			if ( html == 1 )
  237. 			{
  238. 				separatorline = string.Empty;
  239. 				linetemplate = "<tr>\n\t<td>{0}</td>\n\t<td>{1}</td>\n\t<td>{2}</td>\n</tr>\n";
  240.  
  241. 				help += "<table>\n";
  242. 				help += "<tr>\n";
  243. 				help += "\t<th colspan=\"3\">Methods</th>\n";
  244. 				help += "</tr>\n";
  245.  
  246. 				help += "<tr>\n";
  247. 				help += "\t<th>Method Name</th>\n";
  248. 				help += "\t<th>Description</th>\n";
  249. 				help += "\t<th>Requirements</th>\n";
  250. 				help += "</tr>\n";
  251. 			}
  252. 			else
  253. 			{
  254. 				col1width = 21;
  255. 				col2width = 74;
  256. 				col3width = 39;
  257.  
  258. 				separatorline = "\u251C" + new string( '\u2500', 2 + col1width ) + "\u253C" + new string( '\u2500', 2 + col2width ) + "\u253C" + new string( '\u2500', 2 + col3width ) + "\u2524\n";
  259. 				linetemplate = "\u2502 {0,-" + col1width.ToString( ) + "} \u2502 {1,-" + col2width.ToString( ) + "} \u2502 {2,-" + col3width.ToString( ) + "} \u2502\n";
  260.  
  261. 				help += "\u250C" + new string( '\u2500', 8 + col1width + col2width + col3width ) + "\u2510\n";
  262. 				help += "\u2502" + new string( ' ', 8 + col1width + col2width + col3width ) + "\u2502\n";
  263. 				help += string.Format( "\u2502 {0,-" + ( 6 + col1width + col2width + col3width ).ToString( ) + "} \u2502\n", "Methods" );
  264. 				help += "\u2502" + new string( ' ', 8 + col1width + col2width + col3width ) + "\u2502\n";
  265. 				help += "\u255E" + new string( '\u2550', 2 + col1width ) + "\u2564" + new string( '\u2550', 2 + col2width ) + "\u2564" + new string( '\u2550', 2 + col3width ) + "\u2561\n";
  266. 				help += string.Format( linetemplate, "Method Name", "Description", "Requirements" );
  267. 				help += "\u255E" + new string( '\u2550', 2 + col1width ) + "\u256A" + new string( '\u2550', 2 + col2width ) + "\u256A" + new string( '\u2550', 2 + col3width ) + "\u2561\n";
  268. 			}
  269.  
  270. 			help += HelpTableRow( linetemplate, "CheckUpdate", Global.Common.Help._checkupdate, "", html );
  271. 			help += separatorline;
  272.  
  273. 			help += HelpTableRow( linetemplate, "Credits", Global.Common.Help._credits, "", html );
  274. 			help += separatorline;
  275.  
  276. 			help += HelpTableRow( linetemplate, "Help", Global.Common.Help._help, "", html );
  277. 			help += separatorline;
  278.  
  279. 			help += HelpTableRow( linetemplate, "ListProperties", Global.Common.Help._listproperties, "", html );
  280. 			help += separatorline;
  281.  
  282. 			help += HelpTableRow( linetemplate, "SampleCode", Global.Common.Help._samplecode, "", html );
  283. 			help += separatorline;
  284.  
  285. 			help += HelpTableRow( linetemplate, "Show", "Presents a dialog with a group of radio buttons based on the current property values, and saves the text for the selected item in the \"selecteditem\" property, and its index (in list) in the \"selectedindex\" property.", "", html );
  286.  
  287. 			if ( html == 1 )
  288. 			{
  289. 				help += "</table>\n\n\n";
  290. 			}
  291. 			else
  292. 			{
  293. 				help += "\u2514" + new string( '\u2500', 2 + col1width ) + "\u2534" + new string( '\u2500', 2 + col2width ) + "\u2534" + new string( '\u2500', 2 + col3width ) + "\u2518\n\n\n";
  294. 			}
  295.  
  296. 			#endregion Methods
  297.  
  298.  
  299. 			#region Example
  300.  
  301. 			if ( html == 1 )
  302. 			{
  303. 				help += "<h2>VBScript usage example:</h2>\n\n<pre>";
  304. 			}
  305. 			else
  306. 			{
  307. 				help += "VBScript usage example:\n";
  308. 				help += new string( '\u2500', 23 ) + "\n\n";
  309. 			}
  310.  
  311. 			help += SampleCode( );
  312.  
  313. 			if ( html == 1 )
  314. 			{
  315. 				help += "</pre>";
  316. 			}
  317.  
  318. 			help += "\n\n";
  319.  
  320. 			#endregion Example
  321.  
  322.  
  323. 			help = help.Replace( "\n", System.Environment.NewLine );
  324. 			return help;
  325. 		}
  326.  
  327.  
  328. 		private string HelpTableRow( string template, string col1text, string col2text, string col3text, int html )
  329. 		{
  330. 			if ( html == 1 )
  331. 			{
  332. 				return Global.Common.Help.HelpTableRowHTML( col1text, col2text, col3text );
  333. 			}
  334. 			else
  335. 			{
  336. 				return Global.Common.Help.HelpTableRowText( template, col1text, col2text, col3text, "", "" );
  337. 			}
  338. 		}
  339.  
  340.  
  341. 		private string HelpTableRow( string template, string col1text, string col2text, string col3text, string col4text, string col5text, int html )
  342. 		{
  343. 			if ( html == 1 )
  344. 			{
  345. 				return Global.Common.Help.HelpTableRowHTML( col1text, col2text, col3text, col4text, col5text );
  346. 			}
  347. 			else
  348. 			{
  349. 				return Global.Common.Help.HelpTableRowText( template, col1text, col2text, col3text, col4text, col5text );
  350. 			}
  351. 		}
  352.  
  353.  
  354. 		public string ListProperties( )
  355. 		{
  356. 			return Global.Common.Lists.Properties( this );
  357. 		}
  358.  
  359.  
  360. 		public string SampleCode( )
  361. 		{
  362. 			string code = "Set objMultipleChoiceBox = CreateObject( \"RobvanderWoude.MultipleChoiceBox\" )\n\n";
  363. 			code += "With objMultipleChoiceBox\n";
  364. 			code += "\t.list        = \"Bungeejump from helicopter;Firewalk;Paraglide into an active volcan\"\n";
  365. 			code += "\t.preselected = \"0;1;2\"\n";
  366. 			code += "\t.prompt      = \"15 seconds to pick your favorites:\"\n";
  367. 			code += "\t.title       = \"My Bucket List\"\n";
  368. 			code += "\t.top         = 200\n";
  369. 			code += "\t.left        = 300\n";
  370. 			code += "\t.timeout     = 15\n";
  371. 			code += "\t.Show\n";
  372. 			code += "\tWScript.Echo \"Selected bucket list items: \" & .selecteditems\n";
  373. 			code += "\tWScript.Echo\n";
  374. 			code += "\tWScript.Echo .ListProperties( )\n";
  375. 			code += "End With\n\n";
  376. 			code += "Set objMultipleChoiceBox = Nothing";
  377. 			return code;
  378. 		}
  379.  
  380.  
  381. 		[System.STAThread]
  382. 		public void Show( )
  383. 		{
  384. 			int tablength = 4;
  385. 			double cbsafetyfactor = 1.05;
  386.  
  387.  
  388. 			#region Timer
  389.  
  390. 			_timeoutelapsed = false;
  391. 			if ( timeout > 0 )
  392. 			{
  393. 				timer = new System.Timers.Timer( );
  394. 				timer.Elapsed += new System.Timers.ElapsedEventHandler( MultipleChoiceBox_Class_Timer_Elapsed );
  395. 				timer.Interval = _timeout;
  396. 				timer.Start( );
  397. 			}
  398.  
  399. 			#endregion Timer
  400.  
  401.  
  402. 			#region Main Form
  403.  
  404. 			multiplechoiceform = new System.Windows.Forms.Form( );
  405.  
  406. 			multiplechoiceform.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  407. 			multiplechoiceform.MaximizeBox = false;
  408. 			multiplechoiceform.MinimizeBox = false;
  409. 			if ( left < 0 || top < 0 )
  410. 			{
  411. 				multiplechoiceform.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  412. 			}
  413. 			else
  414. 			{
  415. 				multiplechoiceform.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
  416. 				multiplechoiceform.Location = new System.Drawing.Point( left, top );
  417. 			}
  418. 			multiplechoiceform.Text = title;
  419. 			multiplechoiceform.TopMost = topmost;
  420.  
  421. 			#endregion Main Form
  422.  
  423.  
  424. 			#region Initial Sizes
  425.  
  426. 			int horizontalmargin = 10;
  427. 			int verticalmargin = 10;
  428. 			int promptwidth = 0;
  429. 			int promptheight = 20;
  430. 			int cbtextheight = 0; // checkbox text height
  431. 			int cbtextwidth = 0; // checkbox text width
  432. 			int cbwidth = 15; // checkbox width without text
  433. 			int buttonheight = 25;
  434. 			int buttonwidth = 80;
  435.  
  436. 			#endregion Initial Sizes
  437.  
  438.  
  439. 			#region Prompt
  440.  
  441. 			System.Windows.Forms.Label labelprompt = new System.Windows.Forms.Label( );
  442.  
  443. 			if ( string.IsNullOrWhiteSpace( prompt ) )
  444. 			{
  445. 				promptheight = -1 * verticalmargin;
  446. 			}
  447. 			else
  448. 			{
  449. 				// Calculate required height for single prompt line
  450. 				promptheight = System.Windows.Forms.TextRenderer.MeasureText( "Test", labelprompt.Font ).Height;
  451.  
  452. 				// Replace tabs with spaces
  453. 				if ( prompt.IndexOf( "\\t", System.StringComparison.Ordinal ) > -1 )
  454. 				{
  455. 					string tab = new string( ' ', tablength );
  456. 					// First split the prompt on newlines
  457. 					string[] prompt2 = prompt.Split( new string[] { "\\n" }, System.StringSplitOptions.None );
  458. 					for ( int i = 0; i < prompt2.Length; i++ )
  459. 					{
  460. 						if ( prompt2[i].IndexOf( "\\t", System.StringComparison.Ordinal ) > -1 )
  461. 						{
  462. 							// Split each "sub-line" of the prompt on tabs
  463. 							string[] prompt3 = prompt2[i].Split( new string[] { "\\t" }, System.StringSplitOptions.None );
  464. 							// Each substring before a tab gets n spaces attached, and then is shortened to the greatest possible multiple of n
  465. 							for ( int j = 0; j < prompt3.Length - 1; j++ )
  466. 							{
  467. 								prompt3[j] += tab;
  468. 								int length = prompt3[j].Length;
  469. 								length /= tablength;
  470. 								length *= tablength;
  471. 								prompt3[j] = prompt3[j].Substring( 0, length );
  472. 							}
  473. 							prompt2[i] = string.Join( "", prompt3 );
  474. 						}
  475. 					}
  476. 					prompt = string.Join( "\n", prompt2 );
  477. 				}
  478. 				if ( !_literal )
  479. 				{
  480. 					prompt = prompt.Replace( "\\n", "\n" ).Replace( "\\r", "\r" ).Replace( "\\t", "\t" );
  481. 				}
  482. 				labelprompt.Text = prompt;
  483. 				string[] lines = prompt.Split( "\n".ToCharArray( ) );
  484. 				int promptlines = lines.Length;
  485.  
  486. 				foreach ( string line in lines )
  487. 				{
  488. 					promptwidth = System.Math.Max( promptwidth, System.Windows.Forms.TextRenderer.MeasureText( line, labelprompt.Font ).Width );
  489. 				}
  490.  
  491. 				// Calculate required height for multiple line prompt
  492. 				promptheight = promptlines * promptheight;
  493. 			}
  494.  
  495. 			#endregion Prompt
  496.  
  497.  
  498. 			#region Checkboxes
  499.  
  500. 			System.Collections.Generic.List<System.Windows.Forms.CheckBox> checkboxes = new System.Collections.Generic.List<System.Windows.Forms.CheckBox>( );
  501. 			for ( int i = 0; i < _list.Count; i++ )
  502. 			{
  503. 				System.Windows.Forms.CheckBox checkbox = new System.Windows.Forms.CheckBox( );
  504. 				checkbox.Text = _list[i];
  505. 				checkbox.Checked = _preselected.Contains( i );
  506. 				cbtextwidth = System.Math.Max( cbtextwidth, System.Convert.ToInt32( System.Windows.Forms.TextRenderer.MeasureText( _list[i], checkbox.Font ).Width * cbsafetyfactor ) );
  507. 				cbtextheight = System.Math.Max( cbtextheight, System.Convert.ToInt32( System.Windows.Forms.TextRenderer.MeasureText( _list[i], checkbox.Font ).Height * cbsafetyfactor ) );
  508. 				checkboxes.Add( checkbox );
  509. 			}
  510.  
  511. 			groupbox = new System.Windows.Forms.GroupBox( );
  512.  
  513. 			#endregion Checkboxes
  514.  
  515.  
  516. 			#region Buttons
  517.  
  518. 			System.Windows.Forms.Button okButton = new System.Windows.Forms.Button( );
  519. 			okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
  520. 			okButton.Name = "okButton";
  521. 			okButton.Text = captionok;
  522.  
  523. 			System.Windows.Forms.Button cancelButton = new System.Windows.Forms.Button( );
  524. 			cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  525. 			cancelButton.Name = "cancelButton";
  526. 			cancelButton.Text = captioncancel;
  527.  
  528. 			#endregion Buttons
  529.  
  530.  
  531. 			#region Calculate Window Layout
  532.  
  533. 			if ( rows > 0 )
  534. 			{
  535. 				rows = System.Math.Min( rows, _list.Count );
  536. 				columns = (int) System.Math.Floor( (decimal) ( _list.Count + rows - 1 ) / rows );
  537. 			}
  538. 			else if ( columns > 0 )
  539. 			{
  540. 				columns = System.Math.Min( columns, _list.Count );
  541. 				rows = (int) System.Math.Floor( (decimal) ( _list.Count + columns - 1 ) / columns );
  542. 			}
  543. 			else
  544. 			{
  545. 				columns = 1;
  546. 				rows = _list.Count;
  547. 			}
  548.  
  549. 			int cbgroupwidth = 0;
  550. 			int cbgroupheight = 0;
  551. 			int rowheight = 0;
  552. 			int colwidth = 0;
  553.  
  554. 			if ( windowwidth != defaultwindowwidth )
  555. 			{
  556. 				cbgroupwidth = windowwidth - 2 * horizontalmargin;
  557. 				colwidth = (int) System.Math.Floor( (decimal) ( cbgroupwidth - horizontalmargin - columns * ( cbwidth + horizontalmargin ) ) / columns );
  558. 			}
  559. 			else
  560. 			{
  561. 				colwidth = cbtextwidth + cbwidth;
  562. 				cbgroupwidth = System.Math.Max( defaultwindowwidth - 2 * horizontalmargin, columns * ( colwidth + horizontalmargin ) + 2 * horizontalmargin );
  563. 				colwidth = System.Math.Max( colwidth, System.Convert.ToInt32( ( cbgroupwidth - 2 * horizontalmargin ) / columns ) - horizontalmargin );
  564. 				windowwidth = System.Math.Max( defaultwindowwidth, cbgroupwidth + 2 * horizontalmargin );
  565. 			}
  566.  
  567. 			if ( windowheight != defaultwindowheight )
  568. 			{
  569. 				cbgroupheight = windowheight - promptheight - buttonheight - 4 * verticalmargin;
  570. 				rowheight = (int) System.Math.Floor( (decimal) ( cbgroupheight - 2 * verticalmargin ) / rows );
  571. 			}
  572. 			else
  573. 			{
  574. 				rowheight = cbtextheight + verticalmargin;
  575. 				windowheight = System.Math.Max( defaultwindowheight, 6 * verticalmargin + promptheight + buttonheight + rows * rowheight );
  576. 				cbgroupheight = rows * rowheight + 2 * verticalmargin;
  577. 			}
  578.  
  579. 			#endregion Calculate Window Layout
  580.  
  581.  
  582. 			#region Check Available Group Box Space
  583.  
  584. 			if ( cbgroupheight / rows < rowheight || cbgroupwidth / columns < colwidth )
  585. 			{
  586. 				_errors.Add( timestamp + "Window size too small to display all checkboxes; increase window size, reduce or remove prompt, and/or change number of rows and columns" );
  587. 			}
  588.  
  589. 			#endregion Check Available Group Box Space
  590.  
  591.  
  592. 			#region Build Form
  593.  
  594. 			System.Drawing.Size windowsize = new System.Drawing.Size( windowwidth, windowheight );
  595. 			multiplechoiceform.ClientSize = windowsize;
  596.  
  597. 			if ( !string.IsNullOrWhiteSpace( prompt ) )
  598. 			{
  599. 				labelprompt.Size = new System.Drawing.Size( windowwidth - 2 * horizontalmargin, promptheight );
  600. 				labelprompt.Location = new System.Drawing.Point( horizontalmargin, verticalmargin );
  601. 				multiplechoiceform.Controls.Add( labelprompt );
  602. 			}
  603.  
  604. 			groupbox.Size = new System.Drawing.Size( cbgroupwidth, cbgroupheight );
  605. 			groupbox.Location = new System.Drawing.Point( horizontalmargin, promptheight + 2 * verticalmargin );
  606.  
  607. 			foreach ( System.Windows.Forms.CheckBox checkbox in checkboxes )
  608. 			{
  609. 				groupbox.Controls.Add( checkbox );
  610. 			}
  611. 			multiplechoiceform.Controls.Add( groupbox );
  612.  
  613. 			for ( int row = 0; row < rows; row++ )
  614. 			{
  615. 				for ( int column = 0; column < columns; column++ )
  616. 				{
  617. 					int index = row * columns + column;
  618. 					if ( index < checkboxes.Count )
  619. 					{
  620. 						int x = System.Convert.ToInt32( horizontalmargin + column * ( colwidth + horizontalmargin ) );
  621. 						int y = System.Convert.ToInt32( verticalmargin + row * rowheight );
  622. 						checkboxes[index].Size = new System.Drawing.Size( colwidth + horizontalmargin, rowheight );
  623. 						checkboxes[index].Location = new System.Drawing.Point( x, y );
  624. 					}
  625. 				}
  626. 			}
  627.  
  628. 			okButton.Size = new System.Drawing.Size( buttonwidth, buttonheight );
  629. 			okButton.Location = new System.Drawing.Point( windowwidth / 2 - horizontalmargin - buttonwidth, windowheight - buttonheight - verticalmargin );
  630. 			multiplechoiceform.Controls.Add( okButton );
  631.  
  632. 			cancelButton.Size = new System.Drawing.Size( buttonwidth, buttonheight );
  633. 			cancelButton.Location = new System.Drawing.Point( windowwidth / 2 + horizontalmargin, windowheight - buttonheight - verticalmargin );
  634. 			multiplechoiceform.Controls.Add( cancelButton );
  635.  
  636. 			multiplechoiceform.AcceptButton = okButton;  // OK on Enter
  637. 			multiplechoiceform.CancelButton = cancelButton; // Cancel on Esc
  638.  
  639. 			#endregion Build Form
  640.  
  641.  
  642. 			#region Show Dialog
  643.  
  644. 			multiplechoiceform.TopMost = topmost;
  645. 			System.Windows.Forms.DialogResult result = multiplechoiceform.ShowDialog( );
  646. 			if ( !_timeoutelapsed )
  647. 			{
  648. 				_selecteditems.Clear( );
  649. 				_selectedindices.Clear( );
  650. 			}
  651. 			if ( result == System.Windows.Forms.DialogResult.OK )
  652. 			{
  653. 				for ( int i = 0; i < groupbox.Controls.Count; i++ )
  654. 				{
  655. 					System.Windows.Forms.Control control = groupbox.Controls[i];
  656. 					if ( control.GetType( ) == typeof( System.Windows.Forms.CheckBox ) )
  657. 					{
  658. 						System.Windows.Forms.CheckBox cb = (System.Windows.Forms.CheckBox) control;
  659. 						if ( cb.Checked )
  660. 						{
  661. 							_selecteditems.Add( cb.Text );
  662. 							_selectedindices.Add( i );
  663. 						}
  664. 					}
  665. 				}
  666. 			}
  667.  
  668. 			#endregion Show Dialog
  669. 		}
  670.  
  671. 		#endregion Methods
  672.  
  673.  
  674. 		#region Properties
  675.  
  676. 		private string _captioncancel = defaultcaptioncancel;
  677. 		[System.Runtime.InteropServices.ComVisible( true )]
  678. 		public string captioncancel
  679. 		{
  680. 			get
  681. 			{
  682. 				if ( _localizecaptions && _captioncancel == defaultcaptioncancel )
  683. 				{
  684. 					_captioncancel = Global.Common.Localization.Load( "user32.dll", 801, defaultcaptioncancel );
  685. 				}
  686. 				return _captioncancel;
  687. 			}
  688. 			set
  689. 			{
  690. 				if ( string.IsNullOrWhiteSpace( value ) || value.Length > 20 )
  691. 				{
  692. 					_captioncancel = defaultcaptioncancel;
  693. 				}
  694. 				else
  695. 				{
  696. 					_captioncancel = value;
  697. 				}
  698. 				//_debuginfo.Add()
  699. 			}
  700. 		}
  701.  
  702.  
  703. 		private string _captionok = defaultcaptionok;
  704. 		[System.Runtime.InteropServices.ComVisible( true )]
  705. 		public string captionok
  706. 		{
  707. 			get
  708. 			{
  709. 				if ( _localizecaptions && _captionok == defaultcaptionok )
  710. 				{
  711. 					_captionok = Global.Common.Localization.Load( "user32.dll", 800, defaultcaptionok );
  712. 				}
  713. 				return _captionok;
  714. 			}
  715. 			set
  716. 			{
  717. 				if ( string.IsNullOrWhiteSpace( value ) || value.Length > 20 )
  718. 				{
  719. 					_captionok = defaultcaptionok;
  720. 				}
  721. 				else
  722. 				{
  723. 					_captionok = value;
  724. 				}
  725. 			}
  726. 		}
  727.  
  728.  
  729. 		private int _columns = 0;
  730. 		[System.Runtime.InteropServices.ComVisible( true )]
  731. 		public int columns
  732. 		{
  733. 			get
  734. 			{
  735. 				return _columns;
  736. 			}
  737. 			set
  738. 			{
  739. 				_columns = value;
  740. 			}
  741. 		}
  742.  
  743.  
  744. 		private System.Collections.Generic.List<string> _debuginfo = new System.Collections.Generic.List<string>( );
  745. 		[System.Runtime.InteropServices.ComVisible( true )]
  746. 		public string debuginfo
  747. 		{
  748. 			get
  749. 			{
  750. 				return string.Join( "\n", _debuginfo.ToArray( ) );
  751. 			}
  752. 		}
  753.  
  754.  
  755. 		private System.Collections.Generic.List<string> _errors = new System.Collections.Generic.List<string>( );
  756. 		[System.Runtime.InteropServices.ComVisible( true )]
  757. 		public string errors
  758. 		{
  759. 			get
  760. 			{
  761. 				return string.Join( "\n", _errors.ToArray( ) );
  762. 			}
  763. 		}
  764.  
  765.  
  766. 		private static bool _fixedpitchonly = false;
  767. 		[System.Runtime.InteropServices.ComVisible( true )]
  768. 		public int fixedpitchonly
  769. 		{
  770. 			get
  771. 			{
  772. 				return ( _fixedpitchonly ? 1 : 0 );
  773. 			}
  774. 			set
  775. 			{
  776. 				_fixedpitchonly = ( value == 1 );
  777. 			}
  778. 		}
  779.  
  780.  
  781. 		private System.Drawing.FontFamily _fontfamily = defaultfontfamily;
  782. 		[System.Runtime.InteropServices.ComVisible( true )]
  783. 		public string fontfamily
  784. 		{
  785. 			get
  786. 			{
  787. 				return _fontfamily.Name;
  788. 			}
  789. 			set
  790. 			{
  791. 				_fontfamily = Global.Common.Validate.FontFamily( value, defaultfontfamily );
  792. 			}
  793. 		}
  794.  
  795.  
  796. 		private float _fontsize = defaultfontsize;
  797. 		[System.Runtime.InteropServices.ComVisible( true )]
  798. 		public int fontsize
  799. 		{
  800. 			get
  801. 			{
  802. 				return System.Convert.ToInt32( _fontsize );
  803. 			}
  804. 			set
  805. 			{
  806. 				_fontsize = System.Convert.ToSingle( value ).LimitToRange( minimumfontsize, maximumfontsize );
  807. 			}
  808. 		}
  809.  
  810.  
  811. 		private int _left = -1;
  812. 		[System.Runtime.InteropServices.ComVisible( true )]
  813. 		public int left
  814. 		{
  815. 			get
  816. 			{
  817. 				return _left;
  818. 			}
  819. 			set
  820. 			{
  821. 				if ( value < 0 )
  822. 				{
  823. 					_left = 0;
  824. 				}
  825. 				else if ( value > System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width - windowwidth )
  826. 				{
  827. 					_left = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width - windowwidth;
  828. 				}
  829. 				else
  830. 				{
  831. 					_left = value;
  832. 				}
  833. 			}
  834. 		}
  835.  
  836.  
  837. 		private System.Collections.Generic.List<string> _list = new System.Collections.Generic.List<string>( );
  838. 		[System.Runtime.InteropServices.ComVisible( true )]
  839. 		public string list
  840. 		{
  841. 			get
  842. 			{
  843. 				return string.Join( ";", _list );
  844. 			}
  845. 			set
  846. 			{
  847. 				_list = value.Split( ";\n".ToCharArray( ), System.StringSplitOptions.RemoveEmptyEntries ).Select( i => i.Trim( ) ).ToList<string>( );
  848. 			}
  849. 		}
  850. 		[System.Runtime.InteropServices.ComVisible( true )]
  851. 		public string listfile
  852. 		{
  853. 			get
  854. 			{
  855. 				return string.Join( ";", _list );
  856. 			}
  857. 			set
  858. 			{
  859. 				if ( System.IO.File.Exists( value ) )
  860. 				{
  861. 					try
  862. 					{
  863. 						System.IO.StreamReader sr = new System.IO.StreamReader( list );
  864. 						string text = sr.ReadToEnd( );
  865. 						sr.Close( );
  866. 						if ( text.IndexOfAny( ";\n\r".ToCharArray( ) ) == -1 )
  867. 						{
  868. 							_errors.Add( timestamp + "Invalid list file content" );
  869. 						}
  870. 						_list = text.Split( ";\n\r".ToCharArray( ), System.StringSplitOptions.RemoveEmptyEntries ).Select( i => i.Trim( ) ).ToList<string>( );
  871. 					}
  872. 					catch ( System.Exception e )
  873. 					{
  874. 						_errors.Add( timestamp + "Unable to open list file: " + e.Message );
  875. 					}
  876.  
  877. 				}
  878. 				else
  879. 				{
  880. 					_errors.Add( timestamp + "List file not found" );
  881. 				}
  882. 			}
  883. 		}
  884.  
  885.  
  886. 		private bool _literal = false;
  887. 		[System.Runtime.InteropServices.ComVisible( true )]
  888. 		public int literal
  889. 		{
  890. 			get
  891. 			{
  892. 				return ( _literal ? 1 : 0 );
  893. 			}
  894. 			set
  895. 			{
  896. 				_literal = ( value == 1 );
  897. 			}
  898. 		}
  899.  
  900.  
  901. 		private bool _localizecaptions = false;
  902. 		[System.Runtime.InteropServices.ComVisible( true )]
  903. 		public int localizecaptions
  904. 		{
  905. 			get
  906. 			{
  907. 				return ( _localizecaptions ? 1 : 0 );
  908. 			}
  909. 			set
  910. 			{
  911. 				_localizecaptions = ( value == 1 );
  912. 			}
  913. 		}
  914.  
  915.  
  916. 		private bool topmost = true;
  917. 		[System.Runtime.InteropServices.ComVisible( true )]
  918. 		public int modal
  919. 		{
  920. 			get
  921. 			{
  922. 				return ( topmost ? 1 : 0 );
  923. 			}
  924. 			set
  925. 			{
  926. 				topmost = ( value == 1 );
  927. 			}
  928. 		}
  929.  
  930.  
  931. 		private System.Collections.Generic.List<int> _preselected = new System.Collections.Generic.List<int>( );
  932. 		[System.Runtime.InteropServices.ComVisible( true )]
  933. 		public string preselected
  934. 		{
  935. 			get
  936. 			{
  937. 				return string.Join( ";", _preselected );
  938. 			}
  939. 			set
  940. 			{
  941. 				if ( System.Text.RegularExpressions.Regex.IsMatch( value, @"^\d+(;\d+)*$" ) )
  942. 				{
  943. 					_preselected.Clear( );
  944. 					_preselected = value.Split( ";".ToCharArray( ) ).Select( v => int.Parse( v ) ).Distinct( ).ToList<int>( );
  945. 				}
  946. 			}
  947. 		}
  948.  
  949.  
  950. 		private string _prompt = string.Empty;
  951. 		[System.Runtime.InteropServices.ComVisible( true )]
  952. 		public string prompt
  953. 		{
  954. 			get
  955. 			{
  956. 				return _prompt;
  957. 			}
  958. 			set
  959. 			{
  960. 				if ( _literal )
  961. 				{
  962. 					_prompt = value.Trim( );
  963. 				}
  964. 				else
  965. 				{
  966. 					_prompt = value.Replace( "\\n", "\n" ).Replace( "\\t", "\t" ).Trim( );
  967. 				}
  968. 			}
  969. 		}
  970.  
  971.  
  972. 		private int _rows = 0;
  973. 		[System.Runtime.InteropServices.ComVisible( true )]
  974. 		public int rows
  975. 		{
  976. 			get
  977. 			{
  978. 				return _rows;
  979. 			}
  980. 			set
  981. 			{
  982. 				_rows = value;
  983. 			}
  984. 		}
  985.  
  986.  
  987. 		private System.Collections.Generic.List<int> _selectedindices = new System.Collections.Generic.List<int>( );
  988. 		[System.Runtime.InteropServices.ComVisible( true )]
  989. 		public string selectedindices
  990. 		{
  991. 			get
  992. 			{
  993. 				return string.Join( ";", _selectedindices );
  994. 			}
  995. 		}
  996.  
  997.  
  998. 		private static System.Collections.Generic.List<string> _selecteditems = new System.Collections.Generic.List<string>( );
  999. 		[System.Runtime.InteropServices.ComVisible( true )]
  1000. 		public string selecteditems
  1001. 		{
  1002. 			get
  1003. 			{
  1004. 				return string.Join( ";", _selecteditems );
  1005. 			}
  1006. 		}
  1007.  
  1008.  
  1009. 		private int _timeout = 0;
  1010. 		[System.Runtime.InteropServices.ComVisible( true )]
  1011. 		public int timeout
  1012. 		{
  1013. 			get
  1014. 			{
  1015. 				return (int) ( _timeout / 1000 );
  1016. 			}
  1017. 			set
  1018. 			{
  1019. 				if ( value < 0 || value > 3600 )
  1020. 				{
  1021. 					_timeout = 0;
  1022. 				}
  1023. 				else
  1024. 				{
  1025. 					_timeout = value * 1000;
  1026. 				}
  1027. 			}
  1028. 		}
  1029.  
  1030.  
  1031. 		private bool _timeoutelapsed = false;
  1032. 		[System.Runtime.InteropServices.ComVisible( true )]
  1033. 		public int timeoutelapsed
  1034. 		{
  1035. 			get
  1036. 			{
  1037. 				return ( _timeoutelapsed ? 1 : 0 );
  1038. 			}
  1039. 		}
  1040.  
  1041.  
  1042. 		private static string timestamp => Global.Common.TimeStamp( );
  1043.  
  1044.  
  1045. 		private string _title = defaulttitle;
  1046. 		[System.Runtime.InteropServices.ComVisible( true )]
  1047. 		public string title
  1048. 		{
  1049. 			get
  1050. 			{
  1051. 				return _title;
  1052. 			}
  1053. 			set
  1054. 			{
  1055. 				if ( string.IsNullOrWhiteSpace( value ) )
  1056. 				{
  1057. 					_title = defaulttitle;
  1058. 				}
  1059. 				else
  1060. 				{
  1061. 					_title = value.Trim( );
  1062. 				}
  1063. 			}
  1064. 		}
  1065.  
  1066.  
  1067. 		private int _top = -1;
  1068. 		[System.Runtime.InteropServices.ComVisible( true )]
  1069. 		public int top
  1070. 		{
  1071. 			get
  1072. 			{
  1073. 				return _top;
  1074. 			}
  1075. 			set
  1076. 			{
  1077. 				if ( value < 0 )
  1078. 				{
  1079. 					_top = 0;
  1080. 				}
  1081. 				else if ( value > System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height - windowheight )
  1082. 				{
  1083. 					_top = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height - windowheight;
  1084. 				}
  1085. 				else
  1086. 				{
  1087. 					_top = value;
  1088. 				}
  1089. 			}
  1090. 		}
  1091.  
  1092.  
  1093. 		[System.Runtime.InteropServices.ComVisible( true )]
  1094. 		public string Version
  1095. 		{
  1096. 			get
  1097. 			{
  1098. 				return Global.Common.ProgramInfo.FileVersion;
  1099. 			}
  1100. 		}
  1101.  
  1102.  
  1103. 		private int _windowheight = defaultwindowheight;
  1104. 		[System.Runtime.InteropServices.ComVisible( true )]
  1105. 		public int windowheight
  1106. 		{
  1107. 			get
  1108. 			{
  1109. 				return _windowheight;
  1110. 			}
  1111. 			set
  1112. 			{
  1113. 				if ( value < defaultwindowheight )
  1114. 				{
  1115. 					_windowheight = defaultwindowheight;
  1116. 				}
  1117. 				else if ( value > System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height )
  1118. 				{
  1119. 					_windowheight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
  1120. 				}
  1121. 				else
  1122. 				{
  1123. 					_windowheight = value;
  1124. 				}
  1125. 			}
  1126. 		}
  1127.  
  1128.  
  1129. 		private int _windowwidth = defaultwindowwidth;
  1130. 		[System.Runtime.InteropServices.ComVisible( true )]
  1131. 		public int windowwidth
  1132. 		{
  1133. 			get
  1134. 			{
  1135. 				return _windowwidth;
  1136. 			}
  1137. 			set
  1138. 			{
  1139. 				if ( value < defaultwindowwidth )
  1140. 				{
  1141. 					_windowwidth = defaultwindowwidth;
  1142. 				}
  1143. 				else if ( value > System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width )
  1144. 				{
  1145. 					_windowwidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
  1146. 				}
  1147. 				else
  1148. 				{
  1149. 					_windowwidth = value;
  1150. 				}
  1151. 			}
  1152. 		}
  1153.  
  1154. 		#endregion Properties
  1155.  
  1156.  
  1157. 		#region Event Handlers
  1158.  
  1159. 		private void MultipleChoiceBox_Class_CheckedChanged( object sender, System.EventArgs e )
  1160. 		{
  1161. 			_selecteditems.Clear( );
  1162. 			_selectedindices.Clear( );
  1163. 			foreach ( System.Windows.Forms.CheckBox cb in groupbox.Controls )
  1164. 			{
  1165. 				if ( cb.Checked )
  1166. 				{
  1167. 					_selecteditems.Add( cb.Text );
  1168. 					_selectedindices.Add( _list.IndexOf( cb.Text ) );
  1169. 				}
  1170. 			}
  1171. 		}
  1172.  
  1173.  
  1174. 		private void MultipleChoiceBox_Class_Timer_Elapsed( object sender, System.Timers.ElapsedEventArgs e )
  1175. 		{
  1176. 			_timeoutelapsed = true;
  1177. 			foreach ( System.Windows.Forms.CheckBox cb in groupbox.Controls )
  1178. 			{
  1179. 				if ( cb.Checked )
  1180. 				{
  1181. 					_selecteditems.Add( cb.Text );
  1182. 					_selectedindices.Add( _list.IndexOf( cb.Text ) );
  1183. 				}
  1184. 			}
  1185. 			multiplechoiceform.Close( );
  1186. 		}
  1187.  
  1188. 		#endregion Event Handlers
  1189. 	}
  1190. }
  1191.  

page last uploaded: 2019-01-21, 22:48