예제 #1
0
		public static void Paint(SimpleNodeDisplayInfo di)
		{
			Rectangle r=di.Element.Bounds;
			//di.Graphics.SetClip(r);

            Region oldClip = di.Graphics.Clip;
            if (oldClip != null)
                di.Graphics.SetClip(r, CombineMode.Intersect);
            else
                di.Graphics.SetClip(r, CombineMode.Replace);


			//r.Inflate(1,1);
			ElementStyleDisplayInfo displayInfo=new ElementStyleDisplayInfo(di.Style,di.Graphics,r);
			ElementStyleDisplay.Paint(displayInfo);
			di.Graphics.ResetClip();

			if(di.Element.ImageVisible)
				SimpleNodeDisplay.PaintImage(di);
			if(di.Element.TextVisible)
			{
				displayInfo.Bounds=(di.TextBounds.IsEmpty?di.Element.TextBounds:di.TextBounds);
                eTextFormat format = di.Style.TextFormat;
                if (di.RightToLeft)
                    format |= eTextFormat.RightToLeft;
				ElementStyleDisplay.PaintText(displayInfo,di.Element.Text,di.Font, false, format);
			}

            if (oldClip != null)
                di.Graphics.Clip = oldClip;
            else
                di.Graphics.ResetClip();
		}
예제 #2
0
        private void PaintGroup(ItemPaintArgs pa, RibbonTabItemGroup group, Rectangle rect, Rectangle groupBounds)
        {
            if (m_CaptionVisible && !m_QuickToolbarBounds.IsEmpty && rect.IntersectsWith(m_QuickToolbarBounds) || m_SystemCaptionItemBounds.IntersectsWith(groupBounds))
                return;
            eDotNetBarStyle effectiveStyle = this.EffectiveStyle;

            if (effectiveStyle == eDotNetBarStyle.Office2010 || effectiveStyle == eDotNetBarStyle.Metro)
                group.DisplayPositions.Add(new Rectangle(rect.X, rect.Y, rect.Width + 1, rect.Height));
            else
                group.DisplayPositions.Add(rect);


            if (BarFunctions.IsOffice2007Style(effectiveStyle))
            {
                RibbonTabGroupRendererEventArgs e = new RibbonTabGroupRendererEventArgs(pa.Graphics, group, rect, groupBounds, this.GetDefaultGroupFont(), pa, effectiveStyle);
                Rendering.BaseRenderer renderer = GetRenderer();
                renderer.DrawRibbonTabGroup(e);
            }
            else
            {
                ElementStyleDisplayInfo info = new ElementStyleDisplayInfo(group.Style, pa.Graphics, rect);
                ElementStyleDisplay.Paint(info);
                ElementStyleDisplay.PaintText(info, group.GroupTitle, this.GetDefaultGroupFont());
            }
        }
예제 #3
0
		protected override void PaintControlBackground(ItemPaintArgs pa)
		{
            bool mouseOver = m_MouseOver;
            bool fade = m_FadeImageState!=null;

            if (fade)
                mouseOver = false;
            GraphicsPath insideClip = null;
            ElementStyle backStyle = GetBackgroundStyle();
            bool disposeBackStyle = fade;
            try
            {
                if (backStyle != null)
                {
                    Rectangle r = GetBackgroundRectangle();
                    pa.Graphics.SetClip(r, CombineMode.Replace);
                    ElementStyle mouseOverStyle = GetBackgroundMouseOverStyle();
                    if (mouseOver && backStyle != null && mouseOverStyle != null && mouseOverStyle.Custom)
                    {
                        backStyle = backStyle.Copy();
                        disposeBackStyle = true;
                        backStyle.ApplyStyle(mouseOverStyle);
                    }

                    ElementStyleDisplayInfo displayInfo = new ElementStyleDisplayInfo(backStyle, pa.Graphics, r, EffectiveStyle == eDotNetBarStyle.Office2007);
                    ElementStyleDisplay.Paint(displayInfo);
                    pa.Graphics.ResetClip();
                    displayInfo.Bounds = GetBackgroundRectangle();
                    // Adjust so the title shows over the inside light border line
                    displayInfo.Bounds.X--;
                    displayInfo.Bounds.Width++;
                    insideClip = ElementStyleDisplay.GetInsideClip(displayInfo);
                    displayInfo.Bounds.X++;
                    displayInfo.Bounds.Width--;
                }

                if (insideClip != null)
                    pa.Graphics.SetClip(insideClip, CombineMode.Replace);

                m_DialogLauncherRect = Rectangle.Empty;

                if (m_TitleVisible && !this.OverflowState)
                {
                    ElementStyle style = GetTitleStyle();
                    ElementStyle styleMouseOver = GetTitleMouseOverStyle();
                    if (mouseOver && style != null && styleMouseOver != null && styleMouseOver.Custom)
                    {
                        style = style.Copy();
                        style.ApplyStyle(styleMouseOver);
                    }

                    if (style != null)
                    {
                        SimpleNodeDisplayInfo info = new SimpleNodeDisplayInfo(style, pa.Graphics, m_TitleElement, this.Font, (this.RightToLeft == RightToLeft.Yes));
                        if (m_DialogLauncherVisible)
                        {
                            if (m_DialogLauncherButton == null)
                            {
                                Rectangle textRect = m_TitleElement.TextBounds;
                                textRect.Width -= m_TitleRectangle.Height;
                                if (this.RightToLeft == RightToLeft.Yes)
                                    textRect.X += m_TitleRectangle.Height;
                                info.TextBounds = textRect;
                            }
                            else
                            {
                                if (m_MouseOverDialogLauncher && m_DialogLauncherMouseOverButton != null)
                                    m_TitleElement.Image = m_DialogLauncherMouseOverButton;
                                else
                                    m_TitleElement.Image = m_DialogLauncherButton;
                            }
                        }

                        SimpleNodeDisplay.Paint(info);

                        if (m_DialogLauncherVisible && m_TitleElement.Image == null)
                            PaintDialogLauncher(pa);
                        else
                            m_DialogLauncherRect = m_TitleElement.ImageBounds;
                    }
                }

                pa.Graphics.ResetClip();

                m_FadeImageLock.AcquireReaderLock(-1);
                try
                {
                    if (m_FadeImageState != null)
                    {
                        Graphics g = pa.Graphics;
                        Rectangle r = new Rectangle(0, 0, this.Width, this.Height);

                        System.Drawing.Imaging.ColorMatrix matrix1 = new System.Drawing.Imaging.ColorMatrix();
                        matrix1[3, 3] = (float)((float)m_FadeAlpha / 255);
                        using (System.Drawing.Imaging.ImageAttributes imageAtt = new System.Drawing.Imaging.ImageAttributes())
                        {
                            imageAtt.SetColorMatrix(matrix1);

                            g.DrawImage(m_FadeImageState, r, 0, 0, r.Width, r.Height, GraphicsUnit.Pixel, imageAtt);
                        }
                        return;
                    }
                }
                finally
                {
                    m_FadeImageLock.ReleaseReaderLock();
                }
            }
            finally
            {
                if (insideClip != null) insideClip.Dispose();
                if (disposeBackStyle && backStyle != null) backStyle.Dispose();
            }
		}
