Ejemplo n.º 1
0
        /// <summary>
        /// Draws the column header.
        /// </summary>
        /// <param name="cache">The cache.</param>
        /// <param name="column">The column.</param>
        public void DrawColumnHeader(GraphicsCache cache, GridColumn column)
        {
            var viewInfo = _gridView.GetViewInfo() as BandedGridViewInfo;

            if (viewInfo != null)
            {
                GridColumnInfoArgs colInfo = viewInfo.ColumnsInfo[column];
                var bandedGridColumn       = column as BandedGridColumn;
                if (bandedGridColumn != null)
                {
                    GridBandInfoArgs bandInfo = getBandInfo(viewInfo.BandsInfo, bandedGridColumn.OwnerBand);
                    if (colInfo == null || bandInfo == null)
                    {
                        return;
                    }
                    colInfo.Cache = cache;

                    int       top   = bandInfo.Bounds.Top;
                    Rectangle rect  = colInfo.Bounds;
                    int       delta = rect.Top - top;
                    rect.Y         = top;
                    rect.Height   += delta;
                    colInfo.Bounds = rect;
                }
                colInfo.Appearance.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;
                ElementsPainter.Column.CalcObjectBounds(colInfo);
                ElementsPainter.Column.DrawObject(colInfo);
            }
        }
Ejemplo n.º 2
0
        private int GetColumnBestHeight(GridBand column, int width, DevExpress.Utils.AppearanceObject app)
        {
            GridBandInfoArgs   ex       = null;
            BandedGridViewInfo viewInfo = GridView.GetViewInfo() as BandedGridViewInfo;

            viewInfo.GInfo.AddGraphics(null);
            ex = new GridBandInfoArgs(null, viewInfo.GInfo.Cache);
            try
            {
                ex.InnerElements.Add(new DrawElementInfo(new GlyphElementPainter(),
                                                         new GlyphElementInfoArgs(viewInfo.View.Images, 0, null),
                                                         StringAlignment.Near));
                ex.SetAppearance(app);
                ex.Caption     = column.Caption;
                ex.CaptionRect = new Rectangle(0, 0, (int)(width - 10 * DpiXRel), 1000);
            }
            finally
            {
                viewInfo.GInfo.ReleaseGraphics();
            }

            GraphicsInfo grInfo = new GraphicsInfo();

            grInfo.AddGraphics(null);
            ex.Cache = grInfo.Cache;
            int Height = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.Caption);

            return(Height);
        }
        private void OnMouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left || !(sender is MyBandedGridView))
            {
                return;
            }

            MyBandedGridView  view    = (MyBandedGridView)sender;
            BandedGridHitInfo hitInfo = view.CalcHitInfo(e.X, e.Y);

            if (hitInfo.HitTest == BandedGridHitTest.Band)
            {
                GridBandInfoArgs bandInfo = view.ViewInfo.BandsInfo[hitInfo.Band];
                if (CalcButtonBounds(bandInfo.Bounds).Contains(e.X, e.Y))
                {
                    EditorButtonObjectInfoArgs bandButtonInfo = FindButtonInnerElement(bandInfo);
                    if (bandButtonInfo != null)
                    {
                        for (int i = 0; i < hitInfo.Band.Columns.Count; i++)
                        {
                            if (!((MyBandedGridColumn)hitInfo.Band.Columns[i]).DefaultBandColumn)
                            {
                                hitInfo.Band.Columns[i].Visible = !hitInfo.Band.Columns[i].Visible;
                            }
                        }
                    }

                    ((DXMouseEventArgs)e).Handled = true;
                }
            }
        }
        private void OnMouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left || !(sender is MyBandedGridView))
            {
                return;
            }

            MyBandedGridView  view    = (MyBandedGridView)sender;
            BandedGridHitInfo hitInfo = view.CalcHitInfo(e.X, e.Y);

            if (hitInfo.HitTest == BandedGridHitTest.Band)
            {
                GridBandInfoArgs bandInfo = view.ViewInfo.BandsInfo[hitInfo.Band];
                if (CalcButtonBounds(bandInfo.Bounds).Contains(e.X, e.Y))
                {
                    EditorButtonObjectInfoArgs bandButtonInfo = FindButtonInnerElement(bandInfo);
                    if (bandButtonInfo != null)
                    {
                        bandButtonInfo.State = ObjectState.Pressed;
                        view.InvalidateBandHeader(hitInfo.Band);
                    }

                    ((DXMouseEventArgs)e).Handled = true;
                }
                else
                {
                    view.InvalidateBandHeader(hitInfo.Band);
                }
            }
        }
        private EditorButtonObjectInfoArgs FindButtonInnerElement(GridBandInfoArgs bandInfo)
        {
            EditorButtonObjectInfoArgs retValue = null;

            for (int i = 0; i < bandInfo.InnerElements.Count; i++)
            {
                if (bandInfo.InnerElements[i].ElementInfo is EditorButtonObjectInfoArgs)
                {
                    retValue = (EditorButtonObjectInfoArgs)bandInfo.InnerElements[i].ElementInfo;
                    break;
                }
            }

            return(retValue);
        }
