Example #1
0
 public RectangleRegion()
 {
     AreaManager = new AreaManager(this);
     KeyDown    += RectangleRegion_KeyDown;
     MouseDown  += RectangleRegion_MouseDown;
     MouseWheel += RectangleRegion_MouseWheel;
 }
Example #2
0
 public RectangleRegion(Image backgroundImage = null)
     : base(backgroundImage)
 {
     AreaManager = new AreaManager(this);
     KeyDown    += RectangleRegion_KeyDown;
     MouseDown  += RectangleRegion_MouseDown;
     MouseWheel += RectangleRegion_MouseWheel;
 }
Example #3
0
 public RectangleRegion(Image backgroundImage = null)
     : base(backgroundImage)
 {
     AreaManager = new AreaManager(this);
     KeyDown += RectangleRegion_KeyDown;
     MouseDown += RectangleRegion_MouseDown;
     MouseWheel += RectangleRegion_MouseWheel;
 }
Example #4
0
        public ResizeManager(Surface surface, AreaManager areaManager)
        {
            this.areaManager = areaManager;

            MinMoveSpeed = surface.Config.MinMoveSpeed;
            MaxMoveSpeed = surface.Config.MaxMoveSpeed;

            surface.KeyDown += surface_KeyDown;

            nodes = new NodeObject[8];

            for (int i = 0; i < 8; i++)
            {
                nodes[i] = surface.MakeNode();
            }

            nodes[(int)NodePosition.BottomRight].Order = 10;
        }
Example #5
0
        public ResizeManager(Surface surface, AreaManager areaManager)
        {
            this.surface = surface;
            this.areaManager = areaManager;

            MinMoveSpeed = surface.Config.MinMoveSpeed;
            MaxMoveSpeed = surface.Config.MaxMoveSpeed;

            surface.KeyDown += surface_KeyDown;

            nodes = new NodeObject[8];

            for (int i = 0; i < 8; i++)
            {
                nodes[i] = surface.MakeNode();
            }

            nodes[(int)NodePosition.BottomRight].Order = 10;
        }
Example #6
0
        protected override void Draw(Graphics g)
        {
            List <Rectangle> areas = AreaManager.GetValidAreas;

            if (areas.Count > 0 || !AreaManager.CurrentHoverArea.IsEmpty)
            {
                UpdateRegionPath();

                if (areas.Count > 0)
                {
                    using (Region region = new Region(regionDrawPath))
                    {
                        g.Clip = region;
                        g.FillRectangle(lightBackgroundBrush, ScreenRectangle0Based);
                        g.ResetClip();
                    }

                    g.DrawPath(borderPen, regionDrawPath);

                    if (areas.Count > 1)
                    {
                        Rectangle totalArea = AreaManager.CombineAreas();
                        g.DrawCrossRectangle(borderPen, totalArea, 15);

                        if (Config.ShowInfo)
                        {
                            ImageHelpers.DrawTextWithOutline(g, string.Format("X: {0} / Y: {1} / W: {2} / H: {3}", totalArea.X, totalArea.Y,
                                                                              totalArea.Width, totalArea.Height), new PointF(totalArea.X + 5, totalArea.Y - 25), textFont, Color.White, Color.Black);
                        }
                    }
                }

                if (AreaManager.IsCurrentHoverAreaValid)
                {
                    using (GraphicsPath hoverDrawPath = new GraphicsPath {
                        FillMode = FillMode.Winding
                    })
                    {
                        AddShapePath(hoverDrawPath, AreaManager.CurrentHoverArea.SizeOffset(-1));

                        g.DrawPath(borderPen, hoverDrawPath);
                        g.DrawPath(borderDotPen, hoverDrawPath);
                    }
                }

                if (AreaManager.IsCurrentAreaValid)
                {
                    g.DrawRectangleProper(borderPen, AreaManager.CurrentArea);
                    g.DrawRectangleProper(borderDotPen, AreaManager.CurrentArea);
                    DrawObjects(g);

                    if (RulerMode)
                    {
                        DrawRuler(g, AreaManager.CurrentArea, borderPen, 5, 10);
                        DrawRuler(g, AreaManager.CurrentArea, borderPen, 15, 100);

                        Point centerPos = new Point(AreaManager.CurrentArea.X + AreaManager.CurrentArea.Width / 2, AreaManager.CurrentArea.Y + AreaManager.CurrentArea.Height / 2);
                        int   markSize  = 10;
                        g.DrawLine(borderPen, centerPos.X, centerPos.Y - markSize, centerPos.X, centerPos.Y + markSize);
                        g.DrawLine(borderPen, centerPos.X - markSize, centerPos.Y, centerPos.X + markSize, centerPos.Y);
                    }
                }

                if (Config.ShowInfo)
                {
                    foreach (Rectangle area in areas)
                    {
                        if (area.IsValid())
                        {
                            if (RulerMode)
                            {
                                ImageHelpers.DrawTextWithOutline(g, GetRulerText(area), new PointF(area.X + 15, area.Y + 15), textFont, Color.White, Color.Black);
                            }
                            else
                            {
                                ImageHelpers.DrawTextWithOutline(g, GetAreaText(area), new PointF(area.X + 5, area.Y + 5), textFont, Color.White, Color.Black);
                            }
                        }
                    }
                }
            }

            if (Config.ShowMagnifier)
            {
                DrawMagnifier(g);
            }

            if (Config.ShowCrosshair)
            {
                DrawCrosshair(g);
            }
        }
