//---------------------------------------------------------------------------- // // Copyright © 2009-2010, Intel Corporation. All rights reserved. // // File: LinkInterfaceDetails.cs // //---------------------------------------------------------------------------- using System; using System.Drawing; using System.Windows.Forms; namespace UCT.Controls { /// /// A control that display the connection interface (wired/wireless) and /// additionals properties. /// 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 - /// /// Resize the control height /// /// /// 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; } /// /// Set the control height ang the image that indicate the interface state /// /// /// private void SetControlState(int height, int headerHeight, Bitmap image) { this.Height = height; headerPannel.Height = headerHeight; pbInterfaceIcon.Image = image; this.Refresh(); } /// /// Set the control height ang the image that indicate the button expand image /// /// /// private void SetControlExpandButton(int height, int headerHeight, Bitmap image) { this.Height = height; headerPannel.Height = headerHeight; pbExpand.Image = image; this.Refresh(); } /// /// Set the link interface header and icon /// /// /// 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; } /// /// Update the link control and link preference datails /// /// /// 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 } }