using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using AxSftButtonLib25;
using SftButtonLib25;
using Softelvdm.OLEConvert;
namespace Images
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ImageList imageList1;
private Softelvdm.OCXHelper.SftHelperComponent sftHelperComponent1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.CheckBox check1;
private System.Windows.Forms.CheckBox check2;
private AxSftButtonLib25.AxSftButton CloseButton;
private AxSftButtonLib25.AxSftButton axSftButton1;
private AxSftButtonLib25.AxSftButton axSftButton2;
private System.Windows.Forms.Label label5;
private AxSftButtonLib25.AxSftButton axSftButtonCheck;
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.label1 = new System.Windows.Forms.Label();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.sftHelperComponent1 = new Softelvdm.OCXHelper.SftHelperComponent(this.components);
this.label2 = new System.Windows.Forms.Label();
this.CloseButton = new AxSftButtonLib25.AxSftButton();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.axSftButton1 = new AxSftButtonLib25.AxSftButton();
this.check1 = new System.Windows.Forms.CheckBox();
this.axSftButton2 = new AxSftButtonLib25.AxSftButton();
this.check2 = new System.Windows.Forms.CheckBox();
this.axSftButtonCheck = new AxSftButtonLib25.AxSftButton();
this.label5 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.CloseButton)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.axSftButton1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.axSftButton2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.axSftButtonCheck)).BeginInit();
this.SuspendLayout();
//
// label1
//
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label1.Location = new System.Drawing.Point(16, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(296, 24);
this.label1.TabIndex = 1;
this.label1.Text = "Images Sample";
//
// imageList1
//
this.imageList1.ImageSize = new System.Drawing.Size(30, 32);
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.White;
//
// label2
//
this.label2.Location = new System.Drawing.Point(16, 40);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(416, 32);
this.label2.TabIndex = 2;
this.label2.Text = "A SftButton control can define images for each state (hot, pressed, disabled or n" +
"ormal). In this sample, they were defined using the property pages.";
//
// CloseButton
//
this.CloseButton.Location = new System.Drawing.Point(512, 24);
this.CloseButton.Name = "CloseButton";
this.CloseButton.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("CloseButton.OcxState")));
this.CloseButton.Size = new System.Drawing.Size(48, 48);
this.CloseButton.TabIndex = 3;
this.CloseButton.ClickEvent += new System.EventHandler(this.CloseButton_ClickEvent);
//
// label3
//
this.label3.Location = new System.Drawing.Point(16, 80);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(416, 16);
this.label3.TabIndex = 4;
this.label3.Text = "This sample uses translucent PNG images.";
//
// label4
//
this.label4.Location = new System.Drawing.Point(16, 104);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(416, 32);
this.label4.TabIndex = 5;
this.label4.Text = "To see the different images (or states), move the mouse cursor over the control, " +
"click the button and disable it using the \"Disabled\" checkbox next to it.";
//
// axSftButton1
//
this.axSftButton1.Location = new System.Drawing.Point(16, 144);
this.axSftButton1.Name = "axSftButton1";
this.axSftButton1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axSftButton1.OcxState")));
this.axSftButton1.Size = new System.Drawing.Size(184, 80);
this.axSftButton1.TabIndex = 6;
//
// check1
//
this.check1.Location = new System.Drawing.Point(208, 172);
this.check1.Name = "check1";
this.check1.Size = new System.Drawing.Size(112, 24);
this.check1.TabIndex = 7;
this.check1.Text = "Disabled";
this.check1.CheckedChanged += new System.EventHandler(this.check1_CheckedChanged);
//
// axSftButton2
//
this.axSftButton2.Location = new System.Drawing.Point(16, 248);
this.axSftButton2.Name = "axSftButton2";
this.axSftButton2.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axSftButton2.OcxState")));
this.axSftButton2.Size = new System.Drawing.Size(152, 80);
this.axSftButton2.TabIndex = 8;
//
// check2
//
this.check2.Location = new System.Drawing.Point(176, 280);
this.check2.Name = "check2";
this.check2.Size = new System.Drawing.Size(168, 24);
this.check2.TabIndex = 9;
this.check2.Text = "Auto-size this button";
this.check2.CheckedChanged += new System.EventHandler(this.check2_CheckedChanged);
//
// axSftButtonCheck
//
this.axSftButtonCheck.Location = new System.Drawing.Point(16, 344);
this.axSftButtonCheck.Name = "axSftButtonCheck";
this.axSftButtonCheck.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axSftButtonCheck.OcxState")));
this.axSftButtonCheck.Size = new System.Drawing.Size(160, 24);
this.axSftButtonCheck.TabIndex = 10;
this.axSftButtonCheck.ClickEvent += new System.EventHandler(this.axSftButtonCheck_ClickEvent);
this.axSftButtonCheck.DblClick += new System.EventHandler(this.axSftButtonCheck_DblClick);
//
// label5
//
this.label5.Location = new System.Drawing.Point(16, 376);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(448, 32);
this.label5.TabIndex = 11;
this.label5.Text = "We don\'t think you\'ll be using SftButton for check boxes, but it does demonstrate" +
" the flexibility of the control quite nicely.";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(586, 416);
this.Controls.Add(this.label5);
this.Controls.Add(this.axSftButtonCheck);
this.Controls.Add(this.check2);
this.Controls.Add(this.axSftButton2);
this.Controls.Add(this.check1);
this.Controls.Add(this.axSftButton1);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.CloseButton);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Form1";
this.Text = "Softel vdm, Inc. - Images Sample";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.CloseButton)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.axSftButton1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.axSftButton2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.axSftButtonCheck)).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 Size savedSize;
private Point savedLoc;
private void Form1_Load(object sender, System.EventArgs e)
{
// save the button size to demonstrate auto-sizing
savedSize = axSftButton2.Size;
savedLoc = axSftButton2.Location;
// initialize a SftButton control to look like a check box
axSftButtonCheck.BorderAlways = false;
#if VisualStudio2003AndEarlier
axSftButtonCheck.AutoSize = SftButtonAutoSizeConstants.autosizeSftButtonLeftCenter;
#else
axSftButtonCheck.CtlAutoSize = SftButtonAutoSizeConstants.autosizeSftButtonLeftCenter;
#endif
axSftButtonCheck.Bounce = SftButtonBounceStyleConstants.bounceSftButtonNo;
axSftButtonCheck.ButtonStyle = SftButtonStyleConstants.styleSftButtonNone;
axSftButtonCheck.ClickStyle = SftButtonClickStyleConstants.clickstyleSftButtonPictures;
axSftButtonCheck.HoverStyle = SftButtonHoverStyleConstants.hoverstyleSftButtonExact;
axSftButtonCheck.Image1.Appearance = SftPictureImageConstants.sftImageCheckboxYes;
axSftButtonCheck.Text = "A SftButton control that looks like a check box with a caption";
axSftButtonCheck.ShowFocus = false;
}
private void check1_CheckedChanged(object sender, System.EventArgs e)
{
// enable/disable the control so the image changes
axSftButton1.Enabled = !check1.Checked;
}
private void check2_CheckedChanged(object sender, System.EventArgs e)
{
// resize the control
if (check2.Checked) {
#if VisualStudio2003AndEarlier
axSftButton2.AutoSize = SftButtonAutoSizeConstants.autosizeSftButtonLeftCenter;
#else
axSftButton2.CtlAutoSize = SftButtonAutoSizeConstants.autosizeSftButtonLeftCenter;
#endif
} else {
#if VisualStudio2003AndEarlier
axSftButton2.AutoSize = SftButtonAutoSizeConstants.autosizeSftButtonNone;
#else
axSftButton2.CtlAutoSize = SftButtonAutoSizeConstants.autosizeSftButtonNone;
#endif
axSftButton2.Location = savedLoc;
axSftButton2.Size = savedSize;
}
}
private void CloseButton_ClickEvent(object sender, System.EventArgs e)
{
Application.Exit();
}
private void axSftButtonCheck_ClickEvent(object sender, System.EventArgs e)
{
// toggle the check box
if (axSftButtonCheck.Image1.Appearance == SftPictureImageConstants.sftImageCheckboxYes)
axSftButtonCheck.Image1.Appearance = SftPictureImageConstants.sftImageCheckboxNo;
else
axSftButtonCheck.Image1.Appearance = SftPictureImageConstants.sftImageCheckboxYes;
}
private void axSftButtonCheck_DblClick(object sender, System.EventArgs e)
{
axSftButtonCheck_ClickEvent(null, null);
}
}
}