Beispiel #1
0
 /// <summary>
 /// Сброс ластика
 /// </summary>
 public void Reset()
 {
     _prevPoint = PointF.Empty;
     _eraserPath?.Dispose();
     _eraserPath = null;
     _eraseRegion?.Dispose();
     _eraseRegion = null;
 }
 /// <summary>
 /// This Dispose is called from the Dispose and the Destructor.
 /// </summary>
 /// <param name="disposing">When disposing==true all non-managed resources should be freed too!</param>
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (disposing)
     {
         freehandPath?.Dispose();
     }
     freehandPath = null;
 }
Beispiel #3
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            animationTimer?.Dispose();
            brush?.Dispose();
            path?.Dispose();
            animationTimer = null;
            brush          = null;
            path           = null;

            base.Dispose(disposing);
        }
Beispiel #4
0
        public GraphicsPath RenderPath()
        {
            if (TileMap is null)
            {
                throw new InvalidOperationException();
            }

            GraphicsPath temp   = null;
            GraphicsPath result = null;

            try
            {
                temp = new GraphicsPath();

                var viewTile  = TileMap.GetViewTile(GridTile);
                var x         = viewTile.X * TileMap.TileSize.Width;
                var y         = viewTile.Y * TileMap.TileSize.Height;
                var rectangle = new Rectangle(
                    x + Padding.Left,
                    y + Padding.Top,
                    TileMap.TileSize.Width - 1 - Padding.Horizontal,
                    TileMap.TileSize.Height - 1 - Padding.Vertical);

                temp.AddRectangle(rectangle);

                result = temp;
                temp   = null;
                return(result);
            }
            finally
            {
                temp?.Dispose();
            }
        }
 public void Dispose()
 {
     Path?.Dispose();
     Pen?.Dispose();
     EraseRegion?.Dispose();
     Brush?.Dispose();
 }
Beispiel #6
0
        /// <summary>
        /// 绘制矩形。可带圆角、阴影
        /// </summary>
        /// <param name="g"></param>
        /// <param name="rectangle">矩形</param>
        /// <param name="brush">用于填充的画刷。为null则不填充</param>
        /// <param name="border">边框描述对象。对象无效则不描边</param>
        /// <param name="radius">圆角半径</param>
        /// <param name="shadowColor">阴影颜色</param>
        /// <param name="shadowRadius">阴影羽化半径</param>
        /// <param name="offsetX">阴影横向偏移</param>
        /// <param name="offsetY">阴影纵向偏移</param>
        public static void DrawRectangle(Graphics g, Rectangle rectangle, Brush brush, Border border, int radius, Color shadowColor, int shadowRadius = 0, int offsetX = 0, int offsetY = 0)
        {
            if (shadowColor.A == 0 || (shadowRadius == 0 && offsetX == 0 && offsetY == 0))
            {
                DrawRectangle(g, rectangle, brush, border, radius);
                return;
            }

            GraphicsPath path   = null;
            Bitmap       shadow = null;

            try
            {
                path   = GetRoundedRectangle(rectangle, radius);
                shadow = DropShadow.Create(path, shadowColor, shadowRadius);

                var shadowBounds = DropShadow.GetBounds(rectangle, shadowRadius);
                shadowBounds.Offset(offsetX, offsetY);

                g.DrawImageUnscaled(shadow, shadowBounds.Location);
                DrawPath(g, path, brush, border);
            }
            finally
            {
                path?.Dispose();
                shadow?.Dispose();
            }
        }
Beispiel #7
0
        protected void RenderSelection()
        {
            if (selectPoints != null)
            {
                List <Point>  trimPoints  = TrimShapePath(selectPoints);
                List <PointF> shapePoints = CreateShape(trimPoints);

                EventHandler <SelectionPathChangedEventArgs> handler = SelectedPathChanged;
                if (handler != null)
                {
                    GraphicsPath path = null;

                    try
                    {
                        if (shapePoints.Count >= 2)
                        {
                            path = RenderShape(shapePoints);
                        }

                        using (SelectionPathChangedEventArgs args = new SelectionPathChangedEventArgs(path))
                        {
                            handler(this, args);
                        }
                    }
                    finally
                    {
                        path?.Dispose();
                    }
                }
            }
        }
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Resize"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.</param>
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);

            m_borderPath?.Dispose();

            m_borderPath = CreateBorderPath();
        }
Beispiel #9
0
 public void Clear()
 {
     SymbolSize = 0;
     FillPath?.Dispose();
     FillPath = null;
     FramePath?.Dispose();
     FramePath = null;
     InsetPath?.Dispose();
     InsetPath = null;
 }
        public MaterialToggle()
        {
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            animationManager = new AnimationManager(true)
            {
                AnimationType = AnimationType.EaseInOut,
                Increment     = 0.05
            };
            animationManager.OnAnimationProgress += sender => Invalidate();
            rippleAnimationManager = new AnimationManager(false)
            {
                AnimationType      = AnimationType.Linear,
                Increment          = 0.05,
                SecondaryIncrement = 0.05
            };
            rippleAnimationManager.OnAnimationProgress += sender => Invalidate();
            CheckedChanged += (sender, args) =>
            {
                animationManager.StartNewAnimation(Checked ? AnimationDirection.In : AnimationDirection.Out);
            };
            Height    = 40; Width = 67; DoubleBuffered = true;
            BackColor = Color.Transparent;
            Ripple    = true;
            RoundedRectangle?.Dispose();
            RoundedRectangle = new GraphicsPath();
            int radius = 10;

            RoundedRectangle.AddArc(21, Height / 2f - 5.5f, radius - 1, radius, 180, 90);
            RoundedRectangle.AddArc(Width - 31, Height / 2f - 5.5f, radius - 1, radius, -90, 90);
            RoundedRectangle.AddArc(Width - 31, Height / 2f - 5.5f, radius - 1, radius, 0, 90);
            RoundedRectangle.AddArc(21, Height / 2f - 5.5f, radius - 1, radius, 90, 90);

            RoundedRectangle.CloseFigure();
            Shadow      = null;
            ShadowShape = RoundedRectangle;
        }
Beispiel #11
0
 private void Dispose(bool disposing)
 {
     if (!disposed)
     {
         if (disposing)
         {
             bitmap?.Dispose();
             clippingPath?.Dispose();
             region?.Dispose();
             outlinePen?.Dispose();
         }
         disposed = true;
     }
 }
