Beispiel #1
0
        public void MouseDownEsferas(PointF PointPer)
        {
            GraphicsPath graphicsPathIzquierda = new GraphicsPath();

            graphicsPathIzquierda.AddRectangles(new RectangleF[] { cFunctionsProgram.CrearCirculo(C_F_Izquierda.Escaladas) });
            if (graphicsPathIzquierda.IsVisible(PointPer))
            {
                C_F_Izquierda.IsSelect = true;
            }
            else
            {
                C_F_Izquierda.IsSelect = false;
            }

            GraphicsPath graphicsPathDerecha = new GraphicsPath();

            graphicsPathDerecha.AddRectangles(new RectangleF[] { cFunctionsProgram.CrearCirculo(C_F_Derecha.Escaladas) });
            if (graphicsPathDerecha.IsVisible(PointPer))
            {
                C_F_Derecha.IsSelect = true;
            }
            else
            {
                C_F_Derecha.IsSelect = false;
            }
            C_F_Central.IsSelect = false;
        }
Beispiel #2
0
        void updateCrossinForm()
        {
            var cross = map.getCross();

            var       path  = new GraphicsPath();
            Rectangle rect1 = new Rectangle(50, 0, 30, 130);
            Rectangle rect2 = new Rectangle(0, 50, 130, 30);

            Rectangle[] arr = new Rectangle[2];
            arr[0] = rect1;
            arr[1] = rect2;
            path.AddRectangles(arr);
            //path.AddRectangle(rect2);
            path.FillMode = FillMode.Winding;
            // Convert the GraphicsPath into a Region.
            var region     = new Region(path);
            var pictureBox = new PictureBox();

            pictureBox.BackColor = cross.color;
            pictureBox.Region    = region;
            pictureBox.Size      = new Size(130, 130);
            pictureBox.Location  = cross.position;
            pictureBox.Text      = "cross";
            this.Controls.Add(pictureBox);
            Debug.WriteLine("Cross X: " + cross.color.Name + cross.position.X.ToString());
        }
Beispiel #3
0
        /// <summary>Greates the path.</summary>
        public override GraphicsPath CreatePath(Rectangle bounds)
        {
            GraphicsPath path = new GraphicsPath();

            if (bounds.Height <= 0 || bounds.Width <= 0)
            {
                return(path);
            }
            if (bounds.Height < 10 || bounds.Width < 10)
            {
                RoundRectShape rrs = new RoundRectShape(5);
                path = rrs.CreatePath(bounds);
                return(path);
            }

            Rectangle[] rects = GetRectangles(bounds);
            path.AddRectangles(rects);

            //Point[] points = GetRoundedBottomContour(bounds);
            //path.AddLines(points);

            //path.CloseFigure();

            return(path);
        }
 public void Remove(PictureBox treasure)
 {
     treasuresRegion.Exclude(treasure.Bounds);
     treasuresCollection.Remove(treasure);
     treasuresPath.Reset();
     if (treasuresCollection.Count != 0)
     {
         treasuresPath.AddRectangles(treasuresCollection.Select(tr => tr.Bounds).ToArray());
     }
 }
Beispiel #5
0
        static private GraphicsPath Rectangles()
        {
            GraphicsPath path = new GraphicsPath();

            path.AddRectangles(new Rectangle[2] {
                new Rectangle(20, 20, 100, 100),
                new Rectangle(100, 100, 20, 20)
            });
            return(path);
        }
Beispiel #6
0
        /// <summary>
        /// 设置边框控件可视区域
        /// </summary>
        /// <returns></returns>
        private GraphicsPath BuildFrame()
        {
            GraphicsPath path = new GraphicsPath();

            path.AddRectangles(smallRects);

            Rectangle[] rects1 = new Rectangle[8];
            rects1[0] = new Rectangle(linePoints[0], new Size(linePoints[1].X - linePoints[0].X, 1));
            rects1[1] = new Rectangle(linePoints[2], new Size(linePoints[3].X - linePoints[2].X, 1));
            rects1[2] = new Rectangle(linePoints[4], new Size(1, linePoints[5].Y - linePoints[4].Y));
            rects1[3] = new Rectangle(linePoints[6], new Size(1, linePoints[7].Y - linePoints[6].Y));
            rects1[4] = new Rectangle(linePoints[9], new Size(linePoints[8].X - linePoints[9].X, 1));
            rects1[5] = new Rectangle(linePoints[11], new Size(linePoints[10].X - linePoints[11].X, 1));
            rects1[6] = new Rectangle(linePoints[13], new Size(1, linePoints[12].Y - linePoints[13].Y));
            rects1[7] = new Rectangle(linePoints[15], new Size(1, linePoints[14].Y - linePoints[15].Y));

            path.AddRectangles(rects1);

            return(path);
        }
Beispiel #7
0
 public Maze(Rectangle area) : this()
 {
     Path          = new GraphicsPath();
     Path.FillMode = FillMode.Winding;
     Path.AddRectangles(new[] {
         Rectangle.FromLTRB(area.Left, area.Top, area.Right, area.Top + Sizes.Divider),
         Rectangle.FromLTRB(area.Right - Sizes.Divider, area.Top, area.Right, area.Bottom),
         Rectangle.FromLTRB(area.Left, area.Top, area.Left + Sizes.Divider, area.Bottom),
         Rectangle.FromLTRB(area.Left, area.Bottom - Sizes.Divider, area.Right, area.Bottom)
     });
     Walls = new Region(Path);
 }
Beispiel #8
0
        public override void OnPaint(IRenderEventArgs e)
        {
            Graphics g = ((GdiSurface)e.Surface).Graphics;

            SD.Drawing2D.Matrix save = g.Transform;
            g.Transform = Camera.Matrix.ToGdi();

            Rectangle smaller = new Rectangle(start, new Size(50, 20));
            Rectangle bigger  = new Rectangle(start, new Size(55, 25));

            g.DrawRectangle(rectPen, smaller);
            g.DrawRectangle(rectPen, bigger);

            smaller.Inflate(-5, -5);
            bigger.Inflate(5, 5);
            Rectangle[] pathRects =
            {
                Rectangle.FromLTRB(bigger.Left,   bigger.Top,     bigger.Right, smaller.Top),
                Rectangle.FromLTRB(bigger.Left,   smaller.Bottom, bigger.Right, bigger.Bottom),
                Rectangle.FromLTRB(bigger.Left,   smaller.Top,    smaller.Left, smaller.Bottom),
                Rectangle.FromLTRB(smaller.Right, smaller.Top,    bigger.Right, smaller.Bottom)
            };

            Region clipRegion = new Region();

            clipRegion.MakeInfinite();
            clipRegion.Intersect(
                Rectangle.FromLTRB(bigger.Left, bigger.Top, bigger.Right, smaller.Top));
            clipRegion.Union(
                Rectangle.FromLTRB(bigger.Left, smaller.Bottom, bigger.Right, bigger.Bottom));
            clipRegion.Union(
                Rectangle.FromLTRB(bigger.Left, smaller.Top, smaller.Left, smaller.Bottom));
            clipRegion.Union(
                Rectangle.FromLTRB(smaller.Right, smaller.Top, bigger.Right, smaller.Bottom));


            bool       isVisible = false;
            RectangleF testRect  = Rectangle.Inflate(smaller, -1, -1);

            isVisible = clipRegion.IsVisible(testRect);
            if (isVisible)
            {
                clipRegion.MakeInfinite();
            }
            invPath.Reset();
            invPath.FillMode = FillMode.Alternate;
            invPath.AddRectangles(pathRects);
            g.DrawPath(pathPen, invPath);
            g.FillPath(regionBrush, invPath);
        }
Beispiel #9
0
        public override GraphicsPath CreatePath(Rectangle bounds)
        {
            GraphicsPath graphicsPath = new GraphicsPath();

            if (bounds.Height <= 0 || bounds.Width <= 0)
            {
                return(graphicsPath);
            }
            if (bounds.Height < 10 || bounds.Width < 10)
            {
                return(new RoundRectShape(5).CreatePath(bounds));
            }
            Rectangle[] rectangles = this.GetRectangles(bounds);
            graphicsPath.AddRectangles(rectangles);
            return(graphicsPath);
        }
