Ejemplo n.º 1
0
        /// <summary>
        /// 自定义表头颜色
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bandedGridView1_CustomDrawBandHeader(object sender, BandHeaderCustomDrawEventArgs e)
        {
            //背景颜色没有设置且为空,则默认
            if (e.Band.AppearanceHeader == null || (e.Band.AppearanceHeader.BackColor == Color.Empty && !e.Band.AppearanceHeader.Options.UseBackColor))
            {
                return;
            }
            Rectangle rect = e.Bounds;

            //rect.Inflate(-1, -1);

            // 填充标题颜色.
            e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(180, e.Band.AppearanceHeader.BackColor)), rect);
            e.Appearance.DrawString(e.Cache, e.Info.Caption, e.Info.CaptionRect);
            Pen pen = new Pen(Color.LightGray, 0.1f);

            e.Graphics.DrawRectangle(pen, rect);
            // 绘制过滤和排序按钮.
            foreach (DrawElementInfo info in e.Info.InnerElements)
            {
                if (!info.Visible)
                {
                    continue;
                }
                ObjectPainter.DrawObject(e.Cache, info.ElementPainter, info.ElementInfo);
            }
            e.Handled = true;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Handles the CustomDrawBandHeader event of the _gridView control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="BandHeaderCustomDrawEventArgs"/> instance containing the event data.</param>
 void _gridView_CustomDrawBandHeader(object sender, BandHeaderCustomDrawEventArgs e)
 {
     if (_gridBands.Contains(e.Band))
     {
         e.Handled = true;
     }
 }
Ejemplo n.º 3
0
        private void scheduleGridView_CustomDrawBandHeader(object sender, BandHeaderCustomDrawEventArgs e)
        {
            if (e.Band == null) return;

            if (e.Band.AppearanceHeader.BackColor != Color.Empty)
            {
                e.Info.AllowColoring = true;
            }
        }
        private Rectangle CalcCaptionRectWithButton(BandHeaderCustomDrawEventArgs e, bool addButtonWidth)
        {
            Rectangle captionRect = e.Info.CaptionRect;

            if (addButtonWidth)
            {
                captionRect.X += CalcButtonBounds(e.Bounds).Width;
            }
            else
            {
                captionRect.X -= CalcButtonBounds(e.Bounds).Width;
            }

            return(captionRect);
        }
        private void OnCustomDrawBandHeader(object sender, BandHeaderCustomDrawEventArgs e)
        {
            if (e.Band == null)
            {
                return;
            }
            //...
            DrawElementInfo buttonElementInfo = null;

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

            if (buttonElementInfo == null)
            {
                ButtonPredefines buttonKind = ButtonPredefines.Minus;
                if (GetBandColumnsDefaultOnlyVisibility(e.Band))
                {
                    buttonKind = ButtonPredefines.Plus;
                }

                EditorButton               button         = new EditorButton(buttonKind);
                EditorButtonPainter        buttonPainter  = EditorButtonHelper.GetPainter(BorderStyles.Default);
                EditorButtonObjectInfoArgs buttonInfoArgs = new EditorButtonObjectInfoArgs(e.Cache, button, e.Info.Appearance);

                buttonElementInfo = new DrawElementInfo(buttonPainter, buttonInfoArgs);
                buttonElementInfo.ElementInfo.Bounds = CalcButtonBounds(e.Bounds);
                buttonElementInfo.ElementInfo.State  = ObjectState.Normal;

                e.Info.InnerElements.Add(buttonElementInfo);
                e.Info.CaptionRect = CalcCaptionRectWithButton(e, true);
            }

            e.Painter.DrawObject(e.Info);
            e.Handled = true;
        }
Ejemplo n.º 6
0
        private void BandedViewCustomDrawBandHeader(object sender, BandHeaderCustomDrawEventArgs e)
        {
            if (sender.GetType() != typeof(BandedGridView) || sender.GetType() != typeof(AdvBandedGridView))
            {
                return;
            }
            if (e.Band == null)
            {
                return;
            }
            CustomDrawBandHeader?.Invoke(sender, e);

            if (e.Band.Caption == string.Empty)
            {
                var rect = e.Bounds;
                if (_bandHeight == 0)
                {
                    _bandHeight = e.Bounds.Height + 2;
                }

                rect.Height   = _bandHeight;
                e.Info.Bounds = rect;
            }
        }
Ejemplo n.º 7
0
        private void viewLevers_CustomDrawBandHeader(object sender, BandHeaderCustomDrawEventArgs e)
        {
            if (e.Band != null)
            {
                var rect = e.Bounds;
                ControlPaint.DrawBorder3D(e.Graphics, e.Bounds);
                var backColor = e.Band.AppearanceHeader.BackColor;

                if (e.Band.Caption == string.Empty)
                    backColor = Color.LightYellow;

                var brush = e.Cache.GetGradientBrush(rect, backColor, e.Band.AppearanceHeader.BackColor2, e.Band.AppearanceHeader.GradientMode);
                rect.Inflate(-1, -1);

                // Fill column headers with the specified colors.
                e.Graphics.FillRectangle(brush, rect);
                e.Appearance.DrawString(e.Cache, e.Info.Caption, e.Info.CaptionRect);

                // Draw the filter and sort buttons.
                foreach (DevExpress.Utils.Drawing.DrawElementInfo info in e.Info.InnerElements)
                    DevExpress.Utils.Drawing.ObjectPainter.DrawObject(e.Cache, info.ElementPainter, info.ElementInfo);
            }
            e.Handled = true;
        }