Beispiel #12
0
        public virtual void DrawBorder(MapGraphics graph, Frame borderSkin, RectangleF rect, Color backColor, MapHatchStyle backHatchStyle, string backImage, MapImageWrapMode backImageMode, Color backImageTranspColor, MapImageAlign backImageAlign, GradientType backGradientType, Color backSecondaryColor, Color borderColor, int borderWidth, MapDashStyle borderStyle)
        {
            RectangleF rectangleF  = MapGraphics.Round(rect);
            RectangleF rectangleF2 = rectangleF;
            float      num         = 0.2f + 0.4f * (float)(borderSkin.PageColor.R + borderSkin.PageColor.G + borderSkin.PageColor.B) / 765f;
            Color      centerColor = Color.FromArgb((int)((float)(int)borderSkin.PageColor.R * num), (int)((float)(int)borderSkin.PageColor.G * num), (int)((float)(int)borderSkin.PageColor.B * num));

            if (borderSkin.PageColor == Color.Transparent)
            {
                centerColor = Color.FromArgb(60, 0, 0, 0);
            }
            num += 0.2f;
            Color centerColor2 = Color.FromArgb((int)((float)(int)borderSkin.PageColor.R * num), (int)((float)(int)borderSkin.PageColor.G * num), (int)((float)(int)borderSkin.PageColor.B * num));
            float val          = 15f;

            val = Math.Max(val, 2f);
            val = Math.Min(val, rect.Width / 2f);
            val = Math.Min(val, rect.Height / 2f);
            val = (float)Math.Ceiling(val);
            graph.FillRectangle(new SolidBrush(borderSkin.PageColor), rect);
            rectangleF2         = rectangleF;
            rectangleF2.Width  -= val * 0.3f;
            rectangleF2.Height -= val * 0.3f;
            graph.DrawRoundedRectShadowAbs(rectangleF2, cornerRadius, val + 1f, centerColor2, borderSkin.PageColor, 1.4f);
            rectangleF2         = rectangleF;
            rectangleF2.X       = rectangleF.X + val / 3f;
            rectangleF2.Y       = rectangleF.Y + val / 3f;
            rectangleF2.Width  -= val / 3.5f;
            rectangleF2.Height -= val / 3.5f;
            graph.DrawRoundedRectShadowAbs(rectangleF2, cornerRadius, val, centerColor, borderSkin.PageColor, 1.3f);
            rectangleF2         = rectangleF;
            rectangleF2.X       = rectangleF.X + 3f;
            rectangleF2.Y       = rectangleF.Y + 3f;
            rectangleF2.Width  -= val * 0.75f;
            rectangleF2.Height -= val * 0.75f;
            GraphicsPath graphicsPath = graph.CreateRoundedRectPath(rectangleF2, cornerRadius);

            graph.DrawPathAbs(graphicsPath, backColor, backHatchStyle, backImage, backImageMode, backImageTranspColor, backImageAlign, backGradientType, backSecondaryColor, borderColor, borderWidth, borderStyle, PenAlignment.Inset);
            graphicsPath?.Dispose();
            using (Region region = new Region(graph.CreateRoundedRectPath(new RectangleF(rectangleF2.X - val, rectangleF2.Y - val, rectangleF2.Width + val - val * 0.25f, rectangleF2.Height + val - val * 0.25f), cornerRadius)))
            {
                region.Complement(graph.CreateRoundedRectPath(rectangleF2, cornerRadius));
                Region clip = graph.Clip;
                graph.Clip = region;
                graph.DrawRoundedRectShadowAbs(rectangleF2, cornerRadius, val, Color.Transparent, Color.FromArgb(128, Color.Gray), 0.5f);
                graph.Clip = clip;
            }
        }
Beispiel #13
0
        void IRenderable.RenderStaticElements(GaugeGraphics g)
        {
            if (!Visible)
            {
                return;
            }
            g.StartHotRegion(this);
            if (Image.Length != 0)
            {
                DrawImage(g, image, drawShadow: true);
                DrawImage(g, image, drawShadow: false);
                g.EndHotRegion();
                return;
            }
            GraphicsPath graphicsPath  = null;
            GraphicsPath graphicsPath2 = null;

            try
            {
                graphicsPath  = GetTextPath(g);
                graphicsPath2 = GetBackPath(g);
                g.FillPath(Brushes.White, graphicsPath2);
                AntiAliasing antiAliasing  = Common.GaugeContainer.AntiAliasing;
                AntiAliasing antiAliasing2 = g.AntiAliasing;
                if (Common.GaugeContainer.AntiAliasing == AntiAliasing.Text)
                {
                    antiAliasing = AntiAliasing.Graphics;
                }
                else if (Common.GaugeContainer.AntiAliasing == AntiAliasing.Graphics)
                {
                    antiAliasing = AntiAliasing.None;
                }
                g.AntiAliasing = antiAliasing;
                g.FillPath(Brushes.Black, graphicsPath);
                g.AntiAliasing = antiAliasing2;
                g.DrawPath(Pens.Black, graphicsPath2);
                Common.GaugeCore.HotRegionList.SetHotRegion(this, Point.Empty, (GraphicsPath)graphicsPath2.Clone());
            }
            finally
            {
                graphicsPath?.Dispose();
                graphicsPath2?.Dispose();
                g.EndHotRegion();
            }
        }