예제 #4
0
        /// <summary>
        /// Paints insides of the control.
        /// </summary>
        /// <param name="e">Paint event arguments.</param>
        protected override void PaintInnerContent(PaintEventArgs e, ElementStyle style, bool paintText)
        {
            base.PaintInnerContent(e, style, false);
            if (!paintText)
                return;

            Rectangle r = this.ClientRectangle;
            r.X += ElementStyleLayout.LeftWhiteSpace(this.Style);
            r.Width -= ElementStyleLayout.HorizontalStyleWhiteSpace(this.Style);
            r.Y += ElementStyleLayout.TopWhiteSpace(this.Style);
            r.Height -= ElementStyleLayout.VerticalStyleWhiteSpace(this.Style);
            if (r.Width <= 4 || r.Height <= 4) return;

            Graphics g = e.Graphics;

            Font font = this.Font;
            if (this.Style.Font != null)
                font = this.Style.Font;
            Font headerFont = new Font(font, (m_ShowTooltipDescription || m_HeaderText == "") ? FontStyle.Bold : FontStyle.Regular);
            Padding headerPadding = GetHeaderPadding();
            Padding footerPadding = GetFooterPadding();
            Padding textPadding = GetTextPadding();
            Padding imagePadding = GetImagePadding();

            try
            {
                ElementStyleDisplayInfo info = new ElementStyleDisplayInfo(style, g, Rectangle.Empty);
                if (m_HeaderText != "" && HeaderVisible)
                {
                    Rectangle headerRect = new Rectangle(r.X + headerPadding.Left, r.Y + headerPadding.Top, r.Width - headerPadding.Horizontal, r.Height - headerPadding.Vertical);
                    Size headerSize = Size.Empty;
                    if (m_HeaderMarkup == null)
                    {
                        info.Bounds = headerRect;
                        eTextFormat format = eTextFormat.Default | eTextFormat.WordBreak;
                        if (this.RightToLeft == RightToLeft.Yes) format |= eTextFormat.RightToLeft;
                        ElementStyleDisplay.PaintText(info, m_HeaderText, headerFont, true, format);
                        headerSize = TextDrawing.MeasureString(g, m_HeaderText, headerFont, headerRect.Width, format);
                    }
                    else if(headerRect.Width>0 && headerRect.Height>0)
                    {
                        TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, info.Style.TextColor,
                            (this.RightToLeft == RightToLeft.Yes), headerRect, true);
                        m_HeaderMarkup.Arrange(headerRect, d);
                        m_HeaderMarkup.Render(d);
                        headerSize = m_HeaderMarkup.Bounds.Size;
                    }
                    headerSize.Width += headerPadding.Horizontal;
                    headerSize.Height += headerPadding.Vertical;
                    r.Y += headerSize.Height;
                    r.Height -= headerSize.Height;
                }

                if (m_FooterText != "" && FooterVisible && r.Width>0 && r.Height>0 && (m_ShowTooltipDescription || m_HeaderText==""))
                {
                    Size footerSize = Size.Empty;
                    eTextFormat format = eTextFormat.Default | eTextFormat.WordBreak;
                    if (m_FooterMarkup == null)
                        footerSize = TextDrawing.MeasureString(g, m_FooterText, headerFont, r.Width - footerPadding.Horizontal, format);
                    else
                        footerSize = m_FooterMarkup.Bounds.Size;

                    if (m_FooterImage != null && m_FooterImage.Height > footerSize.Height)
                        footerSize.Height = m_FooterImage.Height;

                    Rectangle footerRect = new Rectangle(r.X+footerPadding.Left,
                        r.Bottom-footerSize.Height-footerPadding.Bottom,
                        r.Width - footerPadding.Horizontal, footerSize.Height);
                    if (this.FooterSeparator)
                    {
                        using (Pen pen = new Pen(style.BorderColor, 1))
                            g.DrawLine(pen, 0, footerRect.Y - footerPadding.Top - 1, this.ClientRectangle.Right, footerRect.Y - footerPadding.Top - 1);
                    }
                    if (m_FooterImage != null)
                    {
                        g.DrawImage(m_FooterImage, new Rectangle(footerRect.X, footerRect.Y + (footerRect.Height - m_FooterImage.Height) / 2, m_FooterImage.Width, m_FooterImage.Height));
                        footerRect.X += (m_FooterImage.Width + m_FooterImageSpacing);
                        footerRect.Width -= (m_FooterImage.Width + m_FooterImageSpacing);
                    }
                    if (footerRect.Width > 0 && footerRect.Height > 0)
                    {
                        if (m_FooterMarkup == null)
                        {
                            info.Bounds = footerRect;

                            format |= eTextFormat.VerticalCenter;
                            if (this.RightToLeft == RightToLeft.Yes) format |= eTextFormat.RightToLeft;
                            ElementStyleDisplay.PaintText(info, m_FooterText, headerFont, true, format);
                        }
                        else
                        {
                            TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, info.Style.TextColor,
                            (this.RightToLeft == RightToLeft.Yes), footerRect, true);
                            m_FooterMarkup.Arrange(footerRect, d);
                            m_FooterMarkup.Render(d);
                            footerSize = m_FooterMarkup.Bounds.Size;
                        }
                    }

                    footerSize.Width += footerPadding.Horizontal;
                    footerSize.Height += footerPadding.Vertical;
                    r.Height -= footerSize.Height;
                }

                if (m_ShowTooltipDescription || m_HeaderText == "")
                {
                    if (m_BodyImage != null)
                    {
                        Rectangle imageRect = new Rectangle(r.X + imagePadding.Left, r.Y + imagePadding.Top, m_BodyImage.Width, m_BodyImage.Height);
                        g.DrawImage(m_BodyImage, imageRect);
                        r.X += (imagePadding.Horizontal + m_BodyImage.Width);
                        r.Width -= (imagePadding.Horizontal + m_BodyImage.Width);
                    }

                    if (this.Text != "" && r.Width > 0 && r.Height > 0)
                    {
                        Rectangle textRect = new Rectangle(r.X + textPadding.Left, r.Y + textPadding.Top, r.Width - textPadding.Horizontal, r.Height - textPadding.Vertical);
                        if (m_BodyMarkup == null)
                        {
                            info.Bounds = textRect;
                            if (textRect.Width > 0 && textRect.Height > 0)
                            {
                                eTextFormat format = info.Style.TextFormat;
                                if (this.RightToLeft == RightToLeft.Yes) format |= eTextFormat.RightToLeft;
                                ElementStyleDisplay.PaintText(info, this.Text, font, false, format);
                            }
                        }
                        else if (textRect.Width > 0 && textRect.Height > 0)
                        {
                            TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, info.Style.TextColor,
                                (this.RightToLeft == RightToLeft.Yes), textRect, true);
                            m_BodyMarkup.Arrange(textRect, d);
                            m_BodyMarkup.Render(d);
                        }
                    }
                }
            }
            finally
            {
                headerFont.Dispose();
            }

        }
