(view source code of dialogboxes_colorselectbox.cs as plain text)
using System.Linq;
namespace RobvanderWoude
{
[System.Runtime.InteropServices.Guid( "ACCB429D-7E28-4D60-8B80-44CCE5E7D966" )]
public interface ColorSelectBox_Interface
{
[System.Runtime.InteropServices.DispId( 1 )]
void CheckUpdate( );
[System.Runtime.InteropServices.DispId( 2 )]
string Credits( );
[System.Runtime.InteropServices.DispId( 3 )]
string Help( int html = 0 );
[System.Runtime.InteropServices.DispId( 4 )]
string ListConsoleColors( );
[System.Runtime.InteropServices.DispId( 5 )]
string ListKnownColors( );
[System.Runtime.InteropServices.DispId( 6 )]
string ListProperties( );
[System.Runtime.InteropServices.DispId( 7 )]
string SampleCode( );
[System.Runtime.InteropServices.DispId( 8 )]
void Show( );
}
[System.Runtime.InteropServices.Guid( "0896FD0D-B25E-45DF-898C-7FA60C84C06D" ), System.Runtime.InteropServices.InterfaceType( System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIDispatch )]
public interface ColorSelectBox_Events
{
}
[System.Runtime.InteropServices.Guid( "AA6AA980-FDE6-4233-95FD-A4A4A4F3B691" ), System.Runtime.InteropServices.ClassInterface( System.Runtime.InteropServices.ClassInterfaceType.AutoDual ), System.Runtime.InteropServices.ComSourceInterfaces( typeof( ColorSelectBox_Events ) )]
public class ColorSelectBox : ColorSelectBox_Interface
{
#region Default values
static readonly System.Drawing.Color defaultcolor = System.Drawing.Color.Black;
static string defaulttitle = "Pick a Console Color";
#endregion Default values
#region Controls
static System.Windows.Forms.Form colordialog;
static System.Drawing.Size dialogsize = new System.Drawing.Size( 230, 110 );
static System.Timers.Timer timer;
#endregion Controls
#region Methods
public void CheckUpdate( )
{
Global.Common.ProgramInfo.CheckUpdate( );
}
static int[] Color2RGB( int color )
{
int red = System.Convert.ToInt32( System.Math.Floor( ( (decimal) color ) / 65536 ) );
int green = System.Convert.ToInt32( System.Math.Floor( ( ( (decimal) color ) - red * 65536 ) / 256 ) );
int blue = color - red * 65536 - green * 256;
return new int[3] { red, green, blue };
}
static string ColorName( System.Drawing.Color color, bool returnallnames = false )
{
System.Collections.Generic.List<string> list;
if ( _consolecolorsonly )
{
list = Global.Common.Lists.ConsoleColors( );
}
else
{
list = Global.Common.Lists.KnownColors( );
}
uint rgb = (uint) color.ToArgb( ) % 0x01000000;
System.Globalization.NumberStyles hex = System.Globalization.NumberStyles.HexNumber;
var queryobject = list.Where( c => uint.Parse( c.Split( '=' )[1].Split( "xX".ToCharArray( ) )[1], hex ).Equals( rgb ) );
if ( queryobject.Count( ) == 0 )
{
return color.Name;
}
else
{
if ( returnallnames )
{
return string.Join( ";", queryobject.Select( c => c.Split( '=' )[0] ).ToArray( ) );
}
else
{
return queryobject.First( ).Split( '=' )[0];
}
}
}
public string Credits( )
{
return Global.Common.Credits( );
}
static void GetSelectedColor( )
{
foreach ( System.Windows.Forms.Control colorbox in colordialog.Controls )
{
if ( colorbox.GetType( ) == typeof( System.Windows.Forms.TextBox ) )
{
// If the box has focus, it is the one that was clicked
if ( colorbox.Focused )
{
_selectedcolor = colorbox.BackColor;
colordialog.Close( );
}
}
}
}
public string Help( int html = 0 )
{
int col1width = 0;
int col2width = 0;
int col3width = 0;
int col4width = 0;
int col5width = 0;
string help = string.Empty;
string linetemplate = string.Empty;
string separatorline = string.Empty;
if ( html == 1 )
{
help += "<h1>Help for ColorSelectBox class</h1>\n\n";
help += "<p>Present a color picker dialog, and return the selected color</p>\n\n";
help += "<h2>COM ProgID: RobvanderWoude.ColorSelectBox</h2>\n\n";
}
else
{
help += "Help for ColorSelectBox class\n";
help += new string( '\u2500', help.Length ) + "\n\n";
help += "Present a color picker dialog, and return the selected color\n\n\n";
help += "COM ProgID: RobvanderWoude.ColorSelectBox\n\n\n";
}
#region Properties
if ( html == 1 )
{
separatorline = string.Empty;
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";
help += "<table>\n";
help += "<tr>\n";
help += "\t<th colspan=\"5\">Properties (Note that all properties are string or integer, no booleans, objects or arrays)</th>\n";
help += "</tr>\n";
help += "<tr>\n";
help += "\t<th>Property Name</th>\n";
help += "\t<th>Description</th>\n";
help += "\t<th>Mandatory</th>\n";
help += "\t<th>Read-Only</th>\n";
help += "\t<th>Default (Allowed) Values</th>\n";
help += "</tr>\n";
}
else
{
col1width = 18;
col2width = 50;
col3width = 9;
col4width = 9;
col5width = 42;
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";
linetemplate = "\u2502 {0,-" + col1width.ToString( ) + "} \u2502 {1,-" + col2width.ToString( ) + "} \u2502 {2,-" + col3width.ToString( ) + "} \u2502 {3,-" + col4width.ToString( ) + "} \u2502 {4,-" + col5width.ToString( ) + "} \u2502\n";
help += "\u250C" + new string( '\u2500', 14 + col1width + col2width + col3width + col4width + col5width ) + "\u2510\n";
help += "\u2502" + new string( ' ', 14 + col1width + col2width + col3width + col4width + col5width ) + "\u2502\n";
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)" );
help += "\u2502" + new string( ' ', 14 + col1width + col2width + col3width + col4width + col5width ) + "\u2502\n";
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";
help += string.Format( linetemplate, "Property Name", "Description", "Mandatory", "Read-Only", "Default (Allowed) Values" );
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";
}
help += HelpTableRow( linetemplate, "allnames", "Return a semi-colon list of all names matching the selected RGB value, instead of the first match only (0=false; 1=true)", "no", "no", "0", html );
help += separatorline;
help += HelpTableRow( linetemplate, "allowcustomcolors", "Enable custom colors in dialog (0=false; 1=true)\n(ignored if consolecolorsonly equals 1)", "no", "no", "1: allow", html );
help += separatorline;
help += HelpTableRow( linetemplate, "consolecolorsonly", "Standard 16 console colors only (0=false; 1=true)", "no", "no", "1", html );
help += separatorline;
help += HelpTableRow( linetemplate, "debuginfo", Global.Common.Help.debuginfo, "N/A", "YES", "", html );
help += separatorline;
help += HelpTableRow( linetemplate, "errors", Global.Common.Help.errors, "N/A", "YES", "", html );
help += separatorline;
help += HelpTableRow( linetemplate, "left", Global.Common.Help.left + "\n(ignored if consolecolorsonly equals 0)", "no", "no", "Centered (0..screenwidth - dialogwidth)", html );
help += separatorline;
help += HelpTableRow( linetemplate, "modal", Global.Common.Help.modal + "\n(ignored if consolecolorsonly equals 0)", "no", "no", "1: always on top", html );
help += separatorline;
help += HelpTableRow( linetemplate, "selectedcolorB", "Blue component of selected color", "no", "no", "0 (0..255)", html );
help += separatorline;
help += HelpTableRow( linetemplate, "selectedcolorG", "Green component of selected color", "no", "no", "0 (0..255)", html );
help += separatorline;
help += HelpTableRow( linetemplate, "selectedcolorname", "Name of selected color", "no", "no", defaultcolor.Name, html );
help += separatorline;
help += HelpTableRow( linetemplate, "selectedcolorR", "Red component of selected color", "no", "no", "0 (0..255)", html );
help += separatorline;
help += HelpTableRow( linetemplate, "selectedcolorRGB", "RGB values of selected color", "no", "no", "0,0,0", html );
help += separatorline;
help += HelpTableRow( linetemplate, "timeout", Global.Common.Help.timeout + "\n(ignored if consolecolorsonly equals 0)", "no", "no", "0: no timeout", html );
help += separatorline;
help += HelpTableRow( linetemplate, "timeoutelapsed", Global.Common.Help.timeoutelapsed, "N/A", "YES", "", html );
help += separatorline;
help += HelpTableRow( linetemplate, "title", Global.Common.Help.title + "\n(ignored if consolecolorsonly equals 0)", "no", "no", defaulttitle, html );
help += separatorline;
help += HelpTableRow( linetemplate, "top", Global.Common.Help.top + "\n(ignored if consolecolorsonly equals 0)", "no", "no", "Centered (0..screenheight - dialogheight)", html );
if ( html == 1 )
{
help += "</table>\n\n\n";
}
else
{
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";
}
#endregion Properties
#region Methods
if ( html == 1 )
{
separatorline = string.Empty;
linetemplate = "<tr>\n\t<td>{0}</td>\n\t<td>{1}</td>\n\t<td>{2}</td>\n</tr>\n";
help += "<table>\n";
help += "<tr>\n";
help += "\t<th colspan=\"3\">Methods</th>\n";
help += "</tr>\n";
help += "<tr>\n";
help += "\t<th>Method Name</th>\n";
help += "\t<th>Description</th>\n";
help += "\t<th>Requirements</th>\n";
help += "</tr>\n";
}
else
{
col1width = 18;
col2width = 74;
col3width = 42;
separatorline = "\u251C" + new string( '\u2500', 2 + col1width ) + "\u253C" + new string( '\u2500', 2 + col2width ) + "\u253C" + new string( '\u2500', 2 + col3width ) + "\u2524\n";
linetemplate = "\u2502 {0,-" + col1width.ToString( ) + "} \u2502 {1,-" + col2width.ToString( ) + "} \u2502 {2,-" + col3width.ToString( ) + "} \u2502\n";
help += "\u250C" + new string( '\u2500', 8 + col1width + col2width + col3width ) + "\u2510\n";
help += "\u2502" + new string( ' ', 8 + col1width + col2width + col3width ) + "\u2502\n";
help += string.Format( "\u2502 {0,-" + ( 6 + col1width + col2width + col3width ).ToString( ) + "} \u2502\n", "Methods" );
help += "\u2502" + new string( ' ', 8 + col1width + col2width + col3width ) + "\u2502\n";
help += "\u255E" + new string( '\u2550', 2 + col1width ) + "\u2564" + new string( '\u2550', 2 + col2width ) + "\u2564" + new string( '\u2550', 2 + col3width ) + "\u2561\n";
help += string.Format( linetemplate, "Method Name", "Description", "Requirements" );
help += "\u255E" + new string( '\u2550', 2 + col1width ) + "\u256A" + new string( '\u2550', 2 + col2width ) + "\u256A" + new string( '\u2550', 2 + col3width ) + "\u2561\n";
}
help += HelpTableRow( linetemplate, "CheckUpdate", Global.Common.Help._checkupdate, "", html );
help += separatorline;
help += HelpTableRow( linetemplate, "Credits", Global.Common.Help._credits, "", html );
help += separatorline;
help += HelpTableRow( linetemplate, "Help", Global.Common.Help._help, "", html );
help += separatorline;
help += HelpTableRow( linetemplate, "ListConSoleColors", "Returns a semicolon-separated list of console color name=value pairs", "", html );
help += separatorline;
help += HelpTableRow( linetemplate, "ListKnownColors", "Returns a semicolon-separated list of known color name=value pairs", "", html );
help += separatorline;
help += HelpTableRow( linetemplate, "ListProperties", Global.Common.Help._listproperties, "", html );
help += separatorline;
help += HelpTableRow( linetemplate, "SampleCode", Global.Common.Help._samplecode, "", html );
help += separatorline;
help += HelpTableRow( linetemplate, "Show", "Presents a color picker dialog based on the current property values, and if \"OK\" is clicked, saves the selected color name in the \"selectedcolorname\" property, and the RGB color values in the \"selectedcolorRGB\", \"selectedcolorR\", \"selectedcolorG\" and selectedcolorB\" properties (if \"Cancel\" is clicked, the values for the default color Black are returned).", "", html );
if ( html == 1 )
{
help += "</table>\n\n\n";
}
else
{
help += "\u2514" + new string( '\u2500', 2 + col1width ) + "\u2534" + new string( '\u2500', 2 + col2width ) + "\u2534" + new string( '\u2500', 2 + col3width ) + "\u2518\n\n\n";
}
#endregion Methods
#region Notes
if ( html == 1 )
{
help += "<table>\n<tr>\n\t<th>";
}
help += "Notes:";
if ( html == 1 )
{
help += "</th>\n\t<td>";
}
else
{
help += "\n\t";
}
help += "ColorSelectBox actually uses 2 different color picker dialogs:";
if ( html == 1 )
{
help += "<br />\n\t\t";
}
else
{
help += "\n\t";
}
help += "if \"consolecolorsonly\" equals 0 (false), Windows' native color dialog is used, and you have a choice to allow custom colors or not;";
if ( html == 1 )
{
help += "<br />\n\t\t";
}
else
{
help += "\n\t";
}
help += "if \"consolecolorsonly\" equals 1 (true), a custom, minimalistic dialog is used, with only the 16 standard console colors and nothing";
if ( html == 1 )
{
help += " ";
}
else
{
help += "\n\t";
}
help += "else, not even \"OK\" and \"Cancel\" buttons, but it does come with a timeout option.";
if ( html == 1 )
{
help += "</td>\n</tr>\n</table>";
}
help += "\n\n\n";
#endregion Notes
#region Example
if ( html == 1 )
{
help += "<h2>VBScript usage example:</h2>\n\n<pre>";
}
else
{
help += "VBScript usage example:\n";
help += new string( '\u2500', 23 ) + "\n\n";
}
help += SampleCode( );
if ( html == 1 )
{
help += "</pre>";
}
help += "\n\n";
#endregion Example
help = help.Replace( "\n", System.Environment.NewLine );
return help;
}
private string HelpTableRow( string template, string col1text, string col2text, string col3text, int html )
{
if ( html == 1 )
{
return Global.Common.Help.HelpTableRowHTML( col1text, col2text, col3text );
}
else
{
return Global.Common.Help.HelpTableRowText( template, col1text, col2text, col3text, "", "" );
}
}
private string HelpTableRow( string template, string col1text, string col2text, string col3text, string col4text, string col5text, int html )
{
if ( html == 1 )
{
return Global.Common.Help.HelpTableRowHTML( col1text, col2text, col3text, col4text, col5text );
}
else
{
return Global.Common.Help.HelpTableRowText( template, col1text, col2text, col3text, col4text, col5text );
}
}
public string ListConsoleColors( )
{
return string.Join( ";", Global.Common.Lists.ConsoleColors( ) );
}
public string ListKnownColors( )
{
return string.Join( ";", Global.Common.Lists.KnownColors( ) );
}
public string ListProperties( )
{
return Global.Common.Lists.Properties( this );
}
public string SampleCode( )
{
string code = "Set objColorSelectBox = CreateObject( \"RobvanderWoude.ColorSelectBox\" )\n\n";
code += "With objColorSelectBox\n";
code += "\t.allowcustomcolors = 1\n";
code += "\t.consolecolorsonly = 0\n";
code += "\t.Show\n";
code += "\tWScript.Echo .ListProperties( )\n";
code += "\tWScript.Echo\n";
code += "\t.consolecolorsonly = 1\n";
code += "\t.Show\n";
code += "\tWScript.Echo .ListProperties( )\n";
code += "End With\n\n";
code += "Set objColorSelectBox = Nothing";
return code;
}
public void Show( )
{
_debuginfo.Add( timestamp + "consolecolorsonly = " + consolecolorsonly );
_debuginfo.Add( timestamp + "_consolecolorsonly = " + _consolecolorsonly );
if ( _consolecolorsonly )
{
_debuginfo.Add( timestamp + "Starting ShowConsoleColorsOnly( )" );
ShowConsoleColorsOnly( );
}
else
{
_debuginfo.Add( timestamp + "Starting ShowAllColors( )" );
ShowAllColors( );
}
}
private void ShowAllColors( )
{
System.Windows.Forms.ColorDialog allcolordialog = new System.Windows.Forms.ColorDialog
{
AllowFullOpen = _allowcustomcolors,
AnyColor = true,
FullOpen = false,
SolidColorOnly = !_allowcustomcolors
};
System.Windows.Forms.DialogResult result = allcolordialog.ShowDialog( );
_debuginfo.Add( timestamp + "AllColors dialog button clicked: " + result.ToString( ) );
if ( result == System.Windows.Forms.DialogResult.OK )
{
_selectedcolor = allcolordialog.Color;
}
}
private void ShowConsoleColorsOnly( )
{
#region Timer
_timeoutelapsed = false;
if ( timeout > 0 )
{
timer = new System.Timers.Timer( );
timer.Elapsed += new System.Timers.ElapsedEventHandler( ConsoleColorSelectBox_Timer_Elapsed );
timer.Interval = timeout * 1000;
timer.Start( );
_debuginfo.Add( timestamp + "Timer started with interval " + timeout.ToString( ) );
}
#endregion Timer
// Define dialog window
colordialog = new System.Windows.Forms.Form( );
colordialog.KeyUp += ConsoleColorSelectBox_KeyUp;
colordialog.MaximizeBox = false;
colordialog.MinimizeBox = false;
colordialog.ShowInTaskbar = true;
colordialog.Size = new System.Drawing.Size( 230, 110 );
if ( top < 0 || left < 0 )
{
colordialog.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
}
else
{
colordialog.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
colordialog.Location = new System.Drawing.Point( left, top );
}
colordialog.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
colordialog.Text = title;
colordialog.TopMost = _modal;
int[] cols = new int[8];
int[] rows = new int[2];
// Fill dialog with color boxes
for ( int col = 0; col < cols.Length; col++ )
{
for ( int row = 0; row < rows.Length; row++ )
{
System.Windows.Forms.TextBox colorbox = new System.Windows.Forms.TextBox( );
colorbox.Size = new System.Drawing.Size( 20, 20 );
colorbox.Location = new System.Drawing.Point( 10 + col * 25, 10 + row * 30 );
int[] rgb = Color2RGB( Global.Common.consolecolors[8 * row + col] );
colorbox.BackColor = System.Drawing.Color.FromArgb( rgb[0], rgb[1], rgb[2] );
colorbox.Click += ConsoleColorSelectBox_Colorbox_Click;
colorbox.KeyUp += ConsoleColorSelectBox_KeyUp;
colordialog.Controls.Add( colorbox );
}
}
// Make sure the cursor won't be visible in one of the color boxes
colordialog.Select( );
// Show the dialog window
colordialog.ShowDialog( );
}
#endregion Methods
#region Properties
// Available only for customized colorpicker (_consolecolorsonly = true)
private bool _allnames = false;
[System.Runtime.InteropServices.ComVisible( true )]
public int allnames
{
get
{
return ( _allnames ? 1 : 0 );
}
set
{
_allnames = ( value == 1 );
}
}
// Available only for system colorpicker (_consolecolorsonly = false)
private bool _allowcustomcolors = true;
[System.Runtime.InteropServices.ComVisible( true )]
public int allowcustomcolors
{
get
{
return ( _allowcustomcolors ? 1 : 0 );
}
set
{
_allowcustomcolors = ( value == 1 );
}
}
// Choose between system colopicker (false) or customized one (true)
private static bool _consolecolorsonly = true;
[System.Runtime.InteropServices.ComVisible( true )]
public int consolecolorsonly
{
get
{
return ( _consolecolorsonly ? 1 : 0 );
}
set
{
_consolecolorsonly = ( value == 1 );
}
}
private System.Collections.Generic.List<string> _debuginfo = new System.Collections.Generic.List<string>( );
[System.Runtime.InteropServices.ComVisible( true )]
public string debuginfo
{
get
{
return string.Join( "\n", _debuginfo.ToArray( ) );
}
}
private System.Collections.Generic.List<string> _errors = new System.Collections.Generic.List<string>( );
[System.Runtime.InteropServices.ComVisible( true )]
public string errors
{
get
{
return string.Join( "\n", _errors.ToArray( ) );
}
}
// Available only for customized colorpicker (_consolecolorsonly = true)
private int _left = -1;
[System.Runtime.InteropServices.ComVisible( true )]
public int left
{
get
{
return _left;
}
set
{
if ( value < 0 )
{
_left = 0;
}
else if ( value > System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width - dialogsize.Width )
{
_left = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width - dialogsize.Width;
}
else
{
_left = value;
}
}
}
// Available only for customized colorpicker (_consolecolorsonly = true)
private bool _modal = true;
[System.Runtime.InteropServices.ComVisible( true )]
public int modal
{
get
{
return ( _modal ? 1 : 0 );
}
set
{
_modal = ( value == 1 );
}
}
private static System.Drawing.Color _selectedcolor = defaultcolor;
[System.Runtime.InteropServices.ComVisible( true )]
public string selectedcolorname
{
get
{
return ColorName( _selectedcolor, _allnames );
/*
System.Collections.Generic.List<string> list;
if ( _consolecolorsonly )
{
list = Global.Common.Lists.ConsoleColors( );
}
else
{
list = Global.Common.Lists.KnownColors( );
}
uint rgb = (uint) _selectedcolor.ToArgb( ) % 0x01000000;
System.Globalization.NumberStyles hex = System.Globalization.NumberStyles.HexNumber;
var queryobject = list.Where( c => uint.Parse( c.Split( '=' )[1].Split( 'x' )[1], hex ).Equals( rgb ) );
if ( queryobject.Count( ) == 0 )
{
return _selectedcolor.Name;
}
else
{
string colorname = queryobject.First( ).Split( '=' )[0];
return colorname;
}
*/
}
}
[System.Runtime.InteropServices.ComVisible( true )]
public int selectedcolorB
{
get
{
return _selectedcolor.B;
}
}
[System.Runtime.InteropServices.ComVisible( true )]
public int selectedcolorG
{
get
{
return _selectedcolor.G;
}
}
[System.Runtime.InteropServices.ComVisible( true )]
public int selectedcolorR
{
get
{
return _selectedcolor.R;
}
}
[System.Runtime.InteropServices.ComVisible( true )]
public string selectedcolorRGB
{
get
{
return string.Format( "{0},{1},{2}", _selectedcolor.R, _selectedcolor.G, _selectedcolor.B );
}
}
// Available only for customized colorpicker (_consolecolorsonly = true)
private static int _timeout = 0;
[System.Runtime.InteropServices.ComVisible( true )]
public int timeout
{
get
{
return _timeout;
}
set
{
if ( value < 0 || value > 3600 )
{
_timeout = 0;
}
else
{
_timeout = value;
}
}
}
// Available only for customized colorpicker (_consolecolorsonly = true)
private bool _timeoutelapsed = false;
[System.Runtime.InteropServices.ComVisible( true )]
public int timeoutelapsed
{
get
{
return ( _timeoutelapsed ? 1 : 0 );
}
}
public static string timestamp => Global.Common.TimeStamp( );
// Available only for customized colorpicker (_consolecolorsonly = true)
private static string _title = defaulttitle;
[System.Runtime.InteropServices.ComVisible( true )]
public string title
{
get
{
return _title;
}
set
{
_title = value.Trim( );
}
}
// Available only for customized colorpicker (_consolecolorsonly = true)
private int _top = -1;
[System.Runtime.InteropServices.ComVisible( true )]
public int top
{
get
{
return _top;
}
set
{
if ( value < 0 )
{
_top = 0;
}
else if ( value > System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height - dialogsize.Height )
{
_top = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height - dialogsize.Height;
}
else
{
_top = value;
}
}
}
[System.Runtime.InteropServices.ComVisible( true )]
public string Version
{
get
{
return Global.Common.ProgramInfo.FileVersion;
}
}
#endregion Properties
#region Event handlers
private static void ConsoleColorSelectBox_Colorbox_Click( object sender, System.EventArgs e )
{
if ( _timeout > 0 )
{
timer.Stop( );
}
GetSelectedColor( );
}
private void ConsoleColorSelectBox_KeyUp( object sender, System.Windows.Forms.KeyEventArgs e )
{
if ( e.KeyCode == System.Windows.Forms.Keys.Enter )
{
GetSelectedColor( );
// In case no selected color was found
_selectedcolor = defaultcolor;
colordialog.Close( );
}
else if ( e.KeyCode == System.Windows.Forms.Keys.Escape )
{
_selectedcolor = defaultcolor;
colordialog.Close( );
}
}
private void ConsoleColorSelectBox_Timer_Elapsed( object sender, System.Timers.ElapsedEventArgs e )
{
_timeoutelapsed = true;
_selectedcolor = defaultcolor;
colordialog.Close( );
}
#endregion Event Handlers
}
}
page last modified: 2024-04-16; loaded in 0.0214 seconds