Beispiel #14
0
        protected override void Dispose(bool disposing)
        {
            if (!IsDisposed)
            {
                if (disposing)
                {
                    AppConfig.ConfigChanged             -= AppConfig_ConfigChanged;
                    SystemEvents.DisplaySettingsChanged -= AppConfig_ConfigChanged;
                    SystemEvents.UserPreferenceChanged  -= AppConfig_ConfigChanged;
                }

                _penWidth = 0;
                _bitmap?.Dispose();
                _graphicsPath?.Dispose();
                _dirtyGraphicsPath?.Dispose();
            }
            base.Dispose(disposing);
        }
        internal override void RenderStaticElements(GaugeGraphics g)
        {
            if (!base.Visible)
            {
                return;
            }
            g.StartHotRegion(this);
            base.BackFrame.RenderFrame(g);
            GraphicsState gstate = g.Save();

            if (base.ClipContent && base.BackFrame.FrameStyle != 0 && base.BackFrame.Image == string.Empty)
            {
                GraphicsPath graphicsPath = null;
                try
                {
                    graphicsPath = base.BackFrame.GetBackPath(g);
                    g.SetClip(graphicsPath, CombineMode.Intersect);
                }
                finally
                {
                    graphicsPath?.Dispose();
                }
            }
            Common.GaugeCore.HotRegionList.SetHotRegion(this, g.GetAbsolutePoint(PivotPoint.ToPoint()), base.BackFrame.GetFramePath(g, 0f));
            g.EndHotRegion();
            g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f));
            RenderStaticShadows(g);
            foreach (CircularRange range in Ranges)
            {
                range.Render(g);
            }
            foreach (CircularScale scale in Scales)
            {
                scale.RenderStaticElements(g);
            }
            foreach (CircularPointer pointer in Pointers)
            {
                pointer.ResetCachedXamlRenderer();
            }
            if (base.ClipContent && base.BackFrame.FrameStyle != 0 && base.BackFrame.Image == string.Empty)
            {
                g.Restore(gstate);
            }
        }
        internal override void Render(GaugeGraphics g)
        {
            if (Common == null || !base.Visible || GetScale() == null || double.IsNaN(StartValue) || double.IsNaN(EndValue))
            {
                return;
            }
            Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRendering(Name));
            g.StartHotRegion(this);
            LinearScale  scale        = GetScale();
            Pen          pen          = null;
            Brush        brush        = null;
            GraphicsPath graphicsPath = null;

            try
            {
                graphicsPath = g.GetLinearRangePath(scale.GetPositionFromValue(StartValue), scale.GetPositionFromValue(EndValue), StartWidth, EndWidth, scale.Position, GetGauge().GetOrientation(), DistanceFromScale, Placement, scale.Width);
                if (graphicsPath == null || !g.Graphics.VisibleClipBounds.IntersectsWith(graphicsPath.GetBounds()))
                {
                    g.EndHotRegion();
                    Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(Name));
                    return;
                }
                brush         = g.GetLinearRangeBrush(graphicsPath.GetBounds(), base.FillColor, base.FillHatchStyle, base.FillGradientType, base.FillGradientEndColor, GetGauge().GetOrientation(), GetScale().GetReversed(), StartValue, EndValue);
                pen           = new Pen(base.BorderColor, base.BorderWidth);
                pen.DashStyle = g.GetPenStyle(base.BorderStyle);
                g.FillPath(brush, graphicsPath);
                if (base.BorderStyle != 0 && base.BorderWidth > 0)
                {
                    g.DrawPath(pen, graphicsPath);
                }
            }
            catch (Exception)
            {
                graphicsPath?.Dispose();
                pen?.Dispose();
                brush?.Dispose();
                throw;
            }
            Common.GaugeCore.HotRegionList.SetHotRegion(this, PointF.Empty, graphicsPath);
            g.EndHotRegion();
            Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(Name));
        }
        internal override void RenderDynamicElements(GaugeGraphics g)
        {
            if (!base.Visible)
            {
                return;
            }
            GraphicsState gstate = g.Save();

            if (base.ClipContent && base.BackFrame.FrameStyle != 0 && base.BackFrame.Image == string.Empty)
            {
                GraphicsPath graphicsPath = null;
                try
                {
                    graphicsPath = ((base.BackFrame.FrameStyle != 0) ? base.BackFrame.GetBackPath(g) : base.BackFrame.GetFramePath(g, 0f));
                    g.SetClip(graphicsPath, CombineMode.Intersect);
                }
                finally
                {
                    graphicsPath?.Dispose();
                }
            }
            RenderDynamicShadows(g);
            foreach (Knob knob in Knobs)
            {
                knob.Render(g);
            }
            foreach (CircularPointer pointer in Pointers)
            {
                pointer.Render(g);
            }
            foreach (CircularScale scale in Scales)
            {
                scale.RenderDynamicElements(g);
            }
            if (base.ClipContent && base.BackFrame.FrameStyle != 0 && base.BackFrame.Image == string.Empty)
            {
                g.Restore(gstate);
            }
            base.BackFrame.RenderGlassEffect(g);
            RenderTopImage(g);
        }
Beispiel #18
0
        internal override void RenderStaticElements(GaugeGraphics g)
        {
            if (!base.Visible)
            {
                return;
            }
            AbsoluteSize = g.GetAbsoluteSize(base.Size);
            g.StartHotRegion(this);
            base.BackFrame.RenderFrame(g);
            GraphicsState gstate = g.Save();

            if (base.ClipContent && base.BackFrame.FrameStyle != 0 && base.BackFrame.Image == string.Empty)
            {
                GraphicsPath graphicsPath = null;
                try
                {
                    graphicsPath = ((base.BackFrame.FrameStyle != 0) ? base.BackFrame.GetBackPath(g) : base.BackFrame.GetFramePath(g, 0f));
                    g.SetClip(graphicsPath, CombineMode.Intersect);
                }
                finally
                {
                    graphicsPath?.Dispose();
                }
            }
            Common.GaugeCore.HotRegionList.SetHotRegion(this, PointF.Empty, base.BackFrame.GetFramePath(g, 0f));
            g.EndHotRegion();
            RenderStaticShadows(g);
            foreach (LinearRange range in Ranges)
            {
                range.Render(g);
            }
            foreach (LinearScale scale in Scales)
            {
                scale.RenderStaticElements(g);
            }
            if (base.ClipContent && base.BackFrame.FrameStyle != 0 && base.BackFrame.Image == string.Empty)
            {
                g.Restore(gstate);
            }
        }
Beispiel #19
0
        protected override void Dispose(bool disposing)
        {
            if (!IsDisposed)
            {
                if (disposing)
                {
                    PointCapture.Instance.PointCaptured   -= PointCapture_PointCaptured;
                    PointCapture.Instance.CaptureEnded    -= PointCapture_CaptureEnded;
                    PointCapture.Instance.CaptureCanceled -= PointCapture_CaptureCanceled;
                    PointCapture.Instance.CaptureStarted  -= Instance_CaptureStarted;

                    AppConfig.ConfigChanged             -= AppConfig_ConfigChanged;
                    SystemEvents.DisplaySettingsChanged -= AppConfig_ConfigChanged;
                    SystemEvents.UserPreferenceChanged  -= AppConfig_ConfigChanged;
                }

                _bitmap?.Dispose();
                _graphicsPath?.Dispose();
                _dirtyGraphicsPath?.Dispose();
            }
            base.Dispose(disposing);
        }
Beispiel #20
0
        private void DrawFeatures(MapArgs e, IEnumerable <int> indices)
        {
            Graphics g = e.Device ?? Graphics.FromImage(BackBuffer);

            if (DrawnStatesNeeded)
            {
                FastDrawnState[] states = DrawnStates;
                int max = indices.Max();
                if (max >= states.Length)
                {
                    AssignFastDrawnStates();
                    states = DrawnStates;
                }
                for (int selectState = 0; selectState < 2; selectState++)
                {
                    foreach (ILineCategory category in Symbology.Categories)
                    {
                        // Define the symbology based on the category and selection state
                        ILineSymbolizer ls = category.Symbolizer;
                        if (selectState == SELECTED)
                        {
                            ls = category.SelectionSymbolizer;
                        }
                        g.SmoothingMode = ls.Smoothing ? SmoothingMode.AntiAlias : SmoothingMode.None;

                        // Compute a clipping rectangle that accounts for symbology
                        Rectangle clipRect = ComputeClippingRectangle(e, ls);

                        // Determine the subset of the specified features that are visible and match the category
                        ILineCategory lineCategory = category;
                        int           i            = selectState;

                        List <int> drawnFeatures = new List <int>();

                        foreach (int index in indices)
                        {
                            if (index >= states.Length)
                            {
                                break;
                            }
                            FastDrawnState state = states[index];
                            if (state.Category == lineCategory && state.Selected == (i == 1) && state.Visible)
                            {
                                drawnFeatures.Add(index);
                            }
                        }

                        GraphicsPath graphPath = new GraphicsPath();
                        foreach (int shp in drawnFeatures)
                        {
                            ShapeRange shape = DataSet.ShapeIndices[shp];
                            BuildLineString(graphPath, DataSet.Vertex, shape, e, clipRect);
                        }
                        double scale = 1;
                        if (ls.ScaleMode == ScaleMode.Geographic)
                        {
                            scale = e.ImageRectangle.Width / e.GeographicExtents.Width;
                        }

                        foreach (IStroke stroke in ls.Strokes)
                        {
                            stroke.DrawPath(g, graphPath, scale);
                        }

                        graphPath.Dispose();
                    }
                }
            }
            else
            {
                // Selection state is disabled
                // Category is only the very first category
                ILineCategory   category = Symbology.Categories[0];
                ILineSymbolizer ls       = category.Symbolizer;

                g.SmoothingMode = ls.Smoothing ? SmoothingMode.AntiAlias : SmoothingMode.None;

                Rectangle clipRect = ComputeClippingRectangle(e, ls);
                // Determine the subset of the specified features that are visible and match the category
                GraphicsPath graphPath = new GraphicsPath();
                foreach (int shp in indices)
                {
                    ShapeRange shape = DataSet.ShapeIndices[shp];
                    BuildLineString(graphPath, DataSet.Vertex, shape, e, clipRect);
                }
                double scale = 1;
                if (ls.ScaleMode == ScaleMode.Geographic)
                {
                    scale = e.ImageRectangle.Width / e.GeographicExtents.Width;
                }

                foreach (IStroke stroke in ls.Strokes)
                {
                    stroke.DrawPath(g, graphPath, scale);
                }

                graphPath.Dispose();
            }

            if (e.Device == null)
            {
                g.Dispose();
            }
        }
