Exemple #1
0
        public static void FillPointer(Graphics g, Rectangle rect, int tipSize, int thickness, Color color, Color borderColor, float angle = 0.0f)
        {
            Color colorOther = DrawingUtils.BlendColors(color, Color.White, 1.0f);
            Brush background = new LinearGradientBrush(rect, colorOther, color, System.Drawing.Drawing2D.LinearGradientMode.Vertical);
            Pen   borderPen  = new Pen(borderColor);

            int x = rect.X;
            int y = rect.Y;
            int w = rect.Width;
            int h = rect.Height;

            GraphicsPath backgroundPath = new GraphicsPath();

            backgroundPath.AddLine(x, y, x + w, y);
            backgroundPath.AddLine(x + w, y, x + w, y + h - tipSize);
            backgroundPath.AddLine(x + w, y + h - tipSize, x + w - thickness, y + h - tipSize);
            backgroundPath.AddLine(x + w - thickness, y + h - tipSize, x + w - thickness, y + thickness);
            backgroundPath.AddLine(x + w - thickness, y + thickness, x + thickness, y + thickness);
            backgroundPath.AddLine(x + thickness, y + thickness, x + thickness, y + h - tipSize);
            backgroundPath.AddLine(x + thickness, y + h - tipSize, x + w / 2, y + h - thickness);
            backgroundPath.AddLine(x + w / 2, y + h - thickness, x + w - thickness, y + h - tipSize);
            backgroundPath.AddLine(x + w - thickness, y + h - tipSize, x + w, y + h - tipSize);
            backgroundPath.AddLine(x + w, y + h - tipSize, x + w / 2, y + h);
            backgroundPath.AddLine(x + w / 2, y + h, x, y + h - tipSize);
            backgroundPath.AddLine(x, y + h - tipSize, x, y);
            backgroundPath.CloseFigure();

            Matrix rotateMatrix = new Matrix();

            rotateMatrix.Translate((x + w / 2), (y + h / 2));
            rotateMatrix.Rotate(angle);
            rotateMatrix.Translate(-(x + w / 2), -(y + h / 2));
            backgroundPath.Transform(rotateMatrix);

            g.SmoothingMode = SmoothingMode.AntiAlias;

            g.FillPath(background, backgroundPath);
            g.DrawPath(borderPen, backgroundPath);

            g.SmoothingMode = SmoothingMode.None;

            background.Dispose();
            borderPen.Dispose();
            backgroundPath.Dispose();
        }
Exemple #2
0
        private void PaintReViewTimelineControl(PaintEventArgs e)
        {
            // Create pens and brushes
            Pen   foregroundPen       = new Pen(ForegroundColor);
            Brush foregroundBrush     = new SolidBrush(ForegroundColor);
            Brush playbackheaderBrush = new SolidBrush(PlaybackHeaderColor);
            Brush backgroundBrush     = new SolidBrush(TimelineBackColor);

            Rectangle rect = new Rectangle((int)e.Graphics.VisibleClipBounds.X, (int)e.Graphics.VisibleClipBounds.Y, (int)e.Graphics.VisibleClipBounds.Width, (int)e.Graphics.VisibleClipBounds.Height);

            e.Graphics.FillRectangle(backgroundBrush, rect);

            StringFormat format = new StringFormat();

            format.Alignment     = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;

            int startY    = rect.Y + rect.Height;
            int direction = -1;

            if (!OrientationUp)
            {
                startY    = rect.Y;
                direction = 1;
            }

            int   majorTimeInterval  = MajorTimeInterval;
            float majorPixelInterval = TimeToPixels(majorTimeInterval);
            float minorPixelInterval = (majorPixelInterval / 10.0f);

            float startX = panOffset.X % majorPixelInterval + rect.X;
            float endX   = startX + rect.Width - panOffset.X % majorPixelInterval;

            int count = 0;

            for (float xC = startX; xC <= endX; xC += minorPixelInterval)
            {
                if (count % 10 == 0)
                {
                    // Render major tick
                    int time = (int)(Math.Round(PixelsToTime((float)Math.Round(xC - rect.X - panOffset.X)) * 10.0f) / 10.0f);
                    e.Graphics.DrawString(TimeToString(time), font, foregroundBrush, xC, (rect.Y + rect.Height / 2) + (OrientationUp ? 0 : 5), format);
                    e.Graphics.DrawLine(foregroundPen, xC, startY, xC, startY + direction * 8);
                }
                else
                {
                    // Render minor tick
                    e.Graphics.DrawLine(foregroundPen, xC, startY, xC, startY + direction * 4);
                }
                count++;
            }

            startX = rect.X + panOffset.X;
            if (model != null)
            {
                e.Graphics.FillRectangle(playbackheaderBrush, startX, startY + direction * 2, (int)TimeToPixels(model.Duration), 2);
            }

            Rectangle triangleRect = GetPlaybackHeaderRect();

            triangleRect.Y     += OrientationUp ? (triangleRect.Height - triangleRect.Width) : 0;
            triangleRect.Height = triangleRect.Width;
            DrawingUtils.FillTriangle(e.Graphics, triangleRect, PlaybackHeaderColor, OrientationUp ? 0.0f : 180.0f);

            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            foreach (Annotation annotation in annotationList)
            {
                RectangleF annotationRect = GetAnnotationRectangle(annotation);

                Brush annotationBrush = new System.Drawing.Drawing2D.LinearGradientBrush(annotationRect, annotation == selectedAnnotation ? SelectedAnnotationColor : AnnotationColor, Color.White, System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal);

                e.Graphics.FillEllipse(annotationBrush, annotationRect);
                e.Graphics.DrawEllipse(foregroundPen, annotationRect);
                e.Graphics.DrawLine(foregroundPen, annotationRect.X + annotationRect.Width / 2.0f, 15.0f, annotationRect.X + annotationRect.Width / 2.0f, 100.0f);

                annotationBrush.Dispose();
            }
            e.Graphics.SmoothingMode = SmoothingMode.None;

            foregroundBrush.Dispose();
            foregroundPen.Dispose();
        }