예제 #5
0
        private void PaintTitle(ItemPaintArgs p)
        {
            if (string.IsNullOrEmpty(_TitleText)) return;

            Rectangle r = new Rectangle(this.DisplayRectangle.X, this.DisplayRectangle.Y, this.DisplayRectangle.Width, _TitleSize.Height);
            if (_TitlePosition == eTitlePosition.Bottom)
                r.Y = this.DisplayRectangle.Bottom - _TitleSize.Height;
            
            Graphics g = p.Graphics;
            Font font = p.Font;

            if (_TitleStyle.Custom)
            {
                bool dispose = false;
                ElementStyle style = ElementStyleDisplay.GetElementStyle(_TitleStyle, out dispose);

                ElementStyleDisplayInfo di = new ElementStyleDisplayInfo(style, g, r);
                ElementStyleDisplay.Paint(di);
                ElementStyleDisplay.PaintText(di, _TitleText, font);
                if (dispose) style.Dispose();
            }
            else
            {
                TextDrawing.DrawString(g, _TitleText, font, SystemColors.ControlText, r, eTextFormat.Default);
            }
        }
예제 #6
0
        protected virtual void PaintControlBackground(ItemPaintArgs pa)
		{
            ElementStyle style = GetBackgroundStyle();
			if(style!=null)
			{
                Rectangle r = GetPaintControlBackgroundRectangle();
				ElementStyleDisplayInfo displayInfo=new ElementStyleDisplayInfo(style,pa.Graphics,r);
				ElementStyleDisplay.Paint(displayInfo);
			}
		}
예제 #7
0
        /// <summary>
        /// Paints ribbon tab group.
        /// </summary>
        /// <param name="e">Context information</param>
        public override void PaintTabGroup(RibbonTabGroupRendererEventArgs e)
        {
            Graphics g = e.Graphics;
            Office2007RibbonTabGroupColorTable colorTable = GetColors(e.RibbonTabItemGroup);
            if (colorTable == null)
                return;
            #if FRAMEWORK20
            if (e.ItemPaintArgs.GlassEnabled)
            {
                if (e.ItemPaintArgs.CachedPaint) return;
                PaintTabGroupBackground(g, colorTable, e.Bounds, e.GroupBounds, true);
                
                Rectangle rect = e.Bounds;
                rect.Height -= 2;
                IntPtr hdc = g.GetHdc();
                Font font = e.GroupFont;
                string text = e.RibbonTabItemGroup.GroupTitle;
                ThemeTextFormat tf = GetThemeFormat();
                try
                {
                    IntPtr memdc = WinApi.CreateCompatibleDC(hdc);
                    try
                    {
                        WinApi.BITMAPINFO bmpInfo = new WinApi.BITMAPINFO();
                        bmpInfo.biWidth = rect.Width;
                        bmpInfo.biHeight = -rect.Height;
                        bmpInfo.biPlanes = 1;
                        bmpInfo.biBitCount = 32;
                        bmpInfo.biSize = Marshal.SizeOf(bmpInfo);
                        IntPtr dib = WinApi.CreateDIBSection(hdc, bmpInfo, 0, 0, IntPtr.Zero, 0);
                        WinApi.SelectObject(memdc, dib);

                        IntPtr fontHandle = font.ToHfont();
                        WinApi.SelectObject(memdc, fontHandle);

                        Themes.RECT bounds = GetThemeTextBounds(rect);
                        System.Windows.Forms.VisualStyles.VisualStyleRenderer themeRenderer = new System.Windows.Forms.VisualStyles.VisualStyleRenderer(System.Windows.Forms.VisualStyles.VisualStyleElement.Window.Caption.Active);
                        Themes.DTTOPTS dttOpts = new Themes.DTTOPTS();
                        dttOpts.iGlowSize = 10;
                        dttOpts.crText = new Themes.COLORREF(colorTable.Text);
                        dttOpts.dwFlags = (int)Themes.DTT_VALIDBITS.DTT_COMPOSITED | (int)Themes.DTT_VALIDBITS.DTT_TEXTCOLOR;
                        if (colorTable.Background == null || colorTable.Background.IsEmpty || colorTable.Background.Start.A < 255)
                            dttOpts.dwFlags |= (int)Themes.DTT_VALIDBITS.DTT_GLOWSIZE;
                        dttOpts.dwSize = Marshal.SizeOf(dttOpts);
                        
                        // Draw Background
                        using (Graphics gb = Graphics.FromHdc(memdc))
                        {
                            PaintTabGroupBackground(gb, colorTable, new Rectangle(0, 0, rect.Width, rect.Height + 2), new Rectangle(0, 0, rect.Width, rect.Height + 2), true);
                        }
                        
                        Themes.DrawThemeTextEx(themeRenderer.Handle, memdc, 0, 0, text, -1, (int)tf, ref bounds, ref dttOpts);
                        

                        const int SRCCOPY = 0x00CC0020;
                        WinApi.BitBlt(hdc, rect.Left, rect.Top, rect.Width, rect.Height, memdc, 0, 0, SRCCOPY);

                        WinApi.DeleteObject(fontHandle);
                        WinApi.DeleteObject(dib);
                    }
                    finally
                    {
                        WinApi.DeleteDC(memdc);
                    }
                }
                finally
                {
                    g.ReleaseHdc(hdc);
                }
                return;
            }
            #endif

            PaintTabGroupBackground(g, colorTable, e.Bounds, e.GroupBounds, false);
            ElementStyle style = e.RibbonTabItemGroup.Style; //.Copy();
            Color styleTextColor = style.TextColor;
            Color styleTextShadowColor = style.TextShadowColor;
            Point styleTextShadowOffset = style.TextShadowOffset;
            style.FreezeEvents = true;
            style.TextColor = colorTable.Text;
            style.TextShadowColor = Color.Empty;
            style.TextShadowOffset = Point.Empty;

            ElementStyleDisplayInfo info = new ElementStyleDisplayInfo(style, e.Graphics, GetTextBounds(e));
            ElementStyleDisplay.PaintText(info, e.RibbonTabItemGroup.GroupTitle, e.GroupFont, false, e.RibbonTabItemGroup.Style.TextFormat | GetTextFormat());

            style.TextColor = styleTextColor;
            style.TextShadowColor = styleTextShadowColor;
            style.TextShadowOffset = styleTextShadowOffset;
            style.FreezeEvents = false;
        }
