143 lines
4.9 KiB
C#

//----------------------------------------------------------------------------
//
// Copyright © 2009-2010, Intel Corporation. All rights reserved.
//
// File: LinkInterfaceDetails.cs
//
//----------------------------------------------------------------------------
using System;
using System.Drawing;
using System.Windows.Forms;
namespace UCT.Controls
{
/// <summary>
/// A control that display the connection interface (wired/wireless) and
/// additionals properties.
/// </summary>
public partial class LinkInterfaceDetails : UserControl
{
#region - Members -
private const int WIDE_CONTROL_HEIGHT = 40;
private const int HEADER_CONTROL_HEIGHT = 27;
private const int NARROW_CONTROL_HEIGHT = 20;
private bool IsExpaned = true;
#endregion
#region - Constructors -
public LinkInterfaceDetails()
{
InitializeComponent();
}
#endregion
#region - Methods -
/// <summary>
/// Resize the control height
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void pbExpand_Click(object sender, EventArgs e)
{
// The control is elapsed
if (IsExpaned)
{
SetControlExpandButton(NARROW_CONTROL_HEIGHT, NARROW_CONTROL_HEIGHT, Properties.Resources.scs_panes_down2);
}
else // Control is expanded
{
SetControlExpandButton(WIDE_CONTROL_HEIGHT, WIDE_CONTROL_HEIGHT, Properties.Resources.scs_panes_up2);
}
IsExpaned = !IsExpaned;
}
/// <summary>
/// Set the control height ang the image that indicate the interface state
/// </summary>
/// <param name="height"></param>
/// <param name="image"></param>
private void SetControlState(int height, int headerHeight, Bitmap image)
{
this.Height = height;
headerPannel.Height = headerHeight;
pbInterfaceIcon.Image = image;
this.Refresh();
}
/// <summary>
/// Set the control height ang the image that indicate the button expand image
/// </summary>
/// <param name="height"></param>
/// <param name="image"></param>
private void SetControlExpandButton(int height, int headerHeight, Bitmap image)
{
this.Height = height;
headerPannel.Height = headerHeight;
pbExpand.Image = image;
this.Refresh();
}
/// <summary>
/// Set the link interface header and icon
/// </summary>
/// <param name="link"></param>
/// <param name="LanID"></param>
public void SetInterface(LinkInterface link, string LanID)
{
lblLinkInterface.Text = "Connection interface: " + link.ToString();
switch (link)
{
case LinkInterface.Wireless:
pbExpand.Visible = true;
SetControlState(WIDE_CONTROL_HEIGHT, HEADER_CONTROL_HEIGHT, Properties.Resources.scs_tree_wifi);
break;
case LinkInterface.Wired:
pbExpand.Visible = false;
SetControlState(NARROW_CONTROL_HEIGHT, NARROW_CONTROL_HEIGHT, Properties.Resources.LAN);
break;
}
lblLanID.Text = (string.IsNullOrEmpty(LanID))? "N/A" : LanID;
}
/// <summary>
/// Update the link control and link preference datails
/// </summary>
/// <param name="linkControl"></param>
/// <param name="linkPreference"></param>
internal void SetDetails(LinkControl linkControl, LinkControl linkPreference, bool linkProtectionSupport)
{
if (linkControl == LinkControl.None && linkPreference == LinkControl.None)
{
lblLinkInterface.Text = "Connection interface: Unknown";
pbExpand.Visible = false;
SetControlState(NARROW_CONTROL_HEIGHT, NARROW_CONTROL_HEIGHT, Properties.Resources.lan_disconnect.ToBitmap());
}
else
{
lblLinkControl.Text = linkControl.ToString();
if (!linkProtectionSupport)// In Intel AMT versions earlier than 8.1, there is link preference.
{
lblLinkPrefHeader.Visible = true;
lblLinkPref.Visible = true;
lblLinkPref.Text = linkPreference.ToString();
}
else // In Intel AMT versions greater than 8.1 there is no link prefernce, link protection is instead.
{
lblLinkPrefHeader.Visible = false;
lblLinkPref.Visible = false;
}
}
}
#endregion
}
}