Example #1
0
        //protected override void OnPaintBackground(PaintEventArgs e)
        //{
        //    base.OnPaintBackground(e);
        //    Graphics g = e.Graphics;
        //    Rectangle r = new Rectangle(0,0,this.Width-1, this.Height-1);
        //    using (GraphicsPath path = GetFormPath(r))
        //    {
        //        using (Pen pen = new Pen(Color.Red, 1))
        //        {
        //            path.Widen(pen);
        //            SmoothingMode sm = g.SmoothingMode;
        //            g.SmoothingMode = SmoothingMode.HighQuality;
        //            g.DrawPath(pen, path);
        //            //g.FillPath(SystemBrushes.ControlDarkDark, path);
        //            g.SmoothingMode = sm;
        //        }
        //    }
        //}

        #region Non-client area painting
        /// <summary>
        /// Paints the non-client area of the form.
        /// </summary>
        protected virtual bool WindowsMessageNCPaint(ref Message m)
        {
            if (this.IsGlassEnabled)
            {
                return true;
            }
            else
            {
                if (BarFunctions.IsVista && !BarFunctions.IsWindows7 && _NonClientPaintEnabled)
                {
                    IntPtr dc = WinApi.GetWindowDC(this.Handle);
                    try
                    {
                        using (Graphics g = Graphics.FromHdc(dc))
                        {
                            BufferedBitmap bmp = new BufferedBitmap(g, new Rectangle(0, 0, this.Width, this.Height));
                            try
                            {
                                bmp.Graphics.SetClip(this.GetClientRectangle(new Rectangle(0, 0, this.Width, this.Height)), CombineMode.Exclude);
                                PaintFormBorder(new PaintEventArgs(bmp.Graphics, Rectangle.Empty));
                                bmp.Render(g, this.GetClientRectangle(new Rectangle(0, 0, this.Width, this.Height)));
                            }
                            finally
                            {
                                bmp.Dispose();
                            }
                        }
                    }
                    finally
                    {
                        WinApi.ReleaseDC(this.Handle, dc);
                    }
                }
                
                m.Result = IntPtr.Zero;
                return false;
            }
        }
Example #2
0
        private void RecordStartState(object sender, EventArgs e)
        {
            m_StateBitmap = new Bitmap(m_ViewRectangle.Width, m_ViewRectangle.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
            Graphics g1 = Graphics.FromImage(m_StateBitmap);
            BufferedBitmap bb = new BufferedBitmap(g1, new Rectangle(0, 0, m_ViewRectangle.Width, m_ViewRectangle.Height));
            Graphics g = bb.Graphics;
            Color transparentColor = Color.Empty;
            try
            {
                bool disposeStyle = false;
                ElementStyle style = ElementStyleDisplay.GetElementStyle(this.BackgroundStyle, out disposeStyle);
                if (!style.BackColor.IsEmpty)
                    transparentColor = style.BackColor;
                else if (style.BackColorBlend.Count > 0 && !style.BackColorBlend[0].Color.IsEmpty)
                    transparentColor = style.BackColorBlend[0].Color;
                else
                    transparentColor = Color.WhiteSmoke;

                if (!transparentColor.IsEmpty)
                {
                    using (SolidBrush brush = new SolidBrush(transparentColor))
                        g.FillRectangle(brush, 0, 0, m_StateBitmap.Width, m_StateBitmap.Height);
                }
                System.Windows.Forms.Control cc = this.ContainerControl as System.Windows.Forms.Control;
                bool antiAlias = false;
                ItemPaintArgs pa = null;
                if (cc is ItemControl)
                {
                    antiAlias = ((ItemControl)cc).AntiAlias;
                    pa = ((ItemControl)cc).GetItemPaintArgs(g);
                }
                else if (cc is Bar)
                {
                    antiAlias = ((Bar)cc).AntiAlias;
                    pa = ((Bar)cc).GetItemPaintArgs(g);
                }
                else if (cc is ButtonX)
                {
                    antiAlias = ((ButtonX)cc).AntiAlias;
                    pa = ((ButtonX)cc).GetItemPaintArgs(g);
                }
                else if (cc is MenuPanel)
                {
                    antiAlias = ((MenuPanel)cc).AntiAlias;
                    pa = ((MenuPanel)cc).GetItemPaintArgs(g);
                }

                Rectangle clip = GetClipRectangle();
                System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix();
                myMatrix.Translate( -(clip.X + +m_ScrollPosition.X),
                                    -(clip.Y + m_ScrollPosition.Y), 
                                    System.Drawing.Drawing2D.MatrixOrder.Append);
                g.Transform = myMatrix;

                if (antiAlias)
                {
                    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                    g.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
                }

                if (pa == null)
                {
                    m_StateBitmap.Dispose();
                    m_StateBitmap = null;
                }

                // Do not paint scrollbars just content
                ItemDisplay display = GetItemDisplay();
                display.Paint(this, pa);
                bb.Render(g1);

                if(disposeStyle) style.Dispose();
            }
            finally
            {
                g = null;
                bb.Dispose();
                g1.Dispose();
            }
            if (!transparentColor.IsEmpty)
                m_StateBitmap.MakeTransparent(transparentColor);
        }
Example #3
0
        protected virtual void PaintNonClientAreaBuffered(Graphics targetGraphics)
        {
            BufferedBitmap bmp = new BufferedBitmap(targetGraphics, new Rectangle(0,0,this.Width, this.Height));
            try
            {
                bmp.Graphics.SetClip(this.GetClientRectangle(new Rectangle(0, 0, this.Width, this.Height)), CombineMode.Exclude);
                PaintNonClientArea(bmp.Graphics);

                bmp.Render(targetGraphics, this.GetClientRectangle(new Rectangle(0, 0, this.Width, this.Height)));
            }
            finally
            {
                bmp.Dispose();
            }
        }