예제 #8
0
        internal void DrawColumnHeader(ColumnHeaderRendererEventArgs e, ElementStyleDisplayInfo di)
        {
            // Adjust the header bounds so the header is filled completely
            if (e.Tree != null && e.Tree.CellHorizontalSpacing > 0 && !e.ColumnHeader.IsFirstVisible) {
                Rectangle ob = di.Bounds;
                di.Bounds = new Rectangle(ob.X - e.Tree.CellHorizontalSpacing, ob.Y, ob.Width + e.Tree.CellHorizontalSpacing, ob.Height);
                ElementStyleDisplay.Paint(di);
                di.Bounds = ob;
            }
            else
                ElementStyleDisplay.Paint(di);
            di.Bounds.Inflate(-1, -1);
            if (di.Bounds.Width > 1 && di.Bounds.Height > 1)
            {
                if (e.ColumnHeader.IsFirstVisible)
                {
                    Rectangle r = di.Bounds;
                    r.Width -= 3;
                    r.X += 3;
                    di.Bounds = r;
                }

                if (e.ColumnHeader.SortDirection != eSortDirection.None && !e.SortIndicatorColor.IsEmpty)
                {
                    using (GraphicsPath sortShapePath = UIGraphics.GetTrianglePath(
                        new Point(di.Bounds.Right - 11, di.Bounds.Y + (di.Bounds.Height - 5) / 2), 9, 
                        (e.ColumnHeader.SortDirection == eSortDirection.Ascending ? eTriangleDirection.Top : eTriangleDirection.Bottom)))
                    {
                        SmoothingMode sm = e.Graphics.SmoothingMode;
                        e.Graphics.SmoothingMode = SmoothingMode.Default;
                        using (SolidBrush brush = new SolidBrush(e.SortIndicatorColor))
                            e.Graphics.FillPath(brush, sortShapePath);
                        e.Graphics.SmoothingMode = sm;
                    }
                    di.Bounds.Width -= 12;
                }

                if (e.ColumnHeader.Image != null)
                {
                    Image image = e.ColumnHeader.Image;
                    Rectangle r = di.Bounds;
                    if (e.ColumnHeader.ImageAlignment == eColumnImageAlignment.Left)
                    {
                        e.Graphics.DrawImage(image, r.X,
                                              r.Y + (r.Height - image.Height) / 2, image.Width, image.Height);
                        r.X += image.Width + 2;
                        r.Width -= image.Width + 2;

                    }
                    else if (e.ColumnHeader.ImageAlignment == eColumnImageAlignment.Right)
                    {
                        e.Graphics.DrawImage(image, r.Right - image.Width,
                                              r.Y + (r.Height - image.Height) / 2, image.Width, image.Height);
                        r.Width -= image.Width + 2;
                    }
                    di.Bounds = r;
                }

                ElementStyleDisplay.PaintText(di, e.ColumnHeader.Text, e.Tree.Font);
            }
        }
예제 #9
0
        protected override void OnPaint(PaintEventArgs e)
        {
            ElementStyle style = GetBackgroundStyle();
            if (style.BackColor.A < 255 && !style.BackColor.IsEmpty ||
                this.BackColor == Color.Transparent)
            {
                base.OnPaintBackground(e);
            }
            else
            {
                using (SolidBrush brush = new SolidBrush(this.BackColor))
                    e.Graphics.FillRectangle(brush, this.ClientRectangle);
            }

            if (this.IsGlassEnabled)
            {
                RibbonForm f = this.FindForm() as RibbonForm;
                if (f != null)
                    e.Graphics.SetClip(new Rectangle(0, 0, this.Width, f.GlassHeight), CombineMode.Exclude);
            }

            Office2007ColorTable table = GetOffice2007ColorTable();
            if (table != null)
            {
                using (SolidBrush brush = new SolidBrush(table.Form.BackColor))
                    e.Graphics.FillRectangle(brush, this.ClientRectangle);
            }
            else
            {
                ElementStyleDisplayInfo info = new ElementStyleDisplayInfo(style, e.Graphics, this.ClientRectangle);
                ElementStyleDisplay.PaintBackground(info);
            }

            if (!m_QatPositionedBelow && m_RibbonStrip.HasVisibleTabs && this.EffectiveStyle != eDotNetBarStyle.Metro)
            {
                ShadowPaintInfo shadowInfo = GetShadowPaintInfo();
                //shadowInfo.Rectangle = new Rectangle(-2, 0, this.Bounds.Width - shadowInfo.Size + 1, this.Bounds.Height - shadowInfo.Size);
                shadowInfo.Rectangle = new Rectangle(-6, 0, this.Bounds.Width + 12, this.Bounds.Height);
                shadowInfo.Graphics = e.Graphics;
                ShadowPainter.Paint3(shadowInfo, 2);
            }
        }
예제 #10
0
		protected override void OnPaint(PaintEventArgs e)
		{
			if(m_ItemContainer==null || this.IsDisposed || m_SuspendLayout)
				return;

			using(SolidBrush brush=new SolidBrush(Color.White))
				e.Graphics.FillRectangle(brush,this.DisplayRectangle);
            
            Graphics g = e.Graphics;

            SmoothingMode sm = g.SmoothingMode;
            TextRenderingHint th = g.TextRenderingHint;

			if(m_AntiAlias)
			{
				e.Graphics.SmoothingMode=System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                e.Graphics.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
			}
            
			g.PageUnit=GraphicsUnit.Pixel;

			Rectangle r=this.ClientRectangle;
			
			ColorScheme cs=this.ColorScheme;
			if(m_VisualPropertyChanged)
			{
				m_BackStyle.SetColorScheme(cs);
				m_VisualPropertyChanged=false;
			}

            Rectangle rBack = r;
            rBack.Inflate(1, 1);
            ElementStyleDisplayInfo info = new ElementStyleDisplayInfo(m_BackStyle, g, rBack);
            ElementStyleDisplay.Paint(info);
			
			if(m_BorderStyle==eBorderType.SingleLine)
			{
				r.Inflate(-1,-1);
			}
			else if(m_BorderStyle!=eBorderType.None)
			{
				r.Inflate(-2,-2);
			}
			
			if(this.IsTransparentBackground)
				base.OnPaintBackground(e);

			//g.FillRectangle(new SolidBrush(this.BackColor),r);
			Region oldClip=e.Graphics.Clip;
			e.Graphics.SetClip(r);
			
			ItemPaintArgs pa=new ItemPaintArgs(this as IOwner,this,e.Graphics,cs); // TODO: ADD SUPPORT FOR GRAPHICS
            pa.Renderer = GetRenderer();
            pa.DesignerSelection = m_DesignerSelection;
            pa.GlassEnabled = !this.DesignMode && WinApi.IsGlassEnabled;
			m_ItemContainer.Paint(pa);
			if(oldClip!=null)
				e.Graphics.SetClip(oldClip,System.Drawing.Drawing2D.CombineMode.Replace);
			else
				e.Graphics.ResetClip();
            oldClip.Dispose();

			if(m_ItemContainer.SubItems.Count==0 && this.DesignMode)
			{
				string infoText=INFO_EMPTYEXPLORERBAR;
				Rectangle rText=this.ClientRectangle;
				r.Inflate(-2,-2);
                eTextFormat format = eTextFormat.Default | eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter | eTextFormat.WordBreak;
				Font font=new Font(this.Font.FontFamily,7);
                TextDrawing.DrawString(g, infoText, font, SystemColors.ControlText, rText, format);
				font.Dispose();
			}

            g.SmoothingMode = sm;
            g.TextRenderingHint = th;
		}
