Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for dialogboxes_fontselectbox.cs

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

  1. using System.Linq;
  2.  
  3.  
  4. namespace RobvanderWoude
  5. {
  6. 	[System.Runtime.InteropServices.Guid( "3AC0686B-1892-4886-837F-E5B7DA47C8F8" )]
  7. 	public interface FontSelectBox_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 ListColors( );
  20.  
  21. 		[System.Runtime.InteropServices.DispId( 5 )]
  22. 		string ListFontCharSets( );
  23.  
  24. 		[System.Runtime.InteropServices.DispId( 6 )]
  25. 		string ListProperties( );
  26.  
  27. 		[System.Runtime.InteropServices.DispId( 7 )]
  28. 		string SampleCode( );
  29.  
  30. 		[System.Runtime.InteropServices.DispId( 8 )]
  31. 		void Show( );
  32. 	}
  33.  
  34.  
  35. 	[System.Runtime.InteropServices.Guid( "35867F16-1A9E-4CD0-AA46-869A8A30E745" ), System.Runtime.InteropServices.InterfaceType( System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIDispatch )]
  36. 	public interface FontSelectBox_Events
  37. 	{
  38. 	}
  39.  
  40.  
  41. 	[System.Runtime.InteropServices.Guid( "8194D25A-B967-4B94-ABE6-E51BA5D1526F" ), System.Runtime.InteropServices.ClassInterface( System.Runtime.InteropServices.ClassInterfaceType.AutoDual ), System.Runtime.InteropServices.ComSourceInterfaces( typeof( FontSelectBox_Events ) )]
  42. 	public class FontSelectBox : FontSelectBox_Interface
  43. 	{
  44. 		#region Default Values
  45.  
  46. 		static readonly FontCharSet defaultcharset = FontCharSet.ANSI;
  47. 		static readonly System.Drawing.Color defaultcolor = System.Drawing.Color.Black;
  48. 		static readonly System.Drawing.FontFamily defaultfontfamily = System.Drawing.FontFamily.GenericSansSerif;
  49. 		const float defaultfontsize = 10;
  50. 		static readonly System.Drawing.FontStyle defaultfontstyle = System.Drawing.FontStyle.Regular;
  51. 		const int defaultmaxfontsize = 64;
  52. 		const int defaultminfonstsize = 6;
  53.  
  54. 		#endregion Default Values
  55.  
  56.  
  57. 		#region Methods
  58.  
  59. 		public void CheckUpdate( )
  60. 		{
  61. 			Global.Common.ProgramInfo.CheckUpdate( );
  62. 		}
  63.  
  64.  
  65. 		public string Credits( )
  66. 		{
  67. 			return Global.Common.Credits( );
  68. 		}
  69.  
  70.  
  71. 		public string Help( int html = 0 )
  72. 		{
  73. 			int col1width = 0;
  74. 			int col2width = 0;
  75. 			int col3width = 0;
  76. 			int col4width = 0;
  77. 			int col5width = 0;
  78. 			string help = string.Empty;
  79. 			string linetemplate = string.Empty;
  80. 			string separatorline = string.Empty;
  81.  
  82. 			if ( html == 1 )
  83. 			{
  84. 				help += "<h1>Help for FontSelectBox class</h1>\n\n";
  85. 				help += "<p>Present a font dialog, and return the selected font</p>\n\n";
  86. 				help += "<h2>COM ProgID: RobvanderWoude.FontSelectBox</h2>\n\n";
  87. 			}
  88. 			else
  89. 			{
  90. 				help += "Help for FontSelectBox class\n";
  91. 				help += new string( '\u2500', help.Length ) + "\n\n";
  92. 				help += "Present a font dialog, and return the selected font\n\n\n";
  93. 				help += "COM ProgID: RobvanderWoude.FontSelectBox\n\n\n";
  94. 			}
  95.  
  96.  
  97. 			#region Properties
  98.  
  99. 			if ( html == 1 )
  100. 			{
  101. 				separatorline = string.Empty;
  102. 				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";
  103.  
  104. 				help += "<table>\n";
  105. 				help += "<tr>\n";
  106. 				help += "\t<th colspan=\"5\">Properties (Note that all properties are string or integer, no booleans, objects or arrays)</th>\n";
  107. 				help += "</tr>\n";
  108.  
  109. 				help += "<tr>\n";
  110. 				help += "\t<th>Property Name</th>\n";
  111. 				help += "\t<th>Description</th>\n";
  112. 				help += "\t<th>Mandatory</th>\n";
  113. 				help += "\t<th>Read-Only</th>\n";
  114. 				help += "\t<th>Default (Allowed) Values</th>\n";
  115. 				help += "</tr>\n";
  116. 			}
  117. 			else
  118. 			{
  119. 				col1width = 16;
  120. 				col2width = 50;
  121. 				col3width = 9;
  122. 				col4width = 9;
  123. 				col5width = 44;
  124.  
  125. 				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";
  126. 				linetemplate = "\u2502 {0,-" + col1width.ToString( ) + "} \u2502 {1,-" + col2width.ToString( ) + "} \u2502 {2,-" + col3width.ToString( ) + "} \u2502 {3,-" + col4width.ToString( ) + "} \u2502 {4,-" + col5width.ToString( ) + "} \u2502\n";
  127.  
  128. 				help += "\u250C" + new string( '\u2500', 14 + col1width + col2width + col3width + col4width + col5width ) + "\u2510\n";
  129. 				help += "\u2502" + new string( ' ', 14 + col1width + col2width + col3width + col4width + col5width ) + "\u2502\n";
  130. 				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)" );
  131. 				help += "\u2502" + new string( ' ', 14 + col1width + col2width + col3width + col4width + col5width ) + "\u2502\n";
  132. 				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";
  133. 				help += string.Format( linetemplate, "Property Name", "Description", "Mandatory", "Read-Only", "Default (Allowed) Values" );
  134. 				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";
  135. 			}
  136.  
  137. 			help += HelpTableRow( linetemplate, "choosecharset", "Allow alternative character sets (0=false; 1=true)", "no", "no", "1: allow", html );
  138. 			help += separatorline;
  139.  
  140. 			help += HelpTableRow( linetemplate, "debuginfo", Global.Common.Help.debuginfo, "N/A", "YES", "", html );
  141. 			help += separatorline;
  142.  
  143. 			help += HelpTableRow( linetemplate, "errors", Global.Common.Help.errors, "N/A", "YES", "", html );
  144. 			help += separatorline;
  145.  
  146. 			help += HelpTableRow( linetemplate, "fixedpitchonly", Global.Common.Help.fixedpitchonly, "no", "no", "0: allow proportional fonts as well", html );
  147. 			help += separatorline;
  148.  
  149. 			help += HelpTableRow( linetemplate, "fontcharset", "Font character set used in dialog", "no", "no", defaultcharset.ToString( ), html );
  150. 			help += separatorline;
  151.  
  152. 			help += HelpTableRow( linetemplate, "fontcolorB", "Blue component of font color", "no", "no", "0", html );
  153. 			help += separatorline;
  154.  
  155. 			help += HelpTableRow( linetemplate, "fontcolorG", "Green component of font color", "no", "no", "0", html );
  156. 			help += separatorline;
  157.  
  158. 			help += HelpTableRow( linetemplate, "fontcolorname", "Name of font color", "no", "no", defaultcolor.Name, html );
  159. 			help += separatorline;
  160.  
  161. 			help += HelpTableRow( linetemplate, "fontcolorR", "Red component of font color", "no", "no", "0", html );
  162. 			help += separatorline;
  163.  
  164. 			help += HelpTableRow( linetemplate, "fontcolorRGB", "RGB values of font color", "no", "no", "0,0,0", html );
  165. 			help += separatorline;
  166.  
  167. 			help += HelpTableRow( linetemplate, "fontfamily", Global.Common.Help.fontfamily, "no", "no", defaultfontfamily.Name, html );
  168. 			help += separatorline;
  169.  
  170. 			help += HelpTableRow( linetemplate, "fontsize", Global.Common.Help.fontsize, "no", "no", string.Format( "{0} ({1}..{2})", defaultfontsize, minimumfontsize, maximumfontsize ), html );
  171. 			help += separatorline;
  172.  
  173. 			help += HelpTableRow( linetemplate, "fontstyle", "Font stylee used in dialog", "no", "no", "Regular (Bold, Italic, StrikeOut, UnderLine)", html );
  174. 			help += separatorline;
  175.  
  176. 			help += HelpTableRow( linetemplate, "maximumfontsize", "Maximum font size allowed in dialog", "no", "no", defaultmaxfontsize.ToString( ), html );
  177. 			help += separatorline;
  178.  
  179. 			help += HelpTableRow( linetemplate, "minimumfontsize", "Minimum font size allowed in dialog", "no", "no", defaultminfonstsize.ToString( ), html );
  180. 			help += separatorline;
  181.  
  182. 			help += HelpTableRow( linetemplate, "modal", Global.Common.Help.modal, "no", "no", "1: always on top", html );
  183. 			help += separatorline;
  184.  
  185. 			help += HelpTableRow( linetemplate, "scriptsonly", "Disable non-OEM & symbol fonts   (0=false; 1=true)", "no", "no", "0: allow all", html );
  186. 			help += separatorline;
  187.  
  188. 			help += HelpTableRow( linetemplate, "showcolor", "Allow color choice in dialog     (0=false; 1=true)\n(requires showeffects = 1)", "no", "no", "1: allow", html );
  189. 			help += separatorline;
  190.  
  191. 			help += HelpTableRow( linetemplate, "showeffects", "Allow underline, strikethrough   (0=false; 1=true)", "no", "no", "1: allow", html );
  192. 			help += separatorline;
  193.  
  194. 			help += HelpTableRow( linetemplate, "vectorfonts", "Allow vector fonts in the dialog (0=false; 1=true)", "no", "no", "1: allow", html );
  195. 			help += separatorline;
  196.  
  197. 			help += HelpTableRow( linetemplate, "Version", Global.Common.Help.version, "N/A", "YES", "", html );
  198.  
  199. 			if ( html == 1 )
  200. 			{
  201. 				help += "</table>\n\n\n";
  202. 			}
  203. 			else
  204. 			{
  205. 				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";
  206. 			}
  207.  
  208. 			#endregion Properties
  209.  
  210.  
  211. 			#region Methods
  212.  
  213. 			if ( html == 1 )
  214. 			{
  215. 				separatorline = string.Empty;
  216. 				linetemplate = "<tr>\n\t<td>{0}</td>\n\t<td>{1}</td>\n\t<td>{2}</td>\n</tr>\n";
  217.  
  218. 				help += "<table>\n";
  219. 				help += "<tr>\n";
  220. 				help += "\t<th colspan=\"3\">Methods</th>\n";
  221. 				help += "</tr>\n";
  222.  
  223. 				help += "<tr>\n";
  224. 				help += "\t<th>Method Name</th>\n";
  225. 				help += "\t<th>Description</th>\n";
  226. 				help += "\t<th>Requirements</th>\n";
  227. 				help += "</tr>\n";
  228. 			}
  229. 			else
  230. 			{
  231. 				col1width = 16;
  232. 				col2width = 74;
  233. 				col3width = 44;
  234.  
  235. 				separatorline = "\u251C" + new string( '\u2500', 2 + col1width ) + "\u253C" + new string( '\u2500', 2 + col2width ) + "\u253C" + new string( '\u2500', 2 + col3width ) + "\u2524\n";
  236. 				linetemplate = "\u2502 {0,-" + col1width.ToString( ) + "} \u2502 {1,-" + col2width.ToString( ) + "} \u2502 {2,-" + col3width.ToString( ) + "} \u2502\n";
  237.  
  238. 				help += "\u250C" + new string( '\u2500', 8 + col1width + col2width + col3width ) + "\u2510\n";
  239. 				help += "\u2502" + new string( ' ', 8 + col1width + col2width + col3width ) + "\u2502\n";
  240. 				help += string.Format( "\u2502 {0,-" + ( 6 + col1width + col2width + col3width ).ToString( ) + "} \u2502\n", "Methods" );
  241. 				help += "\u2502" + new string( ' ', 8 + col1width + col2width + col3width ) + "\u2502\n";
  242. 				help += "\u255E" + new string( '\u2550', 2 + col1width ) + "\u2564" + new string( '\u2550', 2 + col2width ) + "\u2564" + new string( '\u2550', 2 + col3width ) + "\u2561\n";
  243. 				help += string.Format( linetemplate, "Method Name", "Description", "Requirements" );
  244. 				help += "\u255E" + new string( '\u2550', 2 + col1width ) + "\u256A" + new string( '\u2550', 2 + col2width ) + "\u256A" + new string( '\u2550', 2 + col3width ) + "\u2561\n";
  245. 			}
  246.  
  247. 			help += HelpTableRow( linetemplate, "CheckUpdate", Global.Common.Help._checkupdate, "", html );
  248. 			help += separatorline;
  249.  
  250. 			help += HelpTableRow( linetemplate, "Credits", Global.Common.Help._credits, "", html );
  251. 			help += separatorline;
  252.  
  253. 			help += HelpTableRow( linetemplate, "Help", Global.Common.Help._help, "", html );
  254. 			help += separatorline;
  255.  
  256. 			help += HelpTableRow( linetemplate, "ListColors", "Returns a semicolon-separated list of all available color names", "", html );
  257. 			help += separatorline;
  258.  
  259. 			help += HelpTableRow( linetemplate, "ListFontCharSets", "Returns a semicolon-separated list of available font character sets", "", html );
  260. 			help += separatorline;
  261.  
  262. 			help += HelpTableRow( linetemplate, "ListProperties", Global.Common.Help._listproperties, "", html );
  263. 			help += separatorline;
  264.  
  265. 			help += HelpTableRow( linetemplate, "SampleCode", Global.Common.Help._samplecode, "", html );
  266. 			help += separatorline;
  267.  
  268. 			help += HelpTableRow( linetemplate, "Show", "Presents a font dialog based on the current property values, and if \"OK\" is clicked, saves the selected font properties in the \"fontfamily\", \"fontsize\", \"fontstyle\", \"fontcharset\", \"fontcolorname\", \"fontcolorRGB\", \"fontcolorR\", \"fontcolorG\" and  \"fontcolorB\" properties (if \"Cancel\" is clicked, the default font and properties are selected).", "", html );
  269.  
  270. 			if ( html == 1 )
  271. 			{
  272. 				help += "</table>\n\n\n";
  273. 			}
  274. 			else
  275. 			{
  276. 				help += "\u2514" + new string( '\u2500', 2 + col1width ) + "\u2534" + new string( '\u2500', 2 + col2width ) + "\u2534" + new string( '\u2500', 2 + col3width ) + "\u2518\n\n\n";
  277. 			}
  278.  
  279. 			#endregion Methods
  280.  
  281.  
  282. 			#region Example
  283.  
  284. 			if ( html == 1 )
  285. 			{
  286. 				help += "<h2>VBScript usage example:</h2>\n\n<pre>";
  287. 			}
  288. 			else
  289. 			{
  290. 				help += "VBScript usage example:\n";
  291. 				help += new string( '\u2500', 23 ) + "\n\n";
  292. 			}
  293.  
  294. 			help += SampleCode( );
  295.  
  296. 			if ( html == 1 )
  297. 			{
  298. 				help += "</pre>";
  299. 			}
  300.  
  301. 			help += "\n\n";
  302.  
  303. 			#endregion Example
  304.  
  305.  
  306. 			help = help.Replace( "\n", System.Environment.NewLine );
  307. 			return help;
  308. 		}
  309.  
  310.  
  311. 		private string HelpTableRow( string template, string col1text, string col2text, string col3text, int html )
  312. 		{
  313. 			if ( html == 1 )
  314. 			{
  315. 				return Global.Common.Help.HelpTableRowHTML( col1text, col2text, col3text );
  316. 			}
  317. 			else
  318. 			{
  319. 				return Global.Common.Help.HelpTableRowText( template, col1text, col2text, col3text, "", "" );
  320. 			}
  321. 		}
  322.  
  323.  
  324. 		private string HelpTableRow( string template, string col1text, string col2text, string col3text, string col4text, string col5text, int html )
  325. 		{
  326. 			if ( html == 1 )
  327. 			{
  328. 				return Global.Common.Help.HelpTableRowHTML( col1text, col2text, col3text, col4text, col5text );
  329. 			}
  330. 			else
  331. 			{
  332. 				return Global.Common.Help.HelpTableRowText( template, col1text, col2text, col3text, col4text, col5text );
  333. 			}
  334. 		}
  335.  
  336.  
  337. 		public string ListColors( )
  338. 		{
  339. 			return string.Join( ";", System.Enum.GetNames( typeof( System.Drawing.Color ) ) );
  340. 		}
  341.  
  342.  
  343. 		public string ListFontCharSets( )
  344. 		{
  345. 			return string.Join( ";", System.Enum.GetNames( typeof( FontCharSet ) ) );
  346. 		}
  347.  
  348.  
  349. 		public string ListProperties( )
  350. 		{
  351. 			return Global.Common.Lists.Properties( this );
  352. 		}
  353.  
  354.  
  355. 		public string SampleCode( )
  356. 		{
  357. 			string code = "Set objFontSelectBox = CreateObject( \"RobvanderWoude.FontSelectBox\" )\n\n";
  358. 			code += "With objFontSelectBox\n";
  359. 			code += "\t.Show\n";
  360. 			code += "\tWScript.Echo .ListProperties( )\n";
  361. 			code += "End With\n\n";
  362. 			code += "Set objFontSelectBox = Nothing";
  363. 			return code;
  364. 		}
  365.  
  366.  
  367. 		public void Show( )
  368. 		{
  369. 			System.Drawing.Font font = new System.Drawing.Font( fontfamily, fontsize );
  370.  
  371. 			System.Windows.Forms.FontDialog fontdialog = null;
  372. 			try
  373. 			{
  374. 				fontdialog = new System.Windows.Forms.FontDialog
  375. 				{
  376. 					AllowScriptChange = _choosecharset,
  377. 					AllowVectorFonts = _vectorfonts,
  378. 					AllowVerticalFonts = false,
  379. 					FixedPitchOnly = _fixedpitchonly,
  380. 					Font = font,
  381. 					FontMustExist = true,
  382. 					MaxSize = maximumfontsize,
  383. 					MinSize = minimumfontsize,
  384. 					ScriptsOnly = _scriptsonly,
  385. 					ShowApply = false,
  386. 					ShowColor = _showcolor,
  387. 					ShowEffects = _showeffects
  388. 				};
  389. 			}
  390. 			catch ( System.Exception e )
  391. 			{
  392. 				_errors.Add( Global.Common.TimeStamp( ) + "Error while trying to build Font Dialog: " + e.Message );
  393. 			}
  394.  
  395. 			try
  396. 			{
  397. 				if ( fontdialog.ShowDialog( ) == System.Windows.Forms.DialogResult.OK )
  398. 				{
  399. 					System.Drawing.Font selectedfont = fontdialog.Font;
  400. 					_fontcharset = (FontCharSet) fontdialog.Font.GdiCharSet;
  401. 					_fontcolor = fontdialog.Color;
  402. 					_fontfamily = selectedfont.FontFamily;
  403. 					_fontsize = selectedfont.Size;
  404. 					_fontstyle = selectedfont.Style;
  405. 				}
  406. 				else
  407. 				{
  408. 					_fontcharset = defaultcharset;
  409. 					_fontcolor = defaultcolor;
  410. 					_fontfamily = defaultfontfamily;
  411. 					_fontsize = defaultfontsize;
  412. 					_fontstyle = defaultfontstyle;
  413. 					_debuginfo.Add( timestamp + "No choice was made, using default font and properties" );
  414. 				}
  415. 			}
  416. 			catch ( System.Exception e )
  417. 			{
  418. 				_errors.Add( Global.Common.TimeStamp( ) + "Error while trying to show Font Dialog and parse the results: " + e.Message );
  419. 			}
  420. 		}
  421.  
  422. 		#endregion Methods
  423.  
  424.  
  425. 		#region Properties
  426.  
  427. 		private bool _choosecharset = true;
  428. 		[System.Runtime.InteropServices.ComVisible( true )]
  429. 		public int choosecharset
  430. 		{
  431. 			get
  432. 			{
  433. 				return ( _choosecharset ? 1 : 0 );
  434. 			}
  435. 			set
  436. 			{
  437. 				_choosecharset = ( value == 1 );
  438. 			}
  439. 		}
  440.  
  441.  
  442. 		private System.Collections.Generic.List<string> _debuginfo = new System.Collections.Generic.List<string>( );
  443. 		[System.Runtime.InteropServices.ComVisible( true )]
  444. 		public string debuginfo
  445. 		{
  446. 			get
  447. 			{
  448. 				return string.Join( "\n", _debuginfo.ToArray( ) );
  449. 			}
  450. 		}
  451.  
  452.  
  453. 		private System.Collections.Generic.List<string> _errors = new System.Collections.Generic.List<string>( );
  454. 		[System.Runtime.InteropServices.ComVisible( true )]
  455. 		public string errors
  456. 		{
  457. 			get
  458. 			{
  459. 				return string.Join( "\n", _errors.ToArray( ) );
  460. 			}
  461. 		}
  462.  
  463.  
  464. 		private bool _fixedpitchonly = false;
  465. 		[System.Runtime.InteropServices.ComVisible( true )]
  466. 		public int fixedpitchonly
  467. 		{
  468. 			get
  469. 			{
  470. 				return ( _fixedpitchonly ? 1 : 0 );
  471. 			}
  472. 			set
  473. 			{
  474. 				_fixedpitchonly = ( value == 1 );
  475. 			}
  476. 		}
  477.  
  478.  
  479. 		private static FontCharSet _fontcharset = defaultcharset;
  480. 		[System.Runtime.InteropServices.ComVisible( true )]
  481. 		public string fontcharset
  482. 		{
  483. 			get
  484. 			{
  485. 				return _fontcharset.ToString( );
  486. 			}
  487. 			set
  488. 			{
  489. 				_fontcharset = Global.Common.Validate.FontCharSet( value );
  490. 			}
  491. 		}
  492.  
  493.  
  494. 		private static System.Drawing.Color _fontcolor = defaultcolor;
  495. 		[System.Runtime.InteropServices.ComVisible( true )]
  496. 		public int fontcolorB
  497. 		{
  498. 			get
  499. 			{
  500. 				return (int) _fontcolor.B;
  501. 			}
  502. 			set
  503. 			{
  504. 				System.Array colorsarray = System.Enum.GetValues( typeof( System.Drawing.Color ) );
  505. 				System.Collections.Generic.List<System.Drawing.Color> colorslist = colorsarray.OfType<System.Drawing.Color>( ).ToList<System.Drawing.Color>( );
  506. 				_fontcolor = colorslist.Where( c => ( c.R.Equals( _fontcolor.R ) && c.G.Equals( _fontcolor.G ) && c.B.Equals( value.LimitToRange( 0, 255 ) ) ) ).First( );
  507. 			}
  508. 		}
  509. 		[System.Runtime.InteropServices.ComVisible( true )]
  510. 		public int fontcolorG
  511. 		{
  512. 			get
  513. 			{
  514. 				return (int) _fontcolor.G;
  515. 			}
  516. 			set
  517. 			{
  518. 				System.Array colorsarray = System.Enum.GetValues( typeof( System.Drawing.Color ) );
  519. 				System.Collections.Generic.List<System.Drawing.Color> colorslist = colorsarray.OfType<System.Drawing.Color>( ).ToList<System.Drawing.Color>( );
  520. 				_fontcolor = colorslist.Where( c => ( c.R.Equals( _fontcolor.R ) && c.G.Equals( value.LimitToRange( 0, 255 ) ) && c.B.Equals( _fontcolor.B ) ) ).First( );
  521. 			}
  522. 		}
  523. 		[System.Runtime.InteropServices.ComVisible( true )]
  524. 		public string fontcolorname
  525. 		{
  526. 			get
  527. 			{
  528. 				return _fontcolor.Name;
  529. 			}
  530. 			set
  531. 			{
  532. 				_fontcolor = Global.Common.Validate.ColorName( value, defaultcolor );
  533. 			}
  534. 		}
  535. 		[System.Runtime.InteropServices.ComVisible( true )]
  536. 		public int fontcolorR
  537. 		{
  538. 			get
  539. 			{
  540. 				return (int) _fontcolor.R;
  541. 			}
  542. 			set
  543. 			{
  544. 				System.Array colorsarray = System.Enum.GetValues( typeof( System.Drawing.Color ) );
  545. 				System.Collections.Generic.List<System.Drawing.Color> colorslist = colorsarray.OfType<System.Drawing.Color>( ).ToList<System.Drawing.Color>( );
  546. 				_fontcolor = colorslist.Where( c => ( c.R.Equals( value.LimitToRange( 0, 255 ) ) && c.G.Equals( _fontcolor.G ) && c.B.Equals( _fontcolor.B ) ) ).First( );
  547. 			}
  548. 		}
  549. 		[System.Runtime.InteropServices.ComVisible( true )]
  550. 		public string fontcolorRGB
  551. 		{
  552. 			get
  553. 			{
  554. 				return string.Format( "{0},{1},{2}", fontcolorR, fontcolorG, fontcolorB );
  555. 			}
  556. 			set
  557. 			{
  558. 				_fontcolor = Global.Common.Validate.ColorRGB( fontcolorRGB, defaultcolor );
  559. 			}
  560. 		}
  561.  
  562.  
  563. 		private static System.Drawing.FontFamily _fontfamily = defaultfontfamily;
  564. 		[System.Runtime.InteropServices.ComVisible( true )]
  565. 		public string fontfamily
  566. 		{
  567. 			get
  568. 			{
  569. 				return _fontfamily.Name;
  570. 			}
  571. 			set
  572. 			{
  573. 				_fontfamily = Global.Common.Validate.FontFamily( value, defaultfontfamily );
  574. 			}
  575. 		}
  576.  
  577.  
  578. 		private static float _fontsize = defaultfontsize;
  579. 		[System.Runtime.InteropServices.ComVisible( true )]
  580. 		public int fontsize
  581. 		{
  582. 			get
  583. 			{
  584. 				return System.Convert.ToInt32( _fontsize );
  585. 			}
  586. 			set
  587. 			{
  588. 				_fontsize = System.Convert.ToSingle( value.LimitToRange( minimumfontsize, maximumfontsize ) );
  589. 			}
  590. 		}
  591.  
  592.  
  593. 		private static System.Drawing.FontStyle _fontstyle = defaultfontstyle;
  594. 		[System.Runtime.InteropServices.ComVisible( true )]
  595. 		public string fontstyle
  596. 		{
  597. 			get
  598. 			{
  599. 				return _fontstyle.ToString( );
  600. 			}
  601. 			set
  602. 			{
  603. 				_fontstyle = Global.Common.Validate.FontStyle( value );
  604. 			}
  605. 		}
  606.  
  607.  
  608. 		private float _maximumfontsize = defaultmaxfontsize;
  609. 		[System.Runtime.InteropServices.ComVisible( true )]
  610. 		public int maximumfontsize
  611. 		{
  612. 			get
  613. 			{
  614. 				return System.Convert.ToInt32( _maximumfontsize );
  615. 			}
  616. 			set
  617. 			{
  618. 				_maximumfontsize = System.Convert.ToSingle( value );
  619. 			}
  620. 		}
  621.  
  622.  
  623. 		private float _minimumfontsize = defaultminfonstsize;
  624. 		[System.Runtime.InteropServices.ComVisible( true )]
  625. 		public int minimumfontsize
  626. 		{
  627. 			get
  628. 			{
  629. 				return System.Convert.ToInt32( _minimumfontsize );
  630. 			}
  631. 			set
  632. 			{
  633. 				_minimumfontsize = System.Convert.ToSingle( value );
  634. 			}
  635. 		}
  636.  
  637.  
  638. 		private bool topmost = true;
  639. 		[System.Runtime.InteropServices.ComVisible( true )]
  640. 		public int modal
  641. 		{
  642. 			get
  643. 			{
  644. 				return ( topmost ? 1 : 0 );
  645. 			}
  646. 			set
  647. 			{
  648. 				topmost = ( value == 1 );
  649. 			}
  650. 		}
  651.  
  652.  
  653. 		private bool _scriptsonly = false;
  654. 		[System.Runtime.InteropServices.ComVisible( true )]
  655. 		public int scriptsonly
  656. 		{
  657. 			get
  658. 			{
  659. 				return ( _scriptsonly ? 1 : 0 );
  660. 			}
  661. 			set
  662. 			{
  663. 				_scriptsonly = ( value == 1 );
  664. 			}
  665. 		}
  666.  
  667.  
  668. 		private bool _showcolor = true;
  669. 		[System.Runtime.InteropServices.ComVisible( true )]
  670. 		public int showcolor
  671. 		{
  672. 			get
  673. 			{
  674. 				return ( _showcolor ? 1 : 0 );
  675. 			}
  676. 			set
  677. 			{
  678. 				_showcolor = ( value == 1 );
  679. 			}
  680. 		}
  681.  
  682.  
  683. 		private bool _showeffects = true;
  684. 		[System.Runtime.InteropServices.ComVisible( true )]
  685. 		public int showeffects
  686. 		{
  687. 			get
  688. 			{
  689. 				return ( _showeffects ? 1 : 0 );
  690. 			}
  691. 			set
  692. 			{
  693. 				_showeffects = ( value == 1 );
  694. 			}
  695. 		}
  696.  
  697.  
  698. 		public static string timestamp => Global.Common.TimeStamp( );
  699.  
  700.  
  701. 		private bool _vectorfonts = true;
  702. 		[System.Runtime.InteropServices.ComVisible( true )]
  703. 		public int vectorfonts
  704. 		{
  705. 			get
  706. 			{
  707. 				return ( _vectorfonts ? 1 : 0 );
  708. 			}
  709. 			set
  710. 			{
  711. 				_vectorfonts = ( value == 1 );
  712. 			}
  713. 		}
  714.  
  715.  
  716. 		[System.Runtime.InteropServices.ComVisible( true )]
  717. 		public string Version
  718. 		{
  719. 			get
  720. 			{
  721. 				return Global.Common.ProgramInfo.FileVersion;
  722. 			}
  723. 		}
  724.  
  725. 		#endregion Properties
  726. 	}
  727. }

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