コード例 #1
0
        public GraphicsPath FindX3DBorderPrimitive(Rectangle rcBorder)
        {
            switch (m_eBorderType)
            {
            case XBorderType.Rounded:
                m_BorderShape = XCoolFormHelper.RoundRect((RectangleF)rcBorder, m_lRadius, m_lRadius, 0, 0);
                break;

            case XBorderType.Inclinated:
                m_BorderShape = createInclinatedBorderPath(rcBorder);
                break;
            }
            return(m_BorderShape);
        }
コード例 #2
0
        /// <summary>
        /// Draws inner & outer 3D borders.
        /// </summary>
        /// <param name="g"> Graphics object</param>
        /// <param name="XBorderPath"> Border path</param>
        /// <param name="rcBorder"> Border bounds</param>
        /// <param name="lCorner"> Radius of a rounded rectangle</param>
        /// <param name="bFlat"> Controls border type mode</param>
        private void DrawBorderLine(
            Graphics g,
            GraphicsPath XBorderPath,
            Rectangle rcBorder,
            int lCorner,
            bool bFlat
            )
        {
            int lC = lCorner;

            #region Draw outer border
            if (bFlat)
            {
                switch (m_eBorderType)
                {
                case XBorderType.Rectangular:
                    XBorderPath = XCoolFormHelper.RoundRect((RectangleF)rcBorder, lC, lC, lC, lC);
                    break;

                case XBorderType.Rounded:
                    XBorderPath = XCoolFormHelper.RoundRect((RectangleF)rcBorder, lC, lC, 0, 0);
                    break;

                case XBorderType.Inclinated:
                    XBorderPath = createInclinatedBorderPath(rcBorder);
                    break;
                }
                using (Pen pFlat = new Pen(m_clrFlatBorder))
                {
                    g.DrawPath(pFlat, XBorderPath);
                }
            }
            else
            {
                for (int o = 0; o < m_clrOuterBorder.Length; o++)
                {
                    switch (m_eBorderType)
                    {
                    case XBorderType.Rectangular:
                        XBorderPath = XCoolFormHelper.RoundRect((RectangleF)rcBorder, lC, lC, lC, lC);
                        break;

                    case XBorderType.Rounded:
                        XBorderPath = XCoolFormHelper.RoundRect((RectangleF)rcBorder, lC, lC, 0, 0);
                        break;

                    case XBorderType.Inclinated:
                        XBorderPath = createInclinatedBorderPath(rcBorder);
                        break;
                    }
                    Pen pen = new Pen(m_clrOuterBorder[o]);
                    g.DrawPath(
                        pen,
                        XBorderPath
                        );
                    DeflateRect(ref rcBorder);
                    if (m_eBorderType != XBorderType.Rectangular)
                    {
                        lC--;
                    }
                }

                #endregion

                #region Draw inner border

                rcBorder.Y      += m_lTitleBarHeight;
                rcBorder.Height -= m_lTitleBarHeight;

                for (int i = 0; i < m_clrInnerBorder.Length; i++)
                {
                    Pen penInner = new Pen(m_clrInnerBorder[i]);
                    g.DrawRectangle(
                        penInner,
                        rcBorder
                        );
                    DeflateRect(ref rcBorder);
                }
            }
            #endregion
        }
コード例 #3
0
        /// <summary>
        /// Fills titlebar button.
        /// </summary>
        /// <param name="rcBtn"> Button bounding rectangle.</param>
        /// <param name="g"> Graphics object.</param>
        /// <param name="clrStart"> Color used to fill the button.</param>
        /// <param name="clrEnd"> Color used to fill the outer glow.</param>
        /// <param name="XBoxClip"> Path to perform clipping tasks.</param>
        private void FillButton(
            Rectangle rcBtn,
            Graphics g,
            Color clrStart,
            Color clrEnd,
            GraphicsPath XBoxClip
            )
        {
            switch (m_eFillMode)
            {
            case XButtonFillMode.UpperGlow:
                rcBtn.Height = 3;
                using (LinearGradientBrush lgb = new LinearGradientBrush(
                           rcBtn,
                           clrStart,
                           clrEnd,
                           LinearGradientMode.Vertical))
                {
                    g.FillRectangle(
                        lgb,
                        rcBtn
                        );
                }
                break;

            case XButtonFillMode.FullFill:
                // restrict drawing inside button box / rectangle:
                g.SetClip(XBoxClip);
                g.SetClip(rcBtn, CombineMode.Intersect);

                #region Fill button
                using (SolidBrush sb = new SolidBrush(clrStart))
                {
                    g.FillRectangle(
                        sb,
                        rcBtn
                        );
                }
                #endregion

                using (XAntiAlias xaa = new XAntiAlias(g))
                {
                    #region Fill shine
                    using (GraphicsPath XBtnGlow = new GraphicsPath())
                    {
                        XBtnGlow.AddEllipse(rcBtn.Left - 5, rcBtn.Bottom - rcBtn.Height / 2 + 3, rcBtn.Width + 11, rcBtn.Height + 11);
                        using (PathGradientBrush pgb = new PathGradientBrush(XBtnGlow))
                        {
                            pgb.CenterColor    = Color.FromArgb(235, Color.White);
                            pgb.SurroundColors = new Color[] { Color.FromArgb(0, clrEnd) };
                            pgb.SetSigmaBellShape(0.8f);

                            g.FillPath(
                                pgb,
                                XBtnGlow
                                );
                        }
                    }
                    #endregion

                    #region Fill upper glow
                    rcBtn.Height = rcBtn.Height / 2 - 2;
                    using (LinearGradientBrush lgb = new LinearGradientBrush(
                               rcBtn,
                               Color.FromArgb(80, Color.White),
                               Color.FromArgb(140, Color.White),
                               LinearGradientMode.Vertical))
                    {
                        using (GraphicsPath XGlowPath = XCoolFormHelper.RoundRect((RectangleF)rcBtn, 0, 0, 4, 4))
                        {
                            lgb.WrapMode = WrapMode.TileFlipXY;
                            g.FillPath(
                                lgb,
                                XGlowPath
                                );
                        }
                    }
                    #endregion
                }
                // reset clipping back:
                g.ResetClip();
                break;
            }
        }