private void Draw(Graphics g) { // Draw snap rectangles if (ShapeManager.IsCreating && ShapeManager.IsSnapResizing) { BaseShape shape = ShapeManager.CurrentShape; if (shape != null && shape.ShapeType != ShapeType.RegionFreehand && shape.ShapeType != ShapeType.DrawingFreehand) { foreach (Size size in Config.SnapSizes) { Rectangle snapRect = CaptureHelpers.CalculateNewRectangle(shape.StartPosition, shape.EndPosition, size); g.DrawRectangleProper(markerPen, snapRect); } } } List <BaseShape> areas = ShapeManager.ValidRegions.ToList(); if (areas.Count > 0) { // Create graphics path from all regions UpdateRegionPath(); // If background is dimmed then draw non dimmed background to region selections if (Config.UseDimming) { using (Region region = new Region(regionDrawPath)) { g.Clip = region; g.FillRectangle(backgroundHighlightBrush, ScreenRectangle0Based); g.ResetClip(); } } // Blink borders of all regions slightly to make non active regions to be visible in both dark and light backgrounds using (Pen blinkBorderPen = new Pen(colorBlinkAnimation.GetColor())) { g.DrawPath(blinkBorderPen, regionDrawPath); } } // Draw effect shapes foreach (BaseEffectShape effectShape in ShapeManager.EffectShapes) { effectShape.OnDraw(g); } // Draw drawing shapes foreach (BaseDrawingShape drawingShape in ShapeManager.DrawingShapes) { drawingShape.OnDraw(g); } // Draw animated rectangle on hover area if (ShapeManager.IsCurrentHoverShapeValid) { using (GraphicsPath hoverDrawPath = new GraphicsPath { FillMode = FillMode.Winding }) { ShapeManager.CurrentHoverShape.AddShapePath(hoverDrawPath, -1); g.DrawPath(borderPen, hoverDrawPath); g.DrawPath(borderDotPen, hoverDrawPath); } } // Draw animated rectangle on selection area if (ShapeManager.IsCurrentShapeTypeRegion && ShapeManager.IsCurrentShapeValid) { g.DrawRectangleProper(borderPen, ShapeManager.CurrentRectangle); g.DrawRectangleProper(borderDotPen, ShapeManager.CurrentRectangle); if (Mode == RegionCaptureMode.Ruler) { DrawRuler(g, ShapeManager.CurrentRectangle, borderPen, 5, 10); DrawRuler(g, ShapeManager.CurrentRectangle, borderPen, 15, 100); Point centerPos = new Point(ShapeManager.CurrentRectangle.X + ShapeManager.CurrentRectangle.Width / 2, ShapeManager.CurrentRectangle.Y + ShapeManager.CurrentRectangle.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); } } // Draw all regions rectangle info if (Config.ShowInfo) { // Add hover area to list so rectangle info can be shown if (ShapeManager.IsCurrentShapeTypeRegion && ShapeManager.IsCurrentHoverShapeValid && areas.All(area => area.Rectangle != ShapeManager.CurrentHoverShape.Rectangle)) { areas.Add(ShapeManager.CurrentHoverShape); } foreach (BaseShape regionInfo in areas) { if (regionInfo.Rectangle.IsValid()) { string areaText = GetAreaText(regionInfo.Rectangle); DrawAreaText(g, areaText, regionInfo.Rectangle); } } } // Draw resize nodes DrawObjects(g); // Draw F1 tips if (Config.ShowHotkeys) { DrawTips(g); } // Draw magnifier if (Config.ShowMagnifier || Config.ShowInfo) { DrawCursorGraphics(g); } // Draw screen wide crosshair if (Config.ShowCrosshair) { DrawCrosshair(g); } // Draw menu tooltips if (IsAnnotationMode && ShapeManager.MenuTextAnimation.Update()) { DrawTextAnimation(g, ShapeManager.MenuTextAnimation); } }
protected override void Draw(Graphics g) { if (AreaManager.IsCreating && AreaManager.IsSnapResizing) { foreach (Size size in Config.SnapSizes) { Rectangle snapRect = CaptureHelpers.CalculateNewRectangle(AreaManager.PositionOnClick, AreaManager.CurrentPosition, size); g.DrawRectangleProper(markerPen, snapRect); } } List <RegionInfo> areas = AreaManager.ValidAreas.ToList(); bool drawAreaExist = areas.Count > 0; if (AreaManager.IsCurrentHoverAreaValid && areas.All(area => area.Area != AreaManager.CurrentHoverArea)) { areas.Add(AreaManager.GetRegionInfo(AreaManager.CurrentHoverArea)); } if (areas.Count > 0) { UpdateRegionPath(); if (drawAreaExist) { if (Config.UseDimming) { using (Region region = new Region(regionDrawPath)) { g.Clip = region; g.FillRectangle(lightBackgroundBrush, ScreenRectangle0Based); g.ResetClip(); } } using (Pen blinkBorderPen = new Pen(colorBlinkAnimation.GetColor())) { g.DrawPath(blinkBorderPen, 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.GetRegionInfo(AreaManager.CurrentHoverArea), -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 (RegionInfo regionInfo in areas) { if (regionInfo.Area.IsValid()) { string areaText = GetAreaText(regionInfo.Area); DrawAreaText(g, areaText, regionInfo.Area); } } } } if (Config.ShowTips) { DrawTips(g, 10, 10); } if (Config.ShowMagnifier) { DrawMagnifier(g); } if (Config.ShowCrosshair) { DrawCrosshair(g); } }