Пример #1
0
        private void detailView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            Trace.WriteLine("detailView_CustomDrawCell");

            GridView view = sender as GridView;

            if (e.RowHandle == view.FocusedRowHandle)
            {
                return;
            }
            Trace.WriteLine(String.Format("detailView_CustomDrawCell: {0}", e.Column.FieldName));
            if (!fieldsList.Contains(e.Column.FieldName))
            {
                return;
            }

            GridCellInfo      ci  = e.Cell as GridCellInfo;
            CheckEditViewInfo cvi = ci.ViewInfo as CheckEditViewInfo;


            cvi.AllowOverridedState = true;
            if (!ci.Column.OptionsColumn.AllowEdit)
            {
                //                cvi.Appearance.BackColor = System.Drawing.Color.LightCoral;
                cvi.OverridedState = DevExpress.Utils.Drawing.ObjectState.Disabled;
            }
            cvi.PaintAppearance.BackColor = cvi.CheckState != CheckState.Checked ? Color.NavajoWhite : Color.PaleGreen;
            cvi.CalcViewInfo(e.Graphics);
        }
Пример #2
0
        private void bandedGridViewChangeStates_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            if (e.Column.Tag != null && this.bandedGridViewChangeStates.GetRowCellValue(e.RowHandle, EMS_EQUIPMENT_STATES_FIELDS.FIELD_EQUIPMENT_STATE_KEY) != null)
            {
                string topStateKey = e.Column.Tag.ToString();

                string leftStateKey = this.bandedGridViewChangeStates.GetRowCellValue(e.RowHandle, EMS_EQUIPMENT_STATES_FIELDS.FIELD_EQUIPMENT_STATE_KEY).ToString();

                if (topStateKey == leftStateKey)
                {
                    #region Disable Grid Cell

                    GridCellInfo cellInfo = e.Cell as GridCellInfo;

                    CheckEditViewInfo checkEditInfo = cellInfo.ViewInfo as CheckEditViewInfo;

                    checkEditInfo.AllowOverridedState = true;
                    checkEditInfo.OverridedState      = ObjectState.Disabled;
                    checkEditInfo.CalcViewInfo(e.Graphics);

                    #endregion

                    #region Set Grid Cell Color

                    e.Appearance.BackColor            = Color.OrangeRed;
                    e.Appearance.Options.UseBackColor = true;

                    #endregion
                }
            }
        }
Пример #3
0
        private void checkEdit1_MouseDown(object sender, MouseEventArgs e)
        {
            CheckEdit         cEdit      = (CheckEdit)sender;
            CheckEditViewInfo cInfo      = (CheckEditViewInfo)cEdit.GetViewInfo();
            Rectangle         r          = cInfo.CheckInfo.GlyphRect;
            Rectangle         editorRect = new Rectangle(new Point(0, 0), cEdit.Size);

            if (!r.Contains(e.Location) && editorRect.Contains(e.Location))
            {
                ((DXMouseEventArgs)e).Handled = true;
            }
        }
Пример #4
0
        private Rectangle getControlExtents(CheckEditViewInfo cInfo)
        {
            var labelRect = getLabelRectangle(cInfo);
            var glyphRect = getGlyphRectangle(cInfo);

            var left   = Math.Min(labelRect.Left, glyphRect.Left);
            var right  = Math.Max(labelRect.Right, glyphRect.Right);
            var bottom = Math.Max(labelRect.Bottom, glyphRect.Bottom);
            var top    = Math.Min(labelRect.Top, glyphRect.Top);

            return(new Rectangle(left, top, right - left, bottom - top));
        }
Пример #5
0
        protected void DrawCheckBox(Graphics g, Rectangle r, bool _checked)
        {
            CheckEditViewInfo info    = edit.CreateViewInfo() as CheckEditViewInfo;
            CheckEditPainter  painter = edit.CreatePainter() as CheckEditPainter;

            info.EditValue = _checked;
            info.Bounds    = r;
            info.CalcViewInfo(g);
            ControlGraphicsInfoArgs args = new ControlGraphicsInfoArgs(info, new GraphicsCache(g), r);

            painter.Draw(args);
            args.Cache.Dispose();
        }