Ejemplo n.º 6
0
        private int GetColumnBestHeight(GridBand column, int width /*, GridBand parent_column*/)
        {
            /*GridBandInfoArgs ex = null;
             *
             * if (parent_column == null)
             *  ex = viewInfo.BandsInfo[column];
             * else
             *  ex = viewInfo.BandsInfo[parent_column].Children[column];
             *
             * GraphicsInfo grInfo = new GraphicsInfo();
             * grInfo.AddGraphics(null);
             * ex.Cache = grInfo.Cache;
             * bool canDrawMore = true;
             * Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.Caption);
             * Size res = ex.InnerElements.CalcMinSize(grInfo.Graphics, ref canDrawMore);
             * res.Height = Math.Max(res.Height, captionSize.Height);
             * res.Width += captionSize.Width;
             * //res = viewInfo.Painter.ElementsPainter.Column.CalcBoundsByClientRectangle(ex, new Rectangle(Point.Empty, res)).Size;
             * grInfo.ReleaseGraphics();
             * return res.Height;*/

            GridBandInfoArgs   ex       = null;
            BandedGridViewInfo viewInfo = GridView.GetViewInfo() as BandedGridViewInfo;

            viewInfo.GInfo.AddGraphics(null);
            ex = new GridBandInfoArgs(null, viewInfo.GInfo.Cache);
            try
            {
                ex.InnerElements.Add(new DrawElementInfo(new GlyphElementPainter(),
                                                         new GlyphElementInfoArgs(viewInfo.View.Images, 0, null),
                                                         StringAlignment.Near));
                ex.SetAppearance(GridView.Appearance.BandPanel);
                ex.Caption     = column.Caption;
                ex.CaptionRect = new Rectangle(0, 0, width, 1000);
            }
            finally
            {
                viewInfo.GInfo.ReleaseGraphics();
            }

            GraphicsInfo grInfo = new GraphicsInfo();

            grInfo.AddGraphics(null);
            ex.Cache = grInfo.Cache;
            Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.Caption);

            return(captionSize.Height);
        }
        private void OnMouseMove(object sender, MouseEventArgs e)
        {
            if (!(sender is MyBandedGridView))
            {
                return;
            }

            MyBandedGridView  view    = (MyBandedGridView)sender;
            BandedGridHitInfo hitInfo = view.CalcHitInfo(e.X, e.Y);

            if (hitInfo.HitTest == BandedGridHitTest.Band)
            {
                GridBandInfoArgs           bandInfo       = view.ViewInfo.BandsInfo[hitInfo.Band];
                EditorButtonObjectInfoArgs bandButtonInfo = FindButtonInnerElement(bandInfo);
                if (bandButtonInfo != null)
                {
                    if (CalcButtonBounds(bandInfo.Bounds).Contains(e.X, e.Y))
                    {
                        bandButtonInfo.State = ObjectState.Hot;
                        view.InvalidateBandHeader(hitInfo.Band);

                        ((DXMouseEventArgs)e).Handled = true;
                    }
                    else
                    {
                        bandButtonInfo.State = ObjectState.Normal;
                        view.InvalidateBandHeader(hitInfo.Band);
                    }
                }
            }
            else
            {
                for (int i = 0; i < view.ViewInfo.BandsInfo.Count; i++)
                {
                    EditorButtonObjectInfoArgs bandButtonInfo = FindButtonInnerElement(view.ViewInfo.BandsInfo[i]);
                    if (bandButtonInfo != null)
                    {
                        bandButtonInfo.State = ObjectState.Normal;
                    }
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Gets the band information.
        /// </summary>
        /// <param name="bands">The bands.</param>
        /// <param name="band">The band.</param>
        /// <returns></returns>
        GridBandInfoArgs getBandInfo(GridBandInfoCollection bands, GridBand band)
        {
            GridBandInfoArgs info = bands[band];

            if (info != null)
            {
                return(info);
            }
            foreach (GridBandInfoArgs bandInfo in bands)
            {
                if (bandInfo.Children != null)
                {
                    info = getBandInfo(bandInfo.Children, band);
                    if (info != null)
                    {
                        return(info);
                    }
                }
            }
            return(null);
        }