Beispiel #21
0
            protected override void OnMouseDown(MouseEventArgs e)
            {
                if (e.Button != MouseButtons.Left)
                {
                    return;
                }

                bool isColor = false, isAnyShape = false;
                var  ic = _flags & (WICFlags.Image | WICFlags.Color | WICFlags.Rectangle);

                if (ic == WICFlags.Color)
                {
                    isColor = true;
                }
                else
                {
                    var mod = ModifierKeys;
                    if (mod != 0 && ic == WICFlags.Rectangle)
                    {
                        return;
                    }
                    switch (mod)
                    {
                    case Keys.None: break;

                    case Keys.Shift: isAnyShape = true; break;

                    case Keys.Control when ic != WICFlags.Image: isColor = true; break;

                    default: return;
                    }
                }

                Result = new WICResult();
                POINT p0 = e.Location;

                if (isColor)
                {
                    Result.color = _img.GetPixel(p0.x, p0.y).ToArgb();
                    Result.rect  = new RECT(p0.x, p0.y, 1, 1);
                }
                else
                {
                    var r = new RECT(p0.x, p0.y, 0, 0);
                    var a = isAnyShape ? new List <POINT>()
                    {
                        p0
                    } : null;
                    var  pen          = Pens.Red;
                    bool notFirstMove = false;
                    _capturing = true;
                    try {
                        if (!ADragDrop.SimpleDragDrop(this, MButtons.Left, m => {
                            if (m.Msg.message != Api.WM_MOUSEMOVE)
                            {
                                return;
                            }
                            POINT p = m.Msg.pt;
                            p.x -= Left; p.y -= Top;                             //screen to client
                            using var g = this.CreateGraphics();
                            if (isAnyShape)
                            {
                                a.Add(p);
                                g.DrawLine(pen, p0, p);
                                p0 = p;
                            }
                            else
                            {
                                if (notFirstMove)                                  //erase prev rect
                                {
                                    r.right++; r.bottom++;
                                    g.DrawImage(_img, r, r, GraphicsUnit.Pixel);
                                    //FUTURE: prevent flickering. Also don't draw under magnifier.
                                }
                                else
                                {
                                    notFirstMove = true;
                                }
                                r = new RECT(p0.x, p0.y, p.x, p.y, false);
                                r.Normalize(true);
                                g.DrawRectangle(pen, r);
                            }
                        }))                           //Esc key etc
                        {
                            this.Invalidate();
                            return;
                        }
                    }
                    finally { _capturing = false; }

                    GraphicsPath path = null;
                    if (isAnyShape && a.Count > 1)
                    {
                        path = _CreatePath(a);
                        r    = (RECT)path.GetBounds();
                    }
                    else
                    {
                        r.right++; r.bottom++;
                    }
                    if (r.IsEmpty)
                    {
                        this.Close();
                        return;
                    }

                    if (ic != WICFlags.Rectangle)
                    {
                        var b = _img.Clone(r, PixelFormat.Format32bppArgb);
                        var d = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, b.PixelFormat);
                        try {
                            _SetAlpha(d, r, path);
                        }
                        finally { b.UnlockBits(d); path?.Dispose(); }
                        Result.image = b;
                    }

                    r.Offset(Left, Top);                     //client to screen
                    Result.rect = r;
                }

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
Beispiel #22
0
        /// <summary>
        /// This gets called to instruct the element to draw itself in the appropriate spot of the graphics object
        /// </summary>
        /// <param name="g">The graphics object to draw to</param>
        /// <param name="printing">Boolean, true if printing to an actual print document</param>
        public override void Draw(Graphics g, bool printing)
        {
            GraphicsPath GP     = new GraphicsPath();
            StringFormat format = new StringFormat();

            format.LineAlignment = StringAlignment.Near;
            format.Alignment     = StringAlignment.Near;

            if (_layoutMap == null || _layoutMap.Scale == 0)
            {
                return;
            }

            // Sets up the pens and brushes
            Brush scaleBrush = new SolidBrush(_color);
            Pen   scalePen   = new Pen(scaleBrush);

            // Calculates the width of one break in greographic units
            float unitLegnth    = g.MeasureString(_unitText, _font).Width * 2;
            float widthNoUnit   = Size.Width - unitLegnth;
            long  geoBreakWidth = Convert.ToInt64((widthNoUnit / 100 * _layoutMap.Scale) / GetConversionFactor(_unit.ToString()) / _numBreaks);

            // If the geobreakWidth is less than 1 we return and don't draw anything
            if (geoBreakWidth < 1)
            {
                return;
            }

            // Save the old transform
            Matrix oldTransform = g.Transform;

            g.TranslateTransform(Location.X, Location.Y);
            TextRenderingHint oldHint = g.TextRenderingHint;

            g.TextRenderingHint = _textHint;

            double n = Math.Pow(10, geoBreakWidth.ToString(CultureInfo.InvariantCulture).Length - 1);

            geoBreakWidth = Convert.ToInt64(Math.Floor(geoBreakWidth / n) * n);
            long  breakWidth = Convert.ToInt64((1D * geoBreakWidth / _layoutMap.Scale) * GetConversionFactor(_unit.ToString()) * 100D);
            float fontHeight = g.MeasureString(geoBreakWidth.ToString(CultureInfo.InvariantCulture), _font).Height;
            float leftStart  = g.MeasureString(Math.Abs(geoBreakWidth).ToString(CultureInfo.InvariantCulture), _font).Width / 2F;

            // Decides if a break should be drawn before the zero
            int startBreak = 0;

            if (_breakBeforeZero)
            {
                startBreak = -1;
            }

            // CGX
            g.SetClip(Rectangle, CombineMode.Union);
            // fin CGX

            g.DrawLine(scalePen, leftStart, fontHeight * 1.6f, leftStart + (breakWidth * _numBreaks), fontHeight * 1.6f);

            //g.DrawString("1 : " + String.Format("{0:0, }", Map.Scale), _font, scaleBrush, leftStart - (g.MeasureString(Math.Abs(geoBreakWidth * startBreak).ToString(), _font).Width / 2), fontHeight * 2.5F);
            //CGX
            PointF pointScale = new PointF(leftStart - (g.MeasureString(Math.Abs(geoBreakWidth * startBreak).ToString(), _font).Width / 2), fontHeight * 2.5F);

            GP.AddString("1 : " + String.Format("{0:0 }", Map.Scale), _font.FontFamily, (int)_font.Style, _font.SizeInPoints * 96F / 72F, pointScale, format);

            for (int i = startBreak; i <= _numBreaks + startBreak; i++)
            {
                PointF pUp   = new PointF(leftStart, fontHeight + (fontHeight * 1.1f));
                PointF pDown = new PointF(leftStart, fontHeight * 1.1f);

                g.DrawLine(scalePen, leftStart, fontHeight * 1.1f, leftStart, fontHeight + (fontHeight * 1.1f));
                GP.AddString(Math.Abs(geoBreakWidth * i).ToString(CultureInfo.InvariantCulture), _font.FontFamily, (int)_font.Style, _font.SizeInPoints * 96F / 72F, new PointF(leftStart - (g.MeasureString(Math.Abs(geoBreakWidth * i).ToString(), _font).Width / 2), 0), format);
                leftStart = leftStart + breakWidth;
            }
            GP.AddString(_unitText, _font.FontFamily, (int)_font.Style, _font.SizeInPoints * 96F / 72F, new PointF(leftStart - breakWidth + (fontHeight / 2), fontHeight * 1.1f), format);

            g.FillPath(new SolidBrush(_color), GP);
            GP.Dispose();

            //Restore the old transform
            g.Transform         = oldTransform;
            g.TextRenderingHint = oldHint;
        }
