208 lines
6.3 KiB
C#
208 lines
6.3 KiB
C#
//
|
|
// Copyright © 2006-2010, Intel Corporation. All rights reserved.
|
|
//
|
|
//File: AMT_OuterButton.cs
|
|
//
|
|
// Contents: Defintion of logic of 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_OuterButton : Button
|
|
{
|
|
bool isAccept = false;
|
|
bool acceptDetermined = false;
|
|
bool enabled = true;
|
|
public AMT_OuterButton()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
// public bool IsAccept { get { return isAccept; } set { isAccept = value; SCS_Button_MouseLeave(null, null); } }
|
|
public AMT_OuterButton(IContainer container)
|
|
{
|
|
container.Add(this);
|
|
|
|
InitializeComponent();
|
|
AMT_OuterButton_EnabledChanged(null, null);
|
|
}
|
|
|
|
private void AMT_OuterButton_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
if (this.Enabled)
|
|
this.BackgroundImage = Properties.Resources.large_pressed24;
|
|
}
|
|
|
|
private void AMT_OuterButton_MouseUp(object sender, MouseEventArgs e)
|
|
{
|
|
if (this.Enabled)
|
|
{
|
|
if (this.Focused)
|
|
if (isAccept)
|
|
this.BackgroundImage = Properties.Resources.large_focus_default24;
|
|
else
|
|
this.BackgroundImage = Properties.Resources.large_focus_normal24;
|
|
else
|
|
if (isAccept)
|
|
this.BackgroundImage = Properties.Resources.large_default24;
|
|
else
|
|
this.BackgroundImage = Properties.Resources.large_normal24;
|
|
}
|
|
|
|
}
|
|
|
|
private void AMT_OuterButton_MouseLeave(object sender, EventArgs e)
|
|
{
|
|
if (this.Enabled)
|
|
{
|
|
if (this.Focused)
|
|
if (isAccept)
|
|
this.BackgroundImage = Properties.Resources.large_focus_default24;
|
|
else
|
|
this.BackgroundImage = Properties.Resources.large_focus_normal24;
|
|
else
|
|
if (isAccept)
|
|
this.BackgroundImage = Properties.Resources.large_default24;
|
|
else
|
|
this.BackgroundImage = Properties.Resources.large_normal24;
|
|
}
|
|
}
|
|
|
|
|
|
private void AMT_OuterButton_MouseEnter(object sender, EventArgs e)
|
|
{
|
|
if (this.Enabled)
|
|
{
|
|
if (this.Focused)
|
|
this.BackgroundImage = Properties.Resources.large_focus_over24;
|
|
else
|
|
this.BackgroundImage = Properties.Resources.large_over24;
|
|
}
|
|
}
|
|
|
|
protected override void OnParentChanged(EventArgs e)
|
|
{
|
|
base.OnParentChanged(e);
|
|
try
|
|
{
|
|
if (this.Parent != null)
|
|
{
|
|
|
|
if (((Form)this.Parent).AcceptButton == this)
|
|
isAccept = true;
|
|
}
|
|
}
|
|
catch { }
|
|
}
|
|
protected override void OnHelpRequested(HelpEventArgs hevent)
|
|
{
|
|
if (this.Enabled == true)
|
|
{
|
|
base.OnHelpRequested(hevent);
|
|
}
|
|
}
|
|
protected override void OnPaint(PaintEventArgs pevent)
|
|
{
|
|
if (!acceptDetermined)
|
|
{
|
|
if (Parent != null)
|
|
{
|
|
try
|
|
{
|
|
if ((Form)Parent != null)
|
|
{
|
|
if (((AMT_OuterButton)((Form)Parent).AcceptButton) == this)
|
|
{
|
|
isAccept = true;
|
|
}
|
|
|
|
}
|
|
}
|
|
catch { }
|
|
acceptDetermined = true;
|
|
}
|
|
}
|
|
base.OnPaint(pevent);
|
|
NotifyDefault(false);
|
|
|
|
}
|
|
private void AMT_OuterButton_EnabledChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
if (this.Text == "")
|
|
return;
|
|
this.TabStop = this.Enabled;
|
|
if (this.Enabled)
|
|
AMT_OuterButton_MouseLeave(sender, e);
|
|
else
|
|
this.BackgroundImage = Properties.Resources.large_disabled24;
|
|
|
|
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_OuterButton_EnabledChanged(null, null);
|
|
}
|
|
}
|
|
|
|
protected override void OnClick(EventArgs e)
|
|
{
|
|
if (Enabled)
|
|
base.OnClick(e);
|
|
}
|
|
|
|
private void AMT_OuterButton_Leave(object sender, EventArgs e)
|
|
{
|
|
if (this.Enabled)
|
|
{
|
|
if (isAccept)
|
|
this.BackgroundImage = Properties.Resources.large_default24;
|
|
else
|
|
this.BackgroundImage = Properties.Resources.large_normal24;
|
|
}
|
|
}
|
|
|
|
private void AMT_OuterButton_Enter(object sender, EventArgs e)
|
|
{
|
|
if (this.Enabled)
|
|
{
|
|
if (isAccept)
|
|
this.BackgroundImage = Properties.Resources.large_focus_default24;
|
|
else
|
|
this.BackgroundImage = Properties.Resources.large_focus_normal24;
|
|
}
|
|
}
|
|
|
|
private void AMT_OuterButton_TextChanged(object sender, EventArgs e)
|
|
{
|
|
AMT_OuterButton_EnabledChanged(null, null);
|
|
|
|
}
|
|
|
|
}
|
|
}
|