예제 #11
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Rectangle clientRect = this.ClientRectangle;

            PaintInfo p = CreatePaintInfo(e);
            bool enabled = this.Enabled;

            if (!enabled)
            {
                Color c = _DisabledBackColor;
                if (c.IsEmpty) c = SystemColors.Control;
                using (SolidBrush brush = new SolidBrush(c))
                    e.Graphics.FillRectangle(brush, clientRect);
            }
            else if (this.BackColor != Color.Transparent)
                e.Graphics.FillRectangle(SystemBrushes.Window, clientRect);
            else if (this.BackColor == Color.Transparent && _CallBasePaintBackground)
                base.OnPaintBackground(e);

            bool disposeStyle = false;
            ElementStyle style = GetBackgroundStyle(out disposeStyle);
            if (style.Custom)
            {
                ElementStyleDisplayInfo displayInfo = new ElementStyleDisplayInfo(style, e.Graphics, clientRect);
                if (!enabled)
                {
                    ElementStyleDisplay.PaintBorder(displayInfo);
                }
                else
                    ElementStyleDisplay.Paint(displayInfo);
                clientRect.X += ElementStyleLayout.LeftWhiteSpace(style);
                clientRect.Y += ElementStyleLayout.TopWhiteSpace(style);
                clientRect.Width -= ElementStyleLayout.HorizontalStyleWhiteSpace(style);
                clientRect.Height -= ElementStyleLayout.VerticalStyleWhiteSpace(style);
                p.RenderOffset = clientRect.Location;
                p.AvailableSize = clientRect.Size;
            }

            if (_FocusHighlightEnabled && this.Focused && !_FocusHighlightColor.IsEmpty)
            {
                using (SolidBrush brush = new SolidBrush(_FocusHighlightColor))
                    e.Graphics.FillRectangle(brush, clientRect);
            }

            if (!_RootVisual.IsLayoutValid)
            {
                if (_RootVisual is VisualGroup)
                    ((VisualGroup)_RootVisual).HorizontalItemAlignment = _InputHorizontalAlignment;
                _RootVisual.PerformLayout(p);
            }

            if (SupportsFreeTextEntry)
            {
                if (!IsFreeTextEntryVisible)
                    HideFreeTextBoxEntry();
                else
                {
                    Control textBox = GetFreeTextBox();
                    Rectangle r = GetFreeTextBounds(textBox.PreferredSize, clientRect);
                    if (textBox.Bounds != r)
                        textBox.Bounds = r;
                    p.RenderSystemItemsOnly = true;
                }
            }

            if (_InputHorizontalAlignment != eHorizontalAlignment.Left)
            {
                if (_InputHorizontalAlignment == eHorizontalAlignment.Right)
                    p.RenderOffset = new Point(clientRect.Width - _RootVisual.Size.Width,
                        (clientRect.Height - _RootVisual.Size.Height) / 2);
                else
                    p.RenderOffset = new Point((clientRect.Width - _RootVisual.Size.Width) / 2,
                        (clientRect.Height - _RootVisual.Size.Height) / 2);
            }
            else
                p.RenderOffset = new Point(0, (clientRect.Height - _RootVisual.Size.Height) / 2);

            if (this.WatermarkEnabled && this.WatermarkText.Length > 0 && this.IsWatermarkRendered)
            {
                Rectangle watermarkBounds = clientRect;
                watermarkBounds.Inflate(-1, -1);
                DrawWatermark(p, watermarkBounds);
            }
            else
                _RootVisual.ProcessPaint(p);

            base.OnPaint(e);

            if (disposeStyle) style.Dispose();
        }
예제 #12
0
 private void PerformRootVisualLayout()
 {
     if (this.InvokeRequired)
     {
         this.BeginInvoke(new MethodInvoker(delegate { this.PerformRootVisualLayout(); }));
         return;
     }
     using (Graphics g = this.CreateGraphics())
     {
         PaintEventArgs e = new PaintEventArgs(g, Rectangle.Empty);
         PaintInfo p = CreatePaintInfo(e);
         Rectangle clientRect = this.ClientRectangle;
         bool disposeStyle = false;
         ElementStyle style = GetBackgroundStyle(out disposeStyle);
         if (style.Custom)
         {
             ElementStyleDisplayInfo displayInfo = new ElementStyleDisplayInfo(style, e.Graphics, clientRect);
             clientRect.X += ElementStyleLayout.LeftWhiteSpace(style);
             clientRect.Y += ElementStyleLayout.TopWhiteSpace(style);
             clientRect.Width -= ElementStyleLayout.HorizontalStyleWhiteSpace(style);
             clientRect.Height -= ElementStyleLayout.VerticalStyleWhiteSpace(style);
             p.RenderOffset = clientRect.Location;
             p.AvailableSize = clientRect.Size;
         }
         _RootVisual.PerformLayout(p);
         e.Dispose();
         if (disposeStyle) style.Dispose();
     }
 }
예제 #13
0
        protected virtual void PaintBackground(PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            Rectangle r = this.ClientRectangle;
            ElementStyle style = this.GetBackgroundStyle();

            if (!this.BackColor.IsEmpty && this.BackColor != Color.Transparent)
            {
                DisplayHelp.FillRectangle(g, r, this.BackColor);
            }

            if (this.BackgroundImage != null)
                base.OnPaintBackground(e);

            if (style.Custom)
            {
                SmoothingMode sm = g.SmoothingMode;
                if (m_AntiAlias)
                    g.SmoothingMode = SmoothingMode.HighQuality;
                ElementStyleDisplayInfo displayInfo = new ElementStyleDisplayInfo(style, e.Graphics, r);
                ElementStyleDisplay.Paint(displayInfo);
                if (m_AntiAlias)
                    g.SmoothingMode = sm;
            }
        }