Beispiel #23
0
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }

            if (darkBackgroundBrush != null)
            {
                darkBackgroundBrush.Dispose();
            }
            if (lightBackgroundBrush != null)
            {
                lightBackgroundBrush.Dispose();
            }
            if (borderPen != null)
            {
                borderPen.Dispose();
            }
            if (borderDotPen != null)
            {
                borderDotPen.Dispose();
            }
            if (nodeBackgroundBrush != null)
            {
                nodeBackgroundBrush.Dispose();
            }
            if (textFont != null)
            {
                textFont.Dispose();
            }
            if (infoFont != null)
            {
                infoFont.Dispose();
            }
            if (textBackgroundBrush != null)
            {
                textBackgroundBrush.Dispose();
            }
            if (textBackgroundPenWhite != null)
            {
                textBackgroundPenWhite.Dispose();
            }
            if (textBackgroundPenBlack != null)
            {
                textBackgroundPenBlack.Dispose();
            }
            if (markerPen != null)
            {
                markerPen.Dispose();
            }

            if (regionFillPath != null)
            {
                if (LastRegionFillPath != null)
                {
                    LastRegionFillPath.Dispose();
                }
                LastRegionFillPath = regionFillPath;
                if (LastRegionDrawPath != null)
                {
                    LastRegionDrawPath.Dispose();
                }
                LastRegionDrawPath = regionDrawPath;
            }
            else
            {
                if (regionFillPath != null)
                {
                    regionFillPath.Dispose();
                }
                if (regionDrawPath != null)
                {
                    regionDrawPath.Dispose();
                }
            }

            base.Dispose(disposing);
        }
Beispiel #24
0
        /// <summary>
        ///   Draws the given <see cref="WallpaperTextOverlay" /> objects by using the given <see cref="Graphics" /> object.
        /// </summary>
        /// <param name="destGraphics">
        ///   The <see cref="Graphics" /> to draw with.
        /// </param>
        /// <param name="rect">
        ///   The destination <see cref="Rectangle" /> to draw into.
        /// </param>
        /// <param name="wallpapers">
        ///   The collection of <see cref="Wallpaper" /> objects which are actually being applied. Note that the items in this
        ///   collection require to be in the same index as the screen where they are going to be applied on.
        /// </param>
        /// <param name="overlayTexts">
        ///   A collection of <see cref="WallpaperTextOverlay" /> objects to be drawn.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///   <paramref name="destGraphics" /> or <paramref name="wallpapers" /> or <paramref name="overlayTexts" /> is <c>null</c>
        ///   .
        /// </exception>
        /// <seealso cref="Graphics">Graphics Class</seealso>
        /// <seealso cref="WallpaperTextOverlay">WallpaperTextOverlay Class</seealso>
        /// <seealso cref="Wallpaper">Wallpaper Class</seealso>
        private static void DrawOverlayTexts(Graphics destGraphics, Rectangle rect, IList <Wallpaper> wallpapers, IList <WallpaperTextOverlay> overlayTexts)
        {
            if (destGraphics == null)
            {
                throw new ArgumentNullException();
            }
            if (wallpapers == null)
            {
                throw new ArgumentNullException();
            }
            if (overlayTexts == null)
            {
                throw new ArgumentNullException();
            }
            if (overlayTexts.Count == 0)
            {
                return;
            }

            GraphicsContainer graphicalContext = null;

            try {
                graphicalContext           = destGraphics.BeginContainer();
                destGraphics.SmoothingMode = SmoothingMode.AntiAlias;
                destGraphics.SetClip(rect);

                foreach (WallpaperTextOverlay overlayText in overlayTexts)
                {
                    if (overlayText != null)
                    {
                        using (StringFormat format = new StringFormat(StringFormatFlags.NoWrap | StringFormatFlags.NoClip)) {
                            switch (overlayText.Position)
                            {
                            case TextOverlayPosition.TopLeft:
                                format.Alignment     = StringAlignment.Near;
                                format.LineAlignment = StringAlignment.Near;
                                break;

                            case TextOverlayPosition.TopMiddle:
                                format.Alignment     = StringAlignment.Center;
                                format.LineAlignment = StringAlignment.Near;
                                break;

                            case TextOverlayPosition.TopRight:
                                format.Alignment     = StringAlignment.Far;
                                format.LineAlignment = StringAlignment.Near;
                                break;

                            case TextOverlayPosition.BottomLeft:
                                format.Alignment     = StringAlignment.Near;
                                format.LineAlignment = StringAlignment.Far;
                                break;

                            case TextOverlayPosition.BottomMiddle:
                                format.Alignment     = StringAlignment.Center;
                                format.LineAlignment = StringAlignment.Far;
                                break;

                            default:
                                format.Alignment     = StringAlignment.Far;
                                format.LineAlignment = StringAlignment.Far;
                                break;
                            }

                            Rectangle textRect = rect;
                            textRect.X += overlayText.HorizontalOffset;
                            textRect.Y += overlayText.VerticalOffset;

                            GraphicsPath textPath   = null;
                            FontFamily   fontFamily = null;
                            Pen          borderPen  = null;
                            SolidBrush   fontBrush  = null;
                            try {
                                float fontSizeInPixels = (destGraphics.DpiY * overlayText.FontSize / 72);
                                fontFamily = new FontFamily(overlayText.FontName);

                                textPath = new GraphicsPath();
                                textPath.AddString(
                                    overlayText.GetEvaluatedText(wallpapers),
                                    fontFamily, (int)overlayText.FontStyle, fontSizeInPixels,
                                    textRect, format);

                                borderPen = new Pen(overlayText.BorderColor, (float)Math.Round(fontSizeInPixels * 0.2, 2));
                                fontBrush = new SolidBrush(overlayText.ForeColor);
                                destGraphics.DrawPath(borderPen, textPath);
                                destGraphics.FillPath(fontBrush, textPath);
                            } finally {
                                textPath?.Dispose();
                                fontFamily?.Dispose();
                                borderPen?.Dispose();
                                fontBrush?.Dispose();
                            }
                        }
                    }
                }
            } finally {
                if (graphicalContext != null)
                {
                    destGraphics.EndContainer(graphicalContext);
                }
            }
        }