Beispiel #10
0
        private void ClaseDibujar()
        {
            StringFormat string_format = new StringFormat();

            string_format.Alignment     = StringAlignment.Near;
            string_format.LineAlignment = StringAlignment.Near;


            gp    = new GraphicsPath();
            gptxt = new GraphicsPath();
            gptxt.AddString(this.nombre, new FontFamily("Arial"), (int)FontStyle.Regular, 14, puntoInicial, StringFormat.GenericDefault);
            gptxt.AddString(this.metodos, new FontFamily("Arial"), (int)FontStyle.Regular, 14, puntoFinal, StringFormat.GenericDefault);

            gp.AddRectangles(this.rects);

            gp.CloseFigure();
        }
Beispiel #11
0
 /// <summary>
 /// Определяем попадание точки на контур фигуры
 /// </summary>
 /// <param name="mousePosition"></param>
 /// <returns></returns>
 public override bool Contained(Point mousePosition)
 {
     using (var path = new GraphicsPath())
     {
         // добавляем в путь контур полилинии
         path.AddLines(markers.Select(x => x.Location).ToArray());
         path.AddRectangles(markers.Select(x => x.Bounds).ToArray());
         // ширина линии для поиска попадания равна размеру маркера
         using (var pen = new Pen(Color.Black, 5f))
         {
             pen.LineJoin = LineJoin.Round;
             pen.StartCap = LineCap.RoundAnchor;
             pen.EndCap   = LineCap.RoundAnchor;
             return(path.IsOutlineVisible(mousePosition, pen));
         }
     }
 }
Beispiel #12
0
        // </snippet12>

        // Snippet for: M:System.Drawing.Drawing2D.GraphicsPath.AddRectangles(System.Drawing.Rectangle[])
        // <snippet13>
        private void AddRectanglesExample(PaintEventArgs e)
        {
            // Adds a pattern of rectangles to a GraphicsPath object.
            GraphicsPath myPath = new GraphicsPath();

            Rectangle[] pathRects =
            {
                new Rectangle(20, 20, 100, 200),
                new Rectangle(40, 40, 120, 220),
                new Rectangle(60, 60, 240, 140)
            };
            myPath.AddRectangles(pathRects);

            // Draw the path to the screen.
            Pen myPen = new Pen(Color.Black, 2);

            e.Graphics.DrawPath(myPen, myPath);
        }
Beispiel #13
0
        public MapTimelineControl()
        {
            this.m_mtsSeek = new MapTimelineSeekButton();

            this.TimelineButtons = new List <MapObject>();

            GraphicsPath gpButtonPath = new GraphicsPath();

            gpButtonPath.AddLines(new Point[] { new Point(0, 6), new Point(6, 12), new Point(6, 6), new Point(12, 12), new Point(12, 0), new Point(6, 6), new Point(6, 0), new Point(0, 6) });
            gpButtonPath.CloseFigure();
            MapTimelineControlButton mtbButton = new MapTimelineControlButton(gpButtonPath, MapTimelineControlButtonType.Rewind);

            mtbButton.TimelineControlButtonClicked += new MapTimelineControlButton.TimelineControlButtonClickedHandler(mtbButton_TimelineControlButtonClicked);
            this.TimelineButtons.Add(mtbButton);

            gpButtonPath = new GraphicsPath();
            gpButtonPath.AddRectangles(new Rectangle[] { new Rectangle(0, 0, 4, 12), new Rectangle(8, 0, 4, 12) });
            mtbButton = new MapTimelineControlButton(gpButtonPath, MapTimelineControlButtonType.Pause);
            mtbButton.TimelineControlButtonClicked += new MapTimelineControlButton.TimelineControlButtonClickedHandler(mtbButton_TimelineControlButtonClicked);
            this.TimelineButtons.Add(mtbButton);

            gpButtonPath = new GraphicsPath();
            gpButtonPath.AddLines(new Point[] { new Point(1, 0), new Point(1, 12), new Point(9, 6), new Point(1, 0) });
            gpButtonPath.CloseFigure();
            mtbButton = new MapTimelineControlButton(gpButtonPath, MapTimelineControlButtonType.Play);
            mtbButton.ForegroundColour              = Color.LightSeaGreen;
            mtbButton.TimelineControlButtonClicked += new MapTimelineControlButton.TimelineControlButtonClickedHandler(mtbButton_TimelineControlButtonClicked);
            this.TimelineButtons.Add(mtbButton);

            gpButtonPath = new GraphicsPath();
            gpButtonPath.AddLines(new Point[] { new Point(0, 0), new Point(0, 12), new Point(6, 6), new Point(6, 12), new Point(12, 6), new Point(6, 0), new Point(6, 6), new Point(0, 0) });
            gpButtonPath.CloseFigure();
            mtbButton = new MapTimelineControlButton(gpButtonPath, MapTimelineControlButtonType.FastForward);
            mtbButton.TimelineControlButtonClicked += new MapTimelineControlButton.TimelineControlButtonClickedHandler(mtbButton_TimelineControlButtonClicked);
            this.TimelineButtons.Add(mtbButton);

            this.SelectedButtonType     = MapTimelineControlButtonType.Play;
            this.m_flControlChangeSpeed = 2.0F;
        }
Beispiel #14
0
        public Ship()
        {
            l.Add(new RectangleF(-10, -15, widthMainBody, heighMainBody));
            l.Add(new RectangleF(-20, -5, 10, 10));
            l.Add(new RectangleF(10, -5, 10, 10));

            Head = new PointF(0, 25);

            _model          = new GraphicsPath();
            _model.FillMode = FillMode.Winding;

            _model.AddLine(-20, -30, -20, 30);
            _model.AddLine(-20, 30, -35, 20);
            _model.AddLine(-35, 20, -35, -20);
            _model.AddLine(-35, -20, -20, -30);

            _model.AddLine(20, -30, 20, 30);
            _model.AddLine(20, 30, 35, 20);
            _model.AddLine(35, 20, 35, -20);
            _model.AddLine(35, -20, 20, -30);


            _model.AddRectangles(l.ToArray());
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            Point point  = new Point(0, 0);
            Point point2 = new Point(0, base.Height);

            if (this._ProgressDirection == ProgressBarEx.ProgressDir.Vertical)
            {
                point2 = new Point(base.Width, 0);
            }
            checked
            {
                using (GraphicsPath graphicsPath = new GraphicsPath())
                {
                    Rectangle rectangle = new Rectangle(0, 0, base.Width, base.Height);
                    int       rad       = (int)Math.Round((double)rectangle.Height / 2.5);
                    if (rectangle.Width < rectangle.Height)
                    {
                        rad = (int)Math.Round((double)rectangle.Width / 2.5);
                    }
                    using (LinearGradientBrush linearGradientBrush = new LinearGradientBrush(point, point2, this._BackColor, this._GradiantColor))
                    {
                        linearGradientBrush.Blend = this.bBlend;
                        if (this._RoundedCorners)
                        {
                            GraphicsPath graphicsPath2 = graphicsPath;
                            this.MakePath(ref graphicsPath2, rectangle, rad);
                            e.Graphics.FillPath(linearGradientBrush, graphicsPath);
                        }
                        else
                        {
                            e.Graphics.FillRectangle(linearGradientBrush, rectangle);
                        }
                    }
                    if (this._Value > this._Minimum)
                    {
                        int num = (int)Math.Round(unchecked ((double)base.Width / (double)(checked (this._Maximum - this._Minimum)) * (double)this._Value));
                        if (this._ProgressDirection == ProgressBarEx.ProgressDir.Vertical)
                        {
                            num              = (int)Math.Round(unchecked ((double)base.Height / (double)(checked (this._Maximum - this._Minimum)) * (double)this._Value));
                            rectangle.Y      = rectangle.Height - num;
                            rectangle.Height = num;
                        }
                        else
                        {
                            rectangle.Width = num;
                        }
                        using (LinearGradientBrush linearGradientBrush2 = new LinearGradientBrush(point, point2, this._ProgressColor, this._GradiantColor))
                        {
                            linearGradientBrush2.Blend = this.bBlend;
                            if (this._RoundedCorners)
                            {
                                if (this._ProgressDirection == ProgressBarEx.ProgressDir.Horizontal)
                                {
                                    rectangle.Height--;
                                }
                                else
                                {
                                    rectangle.Width--;
                                }
                                using (GraphicsPath graphicsPath3 = new GraphicsPath())
                                {
                                    GraphicsPath graphicsPath2 = graphicsPath3;
                                    this.MakePath(ref graphicsPath2, rectangle, rad);
                                    using (GraphicsPath graphicsPath4 = new GraphicsPath())
                                    {
                                        using (Region region = new Region(graphicsPath))
                                        {
                                            region.Intersect(graphicsPath3);
                                            graphicsPath4.AddRectangles(region.GetRegionScans(new Matrix()));
                                        }
                                        e.Graphics.FillPath(linearGradientBrush2, graphicsPath4);
                                        goto IL_272;
                                    }
                                }
                            }
                            e.Graphics.FillRectangle(linearGradientBrush2, rectangle);
                        }
                    }
IL_272:
                    if (this._Image != null)
                    {
                        if (this._ImageLayout == ProgressBarEx.ImageLayoutType.Stretch)
                        {
                            e.Graphics.DrawImage(this._Image, 0, 0, base.Width, base.Height);
                        }
                        else if (this._ImageLayout == ProgressBarEx.ImageLayoutType.None)
                        {
                            e.Graphics.DrawImage(this._Image, 0, 0);
                        }
                        else
                        {
                            int x = (int)Math.Round(unchecked ((double)base.Width / 2.0 - (double)this._Image.Width / 2.0));
                            int y = (int)Math.Round(unchecked ((double)base.Height / 2.0 - (double)this._Image.Height / 2.0));
                            e.Graphics.DrawImage(this._Image, x, y);
                        }
                    }
                    if (this._ShowPercentage | this._ShowText)
                    {
                        string text = "";
                        if (this._ShowText)
                        {
                            text = this.Text;
                        }
                        if (this._ShowPercentage)
                        {
                            text = text + ((int)Math.Round(unchecked (100.0 / (double)(checked (this._Maximum - this._Minimum)) * (double)this._Value))).ToString() + "%";
                        }
                        using (StringFormat stringFormat = new StringFormat
                        {
                            Alignment = StringAlignment.Center,
                            LineAlignment = StringAlignment.Center
                        })
                        {
                            e.Graphics.DrawString(text, this.Font, this._ForeColorBrush, new Rectangle(0, 0, base.Width, base.Height), stringFormat);
                        }
                    }
                    if (this._Border)
                    {
                        rectangle = new Rectangle(0, 0, base.Width - 1, base.Height - 1);
                        if (this._RoundedCorners)
                        {
                            GraphicsPath graphicsPath2 = graphicsPath;
                            this.MakePath(ref graphicsPath2, rectangle, rad);
                            e.Graphics.DrawPath(this._BorderPen, graphicsPath);
                        }
                        else
                        {
                            e.Graphics.DrawRectangle(this._BorderPen, rectangle);
                        }
                    }
                }
            }
        }
 public void AddRectangles(Rectangle[] rects)
 {
     Changed();
     gdiPath.AddRectangles(rects);
 }