Example #7
0
 protected override void Update()
 {
     base.Update();
     AreaManager.Update();
 }
Example #8
0
        protected override void Draw(Graphics g)
        {
            borderDotPen2.DashOffset = (float)timer.Elapsed.TotalSeconds * 10;

            List <Rectangle> areas = AreaManager.GetValidAreas;

            if (areas.Count > 0 || !AreaManager.CurrentHoverArea.IsEmpty)
            {
                UpdateRegionPath();

                if (areas.Count > 0)
                {
                    using (Region region = new Region(regionDrawPath))
                    {
                        g.Clip = region;
                        g.FillRectangle(lightBackgroundBrush, ScreenRectangle0Based);
                        g.ResetClip();
                    }

                    g.DrawPath(borderPen, regionDrawPath);

                    if (areas.Count > 1)
                    {
                        Rectangle totalArea = AreaManager.CombineAreas();
                        g.DrawCrossRectangle(borderPen, totalArea, 15);

                        if (Config.ShowInfo)
                        {
                            ImageHelpers.DrawTextWithOutline(g, string.Format("X: {0} / Y: {1} / W: {2} / H: {3}", totalArea.X, totalArea.Y,
                                                                              totalArea.Width, totalArea.Height), new PointF(totalArea.X + 5, totalArea.Y - 25), textFont, Color.White, Color.Black);
                        }
                    }
                }

                if (AreaManager.IsCurrentHoverAreaValid)
                {
                    using (GraphicsPath hoverDrawPath = new GraphicsPath {
                        FillMode = FillMode.Winding
                    })
                    {
                        AddShapePath(hoverDrawPath, AreaManager.CurrentHoverArea.SizeOffset(-1));

                        g.DrawPath(borderDotPen, hoverDrawPath);
                        g.DrawPath(borderDotPen2, hoverDrawPath);
                    }
                }

                if (AreaManager.IsCurrentAreaValid)
                {
                    g.DrawRectangleProper(borderDotPen, AreaManager.CurrentArea);
                    g.DrawRectangleProper(borderDotPen2, AreaManager.CurrentArea);
                    DrawObjects(g);

                    if (RulerMode)
                    {
                        DrawRuler(g, AreaManager.CurrentArea, borderPen, 5, 10);
                        DrawRuler(g, AreaManager.CurrentArea, borderPen, 15, 100);

                        Point centerPos = new Point(AreaManager.CurrentArea.X + AreaManager.CurrentArea.Width / 2, AreaManager.CurrentArea.Y + AreaManager.CurrentArea.Height / 2);
                        int   markSize  = 10;
                        g.DrawLine(borderPen, centerPos.X, centerPos.Y - markSize, centerPos.X, centerPos.Y + markSize);
                        g.DrawLine(borderPen, centerPos.X - markSize, centerPos.Y, centerPos.X + markSize, centerPos.Y);
                    }
                }

                if (Config.ShowInfo)
                {
                    foreach (Rectangle area in areas)
                    {
                        if (area.IsValid())
                        {
                            string areaText;

                            if (RulerMode)
                            {
                                Point endPos = new Point(area.X + area.Width - 1, area.Y + area.Height - 1);
                                areaText = string.Format("X: {0} / Y: {1} / X2: {2} / Y2: {3}\nWidth: {4} px / Height: {5} px\nDistance: {6:0.00} px / Angle: {7:0.00}°", area.X, area.Y, endPos.X, endPos.Y,
                                                         area.Width, area.Height, MathHelpers.Distance(area.Location, endPos), MathHelpers.LookAtDegree(area.Location, endPos));
                                ImageHelpers.DrawTextWithOutline(g, areaText, new PointF(area.X + 15, area.Y + 15), textFont, Color.White, Color.Black);
                            }
                            else
                            {
                                areaText = string.Format("X: {0} / Y: {1}\nW: {2} / H: {3}", area.X, area.Y, area.Width, area.Height);
                                ImageHelpers.DrawTextWithOutline(g, areaText, new PointF(area.X + 5, area.Y + 5), textFont, Color.White, Color.Black);
                            }
                        }
                    }
                }
            }

            if (Config.ShowMagnifier)
            {
                DrawMagnifier(g);
            }

            if (Config.ShowCrosshair)
            {
                DrawCrosshair(g);
            }
        }