Beispiel #25
0
    private static Image MakeRoundedCorners(Image image, int radius)
    {
        Bitmap bmp = new Bitmap(image, image.Width, image.Height);
        using (Graphics g = Graphics.FromImage(bmp))
        {
            Brush brush = new SolidBrush(Color.White);

            for (int i = 0; i < 4; i++)
            {
                Point[] cornerUpLeft = new Point[3];

                cornerUpLeft[0].X = 0;
                cornerUpLeft[0].Y = 0;

                cornerUpLeft[1].X = radius;
                cornerUpLeft[1].Y = 0;

                cornerUpLeft[2].X = 0;
                cornerUpLeft[2].Y = radius;

                GraphicsPath pathCornerUpLeft = new GraphicsPath();

                pathCornerUpLeft.AddArc(cornerUpLeft[0].X, cornerUpLeft[0].Y,
                                        radius, radius, 180, 90);
                pathCornerUpLeft.AddLine(cornerUpLeft[0].X, cornerUpLeft[0].Y,
                                         cornerUpLeft[1].X, cornerUpLeft[1].Y);
                pathCornerUpLeft.AddLine(cornerUpLeft[0].X, cornerUpLeft[0].Y,
                                         cornerUpLeft[2].X, cornerUpLeft[2].Y);

                g.FillPath(brush, pathCornerUpLeft);
                pathCornerUpLeft.Dispose();

                bmp.RotateFlip(RotateFlipType.Rotate90FlipNone);
            }

            brush.Dispose();
            g.Dispose();
        }
        return bmp;
    }