Beispiel #17
0
        //private Brush _bgColor = new SolidBrush(SystemColors.ControlDarkDark);
        //private Brush _egPen = new SolidBrush(SystemColors.Control);
        //private Pen _linePen = new Pen(Color.White);

        //private Brush _dPen = new SolidBrush(Color.Black);
        //private Brush _lPen = new SolidBrush(Color.DarkGreen);
        //private Brush _rPen = new SolidBrush(Color.Red);

        /// <summary>
        /// 画图
        /// </summary>
        public void ReDraw()
        {
            if (!HasDraw)
            {
                return;
            }

            Brush _bgColor = new SolidBrush(SystemColors.ControlDarkDark);
            Brush _egPen   = new SolidBrush(SystemColors.Control);
            Pen   _linePen = new Pen(Color.White);

            Brush _dPen = new SolidBrush(Color.Black);
            //Brush _lPen = new SolidBrush(Color.DarkGreen);
            Brush _lPen = new SolidBrush(Color.LimeGreen);
            Brush _rPen = new SolidBrush(Color.Red);

            var                     col            = ColCnt;
            var                     row            = RowCnt;
            string                  loction        = CurrentDefect;
            List <DieLayout>        _dielayoutlist = DieLayoutList;
            List <DefectCoordinate> _defectlist    = DefectList;

            if (_dielayoutlist == null || _dielayoutlist.Count < 1)
            {
                return;
            }

            if (ZoomMultiple <= 0)
            {
                ZoomMultiple = 1;
            }

            ////拖拽坐标
            //int dragX = locX;
            //int dragY = locY;

            //die宽、高
            double ww = Math.Round(4.0 * row / col);
            double wh = 4;
            int    rc = Math.Abs(row - col);

            if (rc < 10 || rc > 100)
            {
                if (col > 500)
                {
                    rc = 80;
                }
                else if (col > 200)
                {
                    rc = 60;
                }
                else
                {
                    rc = 30;
                }
            }

            int wd = Convert.ToInt32(col * ww + rc);
            int hg = Convert.ToInt32(row * wh + rc);

            //ww = Math.Round(ww);
            //if (col == row)
            //{
            //    ww = 4;
            //    wh = 4;

            //    hg = row * wh + 60;
            //}
            //else if (col < row)
            //{
            //    ww = 4;
            //    wh = 5;

            //    wd = col * ww + 40;
            //    hg = row * wh + 20;
            //}
            //else if ((col - row) > 30)
            //{
            //    wh = 6;
            //    hg = row * wh + 80;
            //}
            //else if ((col - row) < 10)
            //{
            //    wd = col * ww + 60;
            //    hg = row * wh + 60;
            //}

            //计算偏移量
            int offsetX = Convert.ToInt32((wd - col * ww) / 2 + locX);
            int offsetY = Convert.ToInt32((hg - row * wh) / 2 + locY);

            //背景图
            Bitmap   btp = new Bitmap(wd, hg);
            Graphics gc  = Graphics.FromImage(btp);

            gc.Clear(Color.White);
            gc.SmoothingMode = SmoothingMode.HighSpeed;

            GraphicsPath ep = new GraphicsPath();

            //ep.AddEllipse(locX * ZoomMultiple, locY * ZoomMultiple, btp.Width * ZoomMultiple, btp.Height * ZoomMultiple);
            ep.AddEllipse((int)(locX * ZoomMultiple), (int)(locY * ZoomMultiple), (int)(btp.Width * ZoomMultiple), (int)(btp.Height * ZoomMultiple));
            gc.FillPath(_bgColor, ep);

            //背景颜色
            GraphicsPath bp = new GraphicsPath();
            //晶片颜色
            GraphicsPath wp = new GraphicsPath();
            //缺陷晶片颜色
            GraphicsPath rp = new GraphicsPath();

            bool lineg = false;
            int  lx    = 0;
            int  ly    = 0;

            double scaleX = Math.Round(Convert.ToDouble(this.Width) / wd, 8);
            double scaleY = Math.Round(Convert.ToDouble(this.Height) / hg, 8);
            //var log = WR.Utils.LogService.Getlog(this.GetType());

            //log.Debug("画出die start");
            //画出die
            var bpRectangles     = _dielayoutlist.Select(die => new Rectangle(Convert.ToInt32((die.X * ww + offsetX) * this.ZoomMultiple), Convert.ToInt32(((row - die.Y) * wh + offsetY) * this.ZoomMultiple), Convert.ToInt32(ww * this.ZoomMultiple), Convert.ToInt32(wh * this.ZoomMultiple))).ToArray();
            var wpRectangles     = _dielayoutlist.Select(die => new Rectangle(Convert.ToInt32((die.X * ww + offsetX) * this.ZoomMultiple), Convert.ToInt32(((row - die.Y) * wh + offsetY) * this.ZoomMultiple), Convert.ToInt32((ww - 1) * this.ZoomMultiple), Convert.ToInt32((wh - 1) * this.ZoomMultiple))).ToArray();
            var gcFillRectangles = _dielayoutlist.Where(die => !string.IsNullOrEmpty(die.FillColor)).Select(die => new Rectangle(Convert.ToInt32((die.X * ww + offsetX) * this.ZoomMultiple), Convert.ToInt32(((row - die.Y) * wh + offsetY) * this.ZoomMultiple), Convert.ToInt32((ww - 1) * this.ZoomMultiple), Convert.ToInt32((wh - 1) * this.ZoomMultiple))).ToArray();

            if (bpRectangles.Length > 0)
            {
                bp.AddRectangles(bpRectangles);
            }

            if (wpRectangles.Length > 0)
            {
                wp.AddRectangles(wpRectangles);
            }

            gc.FillPath(_dPen, bp);
            gc.FillPath(_lPen, wp);

            if (gcFillRectangles.Length > 0)
            {
                gc.FillRectangles(new SolidBrush(ConvterColor(Color.Gray.Name)), gcFillRectangles);
            }

            _dielayoutlist.ForEach(die => die.Points = new List <Point>()
            {
                new Point(Convert.ToInt32((die.X * ww + offsetX) * scaleX), Convert.ToInt32(((row - die.Y) * wh + offsetY) * scaleY))
                , new Point(Convert.ToInt32((die.X * ww + offsetX + ww - 1) * scaleX), Convert.ToInt32(((row - die.Y) * wh + offsetY) * scaleY))
                , new Point(Convert.ToInt32((die.X * ww + offsetX + ww - 1) * scaleX), Convert.ToInt32(((row - die.Y) * wh + offsetY + wh - 1) * scaleY))
                , new Point(Convert.ToInt32((die.X * ww + offsetX) * scaleX), Convert.ToInt32(((row - die.Y) * wh + offsetY + wh - 1) * scaleY))
            });
            //foreach (DieLayout die in _dielayoutlist)
            //{
            //    bp.AddRectangle(new Rectangle((die.X * ww + offsetX) * this.ZoomMultiple, ((row - die.Y) * wh + offsetY) * this.ZoomMultiple, ww * this.ZoomMultiple, wh * this.ZoomMultiple));
            //    wp.AddRectangle(new Rectangle((die.X * ww + offsetX) * this.ZoomMultiple, ((row - die.Y) * wh + offsetY) * this.ZoomMultiple, (ww - 1) * this.ZoomMultiple, (wh - 1) * this.ZoomMultiple));

            //    if (!string.IsNullOrEmpty(die.FillColor))
            //        gc.FillRectangle(new SolidBrush(ConvterColor(Color.Gray.Name)), (die.X * ww + offsetX) * this.ZoomMultiple, ((row - die.Y) * wh + offsetY) * this.ZoomMultiple, (ww - 1) * this.ZoomMultiple, (ww - 1) * this.ZoomMultiple);

            //    if (string.Format("{0},{1}", die.X, die.Y) == loction)
            //    {
            //        lineg = true;
            //        lx = die.X;
            //        ly = row - die.Y;

            //        //System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Red, 2);
            //        //myPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
            //        //gc.DrawRectangle(myPen, (die.X * ww + offsetX) * this.ZoomMultiple, ((row - die.Y) * wh + offsetY) * this.ZoomMultiple, ww * this.ZoomMultiple, wh * this.ZoomMultiple);
            //        //myPen.Dispose();
            //    }

            //    die.Points = new List<Point>() { new Point(Convert.ToInt32((die.X * ww + offsetX) * scaleX),Convert.ToInt32(((row - die.Y) * wh + offsetY) * scaleY))
            //        ,new Point(Convert.ToInt32((die.X * ww + offsetX+ww-1) * scaleX),Convert.ToInt32(((row - die.Y) * wh + offsetY) * scaleY))
            //        ,new Point(Convert.ToInt32((die.X * ww + offsetX+ww-1) * scaleX),Convert.ToInt32(((row - die.Y) * wh + offsetY+wh-1) * scaleY))
            //        ,new Point(Convert.ToInt32((die.X * ww + offsetX) * scaleX),Convert.ToInt32(((row - die.Y) * wh + offsetY+wh-1) * scaleY))};
            //}

            //log.Debug("画出die start");

            //bool lineg = false;
            //int lx = 0;
            //int ly = 0;

            //double scaleX = Math.Round(Convert.ToDouble(this.Width) / wd, 8);
            //double scaleY = Math.Round(Convert.ToDouble(this.Height) / hg, 8);

            //画出defect
            //log.Debug("画出defect start");
            foreach (DefectCoordinate def in _defectlist)
            {
                if (string.IsNullOrEmpty(def.Location))
                {
                    continue;
                }

                string[] adr = def.Location.Split(new char[] { ',' });
                int      ax  = int.Parse(adr[0]);
                int      ay  = int.Parse(adr[1]);

                gc.FillRectangle(new SolidBrush(ConvterColor(def.FillColor)), Convert.ToInt32((ax * ww + offsetX) * this.ZoomMultiple), Convert.ToInt32(((row - ay) * wh + offsetY) * this.ZoomMultiple), Convert.ToInt32((ww - 1) * this.ZoomMultiple), Convert.ToInt32((wh - 1) * this.ZoomMultiple));

                def.Points = new List <Point>()
                {
                    new Point(Convert.ToInt32((ax * ww + offsetX) * scaleX), Convert.ToInt32(((row - ay) * wh + offsetY) * scaleY))
                    , new Point(Convert.ToInt32((ax * ww + offsetX + ww - 1) * scaleX), Convert.ToInt32(((row - ay) * wh + offsetY) * scaleY))
                    , new Point(Convert.ToInt32((ax * ww + offsetX + ww - 1) * scaleX), Convert.ToInt32(((row - ay) * wh + offsetY + wh - 1) * scaleY))
                    , new Point(Convert.ToInt32((ax * ww + offsetX) * scaleX), Convert.ToInt32(((row - ay) * wh + offsetY + wh - 1) * scaleY))
                };

                //判断定位画线
                if (def.Location == loction)
                {
                    lineg = true;
                    lx    = ax;
                    ly    = row - ay;

                    //System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
                    //myPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
                    //gc.DrawRectangle(myPen, (ax * ww + offsetX) * this.ZoomMultiple, ((row - ay) * wh + offsetY) * this.ZoomMultiple, (ww - 1) * this.ZoomMultiple, (wh - 1) * this.ZoomMultiple);
                    //myPen.Dispose();
                }
            }
            //log.Debug("画出defect end");

            //定位画线
            if (lineg)
            {
                gc.DrawLine(_linePen, 0, Convert.ToInt32((ly * wh + offsetY + 1) * this.ZoomMultiple), Convert.ToInt32(btp.Width * this.ZoomMultiple), Convert.ToInt32((ly * wh + offsetY + 1) * this.ZoomMultiple));
                gc.DrawLine(_linePen, Convert.ToInt32((lx * ww + offsetX + 1) * this.ZoomMultiple), 0, Convert.ToInt32((lx * ww + offsetX + 1) * this.ZoomMultiple), Convert.ToInt32(btp.Height * this.ZoomMultiple));
            }

            //画出定位三角
            Point p1 = new Point(Convert.ToInt32((btp.Width / 2) * this.ZoomMultiple), Convert.ToInt32((btp.Height - 10) * this.ZoomMultiple));
            Point p2 = new Point(Convert.ToInt32((btp.Width / 2 - 6) * this.ZoomMultiple), Convert.ToInt32(btp.Height * this.ZoomMultiple));
            Point p3 = new Point(Convert.ToInt32((btp.Width / 2 + 6) * this.ZoomMultiple), Convert.ToInt32(btp.Height * this.ZoomMultiple));

            //Point p1 = new Point(btp.Width / 2, btp.Height - 10);
            //Point p2 = new Point(btp.Width / 2 - 6, btp.Height);
            //Point p3 = new Point(btp.Width / 2 + 6, btp.Height);
            gc.FillPolygon(_egPen, new Point[] { p1, p2, p3 }, System.Drawing.Drawing2D.FillMode.Alternate);

            if (this.Status == "Reclass" || Status == "ReDie")
            {
                //System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Red, 1.5f * this.ZoomMultiple);
                System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Red, (float)(1.5 / scaleX));
                myPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                gc.DrawRectangle(myPen, (int)((this.mousedownpoint.X) / scaleX), (int)((this.mousedownpoint.Y) / scaleY),
                                 (int)((this.locStartX - this.mousedownpoint.X) / scaleX), (int)((this.locStartY - this.mousedownpoint.Y) / scaleY));

                if (locStartX == 0 || locStartY == 0)
                {
                    SelectRect = new Rectangle((int)((this.mousedownpoint.X)), (int)((this.mousedownpoint.Y)),
                                               Convert.ToInt32(ww * this.ZoomMultiple), Convert.ToInt32(wh * this.ZoomMultiple));
                }
                else
                {
                    SelectRect = new Rectangle((int)((this.mousedownpoint.X)), (int)((this.mousedownpoint.Y)),
                                               (int)((this.locStartX - this.mousedownpoint.X)), (int)((this.locStartY - this.mousedownpoint.Y)));
                }

                myPen.Dispose();
            }

            gc.Dispose();

            //缩略图片
            Bitmap outBmp = new Bitmap(this.Width, this.Height);

            Graphics g = Graphics.FromImage(outBmp);

            g.Clear(Color.Transparent);

            g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
            g.CompositingQuality = CompositingQuality.HighQuality;
            g.SmoothingMode      = SmoothingMode.HighQuality;

            g.DrawImage(btp, new Rectangle(0, 0, outBmp.Width, outBmp.Height), new Rectangle(0, 0, btp.Width, btp.Height), GraphicsUnit.Pixel);

            //绑定图片
            this.WrImage = outBmp;
            this.scaleX  = scaleX;
            this.scaleY  = scaleY;

            _bgColor.Dispose();
            _egPen.Dispose();
            _linePen.Dispose();

            _dPen.Dispose();
            _lPen.Dispose();
            _rPen.Dispose();

            btp.Dispose();
            //outBmp.Dispose();
            btp = null;
            //outBmp = null;
            g.Dispose();

            HasDraw = true;
            //this.Refresh();
        }
