Example #1
0
        /// <summary>
        /// Creates and paints the button bitmap of the virtual scrollbar.
        /// </summary>
        /// <param name="width">The width of the button.</param>
        /// <param name="height">The height of the button.</param>
        /// <returns>The button image.</returns>
        protected virtual Image CreateScrollButtonBitmap(int width, int height)
        {
            Bitmap bm = new Bitmap(width, height);

            using (Graphics g = Graphics.FromImage(bm))
            {
                int r = Math.Min(width, height / 2) - 1;
                if (r < 1)
                {
                    r = 1;
                }

                backgroundBrush.Color = Color.Fuchsia;
                //g.Clear(Color.Fuchsia);
                g.FillRectangle(backgroundBrush, 0, 0, width, height);

                using (GraphicsPlus gp = new GraphicsPlus(g))
                {
                    Rectangle bounds = new Rectangle(0, 0, width - 1, height - 1);
                    gp.SmoothingMode = SmoothingMode.None;
                    Color color = scrollbarButtonColor;
                    using (SolidBrushPlus brush = new SolidBrushPlus(color, true))
                    {
                        gp.FillRoundRectangle(bounds, r, brush);
                    }
                    using (PenPlus pen = new PenPlus(ScrollBarButtonBorderColor, 1, true))
                    {
                        gp.DrawRoundRectangle(bounds, r, pen);
                    }
                }
            }

            return(bm);
        }
Example #2
0
        private void TestGdiPlus(GraphicsPlus graphics)
        {
            graphics.DrawImage(bmp, 0, 0, ClientRectangle.Width, ClientRectangle.Height);

            PenPlus pen;

            graphics.SetSmoothingMode(SmoothingMode.SmoothingModeAntiAlias);

            pen = new PenPlus(Color.Black, 15);
            pen.SetEndCap(LineCap.LineCapRound);
            pen.SetStartCap(LineCap.LineCapRound);

            pen.SetWidth(3);

            pen.SetColor(Color.FromArgb(0x7f7f7f7f));
            pen.SetWidth(40);
            graphics.DrawLine(pen, 20, 20, ClientRectangle.Right - 20, ClientRectangle.Bottom - 20);
            graphics.DrawLine(pen, ClientRectangle.Right - 20, 20, 20, ClientRectangle.Bottom - 20);

            SmoothingMode mode = graphics.GetSmoothingMode();

            graphics.SetSmoothingMode(SmoothingMode.SmoothingModeAntiAlias);
            foreach (GraphicsPath p in allPaths)
            {
                graphics.DrawPath(penWrite, p);
            }
            graphics.SetSmoothingMode(mode);
            pen.Dispose();
        }
Example #3
0
        private void CreateObjects()
        {
            brSolid  = new SolidBrushPlus(Color.CornflowerBlue);
            penSolid = new PenPlus(Color.Red, 10);
            penSolid.SetEndCap(LineCap.LineCapRound);
            penSolid.SetStartCap(LineCap.LineCapArrowAnchor);

            brHatch = new HatchBrush(HatchStyle.HatchStyle25Percent,
                                     Color.Black, Color.White);
            penHatch = new PenPlus(brHatch, 10);

            penSolidTrans = new PenPlus(Color.FromArgb(-0x5f7f7f7f), 10);

            penSolidCustomCap = new PenPlus(Color.Black, 20);
            GraphicsPath path = new GraphicsPath(FillMode.FillModeAlternate);

            path.AddEllipse(-0.5f, -1.5f, 1, 3);
            CustomLineCap cap = new CustomLineCap(null, path, LineCap.LineCapFlat, 0);

            penSolidCustomCap.SetCustomEndCap(cap);

            penDash = new PenPlus(Color.Black, 5);
            penDash.SetDashStyle(DashStyle.DashStyleDot);

            brGrad = new LinearGradientBrush(
                new GpPointF(0, 0), new GpPointF(100, 100),
                Color.Black, Color.White);
            penGradient = new PenPlus(brGrad, 30);
        }
Example #4
0
        private void drawDirectionLinePlus(GraphicsPlus graphics)
        {
            graphics.SetSmoothingMode(SmoothingMode.SmoothingModeAntiAlias);

            PenPlus pen = new PenPlus(TARGET_LINE_COLOR, 3);

            pen.SetEndCap(LineCap.LineCapRound);
            pen.SetStartCap(LineCap.LineCapRound);

            graphics.DrawLine(pen, this.Width / 2, this.Height / 2, targetPoint.X, targetPoint.Y);
            pen.Dispose();
        }