Beispiel #26
0
        private void DrawSeries(Graphics g)
        {
            if (YScale == null)
            {
                return;
            }

            int idx = 0;

            if (Option.GreaterWarningArea == null && Option.LessWarningArea == null)
            {
                foreach (var series in Option.Series.Values)
                {
                    Color color = series.Color;
                    if (!series.CustomColor)
                    {
                        color = ChartStyle.GetColor(idx);
                    }
                    DrawSeries(g, color, series);
                    idx++;
                }
            }
            else
            {
                Bitmap bmp        = new Bitmap(Width, Height);
                Bitmap bmpGreater = new Bitmap(Width, Height);
                Bitmap bmpLess    = new Bitmap(Width, Height);
                float  wTop       = 0;
                float  wBottom    = Height;

                foreach (var series in Option.Series.Values)
                {
                    Color color = series.Color;
                    if (!series.CustomColor)
                    {
                        color = ChartStyle.GetColor(idx);
                    }

                    using (Graphics graphics = bmp.Graphics())
                    {
                        DrawSeries(graphics, color, series);
                    }

                    if (Option.GreaterWarningArea != null)
                    {
                        using (Graphics graphics = bmpGreater.Graphics())
                        {
                            DrawSeries(graphics, Option.GreaterWarningArea.Color, series);
                        }
                    }

                    if (Option.LessWarningArea != null)
                    {
                        using (Graphics graphics = bmpLess.Graphics())
                        {
                            DrawSeries(graphics, Option.LessWarningArea.Color, series);
                        }
                    }

                    idx++;
                }

                if (Option.GreaterWarningArea != null)
                {
                    wTop = YScale.CalcYPixel(Option.GreaterWarningArea.Value, DrawOrigin.Y, DrawSize.Height);
                    g.DrawImage(bmpGreater, new Rectangle(0, 0, Width, (int)wTop),
                                new Rectangle(0, 0, Width, (int)wTop), GraphicsUnit.Pixel);
                }

                if (Option.LessWarningArea != null)
                {
                    wBottom = YScale.CalcYPixel(Option.LessWarningArea.Value, DrawOrigin.Y, DrawSize.Height);
                    g.DrawImage(bmpLess, new Rectangle(0, (int)wBottom, Width, Height - (int)wBottom),
                                new Rectangle(0, (int)wBottom, Width, Height - (int)wBottom), GraphicsUnit.Pixel);
                }

                g.DrawImage(bmp, new Rectangle(0, (int)wTop, Width, (int)wBottom - (int)wTop),
                            new Rectangle(0, (int)wTop, Width, (int)wBottom - (int)wTop), GraphicsUnit.Pixel);

                bmpGreater.Dispose();
                bmpLess.Dispose();
                bmp.Dispose();
            }

            idx = 0;
            foreach (var series in Option.Series.Values)
            {
                Color color = series.Color;
                if (!series.CustomColor)
                {
                    color = ChartStyle.GetColor(idx);
                }

                if (series.Symbol != UILinePointSymbol.None)
                {
                    using (Brush br = new SolidBrush(ChartStyle.BackColor))
                        using (Pen pn = new Pen(color, series.SymbolLineWidth))
                        {
                            foreach (var p in series.Points)
                            {
                                switch (series.Symbol)
                                {
                                case UILinePointSymbol.Square:
                                    g.FillRectangle(br, p.X - series.SymbolSize, p.Y - series.SymbolSize, series.SymbolSize * 2, series.SymbolSize * 2);
                                    g.DrawRectangle(pn, p.X - series.SymbolSize, p.Y - series.SymbolSize, series.SymbolSize * 2, series.SymbolSize * 2);
                                    break;

                                case UILinePointSymbol.Diamond:
                                {
                                    PointF   pt1 = new PointF(p.X - series.SymbolSize, p.Y);
                                    PointF   pt2 = new PointF(p.X, p.Y - series.SymbolSize);
                                    PointF   pt3 = new PointF(p.X + series.SymbolSize, p.Y);
                                    PointF   pt4 = new PointF(p.X, p.Y + series.SymbolSize);
                                    PointF[] pts = { pt1, pt2, pt3, pt4, pt1 };
                                    g.SetHighQuality();
                                    GraphicsPath path = pts.Path();
                                    g.FillPath(br, path);
                                    g.DrawPath(pn, path);
                                    path.Dispose();
                                }
                                break;

                                case UILinePointSymbol.Triangle:
                                {
                                    PointF   pt1 = new PointF(p.X, p.Y - series.SymbolSize);
                                    PointF   pt2 = new PointF(p.X - series.SymbolSize * 0.866f, p.Y + series.SymbolSize * 0.5f);
                                    PointF   pt3 = new PointF(p.X + series.SymbolSize * 0.866f, p.Y + series.SymbolSize * 0.5f);
                                    PointF[] pts = { pt1, pt2, pt3, pt1 };
                                    g.SetHighQuality();
                                    GraphicsPath path = pts.Path();
                                    g.FillPath(br, path);
                                    g.DrawPath(pn, path);
                                    path.Dispose();
                                }
                                break;

                                case UILinePointSymbol.Circle:
                                    g.SetHighQuality();
                                    g.FillEllipse(br, p.X - series.SymbolSize, p.Y - series.SymbolSize, series.SymbolSize * 2, series.SymbolSize * 2);
                                    g.DrawEllipse(pn, p.X - series.SymbolSize, p.Y - series.SymbolSize, series.SymbolSize * 2, series.SymbolSize * 2);
                                    break;

                                case UILinePointSymbol.Plus:
                                    g.DrawLine(pn, p.X - series.SymbolSize, p.Y, p.X + series.SymbolSize, p.Y);
                                    g.DrawLine(pn, p.X, p.Y - series.SymbolSize, p.X, p.Y + series.SymbolSize);
                                    break;

                                case UILinePointSymbol.Star:
                                    g.SetHighQuality();
                                    g.DrawLine(pn, p.X, p.Y - series.SymbolSize, p.X, p.Y + series.SymbolSize);
                                    g.DrawLine(pn, p.X - series.SymbolSize * 0.866f, p.Y + series.SymbolSize * 0.5f,
                                               p.X + series.SymbolSize * 0.866f, p.Y - series.SymbolSize * 0.5f);
                                    g.DrawLine(pn, p.X - series.SymbolSize * 0.866f, p.Y - series.SymbolSize * 0.5f,
                                               p.X + series.SymbolSize * 0.866f, p.Y + series.SymbolSize * 0.5f);
                                    break;
                                }
                            }
                        }

                    g.SetDefaultQuality();
                }

                idx++;
            }
        }
        private void AddGraphicsPath(SvgTextContentElement element, ref PointF ctp, string text)
        {
            if (text.Length == 0)
            {
                return;
            }

            float        emSize = GetComputedFontSize(element);
            FontFamily   family = GetGDIFontFamily(element, emSize);
            int          style  = GetGDIFontStyle(element);
            StringFormat sf     = GetGDIStringFormat(element);

            GraphicsPath textGeometry = new GraphicsPath();

            float xCorrection = 0;

            if (sf.Alignment == StringAlignment.Near)
            {
                xCorrection = emSize * 1 / 6;
            }
            else if (sf.Alignment == StringAlignment.Far)
            {
                xCorrection = -emSize * 1 / 6;
            }

            float yCorrection = (float)(family.GetCellAscent(FontStyle.Regular)) / (float)(family.GetEmHeight(FontStyle.Regular)) * emSize;

            // TODO: font property
            PointF p = new PointF(ctp.X - xCorrection, ctp.Y - yCorrection);

            textGeometry.AddString(text, family, style, emSize, p, sf);
            if (!textGeometry.GetBounds().IsEmpty)
            {
                float bboxWidth = textGeometry.GetBounds().Width;
                if (sf.Alignment == StringAlignment.Center)
                {
                    bboxWidth /= 2;
                }
                else if (sf.Alignment == StringAlignment.Far)
                {
                    bboxWidth = 0;
                }

                ctp.X += bboxWidth + emSize / 4;
            }

            GdiSvgPaint fillPaint = new GdiSvgPaint(element, "fill");
            Brush       brush     = fillPaint.GetBrush(textGeometry);

            GdiSvgPaint strokePaint = new GdiSvgPaint(element, "stroke");
            Pen         pen         = strokePaint.GetPen(textGeometry);

            if (brush != null)
            {
                if (brush is PathGradientBrush)
                {
                    GdiGradientFill gps = fillPaint.PaintFill as GdiGradientFill;

                    _graphics.SetClip(gps.GetRadialGradientRegion(textGeometry.GetBounds()), CombineMode.Exclude);

                    SolidBrush tempBrush = new SolidBrush(((PathGradientBrush)brush).InterpolationColors.Colors[0]);
                    _graphics.FillPath(this, tempBrush, textGeometry);
                    tempBrush.Dispose();
                    _graphics.ResetClip();
                }

                _graphics.FillPath(this, brush, textGeometry);
                brush.Dispose();
            }

            if (pen != null)
            {
                if (pen.Brush is PathGradientBrush)
                {
                    GdiGradientFill      gps       = strokePaint.PaintFill as GdiGradientFill;
                    GdiGraphicsContainer container = _graphics.BeginContainer();

                    _graphics.SetClip(gps.GetRadialGradientRegion(textGeometry.GetBounds()), CombineMode.Exclude);

                    SolidBrush tempBrush = new SolidBrush(((PathGradientBrush)pen.Brush).InterpolationColors.Colors[0]);
                    Pen        tempPen   = new Pen(tempBrush, pen.Width);
                    _graphics.DrawPath(this, tempPen, textGeometry);
                    tempPen.Dispose();
                    tempBrush.Dispose();

                    _graphics.EndContainer(container);
                }

                _graphics.DrawPath(this, pen, textGeometry);
                pen.Dispose();
            }

            textGeometry.Dispose();
        }
 public void Dispose()
 {
     Path?.Dispose();
 }