Пример #6
0
        protected Rectangle CalcCheckBoxRect(GraphicsCache cache, Rectangle bounds)
        {
            RepositoryItemCheckEdit checkBox = new RepositoryItemCheckEdit();
            CheckEditViewInfo       viewInfo = (CheckEditViewInfo)checkBox.CreateViewInfo();

            viewInfo.Bounds = bounds;
            viewInfo.CalcViewInfo(cache.Graphics);
            ControlGraphicsInfoArgs args = new ControlGraphicsInfoArgs(viewInfo, cache, bounds);
            BaseCheckObjectInfoArgs ci   = ((CheckEditViewInfo)args.ViewInfo).CheckInfo;

            Rectangle retValue = new Rectangle(bounds.X, ci.GlyphRect.Y, ci.GlyphRect.Width, ci.GlyphRect.Height);

            return(retValue);
        }
Пример #7
0
        protected int GetCheckBoxWidth()
        {
            CheckEditViewInfo info = edit.CreateViewInfo() as CheckEditViewInfo;
            int width = 0;

            GraphicsInfo.Default.AddGraphics(null);
            try {
                width = info.CalcBestFit(GraphicsInfo.Default.Graphics).Width;
            }
            finally {
                GraphicsInfo.Default.ReleaseGraphics();
            }
            return(width + CheckboxIndent * 2);
        }
Пример #8
0
 private void grdViewArea_MouseDown(object sender, MouseEventArgs e)
 {
     if ((Control.ModifierKeys & Keys.Control) != Keys.Control)
     {
         GridView    view = sender as GridView;
         GridHitInfo hi   = view.CalcHitInfo(e.Location);
         if (hi.InRowCell)
         {
             if (hi.Column.RealColumnEdit.GetType() == typeof(RepositoryItemCheckEdit))
             {
                 view.FocusedRowHandle = hi.RowHandle;
                 view.FocusedColumn    = hi.Column;
                 view.ShowEditor();
                 CheckEdit         checkEdit = view.ActiveEditor as CheckEdit;
                 CheckEditViewInfo checkInfo = (CheckEditViewInfo)checkEdit.GetViewInfo();
                 Rectangle         glyphRect = checkInfo.CheckInfo.GlyphRect;
                 DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo viewInfo = view.GetViewInfo() as DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo;
                 Rectangle gridGlyphRect =
                     new Rectangle(viewInfo.GetGridCellInfo(hi).Bounds.X + glyphRect.X,
                                   viewInfo.GetGridCellInfo(hi).Bounds.Y + glyphRect.Y,
                                   glyphRect.Width,
                                   glyphRect.Height);
                 if (!gridGlyphRect.Contains(e.Location))
                 {
                     view.CloseEditor();
                     if (!view.IsCellSelected(hi.RowHandle, hi.Column))
                     {
                         view.SelectCell(hi.RowHandle, hi.Column);
                     }
                     else
                     {
                         view.UnselectCell(hi.RowHandle, hi.Column);
                     }
                 }
                 else
                 {
                     checkEdit.Checked = !checkEdit.Checked;
                     view.CloseEditor();
                 }
                 (e as DevExpress.Utils.DXMouseEventArgs).Handled = true;
             }
         }
     }
 }
Пример #9
0
        void DrawCheckBox(Graphics g, Rectangle r, bool chk, bool colHeader)
        {
            CheckEditViewInfo       info    = (edit.CreateViewInfo() as CheckEditViewInfo);
            CheckEditPainter        painter = (edit.CreatePainter() as CheckEditPainter);
            ControlGraphicsInfoArgs args;

            info.EditValue = chk;
            if (colHeader)
            {
                r.Height += 20;
            }
            else
            {
                r.Width += 40;
            }
            info.Bounds = r;
            info.CalcViewInfo(g);
            args = new ControlGraphicsInfoArgs(info, new DevExpress.Utils.Drawing.GraphicsCache(g), r);
            painter.Draw(args);
            args.Cache.Dispose();
        }
Пример #10
0
 private static Rectangle getGlyphRectangle(CheckEditViewInfo cInfo)
 {
     return(cInfo.CheckInfo.GlyphRect);
 }
Пример #11
0
 private static Rectangle getLabelRectangle(CheckEditViewInfo cInfo)
 {
     return(cInfo.CheckInfo.CaptionRect);
 }