예제 #1
0
        protected Size GetLabelSize(TreeNodeAdv node, DrawContext context, string label)
        {
            PerformanceAnalyzer.Start("GetLabelSize");
            CheckThread();
            Font font = GetDrawingFont(node, context, label);
            Size s    = Size.Empty;

            if (UseCompatibleTextRendering)
            {
                s = TextRenderer.MeasureText(label, font, s, TextFormatFlags.NoPrefix);
            }
            else
            {
                SizeF sf = context.Graphics.MeasureString(label, font);
                s = new Size((int)Math.Ceiling(sf.Width), (int)Math.Ceiling(sf.Height));
            }
            PerformanceAnalyzer.Finish("GetLabelSize");

            if (!s.IsEmpty)
            {
                return(s);
            }
            else
            {
                return(new Size(10, Font.Height));
            }
        }
		private void DrawColumnHeaders(Graphics gr)
		{
			PerformanceAnalyzer.Start("DrawColumnHeaders");
			ReorderColumnState reorder = Input as ReorderColumnState;
			int x = 0;
			TreeColumn.DrawBackground(gr, new Rectangle(0, 0, ClientRectangle.Width + 2, ColumnHeaderHeight - 1), false, false);
			gr.TranslateTransform(-OffsetX, 0);
			foreach (TreeColumn c in Columns)
			{
				if (c.IsVisible)
				{
					if (x >= OffsetX && x - OffsetX < this.Bounds.Width)// skip invisible columns
					{
						Rectangle rect = new Rectangle(x, 0, c.Width, ColumnHeaderHeight - 1);
						gr.SetClip(rect);
						bool pressed = ((Input is ClickColumnState || reorder != null) && ((Input as ColumnState).Column == c));
						c.Draw(gr, rect, Font, pressed, _hotColumn == c);
						gr.ResetClip();

						if (reorder != null && reorder.DropColumn == c)
							TreeColumn.DrawDropMark(gr, rect);
					}
					x += c.Width;
				}
			}

			if (reorder != null)
			{
				if (reorder.DropColumn == null)
					TreeColumn.DrawDropMark(gr, new Rectangle(x, 0, 0, ColumnHeaderHeight));
				gr.DrawImage(reorder.GhostImage, new Point(reorder.Location.X +  + reorder.DragOffset, reorder.Location.Y));
			}
			PerformanceAnalyzer.Finish("DrawColumnHeaders");
		}
예제 #3
0
        protected Size GetLabelSize(DrawContext context, string label)
        {
            PerformanceAnalyzer.Start("GetLabelSize");

            Font font = GetDrawingFont(context, label);
            Size s    = Size.Empty;

            if (!UseCompatibleTextRendering)
            {
                s = TextRenderer.MeasureText(label, font);
            }
            else
            {
                SizeF sf = context.Graphics.MeasureString(label, font);
                s = new Size((int)Math.Ceiling(sf.Width), (int)Math.Ceiling(sf.Height));
            }

            PerformanceAnalyzer.Finish("GetLabelSize");

            if (!s.IsEmpty)
            {
                return(s);
            }
            else
            {
                return(new Size(10, font.Height));
            }
        }
예제 #4
0
        public override void Draw(TreeNodeAdv node, DrawContext context)
        {
            if (context.CurrentEditorOwner == this &&
                node == Parent.CurrentNode &&
                !this.EditorDisposing)
            {
                return;
            }

            PerformanceAnalyzer.Start("BaseTextControl.Draw");
            string    label     = GetLabel(node);
            Rectangle bounds    = GetBounds(node, context);
            Rectangle focusRect = new Rectangle(bounds.X, context.Bounds.Y,
                                                bounds.Width, context.Bounds.Height);

            Brush backgroundBrush;
            Color textColor;
            Font  font;

            CreateBrushes(node, context, label, out backgroundBrush, out textColor, out font, ref label);

            if (backgroundBrush != null)
            {
                context.Graphics.FillRectangle(backgroundBrush, focusRect);
            }
            if (context.DrawFocus)
            {
                focusRect.Width--;
                focusRect.Height--;
                if (context.DrawSelection == DrawSelectionMode.None)
                {
                    _focusPen.Color = SystemColors.ControlText;
                }
                else
                {
                    _focusPen.Color = SystemColors.InactiveCaption;
                }
                context.Graphics.DrawRectangle(_focusPen, focusRect);
            }

            PerformanceAnalyzer.Start("BaseTextControl.DrawText");

            if (!UseCompatibleTextRendering)
            {
                TextRenderer.DrawText(context.Graphics, label, font, bounds, textColor, _formatFlags);
            }
            else
            {
                context.Graphics.DrawString(label, font, GetFrush(textColor), bounds, _format);
            }
            PerformanceAnalyzer.Finish("BaseTextControl.DrawText");

            PerformanceAnalyzer.Finish("BaseTextControl.Draw");
        }
