Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for dialogboxes_classic.cs

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

  1. using System.Linq;
  2.  
  3.  
  4. namespace RobvanderWoude
  5. {
  6. 	[System.Runtime.InteropServices.Guid( "D2721C87-05FE-4D16-89A1-B3AE2E1AF30A" )]
  7. 	public interface DialogBoxes_Interface
  8. 	{
  9. 		[System.Runtime.InteropServices.DispId( 1 )]
  10. 		string AllColorsSelectBox( int allowcustomcolors = 1 );
  11.  
  12. 		[System.Runtime.InteropServices.DispId( 2 )]
  13. 		void CheckUpdate( );
  14.  
  15. 		[System.Runtime.InteropServices.DispId( 3 )]
  16. 		string ConsoleColorSelectBox( string title = "", int timeout = 0, int left = -1, int top = -1 );
  17.  
  18. 		[System.Runtime.InteropServices.DispId( 4 )]
  19. 		string Credits( );
  20.  
  21. 		[System.Runtime.InteropServices.DispId( 5 )]
  22. 		string DateTimeBox( string title = "", string initialdt = "", string culture = "fr-CA", string dateformat = "yyyy-MM-dd", string timeformat = "HH:mm:ss", int dateonly = 0, int timeonly = 0, string earliestdate = "", string latestdate = "", int minimumoffset = 0, int maximumoffset = 0, int windowwidth = 0, int windowheight = 0, string okcaption = "OK", string cancelcaption = "Cancel" );
  23.  
  24. 		[System.Runtime.InteropServices.DispId( 6 )]
  25. 		string DropDownBox( string list, string prompt = "", string title = "", int defaultindex = -1, int modal = 1, int windowwidth = 200, int windowheight = 90, int timeout = 0, string okcaption = "OK", string cancelcaption = "Cancel" );
  26.  
  27. 		[System.Runtime.InteropServices.DispId( 7 )]
  28. 		string FontSelectBox( string fontname = "Courier New", int fontsize = 12, int minimumfontsize = 8, int maximumfontsize = 48, int showeffects = 1, int showcolor = 1, int allowvectorfonts = 1, int scriptsonly = 0, int fixedpitchonly = 0, int allowcharsetchange = 1 );
  29.  
  30. 		[System.Runtime.InteropServices.DispId( 8 )]
  31. 		string Help( string dialogname = "", int html = 0 );
  32.  
  33. 		[System.Runtime.InteropServices.DispId( 9 )]
  34. 		string InputBox( string prompt = "", string title = "", string defaultanswer = "", string mask = "", int asciionly = 0, int returnunmasked = 0, string ontheflyregex = "", string endresultregex = "", int regexignorecase = 0, int hidepassword = 0, int showpwcheckbox = 0, string showpwcaption = "", int windowwidth = 200, int windowheight = 110, int timeout = 0, string okcaption = "OK", string cancelcaption = "Cancel" );
  35.  
  36. 		[System.Runtime.InteropServices.DispId( 10 )]
  37. 		string MessageBox( string message, string title = "", string buttons = "OK", string icon = "None", int defaultbutton = 1, string options = "" );
  38.  
  39. 		[System.Runtime.InteropServices.DispId( 11 )]
  40. 		string MultipleChoiceBox( string list, string prompt = "", string title = "", string preselected = "", int rows = 0, int columns = 0, int modal = 1, int windowwidth = 200, int windowheight = 90, int timeout = 0, string okcaption = "OK", string cancelcaption = "Cancel" );
  41.  
  42. 		[System.Runtime.InteropServices.DispId( 12 )]
  43. 		string OpenFileBox( string filter = "All files (*.*)|*.*", string folder = "", string title = "" );
  44.  
  45. 		[System.Runtime.InteropServices.DispId( 13 )]
  46. 		string OpenFolderBox( string startfolder = "", string description = "", int allowcreatenew = 0 );
  47.  
  48. 		[System.Runtime.InteropServices.DispId( 14 )]
  49. 		string PrinterSelectBox( string title = "Select Printer", string preselected = "0", string printercategory = "All", int windowwidth = 400, int windowheight = 220, int timeout = 0, string okcaption = "OK", string cancelcaption = "Cancel" );
  50.  
  51. 		[System.Runtime.InteropServices.DispId( 15 )]
  52. 		string RadioButtonBox( string list, string prompt = "", string title = "", int defaultindex = -1, int rows = 0, int columns = 0, int modal = 1, int windowwidth = 200, int windowheight = 90, int timeout = 0, string okcaption = "OK", string cancelcaption = "Cancel" );
  53.  
  54. 		[System.Runtime.InteropServices.DispId( 16 )]
  55. 		string SampleCode( string dialogname = "" );
  56.  
  57. 		[System.Runtime.InteropServices.DispId( 17 )]
  58. 		string SaveFileBox( string filter = "", string folder = "", string description = "", string title = "", int forceextension = 0, int overwrite = 0 );
  59.  
  60. 		[System.Runtime.InteropServices.DispId( 18 )]
  61. 		int SystemTrayMessage( string message, string title, int escapemessage = 1, int timeout = 10, string iconfile = "shell32.dll", int iconindex = 277, string tooltipicon = "Info", int wait = 1 );
  62.  
  63. 		[System.Runtime.InteropServices.DispId( 19 )]
  64. 		string Version( );
  65. 	}
  66.  
  67.  
  68. 	[System.Runtime.InteropServices.Guid( "FD761AF3-C76E-4B4C-8C64-95464BDD3BCA" ), System.Runtime.InteropServices.InterfaceType( System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIDispatch )]
  69. 	public interface DialogBoxes_Events
  70. 	{
  71. 	}
  72.  
  73.  
  74. 	[System.Runtime.InteropServices.Guid( "2DC15C73-77DD-4766-8A60-57115DE84231" ), System.Runtime.InteropServices.ClassInterface( System.Runtime.InteropServices.ClassInterfaceType.None ), System.Runtime.InteropServices.ComSourceInterfaces( typeof( DialogBoxes_Events ) )]
  75. 	public class DialogBoxes : DialogBoxes_Interface
  76. 	{
  77. 		#region General
  78.  
  79. 		public void CheckUpdate( )
  80. 		{
  81. 			Global.Common.ProgramInfo.CheckUpdate( );
  82. 		}
  83.  
  84.  
  85. 		public string Credits( )
  86. 		{
  87. 			return Global.Common.Credits( );
  88. 		}
  89.  
  90.  
  91. 		public string Help( string dialogname = "", int html = 0 )
  92. 		{
  93. 			System.Collections.Generic.List<string> classnames = System.Reflection.Assembly.GetExecutingAssembly( ).GetTypes( ).Where( t => string.Equals( t.Namespace, "RobvanderWoude", System.StringComparison.Ordinal ) && t.IsClass && ( t.Name.EndsWith( "Box" ) || t.Name.Equals( "SystemTrayMessage" ) ) ).Select( t => t.Name ).Distinct( ).ToList<string>( );
  94. 			if ( string.IsNullOrWhiteSpace( dialogname ) || !classnames.Contains( dialogname, System.StringComparer.InvariantCultureIgnoreCase ) )
  95. 			{
  96. 				dialogname = "All";
  97. 			}
  98.  
  99. 			string help = string.Format( "{0}, Version {1}\n", Global.Common.ProgramInfo.FileName, Version( ) );
  100. 			help += string.Format( "{0}\n", Global.Common.ProgramInfo.Comment );
  101. 			help += string.Format( "{0}\n", Global.Common.ProgramInfo.Copyrights );
  102. 			help += "https://www.robvanderwoude.com\n\n";
  103. 			help += "ProgID: \"RobvanderWoude.DialogBoxes\"\n\n\n";
  104.  
  105. 			if ( dialogname == "All" || dialogname == "ColorSelectBox" || dialogname == "AllColorsSelectBox" || dialogname == "ConsoleColorSelectBox" )
  106. 			{
  107. 				help += ( new ColorSelectBox( ) ).Help( html );
  108. 			}
  109.  
  110. 			if ( dialogname == "All" )
  111. 			{
  112. 				help += "\n\n\n";
  113. 			}
  114.  
  115. 			if ( dialogname == "All" || dialogname == "DateTimeBox" )
  116. 			{
  117. 				help += ( new DateTimeBox( ) ).Help( html );
  118. 			}
  119.  
  120. 			if ( dialogname == "All" )
  121. 			{
  122. 				help += "\n\n\n";
  123. 			}
  124.  
  125. 			if ( dialogname == "All" || dialogname == "DropDownBox" )
  126. 			{
  127. 				help += ( new DropDownBox( ) ).Help( html );
  128. 			}
  129.  
  130. 			if ( dialogname == "All" )
  131. 			{
  132. 				help += "\n\n\n";
  133. 			}
  134.  
  135. 			if ( dialogname == "All" || dialogname == "FontSelectBox" )
  136. 			{
  137. 				help += ( new FontSelectBox( ) ).Help( html );
  138. 			}
  139.  
  140. 			if ( dialogname == "All" )
  141. 			{
  142. 				help += "\n\n\n";
  143. 			}
  144.  
  145. 			if ( dialogname == "All" || dialogname == "InputBox" )
  146. 			{
  147. 				help += ( new InputBox( ) ).Help( html );
  148. 			}
  149.  
  150. 			if ( dialogname == "All" )
  151. 			{
  152. 				help += "\n\n\n";
  153. 			}
  154.  
  155. 			if ( dialogname == "All" || dialogname == "MessageBox" )
  156. 			{
  157. 				help += ( new MessageBox( ) ).Help( html );
  158. 			}
  159.  
  160. 			if ( dialogname == "All" )
  161. 			{
  162. 				help += "\n\n\n";
  163. 			}
  164.  
  165. 			if ( dialogname == "All" || dialogname == "MultipleChoiceBox" )
  166. 			{
  167. 				help += ( new MultipleChoiceBox( ) ).Help( html );
  168. 			}
  169.  
  170. 			if ( dialogname == "All" )
  171. 			{
  172. 				help += "\n\n\n";
  173. 			}
  174.  
  175. 			if ( dialogname == "All" || dialogname == "OpenFileBox" )
  176. 			{
  177. 				help += ( new OpenFileBox( ) ).Help( html );
  178. 			}
  179.  
  180. 			if ( dialogname == "All" )
  181. 			{
  182. 				help += "\n\n\n";
  183. 			}
  184.  
  185. 			if ( dialogname == "All" || dialogname == "OpenFolderBox" )
  186. 			{
  187. 				help += ( new OpenFolderBox( ) ).Help( html );
  188. 			}
  189.  
  190. 			if ( dialogname == "All" )
  191. 			{
  192. 				help += "\n\n\n";
  193. 			}
  194.  
  195. 			if ( dialogname == "All" || dialogname == "PrinterSelectBox" )
  196. 			{
  197. 				help += ( new PrinterSelectBox( ) ).Help( html );
  198. 			}
  199.  
  200. 			if ( dialogname == "All" )
  201. 			{
  202. 				help += "\n\n\n";
  203. 			}
  204.  
  205. 			if ( dialogname == "All" || dialogname == "RadioButtonBox" )
  206. 			{
  207. 				help += ( new RadioButtonBox( ) ).Help( html );
  208. 			}
  209.  
  210. 			if ( dialogname == "All" )
  211. 			{
  212. 				help += "\n\n\n";
  213. 			}
  214.  
  215. 			if ( dialogname == "All" || dialogname == "SaveFileBox" )
  216. 			{
  217. 				help += ( new SaveFileBox( ) ).Help( html );
  218. 			}
  219.  
  220. 			if ( dialogname == "All" )
  221. 			{
  222. 				help += "\n\n\n";
  223. 			}
  224.  
  225. 			if ( dialogname == "All" || dialogname == "SystemTrayMessage" )
  226. 			{
  227. 				help += ( new SystemTrayMessage( ) ).Help( html );
  228. 			}
  229.  
  230. 			help = help.Replace( "\n", System.Environment.NewLine );
  231. 			return help;
  232. 		}
  233.  
  234.  
  235. 		public string SampleCode( string dialogname = "" )
  236. 		{
  237. 			System.Collections.Generic.List<string> classnames = System.Reflection.Assembly.GetExecutingAssembly( ).GetTypes( ).Where( t => string.Equals( t.Namespace, "RobvanderWoude", System.StringComparison.Ordinal ) && t.IsClass && ( t.Name.EndsWith( "Box" ) || t.Name.Equals( "SystemTrayMessage" ) ) ).Select( t => t.Name ).Distinct( ).ToList<string>( );
  238. 			if ( string.IsNullOrWhiteSpace( dialogname ) || !classnames.Contains( dialogname, System.StringComparer.InvariantCultureIgnoreCase ) )
  239. 			{
  240. 				dialogname = "All";
  241. 			}
  242.  
  243. 			string help = string.Format( "' {0}, Version {1}\n", Global.Common.ProgramInfo.FileName, Version( ) );
  244. 			help += string.Format( "' {0}\n", Global.Common.ProgramInfo.Comment );
  245. 			help += string.Format( "' {0}\n", Global.Common.ProgramInfo.Copyrights );
  246. 			help += "' https://www.robvanderwoude.com\n";
  247. 			help += "' ProgID: \"RobvanderWoude.DialogBoxes\"\n\n";
  248.  
  249. 			if ( dialogname == "All" || dialogname == "ColorSelectBox" || dialogname == "AllColorsSelectBox" || dialogname == "ConsoleColorSelectBox" )
  250. 			{
  251. 				help += string.Format( "' {0}:\n\n", dialogname );
  252. 				help += ( new ColorSelectBox( ) ).SampleCode( );
  253. 			}
  254.  
  255. 			if ( dialogname == "All" )
  256. 			{
  257. 				help += "\n\n\n";
  258. 			}
  259.  
  260. 			if ( dialogname == "All" || dialogname == "DateTimeBox" )
  261. 			{
  262. 				help += string.Format( "' {0}:\n\n", dialogname );
  263. 				help += ( new DateTimeBox( ) ).SampleCode( );
  264. 			}
  265.  
  266. 			if ( dialogname == "All" )
  267. 			{
  268. 				help += "\n\n\n";
  269. 			}
  270.  
  271. 			if ( dialogname == "All" || dialogname == "DropDownBox" )
  272. 			{
  273. 				help += string.Format( "' {0}:\n\n", dialogname );
  274. 				help += ( new DropDownBox( ) ).SampleCode( );
  275. 			}
  276.  
  277. 			if ( dialogname == "All" )
  278. 			{
  279. 				help += "\n\n\n";
  280. 			}
  281.  
  282. 			if ( dialogname == "All" || dialogname == "FontSelectBox" )
  283. 			{
  284. 				help += string.Format( "' {0}:\n\n", dialogname );
  285. 				help += ( new FontSelectBox( ) ).SampleCode( );
  286. 			}
  287.  
  288. 			if ( dialogname == "All" )
  289. 			{
  290. 				help += "\n\n\n";
  291. 			}
  292.  
  293. 			if ( dialogname == "All" || dialogname == "InputBox" )
  294. 			{
  295. 				help += string.Format( "' {0}:\n\n", dialogname );
  296. 				help += ( new InputBox( ) ).SampleCode( );
  297. 			}
  298.  
  299. 			if ( dialogname == "All" )
  300. 			{
  301. 				help += "\n\n\n";
  302. 			}
  303.  
  304. 			if ( dialogname == "All" || dialogname == "MessageBox" )
  305. 			{
  306. 				help += string.Format( "' {0}:\n\n", dialogname );
  307. 				help += ( new MessageBox( ) ).SampleCode( );
  308. 			}
  309.  
  310. 			if ( dialogname == "All" )
  311. 			{
  312. 				help += "\n\n\n";
  313. 			}
  314.  
  315. 			if ( dialogname == "All" || dialogname == "MultipleChoiceBox" )
  316. 			{
  317. 				help += string.Format( "' {0}:\n\n", dialogname );
  318. 				help += ( new MultipleChoiceBox( ) ).SampleCode( );
  319. 			}
  320.  
  321. 			if ( dialogname == "All" )
  322. 			{
  323. 				help += "\n\n\n";
  324. 			}
  325.  
  326. 			if ( dialogname == "All" || dialogname == "OpenFileBox" )
  327. 			{
  328. 				help += string.Format( "' {0}:\n\n", dialogname );
  329. 				help += ( new OpenFileBox( ) ).SampleCode( );
  330. 			}
  331.  
  332. 			if ( dialogname == "All" )
  333. 			{
  334. 				help += "\n\n\n";
  335. 			}
  336.  
  337. 			if ( dialogname == "All" || dialogname == "OpenFolderBox" )
  338. 			{
  339. 				help += string.Format( "' {0}:\n\n", dialogname );
  340. 				help += ( new OpenFolderBox( ) ).SampleCode( );
  341. 			}
  342.  
  343. 			if ( dialogname == "All" )
  344. 			{
  345. 				help += string.Format( "' {0}:\n\n", dialogname );
  346. 				help += "\n\n\n";
  347. 			}
  348.  
  349. 			if ( dialogname == "All" || dialogname == "PrinterSelectBox" )
  350. 			{
  351. 				help += string.Format( "' {0}:\n\n", dialogname );
  352. 				help += ( new PrinterSelectBox( ) ).SampleCode( );
  353. 			}
  354.  
  355. 			if ( dialogname == "All" )
  356. 			{
  357. 				help += "\n\n\n";
  358. 			}
  359.  
  360. 			if ( dialogname == "All" || dialogname == "RadioButtonBox" )
  361. 			{
  362. 				help += string.Format( "' {0}:\n\n", dialogname );
  363. 				help += ( new RadioButtonBox( ) ).SampleCode( );
  364. 			}
  365.  
  366. 			if ( dialogname == "All" )
  367. 			{
  368. 				help += "\n\n\n";
  369. 			}
  370.  
  371. 			if ( dialogname == "All" || dialogname == "SaveFileBox" )
  372. 			{
  373. 				help += string.Format( "' {0}:\n\n", dialogname );
  374. 				help += ( new SaveFileBox( ) ).SampleCode( );
  375. 			}
  376.  
  377. 			if ( dialogname == "All" )
  378. 			{
  379. 				help += "\n\n\n";
  380. 			}
  381.  
  382. 			if ( dialogname == "All" || dialogname == "SystemTrayMessage" )
  383. 			{
  384. 				help += string.Format( "' {0}:\n\n", dialogname );
  385. 				help += ( new SystemTrayMessage( ) ).SampleCode( );
  386. 			}
  387.  
  388. 			help = help.Replace( "\n", System.Environment.NewLine );
  389. 			return help;
  390. 		}
  391.  
  392.  
  393. 		public string Version( )
  394. 		{
  395. 			return Global.Common.ProgramInfo.FileVersion;
  396. 		}
  397.  
  398. 		#endregion General
  399.  
  400.  
  401. 		[System.STAThread]
  402. 		public string AllColorsSelectBox( int allowcustomcolors = 1 )
  403. 		{
  404. 			ColorSelectBox colorselectbox = new ColorSelectBox( );
  405.  
  406. 			colorselectbox.consolecolorsonly = 0;
  407. 			colorselectbox.allowcustomcolors = allowcustomcolors;
  408.  
  409. 			colorselectbox.Show( );
  410.  
  411. 			return colorselectbox.selectedcolorname;
  412. 		}
  413.  
  414.  
  415. 		public string ConsoleColorSelectBox( string title = "", int timeout = 0, int left = -1, int top = -1 )
  416. 		{
  417. 			ColorSelectBox colorselectbox = new ColorSelectBox( );
  418.  
  419. 			colorselectbox.consolecolorsonly = 1;
  420. 			colorselectbox.left = left;
  421. 			colorselectbox.timeout = timeout;
  422. 			colorselectbox.title = title;
  423. 			colorselectbox.top = top;
  424.  
  425. 			colorselectbox.Show( );
  426.  
  427. 			return colorselectbox.selectedcolorname;
  428. 		}
  429.  
  430.  
  431. 		public string DateTimeBox( string title = "", string initialdt = "", string culture = "fr-CA", string dateformat = "yyyy-MM-dd", string timeformat = "HH:mm:ss", int dateonly = 0, int timeonly = 0, string earliestdate = "", string latestdate = "", int minimumoffset = 0, int maximumoffset = 0, int windowwidth = 0, int windowheight = 0, string okcaption = "OK", string cancelcaption = "Cancel" )
  432. 		{
  433. 			DateTimeBox datetimebox = new DateTimeBox( );
  434.  
  435. 			datetimebox.captioncancel = cancelcaption;
  436. 			datetimebox.captionok = okcaption;
  437. 			datetimebox.culturegui = culture;
  438. 			datetimebox.culturein = culture;
  439. 			datetimebox.dateformatout = dateformat;
  440. 			datetimebox.dateonly = dateonly;
  441. 			datetimebox.earliestdate = earliestdate;
  442. 			datetimebox.initialdatetime = initialdt;
  443. 			datetimebox.latestdate = latestdate;
  444. 			datetimebox.maxdaysback = minimumoffset;
  445. 			datetimebox.maxdaysforward = maximumoffset;
  446. 			datetimebox.timeformatout = timeformat;
  447. 			datetimebox.timeonly = timeonly;
  448. 			datetimebox.title = title;
  449. 			datetimebox.windowheight = windowheight;
  450. 			datetimebox.windowwidth = windowwidth;
  451.  
  452. 			datetimebox.Show( );
  453.  
  454. 			return datetimebox.selecteddate;
  455. 		}
  456.  
  457.  
  458. 		public string DropDownBox( string list, string prompt = "", string title = "", int defaultindex = -1, int modal = 1, int windowwidth = 200, int windowheight = 90, int timeout = 0, string okcaption = "OK", string cancelcaption = "Cancel" )
  459. 		{
  460. 			DropDownBox dropdownbox = new DropDownBox( );
  461.  
  462. 			dropdownbox.captioncancel = cancelcaption;
  463. 			dropdownbox.captionok = okcaption;
  464. 			dropdownbox.defaultindex = defaultindex;
  465. 			dropdownbox.list = list;
  466. 			dropdownbox.modal = modal;
  467. 			dropdownbox.prompt = prompt;
  468. 			dropdownbox.timeout = timeout;
  469. 			dropdownbox.title = title;
  470. 			dropdownbox.windowheight = windowheight;
  471. 			dropdownbox.windowwidth = windowwidth;
  472.  
  473. 			dropdownbox.Show( );
  474.  
  475. 			return dropdownbox.selecteditem;
  476. 		}
  477.  
  478.  
  479. 		[System.STAThread]
  480. 		public string FontSelectBox( string fontname = "Courier New", int fontsize = 12, int minimumfontsize = 8, int maximumfontsize = 48, int showeffects = 1, int showcolor = 1, int allowvectorfonts = 1, int scriptsonly = 0, int fixedpitchonly = 0, int allowcharsetchange = 1 )
  481. 		{
  482. 			FontSelectBox fontselectbox = new FontSelectBox( );
  483.  
  484. 			fontselectbox.fontfamily = fontname;
  485. 			fontselectbox.fontsize = fontsize;
  486. 			fontselectbox.minimumfontsize = minimumfontsize;
  487. 			fontselectbox.maximumfontsize = maximumfontsize;
  488. 			fontselectbox.showeffects = showeffects;
  489. 			fontselectbox.showcolor = showcolor;
  490. 			fontselectbox.vectorfonts = allowvectorfonts;
  491. 			fontselectbox.scriptsonly = scriptsonly;
  492. 			fontselectbox.fixedpitchonly = fixedpitchonly;
  493. 			fontselectbox.choosecharset = allowcharsetchange;
  494.  
  495. 			fontselectbox.Show( );
  496.  
  497. 			return string.Format( "{0}, {1}, {2}", fontselectbox.fontfamily, fontselectbox.fontsize, fontselectbox.fontstyle );
  498. 		}
  499.  
  500.  
  501. 		public string InputBox( string prompt = "", string title = "", string defaultanswer = "", string mask = "", int asciionly = 0, int returnunmasked = 0, string ontheflyregex = "", string endresultregex = "", int regexcasesensitive = 1, int hidepassword = 0, int showpwcheckbox = 0, string showpwcaption = "", int windowwidth = 200, int windowheight = 110, int timeout = 0, string okcaption = "OK", string cancelcaption = "Cancel" )
  502. 		{
  503. 			InputBox inputbox = new InputBox( );
  504.  
  505. 			inputbox.prompt = prompt;
  506. 			inputbox.title = title;
  507. 			inputbox.initialinput = defaultanswer;
  508. 			inputbox.mask = mask;
  509. 			inputbox.asciionly = asciionly;
  510. 			inputbox.regexonthefly = ontheflyregex;
  511. 			inputbox.regexendresult = endresultregex;
  512. 			inputbox.regexcasesensitive = regexcasesensitive;
  513. 			inputbox.hidepassword = hidepassword;
  514. 			inputbox.allowshowpassword = showpwcheckbox;
  515. 			inputbox.captionshowpassword = showpwcaption;
  516. 			inputbox.windowwidth = windowwidth;
  517. 			inputbox.windowheight = windowheight;
  518. 			inputbox.timeout = timeout;
  519. 			inputbox.captionok = okcaption;
  520. 			inputbox.captioncancel = cancelcaption;
  521.  
  522. 			inputbox.Show( );
  523.  
  524. 			if ( returnunmasked == 1 )
  525. 			{
  526. 				return inputbox.input;
  527. 			}
  528. 			else
  529. 			{
  530. 				return inputbox.maskedinput;
  531. 			}
  532. 		}
  533.  
  534.  
  535. 		[System.STAThread]
  536. 		public string MessageBox( string message, string title = "", string buttons = "OK", string icon = "None", int defaultbutton = 1, string options = "" )
  537. 		{
  538. 			RobvanderWoude.MessageBox messagebox = new RobvanderWoude.MessageBox( );
  539.  
  540. 			messagebox.message = message;
  541. 			messagebox.title = title;
  542. 			messagebox.buttons = buttons;
  543. 			messagebox.icon = icon;
  544. 			messagebox.defaultbutton = defaultbutton;
  545. 			messagebox.options = options;
  546.  
  547. 			messagebox.Show( );
  548.  
  549. 			return messagebox.buttonclicked;
  550. 		}
  551.  
  552.  
  553. 		public string MultipleChoiceBox( string list, string prompt = "", string title = "", string preselected = "", int rows = 0, int columns = 0, int modal = 1, int windowwidth = 200, int windowheight = 90, int timeout = 0, string okcaption = "OK", string cancelcaption = "Cancel" )
  554. 		{
  555. 			MultipleChoiceBox multiplechoicebox = new MultipleChoiceBox( );
  556.  
  557. 			if ( !list.Contains( ";" ) && System.IO.File.Exists( list ) )
  558. 			{
  559. 				multiplechoicebox.list = string.Empty;
  560. 				multiplechoicebox.listfile = list;
  561. 			}
  562. 			else
  563. 			{
  564. 				multiplechoicebox.list = list;
  565. 				multiplechoicebox.listfile = string.Empty;
  566. 			}
  567. 			multiplechoicebox.captioncancel = cancelcaption;
  568. 			multiplechoicebox.captionok = okcaption;
  569. 			multiplechoicebox.columns = columns;
  570. 			multiplechoicebox.modal = modal;
  571. 			multiplechoicebox.preselected = preselected;
  572. 			multiplechoicebox.prompt = prompt;
  573. 			multiplechoicebox.rows = rows;
  574. 			multiplechoicebox.timeout = timeout;
  575. 			multiplechoicebox.title = title;
  576. 			multiplechoicebox.windowheight = windowheight;
  577. 			multiplechoicebox.windowwidth = windowwidth;
  578.  
  579. 			multiplechoicebox.Show( );
  580.  
  581. 			return multiplechoicebox.selecteditems;
  582. 		}
  583.  
  584.  
  585. 		[System.STAThread]
  586. 		public string OpenFileBox( string filter = "All files (*.*)|*.*", string folder = "", string title = "" )
  587. 		{
  588. 			OpenFileBox openfilebox = new OpenFileBox( );
  589.  
  590. 			openfilebox.addallfiles = 1;
  591. 			openfilebox.addextension = 1;
  592. 			openfilebox.filter = filter;
  593. 			openfilebox.multidotted = 1;
  594. 			openfilebox.multiselect = 0;
  595. 			openfilebox.showreadonly = 0;
  596. 			openfilebox.startfolder = folder;
  597. 			openfilebox.title = title;
  598.  
  599. 			openfilebox.Show( );
  600.  
  601. 			return openfilebox.selectedfile;
  602. 		}
  603.  
  604.  
  605. 		[System.STAThread]
  606. 		public string OpenFolderBox( string startfolder = "", string description = "", int allowcreatenew = 0 )
  607. 		{
  608. 			OpenFolderBox openfolderbox = new OpenFolderBox( );
  609.  
  610. 			openfolderbox.allowmakedir = allowcreatenew;
  611. 			openfolderbox.description = description;
  612. 			openfolderbox.rootfolder = "MyComputer";
  613. 			openfolderbox.startfolder = startfolder;
  614.  
  615. 			openfolderbox.Show( );
  616.  
  617. 			return openfolderbox.selectedfolder;
  618. 		}
  619.  
  620.  
  621. 		public string PrinterSelectBox( string title = "Select Printer", string preselected = "0", string printercategory = "All", int windowwidth = 400, int windowheight = 220, int timeout = 0, string okcaption = "OK", string cancelcaption = "Cancel" )
  622. 		{
  623. 			PrinterSelectBox printerselectbox = new PrinterSelectBox( );
  624.  
  625. 			printerselectbox.captioncancel = cancelcaption;
  626. 			printerselectbox.captionok = okcaption;
  627. 			printerselectbox.timeout = timeout;
  628. 			printerselectbox.title = title;
  629. 			printerselectbox.preselected = preselected;
  630. 			printerselectbox.printercategory = printercategory;
  631. 			printerselectbox.windowheight = windowheight;
  632. 			printerselectbox.windowwidth = windowwidth;
  633.  
  634. 			printerselectbox.Show( );
  635.  
  636. 			return printerselectbox.selectedprinter;
  637. 		}
  638.  
  639.  
  640. 		public string RadioButtonBox( string list, string prompt = "", string title = "", int defaultindex = -1, int rows = 0, int columns = 0, int modal = 1, int windowwidth = 200, int windowheight = 90, int timeout = 0, string okcaption = "OK", string cancelcaption = "Cancel" )
  641. 		{
  642. 			RadioButtonBox radiobuttonbox = new RadioButtonBox( );
  643.  
  644. 			if ( !list.Contains( ";" ) && System.IO.File.Exists( list ) )
  645. 			{
  646. 				radiobuttonbox.list = string.Empty;
  647. 				radiobuttonbox.listfile = list;
  648. 			}
  649. 			else
  650. 			{
  651. 				radiobuttonbox.list = list;
  652. 				radiobuttonbox.listfile = string.Empty;
  653. 			}
  654. 			radiobuttonbox.prompt = prompt;
  655. 			radiobuttonbox.title = title;
  656. 			radiobuttonbox.defaultindex = defaultindex;
  657. 			radiobuttonbox.rows = rows;
  658. 			radiobuttonbox.columns = columns;
  659. 			radiobuttonbox.modal = modal;
  660. 			radiobuttonbox.windowwidth = windowwidth;
  661. 			radiobuttonbox.windowheight = windowheight;
  662. 			radiobuttonbox.timeout = timeout;
  663. 			radiobuttonbox.captioncancel = cancelcaption;
  664. 			radiobuttonbox.captionok = okcaption;
  665.  
  666. 			radiobuttonbox.Show( );
  667.  
  668. 			return radiobuttonbox.selecteditem;
  669. 		}
  670.  
  671.  
  672. 		[System.STAThread]
  673. 		public string SaveFileBox( string filter = "", string folder = "", string description = "" , string title = "", int forceextension = 0, int overwrite = 0 )
  674. 		{
  675. 			SaveFileBox savefilebox = new SaveFileBox( );
  676.  
  677. 			savefilebox.addallfiles = 1;
  678. 			savefilebox.addextension = 1;
  679. 			savefilebox.description = description;
  680. 			savefilebox.filter = filter;
  681. 			savefilebox.forceext = forceextension;
  682. 			savefilebox.multidotted = 1;
  683. 			savefilebox.overwrite = overwrite;
  684. 			savefilebox.startfolder = folder;
  685. 			savefilebox.title = title;
  686.  
  687. 			savefilebox.Show( );
  688.  
  689. 			return savefilebox.selectedfile;
  690. 		}
  691.  
  692.  
  693. 		public int SystemTrayMessage( string message, string title, int escapemessage = 1, int timeout = 10, string iconfile = "shell32.dll", int iconindex = 277, string tooltipicon = "Info", int wait = 1 )
  694. 		{
  695. 			SystemTrayMessage systraymessage = new SystemTrayMessage( );
  696.  
  697. 			systraymessage.escapemessage = escapemessage;
  698. 			systraymessage.iconfile = iconfile;
  699. 			systraymessage.iconindex = iconindex;
  700. 			systraymessage.message = message;
  701. 			systraymessage.timeout = timeout;
  702. 			systraymessage.title = title;
  703. 			systraymessage.tooltipicon = tooltipicon;
  704. 			systraymessage.wait = wait;
  705.  
  706. 			systraymessage.Show( );
  707.  
  708. 			if ( systraymessage.wait == 1 )
  709. 			{
  710. 				return systraymessage.balloonclicked;
  711. 			}
  712. 			else
  713. 			{
  714. 				return 0;
  715. 			}
  716. 		}
  717. 	}
  718. }

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