Beispiel #18
0
        private static void CalculateLabelAroundOnLineString(ILineString line, ref BaseLabel label, Map map, IGraphics g, SizeF textSize)
        {
            var sPoints = line.Coordinates;

            // only get point in enverlop of map
            var colPoint      = new Collection <PointF>();
            var bCheckStarted = false;

            //var testEnvelope = map.Envelope.Grow(map.PixelSize*10);
            for (var j = 0; j < sPoints.Length; j++)
            {
                if (map.Envelope.Contains(sPoints[j]))
                {
                    //points[j] = map.WorldToImage(sPoints[j]);
                    colPoint.Add(map.WorldToImage(sPoints[j]));
                    bCheckStarted = true;
                }
                else if (bCheckStarted)
                {
                    // fix bug curved line out of map in center segment of line
                    break;
                }
            }

            if (colPoint.Count > 1)
            {
                label.TextOnPathLabel = new TextOnPath();
                switch (label.Style.HorizontalAlignment)
                {
                case LabelStyle.HorizontalAlignmentEnum.Left:
                    label.TextOnPathLabel.TextPathAlignTop = TextPathAlign.Left;
                    break;

                case LabelStyle.HorizontalAlignmentEnum.Right:
                    label.TextOnPathLabel.TextPathAlignTop = TextPathAlign.Right;
                    break;

                case LabelStyle.HorizontalAlignmentEnum.Center:
                    label.TextOnPathLabel.TextPathAlignTop = TextPathAlign.Center;
                    break;

                default:
                    label.TextOnPathLabel.TextPathAlignTop = TextPathAlign.Center;
                    break;
                }
                switch (label.Style.VerticalAlignment)
                {
                case LabelStyle.VerticalAlignmentEnum.Bottom:
                    label.TextOnPathLabel.TextPathPathPosition = TextPathPosition.UnderPath;
                    break;

                case LabelStyle.VerticalAlignmentEnum.Top:
                    label.TextOnPathLabel.TextPathPathPosition = TextPathPosition.OverPath;
                    break;

                case LabelStyle.VerticalAlignmentEnum.Middle:
                    label.TextOnPathLabel.TextPathPathPosition = TextPathPosition.CenterPath;
                    break;

                default:
                    label.TextOnPathLabel.TextPathPathPosition = TextPathPosition.CenterPath;
                    break;
                }

                var idxStartPath = 0;
                var numberPoint  = colPoint.Count;
                // start Optimzes Path points

                var step = 100;
                if (colPoint.Count >= step * 2)
                {
                    numberPoint = step * 2;;
                    switch (label.Style.HorizontalAlignment)
                    {
                    case LabelStyle.HorizontalAlignmentEnum.Left:
                        //label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Left;
                        idxStartPath = 0;
                        break;

                    case LabelStyle.HorizontalAlignmentEnum.Right:
                        //label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Right;
                        idxStartPath = colPoint.Count - step;
                        break;

                    case LabelStyle.HorizontalAlignmentEnum.Center:
                        //label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Center;
                        idxStartPath = (int)colPoint.Count / 2 - step;
                        break;

                    default:
                        //label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Center;
                        idxStartPath = (int)colPoint.Count / 2 - step;
                        break;
                    }
                }
                // end optimize path point
                var points = new PointF[numberPoint];
                var count  = 0;
                if (colPoint[0].X <= colPoint[colPoint.Count - 1].X)
                {
                    for (var l = idxStartPath; l < numberPoint + idxStartPath; l++)
                    {
                        points[count] = colPoint[l];
                        count++;
                    }
                }
                else
                {
                    //reverse the path
                    for (var k = numberPoint - 1 + idxStartPath; k >= idxStartPath; k--)
                    {
                        points[count] = colPoint[k];
                        count++;
                    }
                }
                //get text size in page units ie pixels
                float textheight = label.Style.Font.Size;
                switch (label.Style.Font.Unit)
                {
                case GraphicsUnit.Display:
                    textheight = textheight * g.DpiY / 75;
                    break;

                case GraphicsUnit.Document:
                    textheight = textheight * g.DpiY / 300;
                    break;

                case GraphicsUnit.Inch:
                    textheight = textheight * g.DpiY;
                    break;

                case GraphicsUnit.Millimeter:
                    textheight = (float)(textheight / 25.4 * g.DpiY);
                    break;

                case GraphicsUnit.Pixel:
                    //do nothing
                    break;

                case GraphicsUnit.Point:
                    textheight = textheight * g.DpiY / 72;
                    break;
                }
                var topFont = new Font(label.Style.Font.FontFamily, textheight, label.Style.Font.Style);
                //
                var path = new GraphicsPath();
                path.AddLines(points);

                label.TextOnPathLabel.PathColorTop          = System.Drawing.Color.Transparent;
                label.TextOnPathLabel.Text                  = label.Text;
                label.TextOnPathLabel.LetterSpacePercentage = 90;
                label.TextOnPathLabel.FillColorTop          = new System.Drawing.SolidBrush(label.Style.ForeColor);
                label.TextOnPathLabel.Font                  = topFont;
                label.TextOnPathLabel.PathDataTop           = path.PathData;
                label.TextOnPathLabel.Graphics              = g;
                //label.TextOnPathLabel.ShowPath=true;
                //label.TextOnPathLabel.PathColorTop = System.Drawing.Color.YellowGreen;
                if (label.Style.Halo != null)
                {
                    label.TextOnPathLabel.ColorHalo = label.Style.Halo;
                }
                else
                {
                    label.TextOnPathLabel.ColorHalo = null;// new System.Drawing.Pen(label.Style.ForeColor, (float)0.5);
                }
                path.Dispose();

                // MeasureString to get region
                label.TextOnPathLabel.MeasureString = true;
                label.TextOnPathLabel.DrawTextOnPath();
                label.TextOnPathLabel.MeasureString = false;
                // Get Region label for CollissionDetection here.
                var pathRegion = new GraphicsPath();

                if (label.TextOnPathLabel.RegionList.Count > 0)
                {
                    //int idxCenter = (int)label.TextOnPathLabel.PointsText.Count / 2;
                    //System.Drawing.Drawing2D.Matrix rotationMatrix = g.Transform.Clone();// new Matrix();
                    //rotationMatrix.RotateAt(label.TextOnPathLabel.Angles[idxCenter], label.TextOnPathLabel.PointsText[idxCenter]);
                    //if (label.TextOnPathLabel.PointsTextUp.Count > 0)
                    //{
                    //    for (int up = label.TextOnPathLabel.PointsTextUp.Count - 1; up >= 0; up--)
                    //    {
                    //        label.TextOnPathLabel.PointsText.Add(label.TextOnPathLabel.PointsTextUp[up]);
                    //    }

                    //}
                    pathRegion.AddRectangles(label.TextOnPathLabel.RegionList.ToArray());

                    // get box for detect colission here
                    label.Box = new LabelBox(pathRegion.GetBounds());
                    //g.FillRectangle(System.Drawing.Brushes.YellowGreen, label.Box);
                }
                pathRegion.Dispose();
            }
        }