Exemple #3
0
        public static void FillRoundedRectangle(Graphics g, Rectangle rect, int radius, Color color, Corners roundedCorners, Color shadowColor, Point shadowOffset)
        {
            Color colorOther = DrawingUtils.BlendColors(color, Color.White, 1.0f);
            Brush background = new System.Drawing.Drawing2D.LinearGradientBrush(rect, colorOther, color, System.Drawing.Drawing2D.LinearGradientMode.Vertical);
            Brush shadow     = new System.Drawing.SolidBrush(shadowColor);

            int x = rect.X;
            int y = rect.Y;
            int b = y + rect.Height;
            int r = x + rect.Width;

            GraphicsPath backgroundPath = new GraphicsPath();

            if ((roundedCorners & Corners.C_UpperLeft) != 0)
            {
                // Draw rounded upper-left
                backgroundPath.AddArc(x, y, radius * 2, radius * 2, 180, 90);
            }
            else
            {
                // Draw flat upper-left
                backgroundPath.AddLine(x, y + radius, x, y);
                backgroundPath.AddLine(x, y, radius, y);
            }

            // Draw top
            backgroundPath.AddLine(x + radius, y, r - radius, y);

            if ((roundedCorners & Corners.C_UpperRight) != 0)
            {
                // Draw rounded upper-right
                backgroundPath.AddArc(r - radius * 2, y, radius * 2, radius * 2, 270, 90);
            }
            else
            {
                // Draw flat upper-right
                backgroundPath.AddLine(r - radius, y, r, y);
                backgroundPath.AddLine(r, y, r, y + radius);
            }

            // Draw right
            backgroundPath.AddLine(r, y + radius, r, b - radius);

            if ((roundedCorners & Corners.C_LowerRight) != 0)
            {
                // Draw rounded lower-right
                backgroundPath.AddArc(r - radius * 2, b - radius * 2, radius * 2, radius * 2, 0, 90);
            }
            else
            {
                // Draw flat lower-right
                backgroundPath.AddLine(r, b - radius, r, b);
                backgroundPath.AddLine(r, b, r - radius, b);
            }

            // Draw bottom
            backgroundPath.AddLine(r - radius, b, x + radius, b);

            if ((roundedCorners & Corners.C_LowerLeft) != 0)
            {
                // Draw rounded lower-left
                backgroundPath.AddArc(x, b - radius * 2, radius * 2, radius * 2, 90, 90);
            }
            else
            {
                // Draw flat lower-left
                backgroundPath.AddLine(x + radius, b, x, b);
                backgroundPath.AddLine(x, b, x, b - radius);
            }

            // Draw left
            backgroundPath.AddLine(x, b - radius, x, y + radius);

            backgroundPath.CloseFigure();

            g.SmoothingMode = SmoothingMode.AntiAlias;

            g.FillPath(background, backgroundPath);
            if (shadowColor != null)
            {
                g.FillPath(shadow, backgroundPath);

                Matrix translateMatrix = new Matrix();
                translateMatrix.Translate(shadowOffset.X, shadowOffset.Y);
                backgroundPath.Transform(translateMatrix);
                g.FillPath(background, backgroundPath);
            }

            g.SmoothingMode = SmoothingMode.None;

            background.Dispose();
            shadow.Dispose();

            backgroundPath.Dispose();
        }