Example #9
0
        protected override void Draw(Graphics g)
        {
            borderDotPen2.DashOffset = (float)timer.Elapsed.TotalSeconds * 10;

            List <Rectangle> areas = AreaManager.GetValidAreas;

            if (areas.Count > 0 || !AreaManager.CurrentHoverArea.IsEmpty)
            {
                UpdateRegionPath();

                if (areas.Count > 0)
                {
                    using (Region region = new Region(regionDrawPath))
                    {
                        g.Clip = region;
                        g.FillRectangle(lightBackgroundBrush, ScreenRectangle0Based);
                        g.ResetClip();
                    }

                    g.DrawPath(borderPen, regionDrawPath);

                    if (areas.Count > 1)
                    {
                        Rectangle totalArea = AreaManager.CombineAreas();
                        g.DrawCrossRectangle(borderPen, totalArea, 15);

                        if (Config.ShowInfo)
                        {
                            ImageHelpers.DrawTextWithOutline(g, string.Format("X:{0} Y:{1} W:{2} H:{3}", totalArea.X, totalArea.Y,
                                                                              totalArea.Width, totalArea.Height), new PointF(totalArea.X + 5, totalArea.Y - 25), textFont, Color.White, Color.Black);
                        }
                    }
                }

                if (AreaManager.IsCurrentHoverAreaValid)
                {
                    using (GraphicsPath hoverDrawPath = new GraphicsPath {
                        FillMode = FillMode.Winding
                    })
                    {
                        AddShapePath(hoverDrawPath, AreaManager.CurrentHoverArea.SizeOffset(-1));

                        g.DrawPath(borderDotPen, hoverDrawPath);
                        g.DrawPath(borderDotPen2, hoverDrawPath);
                    }
                }

                if (AreaManager.IsCurrentAreaValid)
                {
                    g.DrawRectangleProper(borderDotPen, AreaManager.CurrentArea);
                    g.DrawRectangleProper(borderDotPen2, AreaManager.CurrentArea);
                    DrawObjects(g);
                }

                if (Config.ShowInfo)
                {
                    foreach (Rectangle area in areas)
                    {
                        if (area.IsValid())
                        {
                            ImageHelpers.DrawTextWithOutline(g, string.Format("X:{0} Y:{1}\nW:{2} H:{3}", area.X, area.Y, area.Width, area.Height),
                                                             new PointF(area.X + 5, area.Y + 5), textFont, Color.White, Color.Black);
                        }
                    }
                }
            }

            if (Config.ShowMagnifier)
            {
                DrawMagnifier(g);
            }

            if (Config.ShowCrosshair)
            {
                DrawCrosshair(g);
            }
        }