Beispiel #19
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            Point StartPoint = new Point(0, 0);
            Point EndPoint   = new Point(0, this.Height);

            if (_progressDirection == ProgressDir.Vertical)
            {
                EndPoint = new Point(this.Width, 0);
            }

            using (GraphicsPath gp = new GraphicsPath())
            {
                Rectangle rec = new Rectangle(0, 0, this.Width, this.Height);
                int       rad = Convert.ToInt32(rec.Height / 2.5);
                if (rec.Width < rec.Height)
                {
                    rad = Convert.ToInt32(rec.Width / 2.5);
                }

                using (LinearGradientBrush _BackColorBrush = new LinearGradientBrush(StartPoint, EndPoint, _backColor, _gradiantColor))
                {
                    _BackColorBrush.Blend = _bBlend;
                    if (_roundedCorners)
                    {
                        gp.AddArc(rec.X, rec.Y, rad, rad, 180, 90);
                        gp.AddArc(rec.Right - (rad), rec.Y, rad, rad, 270, 90);
                        gp.AddArc(rec.Right - (rad), rec.Bottom - (rad), rad, rad, 0, 90);
                        gp.AddArc(rec.X, rec.Bottom - (rad), rad, rad, 90, 90);
                        gp.CloseFigure();
                        e.Graphics.FillPath(_BackColorBrush, gp);
                    }
                    else
                    {
                        e.Graphics.FillRectangle(_BackColorBrush, rec);
                    }
                }

                if (_value > _minimum)
                {
                    int lngth = Convert.ToInt32((double)(this.Width / (double)(_maximum - _minimum)) * _value);
                    if (_progressDirection == ProgressDir.Vertical)
                    {
                        lngth      = Convert.ToInt32((double)(this.Height / (double)(_maximum - _minimum)) * _value);
                        rec.Y      = rec.Height - lngth;
                        rec.Height = lngth;
                    }
                    else
                    {
                        rec.Width = lngth;
                    }

                    using (LinearGradientBrush _ProgressBrush = new LinearGradientBrush(StartPoint, EndPoint, _progressColor, _gradiantColor))
                    {
                        _ProgressBrush.Blend = _bBlend;
                        if (_roundedCorners)
                        {
                            if (_progressDirection == ProgressDir.Horizontal)
                            {
                                rec.Height -= 1;
                            }
                            else
                            {
                                rec.Width -= 1;
                            }

                            using (GraphicsPath gp2 = new GraphicsPath())
                            {
                                gp2.AddArc(rec.X, rec.Y, rad, rad, 180, 90);
                                gp2.AddArc(rec.Right - (rad), rec.Y, rad, rad, 270, 90);
                                gp2.AddArc(rec.Right - (rad), rec.Bottom - (rad), rad, rad, 0, 90);
                                gp2.AddArc(rec.X, rec.Bottom - (rad), rad, rad, 90, 90);
                                gp2.CloseFigure();
                                using (GraphicsPath gp3 = new GraphicsPath())
                                {
                                    using (Region rgn = new Region(gp))
                                    {
                                        rgn.Intersect(gp2);
                                        gp3.AddRectangles(rgn.GetRegionScans(new Matrix()));
                                    }
                                    e.Graphics.FillPath(_ProgressBrush, gp3);
                                }
                            }
                        }
                        else
                        {
                            e.Graphics.FillRectangle(_ProgressBrush, rec);
                        }
                    }
                }

                if (_image != null)
                {
                    if (_imageLayout == ImageLayoutType.Stretch)
                    {
                        e.Graphics.DrawImage(_image, 0, 0, this.Width, this.Height);
                    }
                    else if (_imageLayout == ImageLayoutType.None)
                    {
                        e.Graphics.DrawImage(_image, 0, 0);
                    }
                    else
                    {
                        int xx = Convert.ToInt32((this.Width / 2) - (_image.Width / 2));
                        int yy = Convert.ToInt32((this.Height / 2) - (_image.Height / 2));
                        e.Graphics.DrawImage(_image, xx, yy);
                    }
                }

                if (_showPercentage | _showText)
                {
                    string perc = "";
                    if (_showText)
                    {
                        perc = this.Text;
                    }
                    if (_showPercentage)
                    {
                        perc += Convert.ToString(Convert.ToInt32(((double)100 / (double)(_maximum - _minimum)) * _value)) + "%";
                    }
                    using (StringFormat sf = new StringFormat {
                        Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                    })
                    {
                        e.Graphics.DrawString(perc, this.Font, _foreColorBrush, new Rectangle(0, 0, this.Width, this.Height), sf);
                    }
                }

                if (_border)
                {
                    rec = new Rectangle(0, 0, this.Width - 1, this.Height - 1);
                    if (_roundedCorners)
                    {
                        gp.Reset();
                        gp.AddArc(rec.X, rec.Y, rad, rad, 180, 90);
                        gp.AddArc(rec.Right - (rad), rec.Y, rad, rad, 270, 90);
                        gp.AddArc(rec.Right - (rad), rec.Bottom - (rad), rad, rad, 0, 90);
                        gp.AddArc(rec.X, rec.Bottom - (rad), rad, rad, 90, 90);
                        gp.CloseFigure();
                        e.Graphics.DrawPath(_borderPen, gp);
                    }
                    else
                    {
                        e.Graphics.DrawRectangle(_borderPen, rec);
                    }
                }
            }
        }
        private void PreViewBMP_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.SmoothingMode   = SmoothingMode.AntiAlias;
            e.Graphics.CompositingMode = CompositingMode.SourceOver;

            Rectangle nAnchor = previewWorkArea;

            if (SWAFlag)
            {
                if (nAnchor.Width < 0)
                {
                    nAnchor.X     += nAnchor.Width;
                    nAnchor.Width *= -1;
                }
                if (nAnchor.Height < 0)
                {
                    nAnchor.Y      += nAnchor.Height;
                    nAnchor.Height *= -1;
                }
            }
            else
            {
                using (GraphicsPath fillPath = new GraphicsPath())
                    using (HatchBrush hatch = new HatchBrush(HatchStyle.DiagonalCross, Color.FromArgb(127, Color.Black), Color.FromArgb(127, Color.White)))
                    {
                        fillPath.AddRectangles(new RectangleF[] { PreViewBMP.ClientRectangle, nAnchor });
                        e.Graphics.FillPath(hatch, fillPath);
                    }
            }
            nAnchor.Width--;
            nAnchor.Height--;
            using (Pen anchorPen = new Pen(SWAFlag ? Color.Blue : Color.FromArgb(128, Color.Blue), 1))
                e.Graphics.DrawRectangle(anchorPen, nAnchor);

            using (Pen vCornersPen = new Pen(Color.FromArgb(128, Color.Red), 3))
            {
                vCornersPen.LineJoin = LineJoin.Bevel;
                e.Graphics.DrawPolygon(vCornersPen, previewCorners);
            }

            if (moveflag && this.sideSelected == -1 && this.CornerSelect > -1)
            {
                bool mirrorX = MirrorX.Checked;
                bool mirrorY = MirrorY.Checked;
                if (mirrorX || mirrorY)
                {
                    if (mirrorX)
                    {
                        e.Graphics.DrawLine(Pens.DimGray, xMirrorPaintPoint.X, xMirrorPaintPoint.Y - 10, xMirrorPaintPoint.X, xMirrorPaintPoint.Y + 10);
                    }

                    if (mirrorY)
                    {
                        e.Graphics.DrawLine(Pens.DimGray, yMirrorPaintPoint.X - 10, yMirrorPaintPoint.Y, yMirrorPaintPoint.X + 10, yMirrorPaintPoint.Y);
                    }

                    if (mirrorX && mirrorY)
                    {
                        int oppositeLR = xMirrorPaintPoint.Y - (xMirrorPaintPoint.Y - yMirrorPaintPoint.Y) * 2;
                        e.Graphics.DrawLine(Pens.DimGray, xMirrorPaintPoint.X, oppositeLR - 10, xMirrorPaintPoint.X, oppositeLR + 10);
                        int oppositeTB = yMirrorPaintPoint.X - (yMirrorPaintPoint.X - xMirrorPaintPoint.X) * 2;
                        e.Graphics.DrawLine(Pens.DimGray, oppositeTB - 10, yMirrorPaintPoint.Y, oppositeTB + 10, yMirrorPaintPoint.Y);
                    }
                }
            }

            for (int i = 0; i < 4; i++)
            {
                Rectangle nubPos      = new Rectangle(previewCorners[i].X - 5, previewCorners[i].Y - 5, 10, 10);
                bool      nubSelected = i == CornerSelect;
                e.Graphics.FillEllipse(nubSelected ? Brushes.LightBlue : Brushes.White, nubPos);
                e.Graphics.DrawEllipse(nubSelected ? Pens.DarkBlue : Pens.Black, nubPos);

                Point     sideNub         = MyUtils.CenterPoint(new[] { previewCorners[i], previewCorners[(i + 1) % 4] });
                Rectangle sideNubPos      = new Rectangle(sideNub.X - 4, sideNub.Y - 4, 8, 8);
                bool      sideNubSelected = moveflag && i == sideSelected;
                e.Graphics.FillEllipse(sideNubSelected ? Brushes.LightGreen : Brushes.White, sideNubPos);
                e.Graphics.DrawEllipse(sideNubSelected ? Pens.DarkGreen : Pens.DimGray, sideNubPos);
            }

            if (moveflag && sideSelected > -1)
            {
                int       iA      = this.sideSelected;
                Rectangle nubPosA = new Rectangle(previewCorners[iA].X - 5, previewCorners[iA].Y - 5, 10, 10);
                e.Graphics.FillEllipse(Brushes.LightBlue, nubPosA);
                e.Graphics.DrawEllipse(Pens.DarkBlue, nubPosA);

                int       iB      = (this.sideSelected + 1) % 4;
                Rectangle nubPosb = new Rectangle(previewCorners[iB].X - 5, previewCorners[iB].Y - 5, 10, 10);
                e.Graphics.FillEllipse(Brushes.LightBlue, nubPosb);
                e.Graphics.DrawEllipse(Pens.DarkBlue, nubPosb);
            }
        }
