Exemplo n.º 1
0
 public static void ExceptIfNotControlVivant(CDataGridViewCellAControleVivant cell)
 {
     if (cell.ControlVivant == null)
     {
         throw new Exception(I.T("The display control has not be initialized for the cell : Column |30058 "
                                 + cell.ColumnIndex + " Line |30053" + cell.RowIndex));
     }
 }
Exemplo n.º 2
0
 public static void ExceptIfNotTypeMappe(CDataGridViewCellAControleVivant cell, List <Type> typesMappes)
 {
     if (cell.TypeDonnee == null)
     {
         throw new Exception(I.T("The cell of column : |30052") + cell.ColumnIndex + I.T(" Line |30053 ") + cell.RowIndex
                             + I.T(" has no parametred type|30054"));
     }
     else if (!typesMappes.Contains(cell.TypeDonnee))
     {
         throw new Exception(I.T("The type|30055 ") + cell.TypeDonnee.Name + I.T(" of the cell : Column |30056 ") + cell.ColumnIndex + I.T(" Line |30053 ") + cell.RowIndex
                             + I.T(" is not supported|30057"));
     }
 }
Exemplo n.º 3
0
        public override object Clone()
        {
            CDataGridViewCellAControleVivant cell = base.Clone() as CDataGridViewCellAControleVivant;

            if (cell != null)
            {
                cell.m_typeDonnee = this.m_typeDonnee;
                cell.m_control    = this.m_control;
                cell.m_oldWidth   = this.m_oldWidth;
                cell.m_oldHeight  = this.m_oldHeight;
                cell.m_cacheImg   = this.m_cacheImg;
            }
            return(cell);
        }
Exemplo n.º 4
0
            public IControlVivant GetControlVivant(CDataGridViewCellAControleVivant cell)
            {
                if (cell.ControlVivant == null)
                {
                    //Il faut créer une instance du control et le tager à la cellule
                    try
                    {
                        Type tpCtrl = m_mappageColonneControle[cell.TypeDonnee];

                        IControlVivant ctrl = (IControlVivant)Activator.CreateInstance(tpCtrl);
                        ctrl.Initialiser(cell.Value);
                        cell.ControlVivant = ctrl;
                    }
                    catch
                    {
                        throw new Exception(I.T("Impossible to build the edition  control of the cell : colonne |30060")
                                            + cell.ColumnIndex + I.T(" Line|30053") + cell.RowIndex);
                    }
                }
                return(cell.ControlVivant);
            }
Exemplo n.º 5
0
        //DESSINER CONTROL
        private void m_dgv_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
            {
                CDataGridViewCellAControleVivant cell = (CDataGridViewCellAControleVivant)m_dgv[e.ColumnIndex, e.RowIndex];
                if (cell.TypeDonnee == null)
                {
                    //Permet de définir un type spécifique à une cellule
                    if (InitialisationCellule != null)
                    {
                        cell.TypeDonnee = InitialisationCellule(cell);
                    }

                    if (cell.TypeDonnee == null)
                    {
                        cell.TypeDonnee = cell.ValueType;
                    }
                }

                CDataGridViewCellAControleVivant.ExceptIfNotTypeMappe(cell, m_factory.TypesSupportes);

                if (!cell.IsInEditMode)
                {
                    //Initialise le control au premier dessin
                    IControlVivant ctrl = m_factory.GetControlVivant(cell);
                    CDataGridViewCellAControleVivant.ExceptIfNotControlVivant(cell);

                    if (m_bControlesToujoursVivants)
                    {
                        bool bReadOnly = m_dgv.ReadOnly;
                        m_dgv.ReadOnly = false;
                        Bitmap bmp = cell.ImageCellule;
                        if (bmp != null)
                        {
                            Rectangle rectPos = new Rectangle(e.CellBounds.X, e.CellBounds.Y, e.CellBounds.Width, e.CellBounds.Height);
                            if (bmp.Width < (rectPos.Width - 1))
                            {
                                rectPos.X++;
                            }

                            e.Graphics.DrawImageUnscaled(bmp, rectPos);
                            Brush b = new SolidBrush(m_dgv.GridColor);
                            Pen   p = new Pen(b);
                            //Bordure inferieure
                            e.Graphics.DrawLine(p,
                                                new Point(e.CellBounds.X, e.CellBounds.Y + e.CellBounds.Height - 1),
                                                new Point(e.CellBounds.X + e.CellBounds.Width, e.CellBounds.Y + e.CellBounds.Height - 1));
                            //Bordure Droite
                            e.Graphics.DrawLine(p,
                                                new Point(e.CellBounds.X + e.CellBounds.Width - 1, e.CellBounds.Y),
                                                new Point(e.CellBounds.X + e.CellBounds.Width - 1, e.CellBounds.Y + e.CellBounds.Height));

                            //BordureGauche
                            if (cell.ColumnIndex == 0)
                            {
                                e.Graphics.DrawLine(p,
                                                    new Point(e.CellBounds.X, e.CellBounds.Y),
                                                    new Point(e.CellBounds.X, e.CellBounds.Y + e.CellBounds.Height));
                            }
                            p.Dispose();
                            b.Dispose();
                            e.Handled = true;
                        }
                        m_dgv.ReadOnly = bReadOnly;
                    }
                }
            }
        }