using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using AxSftBoxLib45;
using SftBoxLib45;
using Softelvdm.OLEConvert;
namespace ColorsSample
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button closeButton;
private System.Windows.Forms.Label label1;
private AxSftBoxLib45.AxSftBox SftBox1;
private AxSftBoxLib45.AxSftBox SftBox2;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private AxSftBoxLib45.AxSftBox SftBox3;
private Softelvdm.OCXHelper.SftHelperComponent sftHelperComponent1;
private System.ComponentModel.IContainer components;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.closeButton = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.SftBox1 = new AxSftBoxLib45.AxSftBox();
this.SftBox2 = new AxSftBoxLib45.AxSftBox();
this.SftBox3 = new AxSftBoxLib45.AxSftBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.sftHelperComponent1 = new Softelvdm.OCXHelper.SftHelperComponent(this.components);
((System.ComponentModel.ISupportInitialize)(this.SftBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.SftBox2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.SftBox3)).BeginInit();
this.SuspendLayout();
//
// closeButton
//
this.closeButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.closeButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.closeButton.Location = new System.Drawing.Point(292, 8);
this.closeButton.Name = "closeButton";
this.closeButton.Size = new System.Drawing.Size(73, 30);
this.closeButton.TabIndex = 0;
this.closeButton.Text = "Close";
this.closeButton.Click += new System.EventHandler(this.closeButton_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(7, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(220, 68);
this.label1.TabIndex = 1;
this.label1.Text = "This example shows how you can use SftBox/OCX to display a color selection. You " +
"can add any color to the control.";
//
// SftBox1
//
this.SftBox1.Location = new System.Drawing.Point(7, 76);
this.SftBox1.Name = "SftBox1";
this.SftBox1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("SftBox1.OcxState")));
this.SftBox1.Size = new System.Drawing.Size(220, 21);
this.SftBox1.TabIndex = 2;
//
// SftBox2
//
this.SftBox2.Location = new System.Drawing.Point(7, 121);
this.SftBox2.Name = "SftBox2";
this.SftBox2.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("SftBox2.OcxState")));
this.SftBox2.Size = new System.Drawing.Size(220, 21);
this.SftBox2.TabIndex = 3;
//
// SftBox3
//
this.SftBox3.Location = new System.Drawing.Point(7, 167);
this.SftBox3.Name = "SftBox3";
this.SftBox3.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("SftBox3.OcxState")));
this.SftBox3.Size = new System.Drawing.Size(220, 21);
this.SftBox3.TabIndex = 4;
//
// label2
//
this.label2.Location = new System.Drawing.Point(7, 204);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(358, 53);
this.label2.TabIndex = 5;
this.label2.Text = "Of course you can add multiple columns, headers and all other features to the com" +
"bo box in your application.";
//
// label3
//
this.label3.Location = new System.Drawing.Point(234, 76);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(131, 121);
this.label3.TabIndex = 6;
this.label3.Text = "Make sure to try the size box that allows you to resize the drop down portion of " +
"the control!";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.CancelButton = this.closeButton;
this.ClientSize = new System.Drawing.Size(374, 259);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.SftBox3);
this.Controls.Add(this.SftBox2);
this.Controls.Add(this.SftBox1);
this.Controls.Add(this.label1);
this.Controls.Add(this.closeButton);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form1";
this.Text = "Softel vdm, Inc. - Color Sample";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.SftBox1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.SftBox2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.SftBox3)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
//--locate-marker--
private void closeButton_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
private void AddColor(AxSftBoxLib45.AxSftBox box, string Text, Color color)
{
SftBoxLib45.SftBoxCell oneCell;
int addColor = box.Items.Add(Text); // add a new item
oneCell = box.get_Cell(addColor, 0); // get the first cell
oneCell.Image.Height = 13;
oneCell.Image.Width = 13;
if (box == SftBox2)
oneCell.Image.Width = 26;
else
oneCell.Image.Width = 13;
oneCell.Image.SetColorSample(OLECvt.ToOleColor(color), OLECvt.ToOleColor(Color.Black)); // set the cell's color sample
// We'll save the color value in the cell's Data property so
// we can use the Items.FindCellData method if needed
oneCell.Data = ColorTranslator.ToWin32(color);
}
private void AddColors(AxSftBoxLib45.AxSftBox box)
{
AddColor(box, "Black", Color.Black);
AddColor(box, "Blue", Color.Blue);
AddColor(box, "Cyan", Color.Cyan);
AddColor(box, "Green", Color.Green);
AddColor(box, "Magenta", Color.Magenta);
AddColor(box, "Red", Color.Red);
AddColor(box, "White", Color.White);
AddColor(box, "Yellow", Color.Yellow);
AddColor(box, "Scroll bar color", Color.FromKnownColor(KnownColor.ScrollBar));
AddColor(box, "Desktop color", Color.FromKnownColor(KnownColor.Desktop));
AddColor(box, "Color of the title bar for the active window", Color.FromKnownColor(KnownColor.ActiveCaption));
AddColor(box, "Color of the title bar for the inactive window", Color.FromKnownColor(KnownColor.InactiveCaption));
AddColor(box, "Menu background color", Color.FromKnownColor(KnownColor.Menu));
AddColor(box, "Window background color", Color.FromKnownColor(KnownColor.Window));
AddColor(box, "Window frame color", Color.FromKnownColor(KnownColor.WindowFrame));
AddColor(box, "Color of text on menus", Color.FromKnownColor(KnownColor.MenuText));
AddColor(box, "Color of text in windows", Color.FromKnownColor(KnownColor.WindowText));
AddColor(box, "Color of text in caption, size box, and scroll arrow", Color.FromKnownColor(KnownColor.ActiveCaptionText));
AddColor(box, "Border color of active window", Color.FromKnownColor(KnownColor.ActiveBorder));
AddColor(box, "Border color of inactive window", Color.FromKnownColor(KnownColor.InactiveBorder));
AddColor(box, "Background color of multiple-document interface (MDI) applications", Color.FromKnownColor(KnownColor.AppWorkspace));
AddColor(box, "Background color of items selected in a control", Color.FromKnownColor(KnownColor.Highlight));
AddColor(box, "Text color of items selected in a control", Color.FromKnownColor(KnownColor.HighlightText));
AddColor(box, "Color of shading on the face of command buttons", Color.FromKnownColor(KnownColor.Control));
AddColor(box, "Color of shading on the edge of command buttons", Color.FromKnownColor(KnownColor.ControlDark));
AddColor(box, "Grayed (disabled) text", Color.FromKnownColor(KnownColor.GrayText));
AddColor(box, "Text color on push buttons", Color.FromKnownColor(KnownColor.ControlText));
AddColor(box, "Color of text in an inactive caption", Color.FromKnownColor(KnownColor.InactiveCaptionText));
AddColor(box, "Highlight color for 3D display elements", Color.FromKnownColor(KnownColor.ControlLightLight));
AddColor(box, "Darkest shadow color for 3D display elements", Color.FromKnownColor(KnownColor.ControlDarkDark));
AddColor(box, "Second lightest of the 3D colors", Color.FromKnownColor(KnownColor.ControlLight));
AddColor(box, "Color of text face", Color.FromKnownColor(KnownColor.Control));
AddColor(box, "Color of text shadow", Color.FromKnownColor(KnownColor.ControlDark));
AddColor(box, "Color of text in ToolTips", Color.FromKnownColor(KnownColor.InfoText));
AddColor(box, "Background color of ToolTips", Color.FromKnownColor(KnownColor.Info));
}
private void Form1_Load(object sender, System.EventArgs e)
{
int index;
short column;
AddColors(SftBox1);
// Select "Red"
SftBox1.Items.FindCellData(ColorTranslator.ToWin32(Color.Red), 0, -1, (short) 0, out index, out column);
SftBox1.Items.Selection = index;
// make sure we get a horizontal scroll bar
SftBox1.Items.RecalcHorizontalExtent(0);
AddColors(SftBox2);
// Select "Red"
SftBox2.Items.FindCellData(ColorTranslator.ToWin32(Color.Red), 0, -1, 0, out index, out column);
SftBox2.Items.Selection = index;
// make sure we get a horizontal scroll bar
SftBox2.Items.RecalcHorizontalExtent(0);
AddColors(SftBox3);
// Select "Red"
SftBox3.Items.FindCellData(ColorTranslator.ToWin32(Color.Red), 0, -1, 0, out index, out column);
SftBox3.Items.Selection = index;
// make sure we get a horizontal scroll bar
SftBox3.Items.RecalcHorizontalExtent(0);
}
}
}