Beispiel #21
0
        private void PSI_Frame_SizeChanged(object sender, EventArgs e)
        {
            // short out if the size isn't really changing.
            if (_width != Width)
            {
                _height = Height;
                _width  = Width;
            }
            else
            if (_height != Height)
            {
                _height = Height;
            }
            else
            {
                return;
            }

            // cleanup old region...
            if (PaintRegion != null)
            {
                if (PaintRegion.Equals(this.Region))
                {
                    this.Region = null;
                    PaintRegion.Dispose();
                }
            }

            try
            {
                // this is the pather we're building

                Image bm          = this.BackgroundImage;
                Image imageRegion = this.BackgroundImage;
                if (imageRegion != null)
                {
                    GraphicsPath regionPath = new GraphicsPath();
                    Region       tmp_region;
                    // First we get the dimensions of our image

                    int imageWidth  = imageRegion.Width;
                    int imageHeight = imageRegion.Height;

                    // This will be the path for our Region

                    Rectangle r  = new Rectangle();
                    Rectangle sr = new Rectangle();
                    //e.Graphics.Clear(Color.Transparent);
                    //------------------ TOP LEFT CORNER
                    sr.X      = 0;
                    sr.Width  = bm.Width / 2 - center_pad_x;
                    sr.Y      = 0;
                    sr.Height = bm.Height / 2 - center_pad_y;
                    r.X       = 0;
                    r.Y       = 0;
                    r.Width   = sr.Width;
                    r.Height  = sr.Height;

                    {
                        tmp_region = MyPath.Clone();
                        // sr and r are the same (not scaling image corners...
                        tmp_region.Intersect(r);
                        regionPath.AddRectangles(tmp_region.GetRegionScans(identity));
                        tmp_region.Dispose();
                    }

                    //------------------ TOP EDGE
                    sr.X      = bm.Width / 2 - center_pad_x;
                    sr.Width  = bm.Width - 2 * (bm.Width / 2 - center_pad_x);
                    sr.Y      = 0;
                    sr.Height = sr.Height;
                    r.X      += r.Width;
                    r.Y       = 0;
                    r.Width   = Width - 2 * (bm.Width / 2 - center_pad_x);
                    r.Height  = sr.Height;
                    {
                        tmp_region = MyPath.Clone();
                        tmp_region.Intersect(sr);

                        m.Reset();
                        m.Translate((float)(sr.X)                            //* (float)sr.Width / (float)r.Width )
                                    , 0);
                        m.Scale((float)r.Width / (float)sr.Width, 1.0F);
                        m.Translate((float)(-r.X)
                                    , 0);
                        regionPath.AddRectangles(tmp_region.GetRegionScans(m));
                        tmp_region.Dispose();
                    }

                    //------------------ TOP RIght Corner
                    sr.X      = bm.Width - (bm.Width / 2 - center_pad_x);
                    sr.Width  = bm.Width / 2 - center_pad_x;
                    sr.Y      = 0;
                    sr.Height = sr.Height;

                    r.X     += r.Width;
                    r.Y      = 0;
                    r.Width  = bm.Width / 2 - center_pad_x;
                    r.Height = sr.Height;
                    {
                        tmp_region = MyPath.Clone();
                        tmp_region.Intersect(sr);

                        m.Reset();
                        m.Translate((r.X - sr.X), 0);
                        regionPath.AddRectangles(tmp_region.GetRegionScans(m));
                        tmp_region.Dispose();
                    }

                    //------------------ BOTTOM LEFT CONRER
                    sr.X      = 0;
                    sr.Width  = bm.Width / 2 - center_pad_x;
                    sr.Y      = bm.Height - (bm.Height / 2 - center_pad_y);
                    sr.Height = bm.Height / 2 - center_pad_y;
                    r.X       = 0;
                    r.Y       = Height - (bm.Height / 2 - center_pad_y);
                    r.Width   = sr.Width;
                    r.Height  = sr.Height;
                    {
                        tmp_region = MyPath.Clone();
                        tmp_region.Intersect(sr);

                        m.Reset();
                        m.Translate(0, r.Y - sr.Y);
                        regionPath.AddRectangles(tmp_region.GetRegionScans(m));
                        tmp_region.Dispose();
                    }

                    //------------------ BOTTOM EDGE
                    sr.X     = bm.Width / 2 - center_pad_x;
                    sr.Width = bm.Width - 2 * (bm.Width / 2 - center_pad_x);
                    //sr.Y = 0;
                    //sr.Height = sr.Height;
                    r.X += r.Width;
                    //r.Y = 0;
                    r.Width = Width - 2 * (bm.Width / 2 - center_pad_x);
                    //r.Height = sr.Height;
                    {
                        tmp_region = MyPath.Clone();
                        tmp_region.Intersect(sr);

                        m.Reset();
                        m.Translate((float)(+sr.X)                            //* (float)sr.Width / (float)r.Width )
                                    , 0);
                        m.Scale((float)r.Width / (float)sr.Width, 1.0F);
                        m.Translate((float)(-r.X)
                                    , r.Y - sr.Y);
                        regionPath.AddRectangles(tmp_region.GetRegionScans(m));
                        tmp_region.Dispose();
                    }

                    //------------------ BOTTOM RIGHT CORNER
                    sr.X     = bm.Width - (bm.Width / 2 - center_pad_x);
                    sr.Width = bm.Width / 2 - center_pad_x;
                    //sr.Y = 0;
                    //sr.Height = sr.Height;

                    r.X += r.Width;
                    //r.Y = 0;
                    r.Width = bm.Width / 2 - center_pad_x;
                    //r.Height = sr.Height;

                    {
                        tmp_region = MyPath.Clone();
                        tmp_region.Intersect(sr);

                        m.Reset();
                        m.Translate((float)(r.X - sr.Y), (float)(r.Y - sr.Y));
                        regionPath.AddRectangles(tmp_region.GetRegionScans(m));
                        tmp_region.Dispose();
                    }

                    //------------------ LEFT EDGE
                    sr.X      = 0;
                    sr.Width  = bm.Width / 2 - center_pad_x;
                    sr.Y      = bm.Height / 2 - center_pad_y;
                    sr.Height = bm.Height - 2 * (bm.Height / 2 - center_pad_y);
                    r.X       = 0;
                    r.Y       = bm.Height / 2 - center_pad_y;
                    r.Width   = sr.Width;
                    r.Height  = Height - 2 * (bm.Height / 2 - center_pad_y);
                    {
                        tmp_region = MyPath.Clone();
                        tmp_region.Intersect(sr);

                        m.Reset();
                        m.Translate(0, (float)(sr.Y));
                        m.Scale(1.0F, (float)r.Height / (float)sr.Height);
                        m.Translate(0, (float)(-r.Y));
                        regionPath.AddRectangles(tmp_region.GetRegionScans(m));
                        tmp_region.Dispose();
                    }

                    //------------------ RIGHT EDGE ( same as left, but on the right
                    sr.X = bm.Width - sr.Width;
                    r.X  = Width - sr.Width;
                    {
                        tmp_region = MyPath.Clone();
                        tmp_region.Intersect(sr);

                        m.Reset();
                        m.Translate(0, (float)(sr.Y));
                        m.Scale(1.0F, (float)r.Height / (float)sr.Height);
                        m.Translate((float)(r.X - sr.X), (float)(-r.Y));
                        regionPath.AddRectangles(tmp_region.GetRegionScans(m));
                        tmp_region.Dispose();
                    }


                    sr.X      = bm.Width / 2 - center_pad_x;
                    sr.Y      = bm.Height / 2 - center_pad_y;
                    sr.Width  = bm.Width - 2 * (bm.Width / 2 - center_pad_x);
                    sr.Height = bm.Height - 2 * (bm.Height / 2 - center_pad_y);
                    r.X       = bm.Width / 2 - center_pad_x;
                    r.Y       = bm.Height / 2 - center_pad_y;
                    r.Width   = Width - 2 * (bm.Width / 2 - center_pad_x);
                    r.Height  = Height - 2 * (bm.Height / 2 - center_pad_y);

                    // the final output rect is easy :)
                    regionPath.AddRectangle(r);

                    PaintRegion = new Region(regionPath);
                }
            }
            catch (Exception ex)
            {
                xperdex.classes.Log.log("Uhmm too small?! bounding error on internal thing." + ex.Message);
            }
        }