예제 #5
0
        public override void Draw(TreeNodeAdv node, DrawContext context)
        {
            if (context.CurrentEditorOwner == this && node == Parent.CurrentNode)
            {
                return;
            }

            PerformanceAnalyzer.Start("BaseTextControl.Draw");

            Rectangle bounds    = GetBounds(node, context);
            Rectangle focusRect = new Rectangle(bounds.X, context.Bounds.Y,
                                                bounds.Width, context.Bounds.Height);

            DrawEventArgs args;

            CreateBrushes(node, context, out args);

            if (args.BackgroundBrush != null)
            {
                context.Graphics.FillRectangle(args.BackgroundBrush, focusRect);
            }
            if (context.DrawFocus)
            {
                focusRect.Width--;
                focusRect.Height--;
                if (context.DrawSelection == DrawSelectionMode.None)
                {
                    _focusPen.Color = SystemColors.ControlText;
                }
                else
                {
                    _focusPen.Color = SystemColors.InactiveCaption;
                }
                context.Graphics.DrawRectangle(_focusPen, focusRect);
            }

            PerformanceAnalyzer.Start("BaseTextControl.DrawText");

            DrawHighLight(context, bounds, args);

            if (!UseCompatibleTextRendering)
            {
                TextRenderer.DrawText(context.Graphics, args.Text, args.Font, bounds, args.TextColor, _formatFlags);
            }
            else
            {
                context.Graphics.DrawString(args.Text, args.Font, GetFrush(args.TextColor), bounds, _format);
            }


            PerformanceAnalyzer.Finish("BaseTextControl.DrawText");
            PerformanceAnalyzer.Finish("BaseTextControl.Draw");
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            BeginPerformanceCount();
			PerformanceAnalyzer.Start("OnPaint");

            DrawContext context = new DrawContext();
            context.Graphics = e.Graphics;
            context.Font = this.Font;
            context.Enabled = Enabled;

            int y = 0;
            int gridHeight = 0;

            if (UseColumns)
            {
				DrawColumnHeaders(e.Graphics);
				y += ColumnHeaderHeight;
                if (Columns.Count == 0 || e.ClipRectangle.Height <= y)
                    return;
            }

			int firstRowY = _rowLayout.GetRowBounds(FirstVisibleRow).Y;
            y -= firstRowY;

            e.Graphics.ResetTransform();
            e.Graphics.TranslateTransform(-OffsetX, y);
            Rectangle displayRect = DisplayRectangle;
            for (int row = FirstVisibleRow; row < RowCount; row++)
            {
                Rectangle rowRect = _rowLayout.GetRowBounds(row);
                gridHeight += rowRect.Height;
                if (rowRect.Y + y > displayRect.Bottom)
                    break;
                else
                    DrawRow(e, ref context, row, rowRect);
            }

			if ((GridLineStyle & GridLineStyle.Vertical) == GridLineStyle.Vertical && UseColumns)
				DrawVerticalGridLines(e.Graphics, firstRowY);

			if (_dropPosition.Node != null && DragMode && HighlightDropPosition)
                DrawDropMark(e.Graphics);

            e.Graphics.ResetTransform();
            DrawScrollBarsBox(e.Graphics);

            if (DragMode && _dragBitmap != null)
                e.Graphics.DrawImage(_dragBitmap, PointToClient(MousePosition));

			PerformanceAnalyzer.Finish("OnPaint");
			EndPerformanceCount(e);
        }