Example #5
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            GpStatusPlus stat       = NativeMethods.GdiplusStartup(out token, input, out output);
            string       bitmapPath = System.IO.Path.GetDirectoryName(GetType().Assembly.GetModules()[0].FullyQualifiedName);

            bitmapPath = System.IO.Path.Combine(bitmapPath, "test.jpg");
            StreamOnFile sf = new StreamOnFile(bitmapPath);

            bmp      = new BitmapPlus(sf);
            penWrite = new PenPlus(Color.Blue, 3);

            path = new GraphicsPath(FillMode.FillModeAlternate);
        }
Example #6
0
        protected virtual void PaintButtonBackground(FluidPaintEventArgs e)
        {
            const int const_radius = 8;

            if (this.shape != ButtonShape.Flat || IsDown)
            {
                Rectangle rect = ButtonRectangle;
                rect.Width--;
                rect.Height--;
                if (rect.Width < 1 || rect.Height < 1)
                {
                    return;
                }

                rect.Offset(e.ControlBounds.X, e.ControlBounds.Y);

                Graphics g = e.Graphics;


                int radius = e.ScaleX(const_radius);
                if (radius > rect.Width / 2)
                {
                    radius = rect.Width / 2;
                }

                Color endColor = this.BackColor;
                if (!Enabled)
                {
                    endColor = ColorConverter.AlphaBlendColor(Color.Black, endColor, 128);
                }
                int   alpha       = Enabled ? 127 : 32;
                Color startColor  = ColorConverter.AlphaBlendColor(endColor, Color.White, alpha); //Color.FromArgb(0x7fffffff);
                Color borderColor = ColorConverter.AlphaBlendColor(endColor, Color.White, 100);

                GraphicShape shape = ButtonShapeToGraphic(this.shape);
                using (GraphicsPlus gp = new GraphicsPlus(g))
                {
                    GraphicsPlus.GradientMode mode = IsDown ? GraphicsPlus.GradientMode.Bottom : GraphicsPlus.GradientMode.Top;
                    gp.GradientFillShape(rect, radius, startColor, endColor, mode, shape, corners);
                    using (PenPlus pen = new PenPlus(borderColor, (float)1))
                    {
                        gp.DrawShape(rect, radius, pen, shape, corners);
                    }
                }
            }
            PerformPaintButtonContent(e);
        }
Example #7
0
        private void drawRotatedArrow(GraphicsPlus graphics)
        {
            Debug.WriteLine("drawRotatedArrow: " + this.rotationAngle, this.ToString());

            Point center = new Point(this.Width / 2, this.Height / 2);

            int arWidthHalf = ARROW_WIDTH / 2;

            //int arHeightHalf = ARROW_HEIGHT / 2;

            Point[] arrowPoints =
            {
                new Point(center.X,                       center.Y - arWidthHalf),
                new Point(center.X - 2 * arWidthHalf / 3, center.Y + arWidthHalf),
                new Point(center.X + 2 * arWidthHalf / 3, center.Y + arWidthHalf),
                new Point(center.X,                       center.Y + arWidthHalf / 2)
            };
            Debug.WriteLine("drawRotatedArrow: points "
                            + PointUtil.pointsStr(arrowPoints), this.ToString());

            PointMath.RotatePoints(arrowPoints, center, this.rotationAngle);
            Debug.WriteLine("drawRotatedArrow: points "
                            + PointUtil.pointsStr(arrowPoints), this.ToString());

            graphics.SetSmoothingMode(SmoothingMode.SmoothingModeAntiAlias);

            PenPlus pen = new PenPlus(ARROW_COLOR, 3);

            pen.SetEndCap(LineCap.LineCapRound);
            pen.SetStartCap(LineCap.LineCapRound);


            graphics.DrawLine(pen, new GpPoint(arrowPoints[0].X, arrowPoints[0].Y),
                              new GpPoint(arrowPoints[1].X, arrowPoints[1].Y));
            graphics.DrawLine(pen, new GpPoint(arrowPoints[1].X, arrowPoints[1].Y),
                              new GpPoint(arrowPoints[3].X, arrowPoints[3].Y));
            graphics.DrawLine(pen, new GpPoint(arrowPoints[3].X, arrowPoints[3].Y),
                              new GpPoint(arrowPoints[2].X, arrowPoints[2].Y));
            graphics.DrawLine(pen, new GpPoint(arrowPoints[2].X, arrowPoints[2].Y),
                              new GpPoint(arrowPoints[0].X, arrowPoints[0].Y));
            pen.Dispose();
        }