Beispiel #22
0
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            Point point  = new Point(0, 0);
            Point point2 = new Point(0, base.Height);
            bool  flag   = this._ProgressDirection == ProgressBarEx.ProgressDir.Vertical;

            if (flag)
            {
                point2 = new Point(base.Width, 0);
            }
            using (GraphicsPath graphicsPath = new GraphicsPath())
            {
                Rectangle rect  = new Rectangle(0, 0, base.Width, base.Height);
                int       num   = Convert.ToInt32((double)rect.Height / 2.5);
                bool      flag2 = rect.Width < rect.Height;
                if (flag2)
                {
                    num = Convert.ToInt32((double)rect.Width / 2.5);
                }
                using (LinearGradientBrush linearGradientBrush = new LinearGradientBrush(point, point2, this._BackColor, this._GradiantColor))
                {
                    linearGradientBrush.Blend = this.bBlend;
                    bool roundedCorners = this._RoundedCorners;
                    if (roundedCorners)
                    {
                        graphicsPath.AddArc(rect.X, rect.Y, num, num, 180f, 90f);
                        graphicsPath.AddArc(rect.Right - num, rect.Y, num, num, 270f, 90f);
                        graphicsPath.AddArc(rect.Right - num, rect.Bottom - num, num, num, 0f, 90f);
                        graphicsPath.AddArc(rect.X, rect.Bottom - num, num, num, 90f, 90f);
                        graphicsPath.CloseFigure();
                        e.Graphics.FillPath(linearGradientBrush, graphicsPath);
                    }
                    else
                    {
                        e.Graphics.FillRectangle(linearGradientBrush, rect);
                    }
                }
                bool flag3 = this._Value > this._Minimum;
                if (flag3)
                {
                    int  num2  = Convert.ToInt32((double)base.Width / (double)(this._Maximum - this._Minimum) * (double)this._Value);
                    bool flag4 = this._ProgressDirection == ProgressBarEx.ProgressDir.Vertical;
                    if (flag4)
                    {
                        num2        = Convert.ToInt32((double)base.Height / (double)(this._Maximum - this._Minimum) * (double)this._Value);
                        rect.Y      = rect.Height - num2;
                        rect.Height = num2;
                    }
                    else
                    {
                        rect.Width = num2;
                    }
                    using (LinearGradientBrush linearGradientBrush2 = new LinearGradientBrush(point, point2, this._ProgressColor, this._GradiantColor))
                    {
                        linearGradientBrush2.Blend = this.bBlend;
                        bool roundedCorners2 = this._RoundedCorners;
                        if (roundedCorners2)
                        {
                            bool flag5 = this._ProgressDirection == ProgressBarEx.ProgressDir.Horizontal;
                            if (flag5)
                            {
                                rect.Height--;
                            }
                            else
                            {
                                rect.Width--;
                            }
                            using (GraphicsPath graphicsPath2 = new GraphicsPath())
                            {
                                graphicsPath2.AddArc(rect.X, rect.Y, num, num, 180f, 90f);
                                graphicsPath2.AddArc(rect.Right - num, rect.Y, num, num, 270f, 90f);
                                graphicsPath2.AddArc(rect.Right - num, rect.Bottom - num, num, num, 0f, 90f);
                                graphicsPath2.AddArc(rect.X, rect.Bottom - num, num, num, 90f, 90f);
                                graphicsPath2.CloseFigure();
                                using (GraphicsPath graphicsPath3 = new GraphicsPath())
                                {
                                    using (Region region = new Region(graphicsPath))
                                    {
                                        region.Intersect(graphicsPath2);
                                        graphicsPath3.AddRectangles(region.GetRegionScans(new Matrix()));
                                    }
                                    e.Graphics.FillPath(linearGradientBrush2, graphicsPath3);
                                }
                            }
                        }
                        else
                        {
                            e.Graphics.FillRectangle(linearGradientBrush2, rect);
                        }
                    }
                }
                bool flag6 = this._Image != null;
                if (flag6)
                {
                    bool flag7 = this._ImageLayout == ProgressBarEx.ImageLayoutType.Stretch;
                    if (flag7)
                    {
                        e.Graphics.DrawImage(this._Image, 0, 0, base.Width, base.Height);
                    }
                    else
                    {
                        bool flag8 = this._ImageLayout == ProgressBarEx.ImageLayoutType.None;
                        if (flag8)
                        {
                            e.Graphics.DrawImage(this._Image, 0, 0);
                        }
                        else
                        {
                            int x = Convert.ToInt32(base.Width / 2 - this._Image.Width / 2);
                            int y = Convert.ToInt32(base.Height / 2 - this._Image.Height / 2);
                            e.Graphics.DrawImage(this._Image, x, y);
                        }
                    }
                }
                bool flag9 = this._ShowPercentage | this._ShowText;
                if (flag9)
                {
                    string text     = "";
                    bool   showText = this._ShowText;
                    if (showText)
                    {
                        text = this.Text;
                    }
                    bool showPercentage = this._ShowPercentage;
                    if (showPercentage)
                    {
                        text = text + Convert.ToString(Convert.ToInt32(100.0 / (double)(this._Maximum - this._Minimum) * (double)this._Value)) + "%";
                    }
                    using (StringFormat stringFormat = new StringFormat
                    {
                        Alignment = StringAlignment.Center,
                        LineAlignment = StringAlignment.Center
                    })
                    {
                        e.Graphics.DrawString(text, this.Font, this._ForeColorBrush, new Rectangle(0, 0, base.Width, base.Height), stringFormat);
                    }
                }
                bool border = this._Border;
                if (border)
                {
                    rect = new Rectangle(0, 0, base.Width - 1, base.Height - 1);
                    bool roundedCorners3 = this._RoundedCorners;
                    if (roundedCorners3)
                    {
                        graphicsPath.Reset();
                        graphicsPath.AddArc(rect.X, rect.Y, num, num, 180f, 90f);
                        graphicsPath.AddArc(rect.Right - num, rect.Y, num, num, 270f, 90f);
                        graphicsPath.AddArc(rect.Right - num, rect.Bottom - num, num, num, 0f, 90f);
                        graphicsPath.AddArc(rect.X, rect.Bottom - num, num, num, 90f, 90f);
                        graphicsPath.CloseFigure();
                        e.Graphics.DrawPath(this._BorderPen, graphicsPath);
                    }
                    else
                    {
                        e.Graphics.DrawRectangle(this._BorderPen, rect);
                    }
                }
            }
        }