├── .gitattributes
├── .github
└── FUNDING.yml
├── .gitignore
├── CONTRIBUTORS.md
├── Changelog.md
├── LICENSE.txt
├── README.md
├── ScreenRuler.sln
├── ScreenRuler
├── App.config
├── Colors
│ ├── ColorSetting.cs
│ ├── CommonThemes.cs
│ └── Theme.cs
├── Configuration
│ ├── ActionCode.cs
│ ├── Enums.cs
│ ├── LocalizedDescriptionAttribute.cs
│ ├── ManagerExtensions.cs
│ ├── Monitor
│ │ ├── MonitorIdForm.Designer.cs
│ │ ├── MonitorIdForm.cs
│ │ ├── MonitorIdForm.resx
│ │ ├── MonitorInfo.cs
│ │ ├── MonitorSetup.cs
│ │ └── MonitorSetupOverlay.cs
│ ├── MonitorDpiConfiguration.cs
│ ├── MonitorDpiConfigurationCollection.cs
│ ├── Settings.cs
│ └── Shortcuts.cs
├── Controls
│ ├── MarkerListBox.cs
│ ├── ShortcutActions.Designer.cs
│ ├── ShortcutActions.cs
│ ├── ShortcutActionsEdit.Designer.cs
│ ├── ShortcutActionsEdit.cs
│ ├── ShortcutActionsEdit.de.resx
│ ├── ShortcutActionsEdit.es.resx
│ └── ShortcutActionsEdit.resx
├── FodyWeavers.xml
├── Forms
│ ├── BaseForm.cs
│ ├── CalibrationForm.Designer.cs
│ ├── CalibrationForm.cs
│ ├── CalibrationForm.de.resx
│ ├── CalibrationForm.es.resx
│ ├── CalibrationForm.fi.resx
│ ├── CalibrationForm.it.resx
│ ├── CalibrationForm.ko.resx
│ ├── CalibrationForm.ml.resx
│ ├── CalibrationForm.nl.resx
│ ├── CalibrationForm.pl.resx
│ ├── CalibrationForm.pt-PT.resx
│ ├── CalibrationForm.resx
│ ├── CalibrationForm.ru.resx
│ ├── CalibrationForm.sk.resx
│ ├── CalibrationForm.sv.resx
│ ├── CalibrationForm.th-TH.resx
│ ├── CalibrationForm.tr.resx
│ ├── CalibrationForm.zh-CN.resx
│ ├── CustomLineForm.Designer.cs
│ ├── CustomLineForm.cs
│ ├── CustomLineForm.de.resx
│ ├── CustomLineForm.es.resx
│ ├── CustomLineForm.fi.resx
│ ├── CustomLineForm.it.resx
│ ├── CustomLineForm.ko.resx
│ ├── CustomLineForm.ml.resx
│ ├── CustomLineForm.nl.resx
│ ├── CustomLineForm.pl.resx
│ ├── CustomLineForm.pt-PT.resx
│ ├── CustomLineForm.resx
│ ├── CustomLineForm.ru.resx
│ ├── CustomLineForm.sk.resx
│ ├── CustomLineForm.sv.resx
│ ├── CustomLineForm.th-TH.resx
│ ├── CustomLineForm.tr.resx
│ ├── CustomLineForm.zh-CN.resx
│ ├── FormResizeMode.cs
│ ├── HelpForm.Designer.cs
│ ├── HelpForm.cs
│ ├── HelpForm.de.resx
│ ├── HelpForm.es.resx
│ ├── HelpForm.fi.resx
│ ├── HelpForm.it.resx
│ ├── HelpForm.ko.resx
│ ├── HelpForm.ml.resx
│ ├── HelpForm.nl.resx
│ ├── HelpForm.pl.resx
│ ├── HelpForm.pt-PT.resx
│ ├── HelpForm.resx
│ ├── HelpForm.ru.resx
│ ├── HelpForm.sk.resx
│ ├── HelpForm.sv.resx
│ ├── HelpForm.th-TH.resx
│ ├── HelpForm.tr.resx
│ ├── HelpForm.zh-CN.resx
│ ├── MarkerListForm.Designer.cs
│ ├── MarkerListForm.cs
│ ├── MarkerListForm.de.resx
│ ├── MarkerListForm.es.resx
│ ├── MarkerListForm.fi.resx
│ ├── MarkerListForm.ko.resx
│ ├── MarkerListForm.ml.resx
│ ├── MarkerListForm.nl.resx
│ ├── MarkerListForm.pl.resx
│ ├── MarkerListForm.pt-PT.resx
│ ├── MarkerListForm.resx
│ ├── MarkerListForm.ru.resx
│ ├── MarkerListForm.sk.resx
│ ├── MarkerListForm.sv.resx
│ ├── MarkerListForm.th-TH.resx
│ ├── MarkerListForm.tr.resx
│ ├── MarkerListForm.zh-CN.resx
│ ├── RulerForm.Designer.cs
│ ├── RulerForm.cs
│ ├── RulerForm.de.resx
│ ├── RulerForm.es.resx
│ ├── RulerForm.fi.resx
│ ├── RulerForm.it.resx
│ ├── RulerForm.ko.resx
│ ├── RulerForm.ml.resx
│ ├── RulerForm.nl.resx
│ ├── RulerForm.pl.resx
│ ├── RulerForm.pt-PT.resx
│ ├── RulerForm.resx
│ ├── RulerForm.ru.resx
│ ├── RulerForm.sk.resx
│ ├── RulerForm.sv.resx
│ ├── RulerForm.th-TH.resx
│ ├── RulerForm.tr.resx
│ ├── RulerForm.zh-CN.resx
│ ├── SetSizeForm.Designer.cs
│ ├── SetSizeForm.cs
│ ├── SetSizeForm.de.resx
│ ├── SetSizeForm.es.resx
│ ├── SetSizeForm.fi.resx
│ ├── SetSizeForm.it.resx
│ ├── SetSizeForm.ko.resx
│ ├── SetSizeForm.ml.resx
│ ├── SetSizeForm.nl.resx
│ ├── SetSizeForm.pl.resx
│ ├── SetSizeForm.pt-PT.resx
│ ├── SetSizeForm.resx
│ ├── SetSizeForm.ru.resx
│ ├── SetSizeForm.sk.resx
│ ├── SetSizeForm.sv.resx
│ ├── SetSizeForm.th-TH.resx
│ ├── SetSizeForm.tr.resx
│ ├── SetSizeForm.zh-CN.resx
│ ├── SettingsForm.Designer.cs
│ ├── SettingsForm.cs
│ ├── SettingsForm.de.resx
│ ├── SettingsForm.es.resx
│ ├── SettingsForm.fi.resx
│ ├── SettingsForm.it.resx
│ ├── SettingsForm.ko.resx
│ ├── SettingsForm.ml.resx
│ ├── SettingsForm.nl.resx
│ ├── SettingsForm.pl.resx
│ ├── SettingsForm.pt-PT.resx
│ ├── SettingsForm.resx
│ ├── SettingsForm.ru.resx
│ ├── SettingsForm.sk.resx
│ ├── SettingsForm.sv.resx
│ ├── SettingsForm.th-TH.resx
│ ├── SettingsForm.tr.resx
│ ├── SettingsForm.zh-CN.resx
│ ├── ShortcutsForm.Designer.cs
│ ├── ShortcutsForm.cs
│ ├── ShortcutsForm.de.resx
│ ├── ShortcutsForm.es.resx
│ ├── ShortcutsForm.ko.resx
│ └── ShortcutsForm.resx
├── Help
│ ├── Help.de.html
│ ├── Help.en.html
│ ├── Help.es.html
│ ├── Help.fi.html
│ ├── Help.it.html
│ ├── Help.ko.html
│ ├── Help.ml.html
│ ├── Help.nl.html
│ ├── Help.pl.html
│ ├── Help.pt.html
│ ├── Help.ru.html
│ ├── Help.sk.html
│ ├── Help.sv.html
│ ├── Help.th-TH.html
│ ├── Help.zh-CN.html
│ └── Help.zh.html
├── Marker.cs
├── MarkerCollection.cs
├── MouseTracker.cs
├── Options.cs
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── EnumResources.Designer.cs
│ ├── EnumResources.de.resx
│ ├── EnumResources.es.resx
│ ├── EnumResources.fi.resx
│ ├── EnumResources.it.resx
│ ├── EnumResources.ko.resx
│ ├── EnumResources.ml.resx
│ ├── EnumResources.nl.resx
│ ├── EnumResources.pl.Designer.cs
│ ├── EnumResources.pl.resx
│ ├── EnumResources.pt-PT.resx
│ ├── EnumResources.resx
│ ├── EnumResources.ru.resx
│ ├── EnumResources.sk.resx
│ ├── EnumResources.sv.resx
│ ├── EnumResources.th-TH.resx
│ ├── EnumResources.tr.resx
│ ├── EnumResources.zh-CN.Designer.cs
│ ├── EnumResources.zh-CN.resx
│ ├── Resources.Designer.cs
│ ├── Resources.de.resx
│ ├── Resources.es.resx
│ ├── Resources.fi.resx
│ ├── Resources.it.resx
│ ├── Resources.ko.resx
│ ├── Resources.ml.resx
│ ├── Resources.nl.resx
│ ├── Resources.pl.Designer.cs
│ ├── Resources.pl.resx
│ ├── Resources.pt-PT.resx
│ ├── Resources.resx
│ ├── Resources.ru.resx
│ ├── Resources.sk.resx
│ ├── Resources.sv.resx
│ ├── Resources.th-TH.resx
│ ├── Resources.tr.resx
│ ├── Resources.zh-CN.Designer.cs
│ ├── Resources.zh-CN.resx
│ └── app.manifest
├── RulerPainter.cs
├── ScreenRuler.csproj
├── Units
│ ├── MeasuringUnit.cs
│ └── UnitConverters.cs
├── WinApi.cs
├── packages.config
└── rulerico.ico
├── choco
├── screenruler.nuspec
└── tools
│ ├── VERIFICATION.txt
│ ├── chocolateyUninstall.ps1
│ └── chocolateyinstall.ps1
└── img
├── icon.png
├── screenruler_2d.png
└── screenruler_styles_small.png
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | ko_fi: alxnull
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | [Xx]64/
19 | [Xx]86/
20 | [Bb]uild/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 |
85 | # Visual Studio profiler
86 | *.psess
87 | *.vsp
88 | *.vspx
89 | *.sap
90 |
91 | # TFS 2012 Local Workspace
92 | $tf/
93 |
94 | # Guidance Automation Toolkit
95 | *.gpState
96 |
97 | # ReSharper is a .NET coding add-in
98 | _ReSharper*/
99 | *.[Rr]e[Ss]harper
100 | *.DotSettings.user
101 |
102 | # JustCode is a .NET coding add-in
103 | .JustCode
104 |
105 | # TeamCity is a build add-in
106 | _TeamCity*
107 |
108 | # DotCover is a Code Coverage Tool
109 | *.dotCover
110 |
111 | # NCrunch
112 | _NCrunch_*
113 | .*crunch*.local.xml
114 | nCrunchTemp_*
115 |
116 | # MightyMoose
117 | *.mm.*
118 | AutoTest.Net/
119 |
120 | # Web workbench (sass)
121 | .sass-cache/
122 |
123 | # Installshield output folder
124 | [Ee]xpress/
125 |
126 | # DocProject is a documentation generator add-in
127 | DocProject/buildhelp/
128 | DocProject/Help/*.HxT
129 | DocProject/Help/*.HxC
130 | DocProject/Help/*.hhc
131 | DocProject/Help/*.hhk
132 | DocProject/Help/*.hhp
133 | DocProject/Help/Html2
134 | DocProject/Help/html
135 |
136 | # Click-Once directory
137 | publish/
138 |
139 | # Publish Web Output
140 | *.[Pp]ublish.xml
141 | *.azurePubxml
142 |
143 | # TODO: Un-comment the next line if you do not want to checkin
144 | # your web deploy settings because they may include unencrypted
145 | # passwords
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # NuGet Packages
150 | *.nupkg
151 | # The packages folder can be ignored because of Package Restore
152 | **/packages/*
153 | # except build/, which is used as an MSBuild target.
154 | !**/packages/build/
155 | # Uncomment if necessary however generally it will be regenerated when needed
156 | #!**/packages/repositories.config
157 | # NuGet v3's project.json files produces more ignoreable files
158 | *.nuget.props
159 | *.nuget.targets
160 |
161 | # Microsoft Azure Build Output
162 | csx/
163 | *.build.csdef
164 |
165 | # Microsoft Azure Emulator
166 | ecf/
167 | rcf/
168 |
169 | # Windows Store app package directory
170 | AppPackages/
171 | BundleArtifacts/
172 |
173 | # Visual Studio cache files
174 | # files ending in .cache can be ignored
175 | *.[Cc]ache
176 | # but keep track of directories ending in .cache
177 | !*.[Cc]ache/
178 |
179 | # Others
180 | ClientBin/
181 | [Ss]tyle[Cc]op.*
182 | ~$*
183 | *~
184 | *.dbmdl
185 | *.dbproj.schemaview
186 | *.pfx
187 | *.publishsettings
188 | node_modules/
189 | orleans.codegen.cs
190 |
191 | # RIA/Silverlight projects
192 | Generated_Code/
193 |
194 | # Backup & report files from converting an old project file
195 | # to a newer Visual Studio version. Backup files are not needed,
196 | # because we have git ;-)
197 | _UpgradeReport_Files/
198 | Backup*/
199 | UpgradeLog*.XML
200 | UpgradeLog*.htm
201 |
202 | # SQL Server files
203 | *.mdf
204 | *.ldf
205 |
206 | # Business Intelligence projects
207 | *.rdl.data
208 | *.bim.layout
209 | *.bim_*.settings
210 |
211 | # Microsoft Fakes
212 | FakesAssemblies/
213 |
214 | # GhostDoc plugin setting file
215 | *.GhostDoc.xml
216 |
217 | # Node.js Tools for Visual Studio
218 | .ntvs_analysis.dat
219 |
220 | # Visual Studio 6 build log
221 | *.plg
222 |
223 | # Visual Studio 6 workspace options file
224 | *.opt
225 |
226 | # Visual Studio LightSwitch build output
227 | **/*.HTMLClient/GeneratedArtifacts
228 | **/*.DesktopClient/GeneratedArtifacts
229 | **/*.DesktopClient/ModelManifest.xml
230 | **/*.Server/GeneratedArtifacts
231 | **/*.Server/ModelManifest.xml
232 | _Pvt_Extensions
233 |
234 | # LightSwitch generated files
235 | GeneratedArtifacts/
236 | ModelManifest.xml
237 |
238 | # Paket dependency manager
239 | .paket/paket.exe
240 |
241 | # FAKE - F# Make
242 | .fake/
243 |
244 | # Custom
245 | *.py
246 | *.bat
247 | FodyWeavers.xsd
248 | *.zip
249 |
--------------------------------------------------------------------------------
/CONTRIBUTORS.md:
--------------------------------------------------------------------------------
1 | # Screen Ruler Contributors
2 |
3 | - [alxnull](https://github.com/alxnull): Core development, English & German translation
4 | - [jensbrak](https://github.com/jensbrak): Golden ratio marker & marker symbols
5 | - Leandro Martin Drudi: Spanish translation
6 | - [lzporter](https://github.com/lzporter): Chinese translation
7 | - [CloverGit](https://github.com/CloverGit): Chinese translation
8 | - [IlBako](https://github.com/IlBako): Italian translation
9 | - [3t8](https://github.com/3t8): Italian translation
10 | - [João Felício](https://github.com/Joaolfelicio): Portuguese translation
11 | - [SvA1](https://github.com/SvA1): Russian translation
12 | - [id-konstantin-stepanov](https://github.com/id-konstantin-stepanov): Russian translation
13 | - [Farshan Ahamed](https://github.com/FarshanAhamed): Malayalam translation
14 | - [SentiWW](https://github.com/SentiWW): Polish translation
15 | - [Minna N.](https://github.com/minna-xD): Finnish translation, bug fixes
16 | - [Michel van Os](https://github.com/michelvosje): Dutch translation
17 | - [FrejBjornsson](https://github.com/FrejBjornsson): Swedish translation
18 | - [kerlos](https://github.com/kerlos): Thai translation
19 | - Peter Ditrich: Slovak translation
20 |
--------------------------------------------------------------------------------
/Changelog.md:
--------------------------------------------------------------------------------
1 | # Screen Ruler Changelog
2 |
3 | ### v.0.10 (2022-09)
4 | - **New:** Fine-grained calibration to display scaling using four scaling modes.
5 | - **New:** Monitor DPI awareness & automatic scaling.
6 | - **New:** Configuration of keyboard shortcuts.
7 | - **New:** Turkish translation.
8 | - **Fixed:** Placement of marker labels in flipped orientation.
9 | - **Fixed:** Intersecting mouse & offset labels.
10 | - **Fixed:** Various UI and usability issues & causes for app crashes
11 | - **Updated:** Spanish translation
12 |
13 | ### v.0.9 (2021-08)
14 | - **New:** Horizontal and vertical flipping of ruler scale
15 | - **New:** Optionally show hypotenuse ("H") and angles in 2D ruler mode
16 | - **New:** Command-line arguments to set startup location or measure opened window
17 | - **New:** Add shortcut ("X") to set marker at cursor position
18 | - **New:** Allow changing of units in marker list
19 | - **New:** Setting to snap ruler scale to screen edges
20 | - **Updated:** Chinese translation
21 |
22 | #### v.0.9.1 (2021-10)
23 | - **Fixed**: Misplaced markers on flipped ruler
24 | - **Fixed**: Crashing marker list window when no markers are set
25 |
26 | ### v.0.8 (2020-11)
27 | - **New:** Portuguese, Russian, Malayalam, Polish, Finnish, Dutch, Swedish and Thai translation
28 | - **Updated:** Italian and Spanish translation
29 | - **Changed:** Divide inch scale into 16 parts; minor UI fixes
30 |
31 | #### v.0.8.1 (2021-01)
32 | - **New:** Slovak translation
33 | - **New:** Increase precision of screen DPI setting
34 | - **New:** Keyboard shortcuts for toggling theme and setting opacity
35 | - **Fixed:** Position of marker labels on ruler
36 |
37 | ### v.0.7 (2020-09)
38 | - **New:** Added window for listing & managing custom markers
39 | - **New:** Option to hide ruler scale
40 | - **New:** Let ruler automatically follow mouse pointer
41 | - **New:** Italian translation
42 | - **New/ Changed:** Minor changes in options & settings (opacity, markers, step size)
43 |
44 | ### v.0.6 (2020-04)
45 | - **New:** Two-dimensional mode: measure the width and height simultaneously
46 | - **New:** Toggle ruler mode using 'Space'
47 | - **New:** Slim ruler scale
48 | - **New:** Ruler icon in notification area instead of task bar
49 | - **New:** Improved dialog for setting ruler size
50 | - **New:** Chinese translation
51 |
52 | ### v.0.5 (2020-02)
53 | - **New:** Marker for Golden Ratio
54 | - **New:** Symbols for marker lines (optional)
55 | - **New:** Spanish translation
56 | - **Changed:** Added window for easy ruler calibration
57 |
58 | ### v.0.4 (2020-01)
59 | - **New:** Configure marker thickness.
60 | - **New:** Configure size of resize/ move steps.
61 | - **New:** Minor: Tool tip and copy shortcut
62 |
63 | ### v.0.3 (2019-07)
64 | - **New:** Select a window from screen to measure it automatically.
65 | - **New:** Measuring unit: percentage of screen width/ height.
66 | - **New:** Fast resizing with mouse wheel.
67 | - **Changed:** Switched shortcuts for resizing and moving (!).
68 | - **Fixed:** Unclear menu label.
69 |
70 | ### v.0.2 (2018-10)
71 | - **New:** Measure in different units (cm, pt, in).
72 | - **New:** Dark ruler theme.
73 | - **New:** Custom coloring of the ruler.
74 | - **New:** Easily resize the ruler with the mouse wheel.
75 | - **New:** Add unlimited number of custom markers and delete them one by one.
76 |
77 | ### v.0.1 (2017-06)
78 | - First released version
79 |
80 | #### v.0.1.1 (2018-02)
81 | - **Fixed:** Bug with negative screen coordinates.
82 |
83 | #### v.0.1.2 (2018-04)
84 | - **New:** Saves the last ruler state for next startup.
85 | - **Fixed:** Resizing with keyboard in vertical mode.
86 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | BSD 3-Clause License
2 |
3 | Copyright (c) 2017-2021, Bluegrams.
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of the copyright holder nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Screen Ruler
2 |
3 | [](https://sourceforge.net/p/screenruler/news/feed.rss)
4 | [](https://github.com/bluegrams/screenruler)
5 | [](https://github.com/bluegrams/screenruler/blob/master/LICENSE.txt)
6 | [](https://sourceforge.net/projects/screenruler/files/)
7 |
8 | > Configurable screen ruler for measuring in pixels, centimeters, inches, points and percent.
9 |
10 | [](https://sourceforge.net/projects/screenruler/files/)
11 |
12 | Screen Ruler is a lightweight and configurable ruler tool for Windows Desktop.
13 | It allows you to measure the size of elements on the screen in different units, including pixels, centimeters and inches.
14 | Measuring is possible either using a two-dimensional, rectangular ruler scale or a one-dimensional, horizontal or vertical scale.
15 | The ruler can be moved and resized precisely using either the mouse or the keyboard and custom marking lines can be added.
16 | Besides coming with a light and a dark theme, Screen Ruler also allows you to fully customize its appearance by changing all color settings.
17 |
18 |
19 |
20 |
21 |
22 | ## Features
23 |
24 | - Measure in pixels, centimeters, inches, points and percent
25 |
26 | - Two-dimensional, rectangular ruler scale
27 |
28 | - One-dimensional, horizontal or vertical ruler scale
29 |
30 | - Dark theme and option for custom coloring
31 |
32 | - Automatically measure the size of windows on screen
33 |
34 | - Add arbitrary number of custom marking lines
35 |
36 | - Measure triangle hypotenuse and angles
37 |
38 | - Auto-mark center, thirds or golden ratio
39 |
40 | - Precise moving, resizing and flipping with keyboard shortcuts
41 |
42 | - Fully portable with no installation needed
43 |
44 | ## Setup and Usage
45 |
46 | #### Requirements
47 |
48 | Screen Ruler requires Windows 7 or newer and .NET Framework 4.8 or higher.
49 |
50 | #### Get Screen Ruler
51 |
52 | - Download the [latest release from SourceForge](https://sourceforge.net/projects/screenruler/files/)
53 |
54 | or
55 |
56 | - Install from [Chocolatey](https://chocolatey.org):
57 | ```
58 | choco install screenruler
59 | ```
60 |
61 | #### How To Use
62 |
63 | From the help window (press `F1` in the app):
64 |
65 | > Keyboard Actions:
66 | Space - Switch ruler mode between horizontal, vertical and two-dimensional.
67 | Z - Select a window to measure. Cancel with 'Esc'.
68 | Arrow keys - Move the ruler by one pixel.
69 | Shift + Arrow keys - Move the ruler by one medium step (defaults to 5px).
70 | Ctrl + Arrow keys - Resize the ruler by one pixel.
71 | Ctrl + Shift + Arrow keys - Resize the ruler by one medium step (defaults to 5px).
72 | Alt + Arrow keys - Dock the ruler to screen boundaries.
73 | Ctrl + C - Copy current length to clipboard.
74 | L - Set marker at current length.
75 | C - Remove the first custom marking line.
76 | Esc - Exit Screen Ruler, window selection or help.
77 | See more keyboard actions in context menu.
78 | >
79 | > Mouse Actions:
80 | Click on a position where a marker is set - Open dialog to view/ delete marker.
81 | Double-click on ruler - Set marker at the clicked position.
82 | Mouse wheel - Resize the ruler.
83 | Shift + Mouse wheel - Fast resizing of the ruler (large steps).
84 |
85 |
86 | ## Version History
87 |
88 | Read [the changelog](https://github.com/bluegrams/screenruler/blob/master/Changelog.md) to see changes in each version.
89 |
90 | ## Feedback and Support
91 |
92 | _Please leave a feedback on [Sourceforge](https://sourceforge.net/p/screenruler/reviews), on [AlternativeTo](https://alternativeto.net/software/bluegrams-screen-ruler/) or anywhere else. Thank you!_
93 |
94 | Places to get help:
95 |
96 | * Ask on [Sourceforge](https://sourceforge.net/p/screenruler/discussion/) (General help, ideas etc.)
97 | * Open an issue on [GitHub](https://github.com/bluegrams/screenruler/issues) (Bugs, feature requests etc.)
98 |
99 | ## Contribute
100 |
101 | You are very welcome to support the development of this app by reporting bugs, adding fixes, translating or suggesting new features.
102 | The easiest way to contribute is to open [pull request on GitHub](https://github.com/bluegrams/screenruler/pulls).
103 |
104 | See all the great people that have contributed in the [list of contributors](https://github.com/bluegrams/screenruler/blob/master/CONTRIBUTORS.md).
105 | Make sure to add yourself in your pull request!
106 |
107 | ## License
108 |
109 | This software is published under [BSD-3-Clause license](https://github.com/Bluegrams/ScreenRuler/blob/master/LICENSE.txt) by Bluegrams.
110 |
--------------------------------------------------------------------------------
/ScreenRuler.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30406.217
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScreenRuler", "ScreenRuler\ScreenRuler.csproj", "{67B8F96E-8237-4C57-983B-A2CA5BDDC9AE}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6A4246E2-D82B-4BAC-BDD1-F3B198ABC8A4}"
9 | ProjectSection(SolutionItems) = preProject
10 | Changelog.md = Changelog.md
11 | CONTRIBUTORS.md = CONTRIBUTORS.md
12 | LICENSE.txt = LICENSE.txt
13 | README.md = README.md
14 | EndProjectSection
15 | EndProject
16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "img", "img", "{E2560076-F4E6-44D0-843A-2F251607367E}"
17 | ProjectSection(SolutionItems) = preProject
18 | img\icon.png = img\icon.png
19 | img\screenruler_2d.png = img\screenruler_2d.png
20 | img\screenruler_styles_small.png = img\screenruler_styles_small.png
21 | EndProjectSection
22 | EndProject
23 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "choco", "choco", "{AAA7F469-AAC5-4DD7-AC3C-619BAE233F57}"
24 | ProjectSection(SolutionItems) = preProject
25 | choco\screenruler.nuspec = choco\screenruler.nuspec
26 | EndProjectSection
27 | EndProject
28 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{07FDF133-B8EB-40FF-9216-9F8D2239D11F}"
29 | ProjectSection(SolutionItems) = preProject
30 | choco\tools\chocolateyinstall.ps1 = choco\tools\chocolateyinstall.ps1
31 | choco\tools\chocolateyUninstall.ps1 = choco\tools\chocolateyUninstall.ps1
32 | EndProjectSection
33 | EndProject
34 | Global
35 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
36 | Debug|Any CPU = Debug|Any CPU
37 | Publish-Portable|Any CPU = Publish-Portable|Any CPU
38 | Publish-Release|Any CPU = Publish-Release|Any CPU
39 | Release|Any CPU = Release|Any CPU
40 | EndGlobalSection
41 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
42 | {67B8F96E-8237-4C57-983B-A2CA5BDDC9AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
43 | {67B8F96E-8237-4C57-983B-A2CA5BDDC9AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
44 | {67B8F96E-8237-4C57-983B-A2CA5BDDC9AE}.Publish-Portable|Any CPU.ActiveCfg = Portable|Any CPU
45 | {67B8F96E-8237-4C57-983B-A2CA5BDDC9AE}.Publish-Portable|Any CPU.Build.0 = Portable|Any CPU
46 | {67B8F96E-8237-4C57-983B-A2CA5BDDC9AE}.Publish-Release|Any CPU.ActiveCfg = Release|Any CPU
47 | {67B8F96E-8237-4C57-983B-A2CA5BDDC9AE}.Publish-Release|Any CPU.Build.0 = Release|Any CPU
48 | {67B8F96E-8237-4C57-983B-A2CA5BDDC9AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
49 | {67B8F96E-8237-4C57-983B-A2CA5BDDC9AE}.Release|Any CPU.Build.0 = Release|Any CPU
50 | EndGlobalSection
51 | GlobalSection(SolutionProperties) = preSolution
52 | HideSolutionNode = FALSE
53 | EndGlobalSection
54 | GlobalSection(NestedProjects) = preSolution
55 | {E2560076-F4E6-44D0-843A-2F251607367E} = {6A4246E2-D82B-4BAC-BDD1-F3B198ABC8A4}
56 | {AAA7F469-AAC5-4DD7-AC3C-619BAE233F57} = {6A4246E2-D82B-4BAC-BDD1-F3B198ABC8A4}
57 | {07FDF133-B8EB-40FF-9216-9F8D2239D11F} = {AAA7F469-AAC5-4DD7-AC3C-619BAE233F57}
58 | EndGlobalSection
59 | GlobalSection(ExtensibilityGlobals) = postSolution
60 | RESX_TaskErrorCategory = Message
61 | RESX_ShowErrorsInErrorList = True
62 | SolutionGuid = {3D95859A-FF01-44A8-A580-18614EAEC245}
63 | RESX_Rules = {"EnabledRules":["StringFormat","WhiteSpaceLead","WhiteSpaceTail","PunctuationTail"]}
64 | EndGlobalSection
65 | EndGlobal
66 |
--------------------------------------------------------------------------------
/ScreenRuler/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ScreenRuler/Colors/ColorSetting.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.Xml.Serialization;
4 |
5 | namespace ScreenRuler.Colors
6 | {
7 | ///
8 | /// Wraps System.Drawing.Color into a serializable object.
9 | ///
10 | [Serializable]
11 | public class ColorSetting
12 | {
13 | public ColorSetting() { }
14 |
15 | public ColorSetting(Color color)
16 | {
17 | this.Color = color;
18 | }
19 |
20 | [XmlIgnore]
21 | public Color Color { get; set; }
22 |
23 | [XmlText]
24 | public string HexCode
25 | {
26 | get { return ToString(); }
27 | set { Color = ColorTranslator.FromHtml(value); }
28 | }
29 |
30 | public override string ToString()
31 | {
32 | return String.Format("#{0}{1}{2}", Color.R.ToString("X2"),
33 | Color.G.ToString("X2"), Color.B.ToString("X2"));
34 | }
35 |
36 | public static implicit operator Color(ColorSetting colorSetting)
37 | {
38 | return colorSetting.Color;
39 | }
40 |
41 | public static implicit operator ColorSetting(Color color)
42 | {
43 | return new ColorSetting(color);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/ScreenRuler/Colors/CommonThemes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 |
4 | namespace ScreenRuler.Colors
5 | {
6 | public enum ThemeOption
7 | {
8 | Light = 0,
9 | Dark = 1,
10 | Custom = 2
11 | }
12 |
13 | public static class CommonThemes
14 | {
15 | ///
16 | /// The default light theme.
17 | ///
18 | public static Theme LightTheme = new Theme()
19 | {
20 | Background = Color.White,
21 | TickColor = Color.Black,
22 | LengthLabelColor = Color.Green,
23 | CenterLineColor = Color.Blue,
24 | MouseLineColor = Color.Orange,
25 | ThirdsLinesColor = Color.DeepSkyBlue,
26 | GoldenLineColor = Color.Gold,
27 | CustomLinesColor = Color.Red
28 | };
29 |
30 | ///
31 | /// The default dark theme.
32 | ///
33 | public static Theme DarkTheme = new Theme()
34 | {
35 | Background = Color.FromArgb(16, 16, 16),
36 | TickColor = Color.White,
37 | LengthLabelColor = Color.White,
38 | CenterLineColor = Color.Fuchsia,
39 | MouseLineColor = Color.Orange,
40 | ThirdsLinesColor = Color.DarkTurquoise,
41 | GoldenLineColor = Color.DarkGoldenrod,
42 | CustomLinesColor = Color.OrangeRed
43 | };
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/ScreenRuler/Colors/Theme.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ScreenRuler.Colors
4 | {
5 | ///
6 | /// A collection of colors that specify the appearance of the ruler.
7 | ///
8 | [Serializable]
9 | public class Theme
10 | {
11 | ///
12 | /// The background color of the ruler.
13 | ///
14 | public ColorSetting Background { get; set; }
15 | ///
16 | /// The color of the ticks on the ruler scale.
17 | ///
18 | public ColorSetting TickColor { get; set; }
19 | ///
20 | /// The color of the label that shows the total length of the ruler.
21 | ///
22 | public ColorSetting LengthLabelColor { get; set; }
23 | ///
24 | /// The color of the marker that indicates the cursor position.
25 | ///
26 | public ColorSetting MouseLineColor { get; set; }
27 | ///
28 | /// The color of the marker that indicates the center of the ruler.
29 | ///
30 | public ColorSetting CenterLineColor { get; set; }
31 | ///
32 | /// The color of the markers that divide the ruler into three parts.
33 | ///
34 | public ColorSetting ThirdsLinesColor { get; set; }
35 | ///
36 | /// The color of the marker that indicates the golden ratio on the ruler.
37 | ///
38 | public ColorSetting GoldenLineColor { get; set; }
39 |
40 | ///
41 | /// The color of custom markers.
42 | ///
43 | public ColorSetting CustomLinesColor { get; set; }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/ScreenRuler/Configuration/ActionCode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using ScreenRuler.Properties;
3 |
4 | namespace ScreenRuler.Configuration
5 | {
6 | ///
7 | /// Defines possible keyboard actions of the app.
8 | /// Mappings from action codes to keys in DefaultShortcuts dict in Configuration/Shortcuts.cs.
9 | ///
10 | public enum ActionCode
11 | {
12 | // No action
13 | None,
14 | // Ruler modes
15 | [LocalizedDescription("Actions_ToggleRulerMode", typeof(EnumResources))]
16 | ToggleRulerMode,
17 | [LocalizedDescription("Actions_ToggleVertical", typeof(EnumResources))]
18 | ToggleVertical,
19 | [LocalizedDescription("conFlipVertically.Text", typeof(RulerForm))]
20 | FlipVertically,
21 | [LocalizedDescription("conFlipHorizontally.Text", typeof(RulerForm))]
22 | FlipHorizontally,
23 | [LocalizedDescription("Actions_ToggleSlimMode", typeof(EnumResources))]
24 | ToggleSlimMode,
25 | [LocalizedDescription("Actions_ToggleHypotenuseMode", typeof(EnumResources))]
26 | ToggleHypotenuseMode,
27 | [LocalizedDescription("conFollowMousePointer.Text", typeof(RulerForm))]
28 | ToggleFollowMouseMode,
29 | // Tools
30 | [LocalizedDescription("conMeasure.Text", typeof(RulerForm))]
31 | MeasureWindow,
32 | [LocalizedDescription("Actions_CopySize", typeof(EnumResources))]
33 | CopySize,
34 | [LocalizedDescription("conLength.Text", typeof(RulerForm))]
35 | SetSize,
36 | // Appearance
37 | [LocalizedDescription("conTopmost.Text", typeof(RulerForm))]
38 | PinTop,
39 | [LocalizedDescription("conMinimize.Text", typeof(RulerForm))]
40 | Minimize,
41 | [LocalizedDescription("Actions_ToggleTheme", typeof(EnumResources))]
42 | ToggleTheme,
43 | [LocalizedDescription("Actions_IncreaseOpacity", typeof(EnumResources))]
44 | IncreaseOpacity,
45 | [LocalizedDescription("Actions_DecreaseOpacity", typeof(EnumResources))]
46 | DecreaseOpacity,
47 | [LocalizedDescription("conHideRulerScale.Text", typeof(RulerForm))]
48 | HideRulerScale,
49 | // Markers
50 | [LocalizedDescription("conMarkCenter.Text", typeof(RulerForm))]
51 | MarkCenter,
52 | [LocalizedDescription("conMarkThirds.Text", typeof(RulerForm))]
53 | MarkThirds,
54 | [LocalizedDescription("conMarkGolden.Text", typeof(RulerForm))]
55 | MarkGoldenRatio,
56 | [LocalizedDescription("conMarkMouse.Text", typeof(RulerForm))]
57 | MarkMouse,
58 | [LocalizedDescription("conEditMarkers.Text", typeof(RulerForm))]
59 | EditMarkers,
60 | [LocalizedDescription("conClearCustomMarker.Text", typeof(RulerForm))]
61 | ClearAllMarkers,
62 | [LocalizedDescription("Actions_DeleteFirstMarker", typeof(EnumResources))]
63 | DeleteFirstMarker,
64 | [LocalizedDescription("Actions_AddMarkerAtCurrent", typeof(EnumResources))]
65 | AddMarkerAtCurrent,
66 | [LocalizedDescription("Actions_AddMarkerAtLength", typeof(EnumResources))]
67 | AddMarkerAtLength,
68 | // Others
69 | [LocalizedDescription("conSettings.Text", typeof(RulerForm))]
70 | Settings,
71 | [LocalizedDescription("conShortcuts.Text", typeof(RulerForm))]
72 | ConfigureShortcuts,
73 | [LocalizedDescription("conCalibrate.Text", typeof(RulerForm))]
74 | CalibrateRuler,
75 | [LocalizedDescription("conHelp.Text", typeof(RulerForm))]
76 | ShowHelp,
77 | [LocalizedDescription("conExit.Text", typeof(RulerForm))]
78 | ExitApp,
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/ScreenRuler/Configuration/Enums.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using ScreenRuler.Properties;
3 |
4 | namespace ScreenRuler.Configuration
5 | {
6 | public enum HypotenuseMode
7 | {
8 | [LocalizedDescription("HypotenuseMode_None", typeof(EnumResources))]
9 | None = 0,
10 | [LocalizedDescription("HypotenuseMode_FixedAtLength", typeof(EnumResources))]
11 | FixedAtLength = 1,
12 | [LocalizedDescription("HypotenuseMode_Moving", typeof(EnumResources))]
13 | Moving = 2,
14 | }
15 |
16 | [Flags]
17 | public enum RulerTransform
18 | {
19 | None = 0,
20 | FlippedX = 1,
21 | FlippedY = 2,
22 | CornerUpperLeft = None,
23 | CornerUpperRight = FlippedX,
24 | CornerLowerLeft = FlippedY,
25 | CornerLowerRight = FlippedX | FlippedY,
26 | }
27 |
28 | public enum DpiScalingMode
29 | {
30 | [LocalizedDescription("DpiScalingMode_Unaware", typeof(EnumResources))]
31 | Unaware = 0,
32 | [LocalizedDescription("DpiScalingMode_Auto", typeof(EnumResources))]
33 | Auto = 1,
34 | [LocalizedDescription("DpiScalingMode_Manual", typeof(EnumResources))]
35 | Manual = 2,
36 | [LocalizedDescription("DpiScalingMode_ManualPerMonitor", typeof(EnumResources))]
37 | ManualPerMonitor = 3,
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/ScreenRuler/Configuration/LocalizedDescriptionAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Resources;
4 | using System.Linq;
5 |
6 | namespace ScreenRuler.Configuration
7 | {
8 | public class LocalizedDescriptionAttribute : DescriptionAttribute
9 | {
10 | ResourceManager resMan;
11 | readonly string resourceKey;
12 |
13 | public LocalizedDescriptionAttribute(string resourceKey, Type resourceType)
14 | {
15 | resMan = new ResourceManager(resourceType);
16 | this.resourceKey = resourceKey;
17 | }
18 |
19 | public override string Description
20 | {
21 | get
22 | {
23 | var s = resMan.GetString(resourceKey);
24 | return String.IsNullOrWhiteSpace(s) ? resourceKey : s;
25 | }
26 | }
27 | }
28 |
29 | public static class EnumExtensions
30 | {
31 | public static string GetDescription(this Enum en)
32 | {
33 | DescriptionAttribute attr = (DescriptionAttribute)en.GetType()
34 | .GetField(en.ToString())
35 | .GetCustomAttributes(typeof(DescriptionAttribute), false)
36 | .FirstOrDefault();
37 | if (attr != null)
38 | {
39 | return attr.Description;
40 | }
41 | else return en.ToString();
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/ScreenRuler/Configuration/ManagerExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using Bluegrams.Application;
4 |
5 | namespace ScreenRuler.Configuration
6 | {
7 | public static class ManagerExtensions
8 | {
9 | ///
10 | /// Loads managed settings from a specified configuration file.
11 | ///
12 | public static void LoadSettingsFromFile(this WinFormsWindowManager manager, string configPath)
13 | {
14 | if (!String.IsNullOrEmpty(configPath))
15 | {
16 | string directory = Path.GetDirectoryName(configPath);
17 | string file = Path.GetFileName(configPath);
18 | PortableSettingsProvider.SettingsDirectory = directory;
19 | PortableSettingsProvider.SettingsFileName = file;
20 | // We only really care about the custom settings object, so only reload that.
21 | var provider = new PortableSettingsProvider();
22 | manager.CustomSettings.Providers.Clear();
23 | manager.CustomSettings.Providers.Add(provider);
24 | foreach (System.Configuration.SettingsProperty prop in manager.CustomSettings.Properties)
25 | prop.Provider = provider;
26 | manager.CustomSettings.Reload();
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ScreenRuler/Configuration/Monitor/MonitorIdForm.Designer.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ScreenRuler.Configuration.Monitor
3 | {
4 | partial class MonitorIdForm
5 | {
6 | ///
7 | /// Required designer variable.
8 | ///
9 | private System.ComponentModel.IContainer components = null;
10 |
11 | ///
12 | /// Clean up any resources being used.
13 | ///
14 | /// true if managed resources should be disposed; otherwise, false.
15 | protected override void Dispose(bool disposing)
16 | {
17 | if (disposing && (components != null))
18 | {
19 | components.Dispose();
20 | }
21 | base.Dispose(disposing);
22 | }
23 |
24 | #region Windows Form Designer generated code
25 |
26 | ///
27 | /// Required method for Designer support - do not modify
28 | /// the contents of this method with the code editor.
29 | ///
30 | private void InitializeComponent()
31 | {
32 | this.lblNum = new System.Windows.Forms.Label();
33 | this.lblName = new System.Windows.Forms.Label();
34 | this.SuspendLayout();
35 | //
36 | // lblNum
37 | //
38 | this.lblNum.Font = new System.Drawing.Font("Microsoft Sans Serif", 72F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
39 | this.lblNum.Location = new System.Drawing.Point(0, 9);
40 | this.lblNum.Margin = new System.Windows.Forms.Padding(0);
41 | this.lblNum.Name = "lblNum";
42 | this.lblNum.Size = new System.Drawing.Size(184, 110);
43 | this.lblNum.TabIndex = 0;
44 | this.lblNum.Text = "2";
45 | this.lblNum.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
46 | //
47 | // lblName
48 | //
49 | this.lblName.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
50 | this.lblName.Location = new System.Drawing.Point(0, 119);
51 | this.lblName.Margin = new System.Windows.Forms.Padding(0);
52 | this.lblName.Name = "lblName";
53 | this.lblName.Size = new System.Drawing.Size(184, 33);
54 | this.lblName.TabIndex = 1;
55 | this.lblName.Text = "Name";
56 | this.lblName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
57 | //
58 | // MonitorIdForm
59 | //
60 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
61 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
62 | this.BackColor = System.Drawing.Color.Black;
63 | this.ClientSize = new System.Drawing.Size(184, 161);
64 | this.Controls.Add(this.lblName);
65 | this.Controls.Add(this.lblNum);
66 | this.ForeColor = System.Drawing.Color.White;
67 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
68 | this.Name = "MonitorIdForm";
69 | this.Opacity = 0.8D;
70 | this.ShowInTaskbar = false;
71 | this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
72 | this.Text = "MonitorIdForm";
73 | this.ResumeLayout(false);
74 |
75 | }
76 |
77 | #endregion
78 |
79 | private System.Windows.Forms.Label lblNum;
80 | private System.Windows.Forms.Label lblName;
81 | }
82 | }
--------------------------------------------------------------------------------
/ScreenRuler/Configuration/Monitor/MonitorIdForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace ScreenRuler.Configuration.Monitor
5 | {
6 | public partial class MonitorIdForm : Form
7 | {
8 | public MonitorIdForm(string monitorId, string monitorName = null)
9 | {
10 | InitializeComponent();
11 | lblNum.Text = monitorId;
12 | lblName.Text = monitorName;
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ScreenRuler/Configuration/Monitor/MonitorIdForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/ScreenRuler/Configuration/Monitor/MonitorInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Text.RegularExpressions;
4 | using WindowsDisplayAPI.DisplayConfig;
5 |
6 | namespace ScreenRuler.Configuration.Monitor
7 | {
8 | ///
9 | /// Represents information on a monitor device.
10 | ///
11 | public class MonitorInfo
12 | {
13 | ///
14 | /// Gets the monitor ID from the display name.
15 | ///
16 | public int Id { get; }
17 | ///
18 | /// Gets the display friendly name.
19 | ///
20 | public string FriendlyName { get; }
21 | ///
22 | /// Gets the display device source name.
23 | ///
24 | public string DisplayName { get; }
25 | ///
26 | /// Gets the display device path.
27 | ///
28 | public string DevicePath { get; }
29 |
30 | public MonitorInfo(PathDisplayTarget pathDisplayTarget)
31 | {
32 | if (int.TryParse(Regex.Match(pathDisplayTarget.ToDisplayDevice().DisplayName, @"\d+").Value, out int result))
33 | Id = result;
34 | else Id = 0;
35 | FriendlyName = pathDisplayTarget.FriendlyName;
36 | DisplayName = pathDisplayTarget.ToDisplayDevice().DisplayName;
37 | DevicePath = pathDisplayTarget.DevicePath;
38 | }
39 |
40 | public override string ToString()
41 | {
42 | string name = !String.IsNullOrEmpty(FriendlyName) ? FriendlyName : DevicePath;
43 | return $"[{Id}] {name}";
44 | }
45 |
46 | ///
47 | /// Retrieves a list of currently attached monitor devices.
48 | ///
49 | /// An array of MonitorInfo instances.
50 | public static MonitorInfo[] GetMonitorInfos()
51 | {
52 | return PathDisplayTarget.GetDisplayTargets().Select(d => new MonitorInfo(d)).ToArray();
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/ScreenRuler/Configuration/Monitor/MonitorSetup.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Windows.Forms;
4 |
5 | namespace ScreenRuler.Configuration.Monitor
6 | {
7 | ///
8 | /// Provides information on currently connected monitors.
9 | ///
10 | public class MonitorSetup
11 | {
12 | #region Singleton
13 | private static readonly MonitorSetup instance;
14 |
15 | static MonitorSetup()
16 | {
17 | instance = new MonitorSetup();
18 | }
19 |
20 | public static MonitorSetup Instance => instance;
21 | #endregion
22 |
23 | public MonitorInfo[] Monitors { get; set; }
24 |
25 | private MonitorSetup()
26 | {
27 | Update();
28 | }
29 |
30 | ///
31 | /// Update list of currently connected monitors.
32 | ///
33 | public void Update()
34 | {
35 | Monitors = MonitorInfo.GetMonitorInfos();
36 | }
37 |
38 | public string GetDevicePath(Screen screen)
39 | => Monitors.Where(m => m.DisplayName == screen.DeviceName).FirstOrDefault()?.DevicePath;
40 |
41 | ///
42 | /// Show a screen overlay that identifies the connected monitors for the specified number of seconds.
43 | ///
44 | /// The number of seconds the overlay should be visible. If <= 0, show until Close() is called.
45 | /// Whether to show the friendly names of the monitors on the overlay windows.
46 | public MonitorSetupOverlay ShowOverlay(short seconds = -1, bool showMonitorNames = true)
47 | {
48 | MonitorSetupOverlay overlay = new MonitorSetupOverlay(Monitors, showMonitorNames);
49 | overlay.Show(seconds);
50 | return overlay;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/ScreenRuler/Configuration/Monitor/MonitorSetupOverlay.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Windows.Forms;
4 |
5 | namespace ScreenRuler.Configuration.Monitor
6 | {
7 | ///
8 | /// Provides a screen overlay that shows IDs on all connected monitors.
9 | ///
10 | public class MonitorSetupOverlay
11 | {
12 | private MonitorInfo[] monitors;
13 | private bool showMonitorNames;
14 | private Timer timer;
15 | private MonitorIdForm[] overlayForms;
16 |
17 | ///
18 | /// Creates a new instance of MonitorSetupOverlay.
19 | ///
20 | /// The used monitor info data.
21 | /// Whether to show the friendly names of the monitors on the overlay windows.
22 | public MonitorSetupOverlay(MonitorInfo[] monitors, bool showMonitorNames = true)
23 | {
24 | this.monitors = monitors;
25 | this.showMonitorNames = showMonitorNames;
26 | this.timer = new Timer();
27 | this.timer.Tick += Timer_Tick;
28 | }
29 |
30 | ///
31 | /// Show the monitor ID overlay for the specified number of seconds.
32 | ///
33 | /// The number of seconds the overlay should be visible. If <= 0, show until Close() is called.
34 | public void Show(short seconds = -1)
35 | {
36 | Close(); // Make sure overlay is not shown twice.
37 | overlayForms = Screen.AllScreens.Select(s => createFormForScreen(s)).ToArray();
38 | overlayForms.ToList().ForEach(form => form.Show());
39 | if (seconds > 0)
40 | {
41 | timer.Interval = seconds * 1000;
42 | timer.Start();
43 | }
44 | }
45 |
46 | private MonitorIdForm createFormForScreen(Screen screen)
47 | {
48 | MonitorInfo monitorInfo = monitors.Where(d => d.DisplayName == screen.DeviceName).FirstOrDefault();
49 | if (monitorInfo != null)
50 | {
51 | MonitorIdForm form = new MonitorIdForm(
52 | monitorInfo.Id.ToString(),
53 | showMonitorNames ? monitorInfo.FriendlyName : String.Empty
54 | );
55 | form.Location = screen.WorkingArea.Location;
56 | return form;
57 | }
58 | else throw new InvalidOperationException($"Could not find valid monitor information for '{screen.DeviceName}'.");
59 | }
60 |
61 | private void Timer_Tick(object sender, EventArgs e)
62 | {
63 | this.Close();
64 | }
65 |
66 | public void Close()
67 | {
68 | if (timer.Enabled)
69 | {
70 | timer.Stop();
71 | }
72 | if (overlayForms != null)
73 | {
74 | foreach (var form in overlayForms)
75 | {
76 | form.Close();
77 | }
78 | overlayForms = null;
79 | }
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ScreenRuler/Configuration/MonitorDpiConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ScreenRuler.Configuration
4 | {
5 | ///
6 | /// Represents the DPI configuration of one monitor.
7 | ///
8 | [Serializable]
9 | public class MonitorDpiConfiguration
10 | {
11 | ///
12 | /// Monitor ID string.
13 | ///
14 | public string Id { get; set; }
15 | ///
16 | /// Manual setting for the monitor's DPI.
17 | ///
18 | public float HorizontalDpi { get; set; } = 96;
19 | ///
20 | /// Manual setting for the monitor's vertical DPI.
21 | ///
22 | public float VerticalDpi { get; set; } = 96;
23 |
24 | public MonitorDpiConfiguration() { }
25 |
26 | public MonitorDpiConfiguration(string id)
27 | {
28 | Id = id;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/ScreenRuler/Configuration/MonitorDpiConfigurationCollection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Xml.Serialization;
6 |
7 | namespace ScreenRuler.Configuration
8 | {
9 | ///
10 | /// Models a serializable collection of MonitorDpiConfiguration.
11 | ///
12 | [Serializable]
13 | public class MonitorDpiConfigurationCollection : ICollection
14 | {
15 | [XmlIgnore]
16 | private Dictionary configurations = new Dictionary();
17 |
18 | [XmlElement]
19 | public MonitorDpiConfiguration[] ConfigurationList
20 | {
21 | get => configurations.Values.ToArray();
22 | set
23 | {
24 | configurations = value.ToDictionary(v => v.Id);
25 | }
26 | }
27 |
28 | public MonitorDpiConfiguration this[string key]
29 | {
30 | get => configurations[key];
31 | set => configurations[key] = value;
32 | }
33 |
34 | public int Count => configurations.Count;
35 |
36 | public bool IsReadOnly => false;
37 |
38 | public void Add(MonitorDpiConfiguration item) => configurations.Add(item.Id, item);
39 |
40 | public void Clear() => configurations.Clear();
41 |
42 | public bool Contains(MonitorDpiConfiguration item) => configurations.ContainsValue(item);
43 |
44 | public bool ContainsKey(string key) => configurations.ContainsKey(key);
45 |
46 | public void CopyTo(MonitorDpiConfiguration[] array, int arrayIndex)
47 | {
48 | configurations.Values.CopyTo(array, arrayIndex);
49 | }
50 |
51 | public IEnumerator GetEnumerator() => configurations.Values.GetEnumerator();
52 |
53 | public bool Remove(MonitorDpiConfiguration item) => configurations.Remove(item.Id);
54 |
55 | IEnumerator IEnumerable.GetEnumerator() => configurations.Values.GetEnumerator();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/ScreenRuler/Configuration/Shortcuts.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Forms;
5 | using System.Xml.Serialization;
6 |
7 | namespace ScreenRuler.Configuration
8 | {
9 | ///
10 | /// Represents a mapping from application action to shortcut keys.
11 | ///
12 | [Serializable]
13 | public class Shortcut
14 | {
15 | public ActionCode Action { get; set; }
16 | [XmlIgnore]
17 | public Keys Keys { get; set; }
18 |
19 | // TODO: KeysConverter is unable to convert to/from invariant culture strings.
20 | // See https://stackoverflow.com/q/61331395/9145461 and https://github.com/dotnet/winforms/issues/2886.
21 | // Therefore, this property is used for serialization to settings,
22 | // meaning that custom shortcuts are NOT preserved when changing the app language.
23 | [XmlElement(ElementName="Keys")]
24 | public string KeysString
25 | {
26 | get
27 | {
28 | KeysConverter keysConverter = new KeysConverter();
29 | string keysString = keysConverter.ConvertToString(Keys);
30 | // Replace some special chars to make string more readable
31 | keysString = keysString.Replace("Oemcomma", ",").Replace("OemPeriod", ".").Replace("None", "");
32 | return keysString;
33 | }
34 | set
35 | {
36 | KeysConverter keysConverter = new KeysConverter();
37 | string keysString = value.Replace(",", "Oemcomma").Replace(".", "OemPeriod");
38 | if (String.IsNullOrEmpty(keysString))
39 | keysString = "None";
40 | Keys = (Keys)keysConverter.ConvertFromString(keysString);
41 | }
42 | }
43 |
44 | public Shortcut()
45 | { }
46 |
47 | public Shortcut(ActionCode action, Keys keys)
48 | {
49 | this.Action = action;
50 | this.Keys = keys;
51 | }
52 |
53 | public override string ToString() => $"{Action}: {Keys}";
54 |
55 | public string[] ToStringArray()
56 | {
57 | return new[] { Action.GetDescription(), KeysString };
58 | }
59 | }
60 |
61 | public static class Shortcuts
62 | {
63 | public static List DefaultShortcuts = new List()
64 | {
65 | // Ruler modes
66 | new Shortcut(ActionCode.ToggleRulerMode, Keys.Space),
67 | new Shortcut(ActionCode.ToggleVertical, Keys.V),
68 | new Shortcut(ActionCode.FlipVertically, Keys.Shift | Keys.F),
69 | new Shortcut(ActionCode.FlipHorizontally, Keys.F),
70 | new Shortcut(ActionCode.ToggleSlimMode, Keys.J),
71 | new Shortcut(ActionCode.ToggleHypotenuseMode, Keys.H),
72 | new Shortcut(ActionCode.ToggleFollowMouseMode, Keys.W),
73 | // Tools
74 | new Shortcut(ActionCode.MeasureWindow, Keys.Z),
75 | new Shortcut(ActionCode.CopySize, Keys.Control | Keys.C),
76 | new Shortcut(ActionCode.SetSize, Keys.Control | Keys.L),
77 | // Appearance
78 | new Shortcut(ActionCode.PinTop, Keys.S),
79 | new Shortcut(ActionCode.Minimize, Keys.Control | Keys.M),
80 | new Shortcut(ActionCode.ToggleTheme, Keys.Control | Keys.T),
81 | new Shortcut(ActionCode.IncreaseOpacity, Keys.Control | Keys.Oemplus),
82 | new Shortcut(ActionCode.DecreaseOpacity, Keys.Control | Keys.OemMinus),
83 | new Shortcut(ActionCode.HideRulerScale, Keys.Control | Keys.H),
84 | // Markers
85 | new Shortcut(ActionCode.MarkCenter, Keys.M),
86 | new Shortcut(ActionCode.MarkThirds, Keys.T),
87 | new Shortcut(ActionCode.MarkGoldenRatio, Keys.G),
88 | new Shortcut(ActionCode.MarkMouse, Keys.P),
89 | new Shortcut(ActionCode.EditMarkers, Keys.Control | Keys.E),
90 | new Shortcut(ActionCode.ClearAllMarkers, Keys.Delete),
91 | new Shortcut(ActionCode.DeleteFirstMarker, Keys.C),
92 | new Shortcut(ActionCode.AddMarkerAtCurrent, Keys.X),
93 | new Shortcut(ActionCode.AddMarkerAtLength, Keys.L),
94 | // Others
95 | new Shortcut(ActionCode.Settings, Keys.Control | Keys.Oemcomma),
96 | new Shortcut(ActionCode.ConfigureShortcuts, Keys.Control | Keys.Shift | Keys.Oemcomma),
97 | new Shortcut(ActionCode.CalibrateRuler, Keys.Control | Keys.K),
98 | new Shortcut(ActionCode.ShowHelp, Keys.F1),
99 | new Shortcut(ActionCode.ExitApp, Keys.Escape),
100 | };
101 |
102 | ///
103 | /// Gets the default shortcut keys for a given action.
104 | ///
105 | /// The action for which to retrieve shortcut keys.
106 | /// The corresponding default shortcut keys.
107 | public static Keys GetDefaultKeys(ActionCode action)
108 | {
109 | return DefaultShortcuts.Where(s => s.Action == action).Select(s => s.Keys).FirstOrDefault();
110 | }
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/ScreenRuler/Controls/MarkerListBox.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Drawing;
5 | using System.Linq;
6 | using System.Windows.Forms;
7 | using ScreenRuler.Units;
8 |
9 | namespace ScreenRuler.Controls
10 | {
11 | public class MarkerListBox : ListBox
12 | {
13 | private UnitConverter unitConverter;
14 |
15 | public UnitConverter UnitConverter
16 | {
17 | get => unitConverter;
18 | set
19 | {
20 | unitConverter = value;
21 | Refresh();
22 | }
23 | }
24 |
25 | public MarkerListBox()
26 | {
27 | // Use pixels as default if nothing else is given
28 | UnitConverter = new UnitConverter(MeasuringUnit.Pixels, Size.Empty, 0);
29 | // We draw the items ourself
30 | DrawMode = DrawMode.OwnerDrawFixed;
31 | }
32 |
33 | protected override void Sort()
34 | {
35 | var sortedItems = Items.Cast()
36 | .OrderBy(m => m, new MarkerComparer())
37 | .Cast