Beispiel #29
0
        private void DrawPointerDown(Graphics g)
        {
            Point[] points1 = new Point[6]
            {
                new Point(this.ThumbBounds.Left + this.ThumbBounds.Width / 2, this.ThumbBounds.Bottom - 1),
                new Point(this.ThumbBounds.Left, this.ThumbBounds.Bottom - this.ThumbBounds.Width / 2 - 1),
                this.ThumbBounds.Location,
                new Point(this.ThumbBounds.Right - 1, this.ThumbBounds.Top),
                new Point(this.ThumbBounds.Right - 1, this.ThumbBounds.Bottom - this.ThumbBounds.Width / 2 - 1),
                new Point(this.ThumbBounds.Left + this.ThumbBounds.Width / 2, this.ThumbBounds.Bottom - 1)
            };
            GraphicsPath path = new GraphicsPath();

            path.AddLines(points1);
            Region region = new Region(path);

            g.Clip = region;
            if (this.ThumbState == 3 || !this.Enabled)
            {
                ControlPaint.DrawButton(g, this.ThumbBounds, ButtonState.All);
            }
            else
            {
                g.Clear(SystemColors.Control);
            }
            g.ResetClip();
            region.Dispose();
            path.Dispose();
            Point[] points2 = new Point[4]
            {
                points1[0],
                points1[1],
                points1[2],
                points1[3]
            };
            g.DrawLines(SystemPens.ControlLightLight, points2);
            Point[] points3 = new Point[3]
            {
                points1[3],
                points1[4],
                points1[5]
            };
            g.DrawLines(SystemPens.ControlDarkDark, points3);
            points1[0].Offset(0, -1);
            points1[1].Offset(1, 0);
            points1[2].Offset(1, 1);
            points1[3].Offset(-1, 1);
            points1[4].Offset(-1, 0);
            points1[5] = points1[0];
            Point[] points4 = new Point[4]
            {
                points1[0],
                points1[1],
                points1[2],
                points1[3]
            };
            g.DrawLines(SystemPens.ControlLight, points4);
            Point[] points5 = new Point[3]
            {
                points1[3],
                points1[4],
                points1[5]
            };
            g.DrawLines(SystemPens.ControlDark, points5);
        }
        public virtual void DrawBorder(MapGraphics graph, Frame borderSkin, RectangleF rect, Color backColor, MapHatchStyle backHatchStyle, string backImage, MapImageWrapMode backImageMode, Color backImageTranspColor, MapImageAlign backImageAlign, GradientType backGradientType, Color backSecondaryColor, Color borderColor, int borderWidth, MapDashStyle borderStyle)
        {
            RectangleF rectangleF  = MapGraphics.Round(rect);
            RectangleF rectangleF2 = rectangleF;
            float      num         = 0.3f + 0.4f * (float)(borderSkin.PageColor.R + borderSkin.PageColor.G + borderSkin.PageColor.B) / 765f;
            Color      color       = Color.FromArgb((int)((float)(int)backColor.R * num), (int)((float)(int)backColor.G * num), (int)((float)(int)backColor.B * num));

            num += 0.2f;
            Color centerColor = Color.FromArgb((int)((float)(int)borderSkin.PageColor.R * num), (int)((float)(int)borderSkin.PageColor.G * num), (int)((float)(int)borderSkin.PageColor.B * num));

            if (borderSkin.PageColor == Color.Transparent)
            {
                centerColor = Color.FromArgb(60, 0, 0, 0);
            }
            Color.FromArgb((int)((float)(int)backColor.R * num), (int)((float)(int)backColor.G * num), (int)((float)(int)backColor.B * num));
            float val = defaultRadiusSize;

            val = Math.Max(val, 2f);
            val = Math.Min(val, rect.Width / 2f);
            val = Math.Min(val, rect.Height / 2f);
            val = (float)Math.Ceiling(val);
            graph.FillRectangle(new SolidBrush(borderSkin.PageColor), rect);
            if (drawOutsideTopLeftShadow)
            {
                rectangleF2         = rectangleF;
                rectangleF2.X      -= val * 0.3f;
                rectangleF2.Y      -= val * 0.3f;
                rectangleF2.Width  -= val * 0.3f;
                rectangleF2.Height -= val * 0.3f;
                graph.DrawRoundedRectShadowAbs(rectangleF2, cornerRadius, val, Color.FromArgb(128, Color.Black), borderSkin.PageColor, outsideShadowRate);
            }
            rectangleF2         = rectangleF;
            rectangleF2.X      += val * 0.3f;
            rectangleF2.Y      += val * 0.3f;
            rectangleF2.Width  -= val * 0.3f;
            rectangleF2.Height -= val * 0.3f;
            graph.DrawRoundedRectShadowAbs(rectangleF2, cornerRadius, val, centerColor, borderSkin.PageColor, outsideShadowRate);
            rectangleF2         = rectangleF;
            rectangleF2.Width  -= val * 0.3f;
            rectangleF2.Height -= val * 0.3f;
            GraphicsPath graphicsPath = graph.CreateRoundedRectPath(rectangleF2, cornerRadius);

            graph.DrawPathAbs(graphicsPath, backColor, backHatchStyle, backImage, backImageMode, backImageTranspColor, backImageAlign, backGradientType, backSecondaryColor, borderColor, borderWidth, borderStyle, PenAlignment.Inset);
            graphicsPath?.Dispose();
            if (drawScrews)
            {
                RectangleF empty = RectangleF.Empty;
                float      num2  = val * 0.4f;
                empty.X      = rectangleF2.X + num2;
                empty.Y      = rectangleF2.Y + num2;
                empty.Width  = val * 0.55f;
                empty.Height = empty.Width;
                DrawScrew(graph, empty);
                empty.X = rectangleF2.Right - num2 - empty.Width;
                DrawScrew(graph, empty);
                empty.X = rectangleF2.Right - num2 - empty.Width;
                empty.Y = rectangleF2.Bottom - num2 - empty.Height;
                DrawScrew(graph, empty);
                empty.X = rectangleF2.X + num2;
                empty.Y = rectangleF2.Bottom - num2 - empty.Height;
                DrawScrew(graph, empty);
            }
            if (drawBottomShadow)
            {
                rectangleF2         = rectangleF;
                rectangleF2.Width  -= val * 0.3f;
                rectangleF2.Height -= val * 0.3f;
                using (Region region = new Region(graph.CreateRoundedRectPath(new RectangleF(rectangleF2.X - val, rectangleF2.Y - val, rectangleF2.Width + 0.5f * val, rectangleF2.Height + 0.5f * val), cornerRadius)))
                {
                    region.Complement(graph.CreateRoundedRectPath(rectangleF2, cornerRadius));
                    Region clip = graph.Clip;
                    graph.Clip          = region;
                    rectangleF2.X      -= 0.5f * val;
                    rectangleF2.Width  += 0.5f * val;
                    rectangleF2.Y      -= 0.5f * val;
                    rectangleF2.Height += 0.5f * val;
                    graph.DrawRoundedRectShadowAbs(rectangleF2, cornerRadius, val, Color.Transparent, Color.FromArgb(175, sunken ? Color.White : color), 1f);
                    graph.Clip = clip;
                }
            }
            rectangleF2         = rectangleF;
            rectangleF2.Width  -= val * 0.3f;
            rectangleF2.Height -= val * 0.3f;
            using (Region region2 = new Region(graph.CreateRoundedRectPath(new RectangleF(rectangleF2.X + val * 0.5f, rectangleF2.Y + val * 0.5f, rectangleF2.Width - 0.2f * val, rectangleF2.Height - 0.2f * val), cornerRadius)))
            {
                RectangleF rect2 = rectangleF2;
                rect2.Width  += val;
                rect2.Height += val;
                region2.Complement(graph.CreateRoundedRectPath(rect2, cornerRadius));
                region2.Intersect(graph.CreateRoundedRectPath(rectangleF2, cornerRadius));
                Region clip2 = graph.Clip;
                graph.Clip = region2;
                graph.DrawRoundedRectShadowAbs(rect2, cornerRadius, val, Color.Transparent, Color.FromArgb(175, sunken ? color : Color.White), 1f);
                graph.Clip = clip2;
            }
        }
 public override void Dispose()
 {
     Path?.Dispose();
     Brush?.Dispose();
     Pen?.Dispose();
 }