Ejemplo n.º 8
0
        private void gvwBase_CustomDrawBandHeader(object sender, BandHeaderCustomDrawEventArgs e)
        {
            try
            {
                if (e.Band == null)
                {
                    return;
                }
                bool boBorder = false;


                if (e.Band.HasChildren)
                {
                    if (e.Band.Children[0].Columns.Count > 0)
                    {
                        if (e.Band.Children[0].Columns[0].Caption == _CurrentDay)
                        {
                            boBorder = true;
                        }
                    }
                }
                else
                {
                    if (e.Band.Columns.Count > 0)
                    {
                        if (e.Band.Columns[0].Caption == _CurrentDay)
                        {
                            boBorder = true;
                        }
                    }
                }

                if (boBorder)
                {
                    Rectangle rect = e.Bounds;
                    rect.Inflate(new Size(1, 1));

                    Brush brush = new SolidBrush(Color.DodgerBlue);
                    e.Graphics.FillRectangle(brush, rect);
                    Pen pen_horizental = new Pen(Color.Blue, 3F);
                    Pen pen_vertical   = new Pen(Color.Blue, 4F);


                    // e.Graphics.DrawLine(pen_horizental, rect.X, rect.Y, rect.X + rect.Width, rect.Y);
                    // draw right
                    // e.Graphics.DrawLine(pen_vertical, rect.X + rect.Width - 2, rect.Y, rect.X + rect.Width - 2, rect.Y + rect.Height);


                    // draw left
                    //  e.Graphics.DrawLine(pen_horizental, rect.X + 1, rect.Y, rect.X + 1, rect.Y + rect.Height);


                    e.Graphics.DrawString(_CurrentDay, e.Appearance.Font, new SolidBrush(Color.White), rect, e.Appearance.GetStringFormat());
                    e.Handled = true;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
Ejemplo n.º 9
0
        private void advBandedGridViewPublication_CustomDrawBandHeader(object sender, BandHeaderCustomDrawEventArgs e)
        {
            if (e.Band == null)
            {
                return;
            }
            if (e.Band != gridBandDiscounts && e.Band != gridBandColorPricing)
            {
                return;
            }
            var rect = e.Bounds;

            ControlPaint.DrawBorder3D(e.Graphics, e.Bounds);
            var brush =
                e.Cache.GetGradientBrush(rect, e.Band.AppearanceHeader.BackColor,
                                         e.Band.AppearanceHeader.BackColor2, e.Band.AppearanceHeader.GradientMode);

            rect.Inflate(-1, -1);
            e.Graphics.FillRectangle(brush, rect);
            e.Appearance.DrawString(e.Cache, e.Info.Caption, e.Info.CaptionRect);
            e.Painter.DrawObject(e.Info);

            Image img = null;

            if (e.Band == gridBandDiscounts)
            {
                img = imageList.Images[0];
            }
            else if (e.Band == gridBandColorPricing)
            {
                img = PrintProduct.ColorOption == ColorOptions.BlackWhite ? null : imageList.Images[1];
            }
            if (img != null)
            {
                var p = Point.Empty;
                p.X = (e.Bounds.Width - (img.Width + (int)e.Graphics.MeasureString(e.Info.Caption, advBandedGridViewPublication.Appearance.BandPanel.Font).Width + 15)) / 2 + e.Bounds.Left;
                p.Y = (e.Bounds.Height - img.Height) / 2 + e.Bounds.Top;
                e.Graphics.DrawImage(img, p);
            }

            e.Handled = true;
        }
Ejemplo n.º 10
0
		private void advBandedGridViewPublication_CustomDrawBandHeader(object sender, BandHeaderCustomDrawEventArgs e)
		{
			if (e.Band == null) return;
			if (e.Band != gridBandDiscounts && e.Band != gridBandColorPricing) return;
			var rect = e.Bounds;
			ControlPaint.DrawBorder3D(e.Graphics, e.Bounds);
			var brush =
				e.Cache.GetGradientBrush(rect, e.Band.AppearanceHeader.BackColor,
					e.Band.AppearanceHeader.BackColor2, e.Band.AppearanceHeader.GradientMode);
			rect.Inflate(-1, -1);
			e.Graphics.FillRectangle(brush, rect);
			e.Appearance.DrawString(e.Cache, e.Info.Caption, e.Info.CaptionRect);
			e.Painter.DrawObject(e.Info);

			Image img = null;
			if (e.Band == gridBandDiscounts)
				img = imageList.Images[0];
			else if (e.Band == gridBandColorPricing)
				img = PrintProduct.ColorOption == ColorOptions.BlackWhite ? null : imageList.Images[1];
			if (img != null)
			{
				var p = Point.Empty;
				p.X = (e.Bounds.Width - (img.Width + (int)e.Graphics.MeasureString(e.Info.Caption, advBandedGridViewPublication.Appearance.BandPanel.Font).Width + 15)) / 2 + e.Bounds.Left;
				p.Y = (e.Bounds.Height - img.Height) / 2 + e.Bounds.Top;
				e.Graphics.DrawImage(img, p);
			}

			e.Handled = true;
		}