예제 #14
0
        /// <summary>
        /// Paints insides of the control.
        /// </summary>
        /// <param name="e">Paint event arguments.</param>
        protected virtual void PaintInnerContent(PaintEventArgs e, ElementStyle style, bool paintText)
        {
            Graphics g = e.Graphics;
            if (m_TextMarkup == null)
                RefreshTextClientRectangle();
            Rectangle r = new Rectangle(0,0,this.Width, this.Height);
            Rectangle rText = m_ClientTextRectangle;
            //rText.Inflate(-1, -1);

            if (!this.Enabled)
                style.TextColor = GetColorScheme().ItemDisabledText;

            ElementStyleDisplayInfo info = new ElementStyleDisplayInfo(style, g, r);
            info.RightToLeft = (this.RightToLeft == RightToLeft.Yes);
            ElementStyleDisplay.Paint(info);
            
            if (paintText)
            {
                if (m_TextMarkup == null)
                {
                    info.Bounds = rText;
                    ElementStyleDisplay.PaintText(info, this.Text, this.Font);
                }
                else
                {
                    TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, this.Font, style.TextColor, (this.RightToLeft == RightToLeft.Yes), e.ClipRectangle, true);
                    m_TextMarkup.Render(d);
                }
            }

        }
예제 #15
0
		private void PaintSingleNode(Node node, NodeDisplayContext context)
		{
            _PaintedNodes.Add(node);
			Rectangle r=NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds,node,context.Offset);
			TreeRenderer renderer=context.NodeRenderer;
			if(node.NodeRenderer!=null && node.RenderMode==eNodeRenderMode.Custom)
				renderer = node.NodeRenderer;
            bool isSelected = node.IsSelectionVisible && node.IsSelected;

			// Paint node background
            ElementStyle style = GetEffectiveNodeBackgroundStyle(node, context);

			Region backRegion=null;
			if(style!=null)
			{
				context.NodeRendererEventArgs.Graphics=context.Graphics;
				context.NodeRendererEventArgs.Node = node;
				context.NodeRendererEventArgs.NodeBounds = r;
				context.NodeRendererEventArgs.Style = style;
                if (!node.FullRowBackground) // Node full row backgrounds are drawn first...
                    renderer.DrawNodeBackground(context.NodeRendererEventArgs);
                ElementStyleDisplayInfo di = new ElementStyleDisplayInfo(style, context.Graphics, context.NodeRendererEventArgs.NodeBounds);
                di.Bounds.Inflate(1, 1);
				backRegion=ElementStyleDisplay.GetStyleRegion(di);
                di.Bounds = r;
			}

            if (NodeDisplay.DrawExpandPart(node) && context.ExpandDisplayInfo != null)
            {
                r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.ExpandBounds, node, context.Offset);
                context.ExpandDisplayInfo.Node = node;
                context.ExpandDisplayInfo.ExpandPartBounds = r;
                context.ExpandDisplayInfo.IsMouseOver = node.MouseOverNodePart == eMouseOverNodePart.Expand;
                renderer.DrawNodeExpandPart(context.ExpandDisplayInfo);
            }

            if (NodeDisplay.HasColumnsVisible(node))
            {
                PaintColumnHeaders(node.NodesColumns, context.Graphics, false);
            }

			Region oldRegion=null;
			if(backRegion!=null)
			{
				oldRegion=context.Graphics.Clip;
				context.Graphics.SetClip(backRegion,CombineMode.Intersect);
			}
			
			ElementStyle cellStyle = null;
            if (context.CellStyleDefault == null)
            {
                cellStyle = new ElementStyle();
                cellStyle.TextColor = style.TextColor;
                cellStyle.TextShadowColor = style.TextShadowColor;
                cellStyle.TextShadowOffset = style.TextShadowOffset;
                cellStyle.TextAlignment = style.TextAlignment;
                cellStyle.TextLineAlignment = style.TextLineAlignment;
                cellStyle.TextTrimming = style.TextTrimming;
                cellStyle.WordWrap = style.WordWrap;
                cellStyle.Font = style.Font;
                cellStyle.UseMnemonic = style.UseMnemonic;
            }
            
			foreach(Cell cell in node.Cells)
			{
                if (!cell.IsVisible) continue;
                if (cell.StyleNormal != null)
                {
                    if (context.CellStyleDefault != null)
                        style = context.CellStyleDefault.Copy();
                    else
                        style = cellStyle.Copy();
                    style.ApplyStyle(cell.StyleNormal);
                }
                else if (context.CellStyleDefault != null)
                    style = context.CellStyleDefault.Copy();
                else
                {
                    if (!cell.Enabled || cell.IsMouseDown && (cell.StyleMouseDown != null || context.CellStyleMouseDown != null) ||
                        cell.IsSelected && (cell.StyleSelected != null || context.CellStyleSelected != null) ||
                        cell.IsMouseOver && (cell.StyleMouseOver != null || context.CellStyleMouseOver != null))
                        style = cellStyle.Copy();
                    else
                        style = cellStyle;
                }

				if(!cell.Enabled && cell.StyleDisabled!=null)
					style.ApplyStyle(cell.StyleDisabled);
				else if(!cell.Enabled && context.CellStyleDisabled!=null)
					style.ApplyStyle(context.CellStyleDisabled);
				else if(cell.IsMouseDown && cell.StyleMouseDown!=null)
					style.ApplyStyle(cell.StyleMouseDown);
				else if(cell.IsMouseDown && context.CellStyleMouseDown!=null)
					style.ApplyStyle(context.CellStyleMouseDown);
				else 
				{
					if(cell.IsSelected && cell.StyleSelected!=null)
						style.ApplyStyle(cell.StyleSelected);
                    else if (cell.IsSelected && context.CellStyleSelected != null && context.CellStyleSelected.Custom)
						style.ApplyStyle(context.CellStyleSelected);

					if(cell.IsMouseOver && cell.StyleMouseOver!=null)
						style.ApplyStyle(cell.StyleMouseOver);
					else if(cell.IsMouseOver && context.CellStyleMouseOver!=null)
						style.ApplyStyle(context.CellStyleMouseOver);
				}

				r=NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeBounds,node,context.Offset);
				
				if(style!=null)
				{
					if(style.Font==null)
						style.Font=context.DefaultFont;
                    if (isSelected)
                    {
                        style.BackColor = Color.Empty;
                        style.BackColorSchemePart = eColorSchemePart.None;
                        style.BackColor2 = Color.Empty;
                        style.BackColor2SchemePart = eColorSchemePart.None;
                    }

					Rectangle rCell=cell.BoundsRelative;
					Rectangle rText=cell.TextContentBounds;
					rCell.Offset(r.Location);
					rText.Offset(r.Location);
					ElementStyleDisplayInfo di=GetElementStyleDisplayInfo(style,context.Graphics,rCell);
					ElementStyleDisplay.Paint(di);
					NodeCellRendererEventArgs ci=GetCellDisplayInfo(style,context.Graphics,cell,r.Location, context.ColorScheme);
					
					if(ci.Cell.CheckBoxVisible)
						renderer.DrawCellCheckBox(ci);
					if(!ci.Cell.Images.LargestImageSize.IsEmpty)
						renderer.DrawCellImage(ci);
					renderer.DrawCellText(ci);
                    if (context.View == eView.Tile && node.HasChildNodes && !context.TileGroupLineColor.IsEmpty)
                        renderer.DrawTileGroupLine(new NodeRendererEventArgs(context.Graphics, node, r, style, context.TileGroupLineColor));                        
				}
			}

            if (backRegion != null)
            {
                context.Graphics.SetClip(oldRegion, CombineMode.Replace);
                backRegion.Dispose();
            }
            if(oldRegion!=null) oldRegion.Dispose();
		}
