crashanalysercmd/Libraries/Engine/CrashItemLib/Crash/Base/DataBinding/CIDBRow.cs
author Jussi Ryoma <ext-jussi.s.ryoma@nokia.com>
Fri, 27 Aug 2010 12:21:46 +0300
changeset 3 045ade241ef5
parent 0 818e61de6cd1
permissions -rw-r--r--
Version 1.0.13. The most important changes are: -detailed defect hash added -panic descriptions updated -release build is working -simple command line usage added

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
* 
* Description:
*
*/
using System;
using System.Text;
using System.Collections.Generic;
using System.Drawing;

namespace CrashItemLib.Crash.Base.DataBinding
{
    public class CIDBRow : IEnumerable<CIDBCell>
	{
		#region Constructors
        public CIDBRow()
        {
        }

        public CIDBRow( params CIDBCell[] aCells )
        {
            iCells.AddRange( aCells );
        }

        public CIDBRow( Color aForeColor )
            : this( aForeColor, Color.Transparent )
        {
        }

        public CIDBRow( Color aForeColor, Color aBackColor )
        {
            iForeColor = aForeColor;
            iBackColor = aBackColor;
        }
		#endregion

        #region API
        public void Add( CIDBCell aCell )
        {
            aCell.Row = this;
            iCells.Add( aCell );
        }
        #endregion

        #region Properties
        public int Count
        {
            get { return iCells.Count; }
        }

        public CIDBCell this[ int aIndex ]
        {
            get { return iCells[ aIndex ]; }
        }

        public Color ForeColor
        {
            get { return iForeColor; }
            set { iForeColor = value; }
        }

        public Color BackColor
        {
            get { return iBackColor; }
            set { iBackColor = value; }
        }

        public CIElement Element
        {
            get
            {
                CIElement element = iElement;
                //
                if ( element == null && Model != null )
                {
                    element = Model.Element;
                }
                //
                return element;
            }
            set { iElement = value; }
        }

        internal CIDBModel Model
        {
            get { return iModel; }
            set
            { 
                iModel = value;

                // Try to ensure the element points to something
                if ( iElement == null )
                {
                    iElement = Model.Element;
                }
            }
        }
        #endregion

        #region From IEnumerable<CICell>
        public IEnumerator<CIDBCell> GetEnumerator()
        {
            foreach ( CIDBCell c in iCells )
            {
                yield return c;
            }
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            foreach ( CIDBCell c in iCells )
            {
                yield return c;
            }
        }
        #endregion

        #region Data members
        private Color iForeColor = Color.Black;
        private Color iBackColor = Color.Transparent;
        private List<CIDBCell> iCells = new List<CIDBCell>();
        private CIDBModel iModel = null;
        private CIElement iElement = null;
        #endregion
    }
}