windowcapture
исходный код / Models/HighlightRect.cs

HighlightRect.cs

64 строк · 2,133 байт · модуль Models
 1using System;
 2using System.Drawing;
 3
 4namespace WindowCapture.Models
 5{
 6    public enum BlurState
 7    {
 8        None,           // No blur effect
 9        BlurInside,     // Regular blur inside the rectangle
10        BlurOutside,    // Regular blur outside the rectangle
11        MotionInside,   // Motion blur inside the rectangle
12        MotionOutside   // Motion blur outside the rectangle
13    }
14
15    public class HighlightRect
16    {
17        // Unique ID for this highlight
18        public int Id;
19        private static int nextId = 1;
20
21        // Geometry
22        public Rectangle Rect;
23
24        // Effect state
25        public BlurState CurrentBlurState = BlurState.None;
26
27        // Dim disabled (toggled with MMB hold)
28        public bool DimDisabled = false;
29
30        // Show border for this highlight (default from global Settings)
31        public bool ShowBorder = true;
32
33        // Individual effect settings (default from global Settings)
34        public float BlurRadius = 1.0f;
35        public int MotionBlurDistance = 15;
36
37        public HighlightRect(Rectangle rect)
38        {
39            Id = nextId++;
40            Rect = rect;
41            // Copy default settings from global Settings
42            BlurRadius = Settings.BlurRadius;
43            MotionBlurDistance = Settings.MotionBlurDistance;
44            // ShowBorder uses default (true), controlled by global Settings.ShowHighlightBorder
45        }
46
47        // Get scaled blur radius based on image resolution
48        // Uses current Settings.BlurRadius to allow live settings changes
49        public int GetScaledBlurRadius(int imageWidth)
50        {
51            // Scale blur based on resolution (reference: 1920px width)
52            float scale = (float)imageWidth / Settings.ReferenceResolution;
53            // Use Settings.BlurRadius directly so settings changes take effect immediately
54            int scaledRadius = (int)Math.Round(Settings.BlurRadius * scale);
55            return Math.Max(1, scaledRadius);
56        }
57
58        // Reset ID counter (for new editor session)
59        public static void ResetIdCounter()
60        {
61            nextId = 1;
62        }
63    }
64}