예제 #16
0
		public override void Paint(ItemPaintArgs pa)
		{
			if(this.DisplayRectangle.Width<=0 || this.DisplayRectangle.Height<=0 || m_IsPainting)
				return;

            m_IsPainting = true;
            try
            {
                if (this.IsThemed)
                {
                    PaintThemed(pa);
                    this.DrawInsertMarker(pa.Graphics);
                    return;
                }

                if (this.SuspendLayout)
                    return;
                System.Drawing.Graphics g = pa.Graphics;
                if (m_NeedRecalcSize)
                    RecalcSize();

                Rectangle r = m_PanelRect;
                r.Offset(m_Rect.X, m_Rect.Y);
                bool disposeFont = false;
                Font font = this.GetFont(out disposeFont);
                System.Windows.Forms.Control ctrl = this.ContainerControl as System.Windows.Forms.Control;

                System.Drawing.Image image = this.GetImage();
                Rectangle rText = r;
                rText.X += m_Margin;
                // This is left margin of the text
                rText.X += m_Margin * 2;
                rText.Width -= (m_Margin * 3);
                if (image != null)
                {
                    rText.Width -= (image.Width + m_Margin);
                    rText.X += (image.Width + m_Margin);
                }
                if (m_ExpandButtonVisible)
                    rText.Width -= EXPAND_MARGIN;

                ElementStyleDisplayInfo info = new ElementStyleDisplayInfo();
                info.Bounds = r;
                info.Graphics = g;
                if (m_MouseOver)
                    info.Style = m_TitleHotStyle;
                else
                    info.Style = m_TitleStyle;
                ElementStyleDisplay.Paint(info);
                if (info.Style.Font != null)
                    font = info.Style.Font;
                if (pa.RightToLeft)
                {
                    TextDrawing.DrawString(g, m_Text, font, info.Style.TextColor, GetRtlRectangle(m_PanelRect, rText), info.Style.TextFormat | eTextFormat.RightToLeft);
                }
                else
                    TextDrawing.DrawString(g, m_Text, font, info.Style.TextColor, rText, info.Style.TextFormat);

                //g.ResetClip();
                //g.Clip=oldClip;

                if (m_ExpandButtonVisible)
                {
                    Rectangle expandedRect = m_ExpandButtonRect;
                    expandedRect.Offset(m_Rect.X, m_Rect.Y);
                    if (pa.RightToLeft)
                        PaintExpandButton(pa, GetRtlRectangle(m_Rect, expandedRect), m_MouseOver, m_MouseDown, m_Expanded);
                    else
                        PaintExpandButton(pa, expandedRect, m_MouseOver, m_MouseDown, m_Expanded);
                }

                int cornerSize = m_TitleStyle.CornerDiameter;
                // Paint Background
                Rectangle backRect = new Rectangle(m_Rect.X, m_PanelRect.Bottom + m_Rect.Y, m_Rect.Width, m_Rect.Height - m_PanelRect.Bottom);
                if (backRect.Width > 0 && backRect.Height > 0)
                {
                    //g.Clip=new Region(backRect);
                    info.Style = m_BackStyle;
                    info.Bounds = backRect;
                    ElementStyleDisplay.Paint(info);
                    //m_BackgroundStyle.Paint(g,backRect,"",Rectangle.Empty,this.GetFont(),new Point[]{new Point(backRect.X,backRect.Y),new Point(backRect.X,backRect.Bottom-1),new Point(backRect.X,backRect.Bottom-1),new Point(backRect.Right-1,backRect.Bottom-1),new Point(backRect.Right-1,backRect.Bottom-1),new Point(backRect.Right-1,backRect.Y)});
                    //g.ResetClip();
                    //g.Clip=oldClip;
                    if (m_DropShadow)
                    {
                        ShadowPaintInfo shadowInfo = GetShadowPaintInfo();
                        shadowInfo.Rectangle = new Rectangle(m_Rect.X, m_Rect.Y + m_PanelRect.Top + cornerSize, m_Rect.Width, m_Rect.Height - m_PanelRect.Top - cornerSize);
                        shadowInfo.Graphics = g;
                        ShadowPainter.Paint(shadowInfo);
                    }
                }
                else
                {
                    if (m_DropShadow)
                    {
                        r.Y += cornerSize;
                        r.Height -= cornerSize;
                        ShadowPaintInfo shadowInfo = GetShadowPaintInfo();
                        shadowInfo.Rectangle = r;
                        shadowInfo.Graphics = g;
                        ShadowPainter.Paint(shadowInfo);
                    }
                }

                // Draw Image
                if (image != null)
                {
                    if (pa.RightToLeft)
                        g.DrawImage(image, GetRtlRectangle(m_PanelRect, new Rectangle(r.Left + m_Margin, r.Bottom - m_Margin - image.Height, image.Width, image.Height)));
                    else
                        g.DrawImage(image, r.Left + m_Margin, r.Bottom - m_Margin - image.Height, image.Width, image.Height);
                }

                if (this.Focused)
                {
                    if (this.DesignMode)
                    {
                        Rectangle rFocus = r;
                        rFocus.Inflate(-1, -1);
                        if (pa.RightToLeft) rFocus = GetRtlRectangle(m_PanelRect, rFocus);
                        DesignTime.DrawDesignTimeSelection(g, r, pa.Colors.ItemDesignTimeBorder);
                    }
                    else
                    {
                        Rectangle rFocus = rText;
                        rFocus.Inflate(0, -1);
                        rFocus.Width -= 2;
                        rFocus.X -= 2;
                        if (pa.RightToLeft) rFocus = GetRtlRectangle(m_PanelRect, rFocus);
                        System.Windows.Forms.ControlPaint.DrawFocusRectangle(g, rFocus);
                    }
                }

                if ((this.Expanded || this.Parent is ExplorerBarContainerItem && ((ExplorerBarContainerItem)this.Parent)._Animating) && m_SubItems != null) // && m_ControlHost==null)
                {
                    r = new Rectangle(m_Rect.X, m_Rect.Y + r.Height + 1, m_Rect.Width, m_Rect.Height - r.Height - 1);
                    for (int i = 0; i < m_SubItems.Count; i++)
                    {
                        BaseItem item = m_SubItems[i];
                        if (!item.Displayed || !item.Visible)
                            continue;
                        if (item.BeginGroup)
                        {
                            using (Pen line = new Pen(pa.Colors.ItemSeparator, 1))
                                g.DrawLine(line, item.LeftInternal + 2, item.TopInternal - 2, item.DisplayRectangle.Right - 4, item.TopInternal - 2);
                        }
                        item.Paint(pa);
                    }
                }

                if (disposeFont)
                    font.Dispose();

                this.DrawInsertMarker(pa.Graphics);

                PaintInfoText(pa);
            }
            finally
            {
                m_IsPainting = false;
            }
		}
