189 lines
6.2 KiB
C#
189 lines
6.2 KiB
C#
//
|
|
// Copyright © 2006-2010, Intel Corporation. All rights reserved.
|
|
//
|
|
//File: AMT_InnerButton.cs
|
|
//
|
|
// Contents: Defintion of logic of a button (GUI componet)
|
|
//
|
|
using System;
|
|
using System.ComponentModel;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
|
|
namespace AMT_SW_GUI
|
|
{
|
|
public partial class AMT_InnerButton : Button
|
|
{
|
|
bool enabled = true;
|
|
bool wide = false;
|
|
public AMT_InnerButton()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public AMT_InnerButton(IContainer container)
|
|
{
|
|
container.Add(this);
|
|
|
|
InitializeComponent();
|
|
AMT_InnerButton_EnabledChanged(null, null);
|
|
}
|
|
|
|
private void AMT_InnerButton_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
if (this.Enabled)
|
|
if (wide && this.Size.Width > 105)
|
|
this.BackgroundImage = Properties.Resources.W_thin_pressed;
|
|
else
|
|
this.BackgroundImage = Properties.Resources.thin_pressed;
|
|
}
|
|
|
|
private void AMT_InnerButton_MouseUp(object sender, MouseEventArgs e)
|
|
{
|
|
if (this.Enabled)
|
|
{
|
|
if (this.Focused)
|
|
if (wide && this.Size.Width > 105)
|
|
this.BackgroundImage = Properties.Resources.W_thin_focus_normal;
|
|
else
|
|
this.BackgroundImage = Properties.Resources.thin_focus_normal;
|
|
else
|
|
if (wide && this.Size.Width > 105)
|
|
this.BackgroundImage = Properties.Resources.W_thin_normal;
|
|
else
|
|
this.BackgroundImage = Properties.Resources.thin_normal;
|
|
}
|
|
}
|
|
|
|
private void AMT_InnerButton_MouseLeave(object sender, EventArgs e)
|
|
{
|
|
if (this.Enabled)
|
|
{
|
|
if (this.Focused)
|
|
if (wide && this.Size.Width > 105)
|
|
this.BackgroundImage = Properties.Resources.W_thin_focus_normal;
|
|
else
|
|
this.BackgroundImage = Properties.Resources.thin_focus_normal;
|
|
else
|
|
if (wide && this.Size.Width > 105)
|
|
this.BackgroundImage = Properties.Resources.W_thin_normal;
|
|
else
|
|
this.BackgroundImage = Properties.Resources.thin_normal;
|
|
}
|
|
}
|
|
|
|
|
|
protected override void OnTextChanged(EventArgs e)
|
|
{
|
|
base.OnTextChanged(e);
|
|
AMT_InnerButton_MouseLeave(null, null);
|
|
}
|
|
|
|
protected override void OnHelpRequested(HelpEventArgs hevent)
|
|
{
|
|
if (this.Enabled == true)
|
|
{
|
|
base.OnHelpRequested(hevent);
|
|
}
|
|
}
|
|
private void AMT_InnerButton_MouseEnter(object sender, EventArgs e)
|
|
{
|
|
if (this.Enabled)
|
|
{
|
|
if (this.Focused)
|
|
if (wide && this.Size.Width > 105)
|
|
this.BackgroundImage = Properties.Resources.W_thin_focus_over;
|
|
else
|
|
this.BackgroundImage = Properties.Resources.thin_focus_over;
|
|
else
|
|
if (wide && this.Size.Width > 105)
|
|
this.BackgroundImage = Properties.Resources.W_thin_over;
|
|
else
|
|
this.BackgroundImage = Properties.Resources.thin_over;
|
|
}
|
|
}
|
|
private void AMT_InnerButton_EnabledChanged(object sender, EventArgs e)
|
|
{
|
|
this.TabStop = this.Enabled;
|
|
if (this.Enabled)
|
|
AMT_InnerButton_MouseLeave(null, null);
|
|
else
|
|
if (wide && this.Size.Width > 105)
|
|
this.BackgroundImage = Properties.Resources.W_thin_disabled;
|
|
else
|
|
this.BackgroundImage = Properties.Resources.thin_disabled;
|
|
|
|
if (this.Enabled)
|
|
this.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(59)))), ((int)(((byte)(108)))));
|
|
else
|
|
this.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(158)))), ((int)(((byte)(158)))), ((int)(((byte)(158)))));
|
|
|
|
}
|
|
protected override bool ShowFocusCues
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
public new bool Enabled
|
|
{
|
|
get { return enabled; }
|
|
set
|
|
{
|
|
base.Enabled = true;
|
|
bool difference = (enabled != value);
|
|
enabled = value;
|
|
if (difference)
|
|
AMT_InnerButton_EnabledChanged(null, null);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>This feature can cause the button to dynamically become a wide button.</summary>
|
|
[Description("This feature can cause the button to dynamically become a wide button. Important for localization")]
|
|
|
|
public bool CanBeWide
|
|
{
|
|
get { return wide; }
|
|
set { wide = value; if (wide) this.BackgroundImage = Properties.Resources.W_thin_normal; }
|
|
}
|
|
|
|
|
|
protected override void OnClick(EventArgs e)
|
|
{
|
|
if (Enabled)
|
|
base.OnClick(e);
|
|
}
|
|
private void AMT_InnerButton_Enter(object sender, EventArgs e)
|
|
{
|
|
if (this.Enabled)
|
|
{
|
|
if (wide && this.Size.Width > 105)
|
|
this.BackgroundImage = Properties.Resources.W_thin_focus_normal;
|
|
else
|
|
this.BackgroundImage = Properties.Resources.thin_focus_normal;
|
|
}
|
|
}
|
|
|
|
private void AMT_InnerButton_Leave(object sender, EventArgs e)
|
|
{
|
|
if (this.Enabled)
|
|
{
|
|
if (wide && this.Size.Width > 105)
|
|
this.BackgroundImage = Properties.Resources.W_thin_normal;
|
|
else
|
|
this.BackgroundImage = Properties.Resources.thin_normal;
|
|
}
|
|
}
|
|
|
|
private void AMT_InnerButton_TextChanged(object sender, EventArgs e)
|
|
{
|
|
AMT_InnerButton_EnabledChanged(null, null);
|
|
}
|
|
}
|
|
}
|