Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for dialogboxes_savefilebox.cs

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

  1. namespace RobvanderWoude
  2. {
  3. 	[System.Runtime.InteropServices.Guid( "4CB376E6-5238-4033-9EFB-18972527028C" )]
  4. 	public interface SaveFileBox_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 SampleCode( );
  20.  
  21. 		[System.Runtime.InteropServices.DispId( 6 )]
  22. 		void Show( );
  23. 	}
  24.  
  25.  
  26. 	[System.Runtime.InteropServices.Guid( "3A5B9C48-7956-4B36-9301-0F98F1B3D067" ), System.Runtime.InteropServices.InterfaceType( System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIDispatch )]
  27. 	public interface SaveFileBox_Events
  28. 	{
  29. 	}
  30.  
  31.  
  32. 	[System.Runtime.InteropServices.Guid( "128D27C4-4387-4FFC-9F7E-95385D1CF6E6" ), System.Runtime.InteropServices.ClassInterface( System.Runtime.InteropServices.ClassInterfaceType.AutoDual ), System.Runtime.InteropServices.ComSourceInterfaces( typeof( SaveFileBox_Events ) )]
  33. 	public class SaveFileBox : SaveFileBox_Interface
  34. 	{
  35. 		#region Default Values
  36.  
  37. 		const string defaultdescription = "Specify a file";
  38. 		const string defaultfilter = "All files (*.*)|*.*";
  39. 		static readonly string defaultstartfolder = System.IO.Directory.GetCurrentDirectory( );
  40. 		static readonly string defaulttitle = string.Format( "{0},  Version {1}", Global.Common.ProgramInfo.FileName, Global.Common.ProgramInfo.FileVersion );
  41.  
  42. 		#endregion Default Values
  43.  
  44.  
  45. 		#region Methods
  46.  
  47. 		public void CheckUpdate( )
  48. 		{
  49. 			Global.Common.ProgramInfo.CheckUpdate( );
  50. 		}
  51.  
  52.  
  53. 		public string Credits( )
  54. 		{
  55. 			return Global.Common.Credits( );
  56. 		}
  57.  
  58.  
  59. 		public string Help( int html = 0 )
  60. 		{
  61. 			int col1width = 0;
  62. 			int col2width = 0;
  63. 			int col3width = 0;
  64. 			int col4width = 0;
  65. 			int col5width = 0;
  66. 			string help = string.Empty;
  67. 			string linetemplate = string.Empty;
  68. 			string separatorline = string.Empty;
  69.  
  70. 			if ( html == 1 )
  71. 			{
  72. 				help += "<h1>Help for OpenFileBox class</h1>\n\n";
  73. 				help += "<p>Present an Open File dialog, and return the selected file path</p>\n\n";
  74. 				help += "<h2>COM ProgID: RobvanderWoude.OpenFileBox</h2>\n\n";
  75. 			}
  76. 			else
  77. 			{
  78. 				help += "Help for OpenFileBox class\n";
  79. 				help += new string( '\u2500', help.Length ) + "\n\n";
  80. 				help += "Present an Open File dialog, and return the selected file path\n\n\n";
  81. 				help += "COM ProgID: RobvanderWoude.OpenFileBox\n\n\n";
  82. 			}
  83.  
  84.  
  85. 			#region Properties
  86.  
  87. 			if ( html == 1 )
  88. 			{
  89. 				separatorline = string.Empty;
  90. 				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";
  91.  
  92. 				help += "<table>\n";
  93. 				help += "<tr>\n";
  94. 				help += "\t<th colspan=\"5\">Properties (Note that all properties are string or integer, no booleans, objects or arrays)</th>\n";
  95. 				help += "</tr>\n";
  96.  
  97. 				help += "<tr>\n";
  98. 				help += "\t<th>Property Name</th>\n";
  99. 				help += "\t<th>Description</th>\n";
  100. 				help += "\t<th>Mandatory</th>\n";
  101. 				help += "\t<th>Read-Only</th>\n";
  102. 				help += "\t<th>Default (Allowed) Values</th>\n";
  103. 				help += "</tr>\n";
  104. 			}
  105. 			else
  106. 			{
  107. 				col1width = 16;
  108. 				col2width = 50;
  109. 				col3width = 9;
  110. 				col4width = 9;
  111. 				col5width = 44;
  112.  
  113. 				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";
  114. 				linetemplate = "\u2502 {0,-" + col1width.ToString( ) + "} \u2502 {1,-" + col2width.ToString( ) + "} \u2502 {2,-" + col3width.ToString( ) + "} \u2502 {3,-" + col4width.ToString( ) + "} \u2502 {4,-" + col5width.ToString( ) + "} \u2502\n";
  115.  
  116. 				help += "\u250C" + new string( '\u2500', 14 + col1width + col2width + col3width + col4width + col5width ) + "\u2510\n";
  117. 				help += "\u2502" + new string( ' ', 14 + col1width + col2width + col3width + col4width + col5width ) + "\u2502\n";
  118. 				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)" );
  119. 				help += "\u2502" + new string( ' ', 14 + col1width + col2width + col3width + col4width + col5width ) + "\u2502\n";
  120. 				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";
  121. 				help += string.Format( linetemplate, "Property Name", "Description", "Mandatory", "Read-Only", "Default (Allowed) Values" );
  122. 				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";
  123. 			}
  124.  
  125. 			help += HelpTableRow( linetemplate, "addallfiles", "Add \"All files (*.*)\" to filter  (0=false; 1=true)", "no", "no", "1", html );
  126. 			help += separatorline;
  127.  
  128. 			help += HelpTableRow( linetemplate, "addextension", "Add extension if user forgot it  (0=false; 1=true)", "no", "no", "1", html );
  129. 			help += separatorline;
  130.  
  131. 			help += HelpTableRow( linetemplate, "debuginfo", Global.Common.Help.debuginfo, "N/A", "YES", "", html );
  132. 			help += separatorline;
  133.  
  134. 			help += HelpTableRow( linetemplate, "defaultextension", "Default extension to be added", "no", "no", "", html );
  135. 			help += separatorline;
  136.  
  137. 			help += HelpTableRow( linetemplate, "description", "Text above directory tree", "no", "no", "", 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, "filter", "File filter", "no", "no", "\"All files (*.*)|*.*\"", html );
  144. 			help += separatorline;
  145.  
  146. 			help += HelpTableRow( linetemplate, "forceext", "Append default extension if missing", "", html );
  147. 			help += separatorline;
  148.  
  149. 			help += HelpTableRow( linetemplate, "multidotted", "Allow multiple extensions        (0=false; 1=true)", "no", "no", "1", html );
  150. 			help += separatorline;
  151.  
  152. 			help += HelpTableRow( linetemplate, "overwrite", "Overwrite file if it exists      (0=false; 1=true)", "no", "no", "0", html );
  153. 			help += separatorline;
  154.  
  155. 			help += HelpTableRow( linetemplate, "selectedfile", "The path of the selected file(s)", "N/A", "YES", "", html );
  156. 			help += separatorline;
  157.  
  158. 			help += HelpTableRow( linetemplate, "startfolder", "The initial folder for the dialog", "no", "no", "", html );
  159. 			help += separatorline;
  160.  
  161. 			help += HelpTableRow( linetemplate, "title", Global.Common.Help.title, "no", "no", defaulttitle, html );
  162. 			help += separatorline;
  163.  
  164. 			help += HelpTableRow( linetemplate, "verbose",   "Prompt if file does not exist    (0=false; 1=true)", "no", "no", "0", html );
  165. 			help += separatorline;
  166.  
  167. 			help += HelpTableRow( linetemplate, "Version", Global.Common.Help.version, "N/A", "YES", "", 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 = 18;
  202. 				col2width = 74;
  203. 				col3width = 42;
  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, "SampleCode", Global.Common.Help._samplecode, "", html );
  230. 			help += separatorline;
  231.  
  232. 			help += HelpTableRow( linetemplate, "Show", "Presents an Open File dialog based on the current property values, and if \"OK\"is clicked, saves the selected file path in the \"selectedfile\" property (if \"Cancel\" is clicked, \"selectedfile\" will be empty)", "", html );
  233.  
  234. 			if ( html == 1 )
  235. 			{
  236. 				help += "</table>\n\n\n";
  237. 			}
  238. 			else
  239. 			{
  240. 				help += "\u2514" + new string( '\u2500', 2 + col1width ) + "\u2534" + new string( '\u2500', 2 + col2width ) + "\u2534" + new string( '\u2500', 2 + col3width ) + "\u2518\n\n\n";
  241. 			}
  242.  
  243. 			#endregion Methods
  244.  
  245.  
  246. 			#region Example
  247.  
  248. 			if ( html == 1 )
  249. 			{
  250. 				help += "<h2>VBScript usage example:</h2>\n\n<pre>";
  251. 			}
  252. 			else
  253. 			{
  254. 				help += "VBScript usage example:\n";
  255. 				help += new string( '\u2500', 23 ) + "\n\n";
  256. 			}
  257.  
  258. 			help += SampleCode( );
  259.  
  260. 			if ( html == 1 )
  261. 			{
  262. 				help += "</pre>";
  263. 			}
  264.  
  265. 			help += "\n\n";
  266.  
  267. 			#endregion Example
  268.  
  269.  
  270. 			help = help.Replace( "\n", System.Environment.NewLine );
  271. 			return help;
  272. 		}
  273.  
  274.  
  275. 		private string HelpTableRow( string template, string col1text, string col2text, string col3text, int html )
  276. 		{
  277. 			if ( html == 1 )
  278. 			{
  279. 				return Global.Common.Help.HelpTableRowHTML( col1text, col2text, col3text );
  280. 			}
  281. 			else
  282. 			{
  283. 				return Global.Common.Help.HelpTableRowText( template, col1text, col2text, col3text, "", "" );
  284. 			}
  285. 		}
  286.  
  287.  
  288. 		private string HelpTableRow( string template, string col1text, string col2text, string col3text, string col4text, string col5text, int html )
  289. 		{
  290. 			if ( html == 1 )
  291. 			{
  292. 				return Global.Common.Help.HelpTableRowHTML( col1text, col2text, col3text, col4text, col5text );
  293. 			}
  294. 			else
  295. 			{
  296. 				return Global.Common.Help.HelpTableRowText( template, col1text, col2text, col3text, col4text, col5text );
  297. 			}
  298. 		}
  299.  
  300.  
  301. 		public string ListProperties( )
  302. 		{
  303. 			return Global.Common.Lists.Properties( this );
  304. 		}
  305.  
  306.  
  307. 		public string SampleCode( )
  308. 		{
  309. 			string code = "Set objSaveFileBox = CreateObject( \"RobvanderWoude.SaveFileBox\" )\n\n";
  310. 			code += "With objSaveFileBox\n";
  311. 			code += "\t.startfolder = \"D:\\\"\n";
  312. 			code += "\t.Show\n";
  313. 			code += "\tWScript.Echo \"Selected target file: \" & .selectedfile\n";
  314. 			code += "\tWScript.Echo\n";
  315. 			code += "\tWScript.Echo .ListProperties( )\n";
  316. 			code += "End With\n\n";
  317. 			code += "Set objSaveFileBox = Nothing";
  318. 			return code;
  319. 		}
  320.  
  321.  
  322. 		[System.STAThread]
  323. 		public void Show( )
  324. 		{
  325. 			#region Apply Settings
  326.  
  327. 			string ext = System.Text.RegularExpressions.Regex.Match( filter, @"(\.[^.]+)$", System.Text.RegularExpressions.RegexOptions.IgnoreCase ).Groups[0].ToString( );
  328. 			if ( string.IsNullOrWhiteSpace( ext ) )
  329. 			{
  330. 				_errors.Add( Global.Common.TimeStamp( ) + "Invalid filetype specification" );
  331. 			}
  332. 			// If only "*.ext" is specified, use "ext files (*.ext)|*.ext" instead
  333. 			if ( System.Text.RegularExpressions.Regex.IsMatch( filter, @"^\*\.(\*|\w+)$" ) )
  334. 			{
  335. 				if ( ext == ".*" )
  336. 				{
  337. 					filter = string.Format( "All files (*.{0})|*.{0}", ext );
  338. 				}
  339. 				else
  340. 				{
  341. 					filter = string.Format( "{0} files (*.{0})|*.{0}", ext );
  342. 				}
  343. 			}
  344. 			// Use "All files" filter if not specified
  345. 			if ( string.IsNullOrWhiteSpace( filter ) )
  346. 			{
  347. 				filter = "All files (*.*)|*.*";
  348. 			}
  349.  
  350. 			#endregion Apply Settings
  351.  
  352.  
  353. 			try
  354. 			{
  355. 				using ( System.Windows.Forms.SaveFileDialog dialog = new System.Windows.Forms.SaveFileDialog( ) )
  356. 				{
  357. 					dialog.AddExtension = _forceext;
  358. 					dialog.CheckFileExists = false;
  359. 					dialog.CheckPathExists = !_overwrite;
  360. 					dialog.CreatePrompt = _verbose;
  361. 					dialog.DefaultExt = defaultextension;
  362. 					dialog.Filter = filter;
  363. 					dialog.FilterIndex = 1;
  364. 					dialog.InitialDirectory = startfolder;
  365. 					dialog.OverwritePrompt = !_overwrite;
  366. 					dialog.RestoreDirectory = true;
  367. 					dialog.SupportMultiDottedExtensions = _multidotted;
  368. 					dialog.Title = title;
  369. 					dialog.ValidateNames = true;
  370. 					if ( dialog.ShowDialog( ) == System.Windows.Forms.DialogResult.OK )
  371. 					{
  372. 						_selectedfile = dialog.FileName;
  373. 					}
  374. 					else
  375. 					{
  376. 						// Canceled
  377. 						_selectedfile = string.Empty;
  378. 					}
  379. 				}
  380. 			}
  381. 			catch ( System.Exception e )
  382. 			{
  383. 				_errors.Add( Global.Common.TimeStamp( ) + "Error while trying to show Save File dialog: " + e.Message );
  384. 			}
  385. 		}
  386.  
  387. 		#endregion Methods
  388.  
  389.  
  390. 		#region Properties
  391.  
  392. 		private bool _addallfiles = true;
  393. 		[System.Runtime.InteropServices.ComVisible( true )]
  394. 		public int addallfiles
  395. 		{
  396. 			get
  397. 			{
  398. 				return ( _addallfiles ? 1 : 0 );
  399. 			}
  400. 			set
  401. 			{
  402. 				_addallfiles = ( value == 1 );
  403. 			}
  404. 		}
  405.  
  406.  
  407. 		private bool _addextension = false;
  408. 		[System.Runtime.InteropServices.ComVisible( true )]
  409. 		public int addextension
  410. 		{
  411. 			get
  412. 			{
  413. 				return ( _addextension ? 1 : 0 );
  414. 			}
  415. 			set
  416. 			{
  417. 				_addextension = ( value == 1 );
  418. 			}
  419. 		}
  420.  
  421.  
  422. 		private System.Collections.Generic.List<string> _debuginfo = new System.Collections.Generic.List<string>( );
  423. 		[System.Runtime.InteropServices.ComVisible( true )]
  424. 		public string debuginfo
  425. 		{
  426. 			get
  427. 			{
  428. 				return string.Join( "\n", _debuginfo.ToArray( ) );
  429. 			}
  430. 		}
  431.  
  432.  
  433. 		private string _defaultextension = string.Empty;
  434. 		[System.Runtime.InteropServices.ComVisible( true )]
  435. 		public string defaultextension
  436. 		{
  437. 			get
  438. 			{
  439. 				return _defaultextension;
  440. 			}
  441. 			set
  442. 			{
  443. 				if ( value.StartsWith( "." ) )
  444. 				{
  445. 					_defaultextension = value.Trim( );
  446. 				}
  447. 				else
  448. 				{
  449. 					_debuginfo.Add( timestamp + "Invalid default extension, using \".*\" instead" );
  450. 					_defaultextension = ".*";
  451. 				}
  452. 			}
  453. 		}
  454.  
  455.  
  456. 		private string _description = defaultdescription;
  457. 		[System.Runtime.InteropServices.ComVisible( true )]
  458. 		public string description
  459. 		{
  460. 			get
  461. 			{
  462. 				return _description;
  463. 			}
  464. 			set
  465. 			{
  466. 				_description = value.Trim( );
  467. 			}
  468. 		}
  469.  
  470.  
  471. 		private System.Collections.Generic.List<string> _errors = new System.Collections.Generic.List<string>( );
  472. 		[System.Runtime.InteropServices.ComVisible( true )]
  473. 		public string errors
  474. 		{
  475. 			get
  476. 			{
  477. 				return string.Join( "\n", _errors.ToArray( ) );
  478. 			}
  479. 		}
  480.  
  481.  
  482. 		private string _filter = defaultfilter;
  483. 		[System.Runtime.InteropServices.ComVisible( true )]
  484. 		public string filter
  485. 		{
  486. 			get
  487. 			{
  488. 				return _filter;
  489. 			}
  490. 			set
  491. 			{
  492. 				// If only "*.ext" is specified, use "ext files (*.ext)|*.ext" instead
  493. 				if ( System.Text.RegularExpressions.Regex.IsMatch( value, @"^\*\.(\*|\w+)$" ) )
  494. 				{
  495. 					string ext = value.Substring( 2 ).ToLower( );
  496. 					if ( ext == ".*" )
  497. 					{
  498. 						_filter = string.Format( "All files (*.{0})|*.{0}", ext );
  499. 					}
  500. 					else
  501. 					{
  502. 						_filter = string.Format( "{0} files (*.{0})|*.{0}", ext );
  503. 					}
  504. 				}
  505. 				else
  506. 				{
  507. 					_filter = value;
  508. 				}
  509. 				if ( _addallfiles )
  510. 				{
  511. 					// Append "All files" filter if not specified
  512. 					if ( !System.Text.RegularExpressions.Regex.IsMatch( filter, @"All files\s+\(\*\.\*\)\|\*\.\*", System.Text.RegularExpressions.RegexOptions.IgnoreCase ) )
  513. 					{
  514. 						if ( string.IsNullOrWhiteSpace( _filter ) )
  515. 						{
  516. 							_filter = "All files (*.*)|*.*";
  517. 						}
  518. 						else
  519. 						{
  520. 							_filter += "|All files (*.*)|*.*";
  521. 						}
  522. 					}
  523. 				}
  524. 			}
  525. 		}
  526.  
  527.  
  528. 		private bool _forceext = true;
  529. 		[System.Runtime.InteropServices.ComVisible( true )]
  530. 		public int forceext
  531. 		{
  532. 			get
  533. 			{
  534. 				return ( _forceext ? 1 : 0 );
  535. 			}
  536. 			set
  537. 			{
  538. 				_forceext = ( value == 1 );
  539. 			}
  540. 		}
  541.  
  542.  
  543. 		private bool _multidotted = true;
  544. 		[System.Runtime.InteropServices.ComVisible( true )]
  545. 		public int multidotted
  546. 		{
  547. 			get
  548. 			{
  549. 				return ( _multidotted ? 1 : 0 );
  550. 			}
  551. 			set
  552. 			{
  553. 				_multidotted = ( value == 1 );
  554. 			}
  555. 		}
  556.  
  557.  
  558. 		private bool _overwrite = false;
  559. 		[System.Runtime.InteropServices.ComVisible( true )]
  560. 		public int overwrite
  561. 		{
  562. 			get
  563. 			{
  564. 				return ( _overwrite ? 1 : 0 );
  565. 			}
  566. 			set
  567. 			{
  568. 				_overwrite = ( value == 1 );
  569. 			}
  570. 		}
  571.  
  572.  
  573. 		private string _selectedfile = string.Empty;
  574. 		[System.Runtime.InteropServices.ComVisible( true )]
  575. 		public string selectedfile
  576. 		{
  577. 			get
  578. 			{
  579. 				return _selectedfile;
  580. 			}
  581. 		}
  582.  
  583.  
  584. 		private string _startfolder = defaultstartfolder;
  585. 		[System.Runtime.InteropServices.ComVisible( true )]
  586. 		public string startfolder
  587. 		{
  588. 			get
  589. 			{
  590. 				return _startfolder;
  591. 			}
  592. 			set
  593. 			{
  594. 				if ( System.IO.Directory.Exists( value ) )
  595. 				{
  596. 					try
  597. 					{
  598. 						_startfolder = System.IO.Path.GetFullPath( value );
  599. 					}
  600. 					catch ( System.ArgumentException )
  601. 					{
  602. 						try
  603. 						{
  604. 							// Assuming the error is caused by a trailing backslash in doublequotes
  605. 							_startfolder = System.IO.Path.GetFullPath( value.Substring( 0, startfolder.IndexOf( '"' ) ) + "." );
  606. 						}
  607. 						catch ( System.Exception )
  608. 						{
  609. 							_debuginfo.Add( timestamp + "Invalid start directory, using current directory instead" );
  610. 							_startfolder = ".";
  611. 						}
  612. 					}
  613. 				}
  614. 				else
  615. 				{
  616. 					_debuginfo.Add( timestamp + "Invalid start directory, using current directory instead" );
  617. 					_startfolder = ".";
  618. 				}
  619. 				_selectedfile = _startfolder;
  620. 			}
  621. 		}
  622.  
  623.  
  624. 		public static string timestamp => Global.Common.TimeStamp( );
  625.  
  626.  
  627. 		private string _title = defaulttitle;
  628. 		[System.Runtime.InteropServices.ComVisible( true )]
  629. 		public string title
  630. 		{
  631. 			get
  632. 			{
  633. 				return _title;
  634. 			}
  635. 			set
  636. 			{
  637. 				_title = value.Trim( );
  638. 			}
  639. 		}
  640.  
  641.  
  642. 		private bool _verbose = false;
  643. 		[System.Runtime.InteropServices.ComVisible( true )]
  644. 		public int verbose
  645. 		{
  646. 			get
  647. 			{
  648. 				return ( _verbose ? 1 : 0 );
  649. 			}
  650. 			set
  651. 			{
  652. 				_verbose = ( value == 1 );
  653. 			}
  654. 		}
  655.  
  656.  
  657. 		[System.Runtime.InteropServices.ComVisible( true )]
  658. 		public string Version
  659. 		{
  660. 			get
  661. 			{
  662. 				return Global.Common.ProgramInfo.FileVersion;
  663. 			}
  664. 		}
  665.  
  666. 		#endregion Properties
  667. 	}
  668. }
  669.  

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