예제 #17
0
        internal void PaintColumnHeaders(TreeRenderer renderer, ColumnHeaderCollection columns, Graphics g, bool treeControlHeader)
        {
            ColumnHeaderRendererEventArgs ce = new ColumnHeaderRendererEventArgs();
            ce.Graphics = g;
            ce.Tree = this.Tree;
            ce.SortIndicatorColor = renderer.ColorTable.ColumnSortIndicatorColor;

            ElementStyle defaultNormalStyle = GetDefaultColumnStyleNormal(renderer);
            ElementStyle headerStyle = null;
            if(treeControlHeader)
                headerStyle = this.Tree.ColumnsBackgroundStyle == null ? GetDefaultHeaderStyle(renderer) : this.Tree.ColumnsBackgroundStyle;
            else
                headerStyle = this.Tree.NodesColumnsBackgroundStyle == null ? GetDefaultNodesHeaderStyle(renderer) : this.Tree.NodesColumnsBackgroundStyle;

            if (Tree.ColumnStyleNormal != null && Tree.ColumnStyleNormal.Custom)
                defaultNormalStyle = Tree.ColumnStyleNormal;

            Point offset = Point.Empty;
            if (this.Tree.AutoScroll)
            {
                offset = this.Tree.GetAutoScrollPositionOffset();
                if (treeControlHeader)
                    offset.Y = 0;
            }

            Rectangle columnsBounds = columns.Bounds;
            if (!treeControlHeader) columnsBounds.Offset(offset);
            ElementStyleDisplayInfo di = new ElementStyleDisplayInfo(headerStyle, g, columnsBounds);
            ElementStyleDisplay.Paint(di);
            Color columnSeparator = (headerStyle != null && !headerStyle.BorderColor.IsEmpty) ? headerStyle.BorderColor : Color.Empty;
            for (int i = 0; i < columns.Count; i++)
            {
                ColumnHeader column = columns.ColumnAtDisplayIndex(i);
                if (!column.Visible) continue;
                ElementStyle style = null;
                if (column.StyleNormal != "")
                    style = Tree.Styles[column.StyleNormal].Copy();
                else
                    style = defaultNormalStyle.Copy();

                if (column.IsMouseDown)
                {
                    if (column.StyleMouseDown != "")
                        style.ApplyStyle(Tree.Styles[column.StyleMouseDown]);
                    else if (Tree.ColumnStyleMouseDown != null)
                        style.ApplyStyle(Tree.ColumnStyleMouseDown);
                }
                else if (column.IsMouseOver)
                {
                    if (column.StyleMouseOver != "")
                        style.ApplyStyle(Tree.Styles[column.StyleMouseOver]);
                    else if (Tree.ColumnStyleMouseOver != null)
                        style.ApplyStyle(Tree.ColumnStyleMouseOver);
                }

                ce.ColumnHeader = column;
                Rectangle columnBounds = column.Bounds;
                columnBounds.Offset(offset);
                ce.Bounds = columnBounds;
                ce.Style = style;
                renderer.DrawColumnHeader(ce);
                if (!columnSeparator.IsEmpty)
                    DisplayHelp.DrawLine(g, columnBounds.Right - (column.IsLastVisible ? 0 : 1), columnBounds.Y, columnBounds.Right - (column.IsLastVisible ? 0 : 1), columnBounds.Bottom - 1, columnSeparator, 1);
            }
        }
예제 #18
0
        protected virtual void PaintControl(PaintEventArgs e)
        {
            ElementStyleDisplayInfo info = new ElementStyleDisplayInfo();
            info.Bounds = this.DisplayRectangle;
            info.Graphics = e.Graphics;
            info.Style = m_BackgroundStyle;
            ElementStyleDisplay.Paint(info);

            if (!m_ButtonBounds.IsEmpty && this.Tabs.Count > 0)
            {
                Rectangle r = GetButtonsBackground();
                info.Bounds = r;
                info.Graphics = e.Graphics;
                info.Style = m_ButtonBackAreaStyle;
                ElementStyleDisplay.Paint(info);
            }

            SmoothingMode sm = e.Graphics.SmoothingMode;
            TextRenderingHint th = e.Graphics.TextRenderingHint;

            if (m_AntiAlias)
            {
                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                e.Graphics.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
            }

            if (!m_TabsBounds.IsEmpty)
            {
                Rectangle r = GetTabBounds();
                e.Graphics.SetClip(r);
                ISimpleTab[] tabs = new ISimpleTab[m_Tabs.Count];
                m_Tabs.CopyTo(tabs);
                m_TabDisplay.Paint(e.Graphics, tabs);
                e.Graphics.ResetClip();
            }

            if (m_Overlay == null)
            {
                BubbleButtonDisplayInfo displayInfo = GetBubbleButtonDisplayInfo();
                displayInfo.Graphics = e.Graphics;

                if (m_SelectedTab != null)
                {
                    foreach (BubbleButton button in m_SelectedTab.Buttons)
                    {
                        displayInfo.Button = button;
                        BubbleButtonDisplay.Paint(displayInfo);
                    }
                }
            }

            if (this.DesignMode && this.Tabs.Count == 0)
            {
                Rectangle r = this.DisplayRectangle;
                eTextFormat format = eTextFormat.Default | eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter |
                    eTextFormat.EndEllipsis | eTextFormat.WordBreak;
                string INFO_TEXT = "Right-click and choose Create Tab or Button to add new items.";
                TextDrawing.DrawString(e.Graphics, INFO_TEXT, this.Font, SystemColors.ControlDarkDark, r, format);
            }


            e.Graphics.TextRenderingHint = th;
            e.Graphics.SmoothingMode = sm;
        }