|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace Bornander.UI.ListItems
{
public partial class FormulaOneTeam : UserControl, IExtendedListItem
{
private bool onOddRow = false;
private bool isSelected = false;
public FormulaOneTeam()
{
InitializeComponent();
}
public FormulaOneTeam(Image carPicture, Image firstDriverPicture, Image secondDriverPicture, string teamName, string firstDriverName, string secondDriverName)
{
InitializeComponent();
this.carPicture.Image = carPicture;
this.firstDriver.Image = firstDriverPicture;
this.secondDriver.Image = secondDriverPicture;
this.teamName.Text = teamName;
this.firstDriverName.Text = firstDriverName;
this.secondDriverName.Text = secondDriverName;
SetSelectedState(false);
}
private void SetSelectedState(bool isSelected)
{
carPicture.Visible = !isSelected;
teamName.Visible = !isSelected;
firstDriver.Visible = isSelected;
secondDriver.Visible = isSelected;
firstDriverName.Visible = isSelected;
secondDriverName.Visible = isSelected;
}
private void SetBackColor()
{
if (isSelected)
BackColor = onOddRow ? Color.AliceBlue : Color.LightBlue;
else
BackColor = onOddRow ? Color.White : Color.Silver;
}
#region IExtendedListItem Members
public void SelectedChanged(bool isSelected)
{
this.isSelected = isSelected;
SetSelectedState(isSelected);
SetBackColor();
}
public void PositionChanged(int index)
{
onOddRow = (index & 1) == 0;
SetBackColor();
}
#endregion
#region Public properties
public string TeamName
{
get { return teamName.Text; }
}
public string FirstDriver
{
get { return firstDriverName.Text; }
}
public string SecondDriver
{
get { return secondDriverName.Text; }
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Article videos
Oakmead Apps Android Games
21 Feb 2014: Best VB.NET Article of January 2014 - Second Prize
18 Oct 2013: Best VB.NET article of September 2013
23 Jun 2012: Best C++ article of May 2012
20 Apr 2012: Best VB.NET article of March 2012
22 Feb 2010: Best overall article of January 2010
22 Feb 2010: Best C# article of January 2010