├── .gitattributes
├── .gitignore
├── Accents
└── Styles.axaml
├── App.axaml
├── App.axaml.cs
├── Assets
├── fileopen-black-x256.png
├── fileopen-black.svg
├── fileopen-white-x256.png
├── fileopen-white.svg
├── icon.ico
├── refresh-black-x256.png
├── refresh-black.svg
├── refresh-white-x256.png
├── refresh-white.svg
├── reset-black-x256.png
└── reset-white-x256.png
├── Cursor_Installer_Creator.csproj
├── Cursor_Installer_Creator.sln
├── Data
├── CCursor.cs
├── CursorAssignment.cs
└── Version.cs
├── Extensions
└── GridExtensions.cs
├── LICENSE.txt
├── Program.cs
├── README.md
├── Resources
├── cursor-assignment.csv
├── preview-dark.png
├── preview-light-small.png
├── preview-light.png
└── preview-social-media.png
├── Tools
├── Cursor-Installer.exe
└── SetupIcon.ico
├── Utils
├── CursorHelper.cs
└── GitHubUpdater.cs
├── Views
├── CursorInstallerMainView.axaml
├── CursorInstallerMainView.axaml.cs
├── CursorItemView.axaml
├── CursorItemView.axaml.cs
├── CursorListView.axaml
├── CursorListView.axaml.cs
├── MainView.axaml
├── MainView.axaml.cs
├── MainWindow.axaml
├── MainWindow.axaml.cs
├── UpdateNotifyView.axaml
└── UpdateNotifyView.axaml.cs
└── app.manifest
/.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 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Oo]ut/
33 | [Ll]og/
34 | [Ll]ogs/
35 |
36 | # Visual Studio 2015/2017 cache/options directory
37 | .vs/
38 | # Uncomment if you have tasks that create the project's static files in wwwroot
39 | #wwwroot/
40 |
41 | # Visual Studio 2017 auto generated files
42 | Generated\ Files/
43 |
44 | # MSTest test Results
45 | [Tt]est[Rr]esult*/
46 | [Bb]uild[Ll]og.*
47 |
48 | # NUnit
49 | *.VisualState.xml
50 | TestResult.xml
51 | nunit-*.xml
52 |
53 | # Build Results of an ATL Project
54 | [Dd]ebugPS/
55 | [Rr]eleasePS/
56 | dlldata.c
57 |
58 | # Benchmark Results
59 | BenchmarkDotNet.Artifacts/
60 |
61 | # .NET Core
62 | project.lock.json
63 | project.fragment.lock.json
64 | artifacts/
65 |
66 | # ASP.NET Scaffolding
67 | ScaffoldingReadMe.txt
68 |
69 | # StyleCop
70 | StyleCopReport.xml
71 |
72 | # Files built by Visual Studio
73 | *_i.c
74 | *_p.c
75 | *_h.h
76 | *.ilk
77 | *.meta
78 | *.obj
79 | *.iobj
80 | *.pch
81 | *.pdb
82 | *.ipdb
83 | *.pgc
84 | *.pgd
85 | *.rsp
86 | *.sbr
87 | *.tlb
88 | *.tli
89 | *.tlh
90 | *.tmp
91 | *.tmp_proj
92 | *_wpftmp.csproj
93 | *.log
94 | *.vspscc
95 | *.vssscc
96 | .builds
97 | *.pidb
98 | *.svclog
99 | *.scc
100 |
101 | # Chutzpah Test files
102 | _Chutzpah*
103 |
104 | # Visual C++ cache files
105 | ipch/
106 | *.aps
107 | *.ncb
108 | *.opendb
109 | *.opensdf
110 | *.sdf
111 | *.cachefile
112 | *.VC.db
113 | *.VC.VC.opendb
114 |
115 | # Visual Studio profiler
116 | *.psess
117 | *.vsp
118 | *.vspx
119 | *.sap
120 |
121 | # Visual Studio Trace Files
122 | *.e2e
123 |
124 | # TFS 2012 Local Workspace
125 | $tf/
126 |
127 | # Guidance Automation Toolkit
128 | *.gpState
129 |
130 | # ReSharper is a .NET coding add-in
131 | _ReSharper*/
132 | *.[Rr]e[Ss]harper
133 | *.DotSettings.user
134 |
135 | # TeamCity is a build add-in
136 | _TeamCity*
137 |
138 | # DotCover is a Code Coverage Tool
139 | *.dotCover
140 |
141 | # AxoCover is a Code Coverage Tool
142 | .axoCover/*
143 | !.axoCover/settings.json
144 |
145 | # Coverlet is a free, cross platform Code Coverage Tool
146 | coverage*.json
147 | coverage*.xml
148 | coverage*.info
149 |
150 | # Visual Studio code coverage results
151 | *.coverage
152 | *.coveragexml
153 |
154 | # NCrunch
155 | _NCrunch_*
156 | .*crunch*.local.xml
157 | nCrunchTemp_*
158 |
159 | # MightyMoose
160 | *.mm.*
161 | AutoTest.Net/
162 |
163 | # Web workbench (sass)
164 | .sass-cache/
165 |
166 | # Installshield output folder
167 | [Ee]xpress/
168 |
169 | # DocProject is a documentation generator add-in
170 | DocProject/buildhelp/
171 | DocProject/Help/*.HxT
172 | DocProject/Help/*.HxC
173 | DocProject/Help/*.hhc
174 | DocProject/Help/*.hhk
175 | DocProject/Help/*.hhp
176 | DocProject/Help/Html2
177 | DocProject/Help/html
178 |
179 | # Click-Once directory
180 | publish/
181 |
182 | # Publish Web Output
183 | *.[Pp]ublish.xml
184 | *.azurePubxml
185 | # Note: Comment the next line if you want to checkin your web deploy settings,
186 | # but database connection strings (with potential passwords) will be unencrypted
187 | *.pubxml
188 | *.publishproj
189 |
190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
191 | # checkin your Azure Web App publish settings, but sensitive information contained
192 | # in these scripts will be unencrypted
193 | PublishScripts/
194 |
195 | # NuGet Packages
196 | *.nupkg
197 | # NuGet Symbol Packages
198 | *.snupkg
199 | # The packages folder can be ignored because of Package Restore
200 | **/[Pp]ackages/*
201 | # except build/, which is used as an MSBuild target.
202 | !**/[Pp]ackages/build/
203 | # Uncomment if necessary however generally it will be regenerated when needed
204 | #!**/[Pp]ackages/repositories.config
205 | # NuGet v3's project.json files produces more ignorable files
206 | *.nuget.props
207 | *.nuget.targets
208 |
209 | # Microsoft Azure Build Output
210 | csx/
211 | *.build.csdef
212 |
213 | # Microsoft Azure Emulator
214 | ecf/
215 | rcf/
216 |
217 | # Windows Store app package directories and files
218 | AppPackages/
219 | BundleArtifacts/
220 | Package.StoreAssociation.xml
221 | _pkginfo.txt
222 | *.appx
223 | *.appxbundle
224 | *.appxupload
225 |
226 | # Visual Studio cache files
227 | # files ending in .cache can be ignored
228 | *.[Cc]ache
229 | # but keep track of directories ending in .cache
230 | !?*.[Cc]ache/
231 |
232 | # Others
233 | ClientBin/
234 | ~$*
235 | *~
236 | *.dbmdl
237 | *.dbproj.schemaview
238 | *.jfm
239 | *.pfx
240 | *.publishsettings
241 | orleans.codegen.cs
242 |
243 | # Including strong name files can present a security risk
244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
245 | #*.snk
246 |
247 | # Since there are multiple workflows, uncomment next line to ignore bower_components
248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
249 | #bower_components/
250 |
251 | # RIA/Silverlight projects
252 | Generated_Code/
253 |
254 | # Backup & report files from converting an old project file
255 | # to a newer Visual Studio version. Backup files are not needed,
256 | # because we have git ;-)
257 | _UpgradeReport_Files/
258 | Backup*/
259 | UpgradeLog*.XML
260 | UpgradeLog*.htm
261 | ServiceFabricBackup/
262 | *.rptproj.bak
263 |
264 | # SQL Server files
265 | *.mdf
266 | *.ldf
267 | *.ndf
268 |
269 | # Business Intelligence projects
270 | *.rdl.data
271 | *.bim.layout
272 | *.bim_*.settings
273 | *.rptproj.rsuser
274 | *- [Bb]ackup.rdl
275 | *- [Bb]ackup ([0-9]).rdl
276 | *- [Bb]ackup ([0-9][0-9]).rdl
277 |
278 | # Microsoft Fakes
279 | FakesAssemblies/
280 |
281 | # GhostDoc plugin setting file
282 | *.GhostDoc.xml
283 |
284 | # Node.js Tools for Visual Studio
285 | .ntvs_analysis.dat
286 | node_modules/
287 |
288 | # Visual Studio 6 build log
289 | *.plg
290 |
291 | # Visual Studio 6 workspace options file
292 | *.opt
293 |
294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
295 | *.vbw
296 |
297 | # Visual Studio LightSwitch build output
298 | **/*.HTMLClient/GeneratedArtifacts
299 | **/*.DesktopClient/GeneratedArtifacts
300 | **/*.DesktopClient/ModelManifest.xml
301 | **/*.Server/GeneratedArtifacts
302 | **/*.Server/ModelManifest.xml
303 | _Pvt_Extensions
304 |
305 | # Paket dependency manager
306 | .paket/paket.exe
307 | paket-files/
308 |
309 | # FAKE - F# Make
310 | .fake/
311 |
312 | # CodeRush personal settings
313 | .cr/personal
314 |
315 | # Python Tools for Visual Studio (PTVS)
316 | __pycache__/
317 | *.pyc
318 |
319 | # Cake - Uncomment if you are using it
320 | # tools/**
321 | # !tools/packages.config
322 |
323 | # Tabs Studio
324 | *.tss
325 |
326 | # Telerik's JustMock configuration file
327 | *.jmconfig
328 |
329 | # BizTalk build output
330 | *.btp.cs
331 | *.btm.cs
332 | *.odx.cs
333 | *.xsd.cs
334 |
335 | # OpenCover UI analysis results
336 | OpenCover/
337 |
338 | # Azure Stream Analytics local run output
339 | ASALocalRun/
340 |
341 | # MSBuild Binary and Structured Log
342 | *.binlog
343 |
344 | # NVidia Nsight GPU debugger configuration file
345 | *.nvuser
346 |
347 | # MFractors (Xamarin productivity tool) working folder
348 | .mfractor/
349 |
350 | # Local History for Visual Studio
351 | .localhistory/
352 |
353 | # BeatPulse healthcheck temp database
354 | healthchecksdb
355 |
356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
357 | MigrationBackup/
358 |
359 | # Ionide (cross platform F# VS Code tools) working folder
360 | .ionide/
361 |
362 | # Fody - auto-generated XML schema
363 | FodyWeavers.xsd
--------------------------------------------------------------------------------
/Accents/Styles.axaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 | #2b2b2b
7 | #000000
8 | #00adb5
9 | #eeeeee
10 | #d9d9d9
11 | /Assets/fileopen-black-x256.png
12 | /Assets/refresh-black-x256.png
13 | /Assets/reset-black-x256.png
14 |
15 |
16 | #eeeeee
17 | #ffffff
18 | #00adb5
19 | #2b2b2b
20 | #404040
21 | /Assets/fileopen-white-x256.png
22 | /Assets/refresh-white-x256.png
23 | /Assets/reset-white-x256.png
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/App.axaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/App.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Controls;
3 | using Avalonia.Controls.ApplicationLifetimes;
4 | using Avalonia.Markup.Xaml;
5 | using Cursor_Installer_Creator.Views;
6 | using System.IO;
7 |
8 | namespace Cursor_Installer_Creator;
9 |
10 | public partial class App : Application
11 | {
12 | public override void Initialize() => AvaloniaXamlLoader.Load(this);
13 |
14 | public override void OnFrameworkInitializationCompleted()
15 | {
16 | if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
17 | {
18 | desktop.Exit += (_, _) => Directory.Delete(Program.TempPath, true);
19 | desktop.MainWindow = new MainWindow
20 | {
21 | WindowStartupLocation = WindowStartupLocation.CenterScreen,
22 | };
23 | }
24 |
25 | base.OnFrameworkInitializationCompleted();
26 | }
27 | }
--------------------------------------------------------------------------------
/Assets/fileopen-black-x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Der-Floh/Cursor-Installer-Creator/064877b466a28a1089691c0209516f1e6d52c918/Assets/fileopen-black-x256.png
--------------------------------------------------------------------------------
/Assets/fileopen-black.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Assets/fileopen-white-x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Der-Floh/Cursor-Installer-Creator/064877b466a28a1089691c0209516f1e6d52c918/Assets/fileopen-white-x256.png
--------------------------------------------------------------------------------
/Assets/fileopen-white.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Assets/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Der-Floh/Cursor-Installer-Creator/064877b466a28a1089691c0209516f1e6d52c918/Assets/icon.ico
--------------------------------------------------------------------------------
/Assets/refresh-black-x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Der-Floh/Cursor-Installer-Creator/064877b466a28a1089691c0209516f1e6d52c918/Assets/refresh-black-x256.png
--------------------------------------------------------------------------------
/Assets/refresh-black.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Assets/refresh-white-x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Der-Floh/Cursor-Installer-Creator/064877b466a28a1089691c0209516f1e6d52c918/Assets/refresh-white-x256.png
--------------------------------------------------------------------------------
/Assets/refresh-white.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Assets/reset-black-x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Der-Floh/Cursor-Installer-Creator/064877b466a28a1089691c0209516f1e6d52c918/Assets/reset-black-x256.png
--------------------------------------------------------------------------------
/Assets/reset-white-x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Der-Floh/Cursor-Installer-Creator/064877b466a28a1089691c0209516f1e6d52c918/Assets/reset-white-x256.png
--------------------------------------------------------------------------------
/Cursor_Installer_Creator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | WinExe
4 | net9.0-windows7.0
5 | enable
6 | true
7 | app.manifest
8 | true
9 | True
10 | en
11 | Assets\icon.ico
12 | true
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | Always
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/Cursor_Installer_Creator.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.11.35103.136
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cursor_Installer_Creator", "Cursor_Installer_Creator.csproj", "{903A5D99-5920-409D-A5D9-414AFB6F65B7}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {903A5D99-5920-409D-A5D9-414AFB6F65B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {903A5D99-5920-409D-A5D9-414AFB6F65B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {903A5D99-5920-409D-A5D9-414AFB6F65B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {903A5D99-5920-409D-A5D9-414AFB6F65B7}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {24116C50-2A30-4A91-B18A-C1FB8255EBE7}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/Data/CCursor.cs:
--------------------------------------------------------------------------------
1 | using Cursor_Installer_Creator.Utils;
2 | using System.IO;
3 |
4 | namespace Cursor_Installer_Creator.Data;
5 |
6 | public enum CCursorType
7 | {
8 | cur,
9 | ani,
10 | unknown,
11 | }
12 |
13 | public sealed class CCursor
14 | {
15 | public required CursorAssignment Assignment { get; set; }
16 | public required string CursorPath { get; set; }
17 |
18 | public CCursorType GetCursorType()
19 | {
20 | if (string.IsNullOrWhiteSpace(CursorPath))
21 | return CCursorType.unknown;
22 |
23 | if (CursorPath.EndsWith(".ani"))
24 | return CCursorType.ani;
25 | else if (CursorPath.EndsWith(".cur"))
26 | return CCursorType.cur;
27 |
28 | return CCursorType.unknown;
29 | }
30 |
31 | public string? GetImagePath()
32 | {
33 | var imagePath = Path.Combine(Program.TempPath, $"{Assignment.WindowsReg}.png");
34 | if (File.Exists(imagePath))
35 | return imagePath;
36 |
37 | imagePath = CursorHelper.CreateCursorImage(this);
38 | return File.Exists(imagePath) ? imagePath : null;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Data/CursorAssignment.cs:
--------------------------------------------------------------------------------
1 | using CsvHelper;
2 | using CsvHelper.Configuration;
3 | using System.Collections.Generic;
4 | using System.Globalization;
5 | using System.IO;
6 | using System.Linq;
7 |
8 | namespace Cursor_Installer_Creator.Data;
9 |
10 | public enum CursorAssignmentType
11 | {
12 | ID,
13 | Name,
14 | DisplayName,
15 | Windows,
16 | WindowsReg,
17 | WindowsInstall,
18 | Avalonia
19 | }
20 |
21 | public sealed class CursorAssignment
22 | {
23 | public static Dictionary CursorAssignments { get; } = ReadCsvString(CursorAssignmentMap.AssignmentCSVMap);
24 |
25 | public int ID { get; set; }
26 | public int Order { get; set; }
27 | public string Name { get; set; } = string.Empty;
28 | public string DisplayName { get; set; } = string.Empty;
29 | public string Windows { get; set; } = string.Empty;
30 | public string WindowsReg { get; set; } = string.Empty;
31 | public string WindowsInstall { get; set; } = string.Empty;
32 | public string Avalonia { get; set; } = string.Empty;
33 |
34 | public static Dictionary ReadCsvString(string fileContent)
35 | {
36 | using var reader = new StringReader(fileContent);
37 | using var csv = new CsvReader(reader, new CsvConfiguration(CultureInfo.InvariantCulture));
38 | csv.Context.RegisterClassMap();
39 | var records = csv.GetRecords();
40 | var dictionary = new Dictionary();
41 | foreach (var record in records)
42 | {
43 | if (string.IsNullOrWhiteSpace(record.Name))
44 | continue;
45 | dictionary[record.ID] = record;
46 | }
47 | return dictionary;
48 | }
49 |
50 | public static CursorAssignment? FromName(string name, CursorAssignmentType type)
51 | {
52 | return type switch
53 | {
54 | CursorAssignmentType.Name => CursorAssignments.Values.FirstOrDefault(x => x.Name == name),
55 | CursorAssignmentType.DisplayName => CursorAssignments.Values.FirstOrDefault(x => x.DisplayName == name),
56 | CursorAssignmentType.Windows => CursorAssignments.Values.FirstOrDefault(x => x.Windows == name),
57 | CursorAssignmentType.WindowsReg => CursorAssignments.Values.FirstOrDefault(x => x.WindowsReg == name),
58 | CursorAssignmentType.WindowsInstall => CursorAssignments.Values.FirstOrDefault(x => x.WindowsInstall == name),
59 | CursorAssignmentType.Avalonia => CursorAssignments.Values.FirstOrDefault(x => x.Avalonia == name),
60 | _ => null,
61 | };
62 | }
63 |
64 | public static CursorAssignment? FromName(string name)
65 | {
66 | var assignment = FromName(name, CursorAssignmentType.Name);
67 | assignment ??= FromName(name, CursorAssignmentType.DisplayName);
68 | assignment ??= FromName(name, CursorAssignmentType.Windows);
69 | assignment ??= FromName(name, CursorAssignmentType.WindowsReg);
70 | assignment ??= FromName(name, CursorAssignmentType.WindowsInstall);
71 | assignment ??= FromName(name, CursorAssignmentType.Avalonia);
72 | return assignment;
73 | }
74 | }
75 |
76 | public sealed class CursorAssignmentMap : ClassMap
77 | {
78 | public CursorAssignmentMap()
79 | {
80 | Map(m => m.ID).Name("ID");
81 | Map(m => m.Order).Name("Order");
82 | Map(m => m.Name).Name("Name");
83 | Map(m => m.DisplayName).Name("DisplayName");
84 | Map(m => m.Windows).Name("Windows");
85 | Map(m => m.WindowsReg).Name("WindowsReg");
86 | Map(m => m.WindowsInstall).Name("WindowsInstall");
87 | Map(m => m.Avalonia).Name("Avalonia");
88 | }
89 |
90 | public static string AssignmentCSVMap { get; } = @"ID,Order,Name,DisplayName,Windows,WindowsReg,WindowsInstall,Avalonia
91 | 32512,1,IDC_ARROW,Normal Select,arrow_m,Arrow,pointer,Arrow
92 | 32513,6,IDC_IBEAM,Text Select,beam_im,IBeam,text,Ibeam
93 | 32514,4,IDC_WAIT,Busy,busy_m,Wait,busy,Wait
94 | 32515,5,IDC_CROSS,Precision Select,cross_im,Crosshair,cross,Cross
95 | 32516,14,IDC_UPARROW,Alternate Select,up_m,UpArrow,alternate,UpArrow
96 | 32642,11,IDC_SIZENWSE,Diagonal Resize 1,lnwse,SizeNWSE,dgn1,TopLeftCorner
97 | 32643,12,IDC_SIZENESW,Diagonal Resize 2,lnesw,SizeNESW,dgn2,TopRightCorner
98 | 32644,10,IDC_SIZEWE,Horizontal Resize,lwe,SizeWE,horz,SizeWestEast
99 | 32645,9,IDC_SIZENS,Vertical Resize,lns,SizeNS,vert,SizeNorthSouth
100 | 32646,13,IDC_SIZEALL,Move,move_m,SizeAll,move,SizeAll
101 | 32648,8,IDC_NO,Unavailable,no_m,No,unavailiable,No
102 | 32649,15,IDC_HAND,Link Select,aero_link_im,Hand,link,Hand
103 | 32650,3,IDC_APPSTARTING,Working in Background,wait_m,AppStarting,work,AppStarting
104 | 32651,2,IDC_HELP,Help Select,help_m,Help,help,Help
105 | 32671,16,IDC_PIN,Location Select,pin_m,Pin,pin,
106 | 32672,17,IDC_PERSON,Person Select,person_m,Person,person,
107 | 32631,7,OCR_NWPEN,Handwriting,pen_m,NWPen,hand,
108 | ";
109 | }
110 |
--------------------------------------------------------------------------------
/Data/Version.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 |
4 | namespace Cursor_Installer_Creator.Data;
5 |
6 | public sealed class Version
7 | {
8 | public int Major { get; set; } = -1;
9 | public int Minor { get; set; } = -1;
10 | public int Patch { get; set; } = -1;
11 | public bool IsPrerelease { get; set; }
12 |
13 | public Version() { }
14 |
15 | public Version(int major, int minor, int patch, bool isPrerelease = false)
16 | {
17 | Major = major;
18 | Minor = minor;
19 | Patch = patch;
20 | IsPrerelease = isPrerelease;
21 | }
22 |
23 | public Version(string? version)
24 | {
25 | if (string.IsNullOrWhiteSpace(version))
26 | return;
27 |
28 | version = version.ToLower();
29 | version = version.TrimStart('v');
30 |
31 | var parts = version.Split('-');
32 | IsPrerelease = parts.Length > 1;
33 |
34 | var versionParts = parts[0].Split('.').Select(int.Parse).ToArray();
35 | Major = versionParts[0];
36 | Minor = versionParts[1];
37 | Patch = versionParts[2];
38 | }
39 |
40 | public override string ToString() => IsPrerelease ? $"{Major}.{Minor}.{Patch}-alpha" : $"{Major}.{Minor}.{Patch}";
41 |
42 | public override bool Equals(object? obj)
43 | {
44 | if (obj is Version otherVersion)
45 | {
46 | return Major == otherVersion.Major
47 | && Minor == otherVersion.Minor
48 | && Patch == otherVersion.Patch
49 | && IsPrerelease == otherVersion.IsPrerelease;
50 | }
51 | return base.Equals(obj);
52 | }
53 |
54 | public override int GetHashCode() => HashCode.Combine(Major, Minor, Patch, IsPrerelease);
55 |
56 | public static bool operator >(Version v1, Version v2)
57 | {
58 | if (v1.Major != v2.Major)
59 | return v1.Major > v2.Major;
60 | if (v1.Minor != v2.Minor)
61 | return v1.Minor > v2.Minor;
62 | if (v1.Patch != v2.Patch)
63 | return v1.Patch > v2.Patch;
64 | return !v1.IsPrerelease && v2.IsPrerelease;
65 | }
66 |
67 | public static bool operator <(Version v1, Version v2)
68 | {
69 | return !(v1 > v2) && !v1.Equals(v2);
70 | }
71 |
72 | public static bool operator >=(Version v1, Version v2)
73 | {
74 | return v1 > v2 || v1.Equals(v2);
75 | }
76 |
77 | public static bool operator <=(Version v1, Version v2)
78 | {
79 | return v1 < v2 || v1.Equals(v2);
80 | }
81 |
82 | public static Version operator +(Version v1, Version v2)
83 | {
84 | return new Version(
85 | v1.Major + v2.Major,
86 | v1.Minor + v2.Minor,
87 | v1.Patch + v2.Patch,
88 | v1.IsPrerelease || v2.IsPrerelease
89 | );
90 | }
91 |
92 | public static Version operator -(Version v1, Version v2)
93 | {
94 | return new Version(
95 | Math.Max(v1.Major - v2.Major, 0),
96 | Math.Max(v1.Minor - v2.Minor, 0),
97 | Math.Max(v1.Patch - v2.Patch, 0),
98 | v1.IsPrerelease
99 | );
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/Extensions/GridExtensions.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using System.Linq;
3 |
4 | namespace Cursor_Installer_Creator.Extensions;
5 |
6 | public static class GridExtensions
7 | {
8 | public static T? GetByRowColumn(this Grid grid, int row, int column) => grid.Children.OfType().FirstOrDefault(child => Grid.GetRow(child as Control) == row && Grid.GetColumn(child as Control) == column);
9 | public static (int, int) GetRowColumnByIndex(this Grid grid, int index)
10 | {
11 | var row = index / grid.ColumnDefinitions.Count;
12 | var column = index % grid.ColumnDefinitions.Count;
13 |
14 | return (row, column);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) [year] [fullname]
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Program.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using System;
3 | using System.IO;
4 |
5 | namespace Cursor_Installer_Creator;
6 |
7 | internal class Program
8 | {
9 | public static string TempPath { get; private set; } = Path.Combine(Path.GetTempPath(), "CursorTemp");
10 |
11 | // Initialization code. Don't use any Avalonia, third-party APIs or any
12 | // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
13 | // yet and stuff might break.
14 | [STAThread]
15 | public static void Main(string[] args) => BuildAvaloniaApp()
16 | .StartWithClassicDesktopLifetime(args);
17 |
18 | // Avalonia configuration, don't remove; also used by visual designer.
19 | public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure().UsePlatformDetect().WithInterFont().LogToTrace();
20 | }
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Cursor-Installer-Creator
2 |
3 | A program to create Cursor-Installer files simply and fast.
4 |
5 |
6 |
7 |
8 |
9 |
10 | ### [Download Latest Release](https://github.com/Der-Floh/Cursor-Installer-Creator/releases/latest)
11 |
12 | ## Usage
13 |
14 | Pick or Drag & Drop cursor files in their corresponding slot. Give the cursor package a name and hit create package. Optionally you can also decide wether to create the package inside a .zip compressed archive or just inside a folder.
15 |
16 | ## Features
17 |
18 | - Pick .cur and .ani cursor files
19 | - Drag and Drop .cur and .ani files
20 | - Create Installer-Package as Folder or .zip archive
21 | - Directly install a new cursor from the program
22 | - Reset individual cursors to default
23 | - Import Cursor-Installer (.inf) File
24 | - Preview Cursors
25 | - Light and Dark Mode
26 |
27 |
28 |
29 | ### If you found an error or want to submit an idea feel free to create an [Issue](https://github.com/Der-Floh/Cursor-Installer-Creator/issues/new) or view all [Issues](https://github.com/Der-Floh/Cursor-Installer-Creator/issues)
30 |
31 |
32 |
33 | [](https://www.buymeacoffee.com/der_floh)
34 |
--------------------------------------------------------------------------------
/Resources/cursor-assignment.csv:
--------------------------------------------------------------------------------
1 | ID,Order,Name,DisplayName,Windows,WindowsReg,WindowsInstall,Avalonia
2 | 32512,1,IDC_ARROW,Normal Select,arrow_m,Arrow,pointer,Arrow
3 | 32513,6,IDC_IBEAM,Text Select,beam_im,IBeam,text,Ibeam
4 | 32514,4,IDC_WAIT,Busy,busy_m,Wait,busy,Wait
5 | 32515,5,IDC_CROSS,Precision Select,cross_im,Crosshair,cross,Cross
6 | 32516,14,IDC_UPARROW,Alternate Select,up_m,UpArrow,alternate,UpArrow
7 | 32642,11,IDC_SIZENWSE,Diagonal Resize 1,lnwse,SizeNWSE,dgn1,TopLeftCorner
8 | 32643,12,IDC_SIZENESW,Diagonal Resize 2,lnesw,SizeNESW,dgn2,TopRightCorner
9 | 32644,10,IDC_SIZEWE,Horizontal Resize,lwe,SizeWE,horz,SizeWestEast
10 | 32645,9,IDC_SIZENS,Vertical Resize,lns,SizeNS,vert,SizeNorthSouth
11 | 32646,13,IDC_SIZEALL,Move,move_m,SizeAll,move,SizeAll
12 | 32648,8,IDC_NO,Unavailable,no_m,No,unavailiable,No
13 | 32649,15,IDC_HAND,Link Select,aero_link_im,Hand,link,Hand
14 | 32650,3,IDC_APPSTARTING,Working in Background,wait_m,AppStarting,work,AppStarting
15 | 32651,2,IDC_HELP,Help Select,help_m,Help,help,Help
16 | 32671,16,IDC_PIN,Location Select,pin_m,Pin,pin,
17 | 32672,17,IDC_PERSON,Person Select,person_m,Person,person,
18 | 32631,7,OCR_NWPEN,Handwriting,pen_m,NWPen,hand,
19 |
--------------------------------------------------------------------------------
/Resources/preview-dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Der-Floh/Cursor-Installer-Creator/064877b466a28a1089691c0209516f1e6d52c918/Resources/preview-dark.png
--------------------------------------------------------------------------------
/Resources/preview-light-small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Der-Floh/Cursor-Installer-Creator/064877b466a28a1089691c0209516f1e6d52c918/Resources/preview-light-small.png
--------------------------------------------------------------------------------
/Resources/preview-light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Der-Floh/Cursor-Installer-Creator/064877b466a28a1089691c0209516f1e6d52c918/Resources/preview-light.png
--------------------------------------------------------------------------------
/Resources/preview-social-media.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Der-Floh/Cursor-Installer-Creator/064877b466a28a1089691c0209516f1e6d52c918/Resources/preview-social-media.png
--------------------------------------------------------------------------------
/Tools/Cursor-Installer.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Der-Floh/Cursor-Installer-Creator/064877b466a28a1089691c0209516f1e6d52c918/Tools/Cursor-Installer.exe
--------------------------------------------------------------------------------
/Tools/SetupIcon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Der-Floh/Cursor-Installer-Creator/064877b466a28a1089691c0209516f1e6d52c918/Tools/SetupIcon.ico
--------------------------------------------------------------------------------
/Utils/CursorHelper.cs:
--------------------------------------------------------------------------------
1 | using Cursor_Installer_Creator.Data;
2 | using Microsoft.Win32;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Diagnostics;
6 | using System.Drawing;
7 | using System.Drawing.Imaging;
8 | using System.IO;
9 | using System.IO.Compression;
10 | using System.Linq;
11 | using System.Runtime.InteropServices;
12 | using System.Text;
13 | using Cursor = System.Windows.Forms.Cursor;
14 |
15 | namespace Cursor_Installer_Creator.Utils;
16 |
17 | public static class CursorHelper
18 | {
19 | public static List GetSelectedCursors()
20 | {
21 | var ccursors = new List();
22 |
23 | var assignmentsAll = CursorAssignment.CursorAssignments.Values.ToList();
24 | using var key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Cursors");
25 | if (key is not null)
26 | {
27 | // Search Registry for cursors
28 | var valueNames = key.GetValueNames();
29 | foreach (var valueName in valueNames)
30 | {
31 | var cursorPath = key.GetValue(valueName)?.ToString();
32 | if (string.IsNullOrWhiteSpace(cursorPath) || !File.Exists(cursorPath))
33 | {
34 | var assignment = CursorAssignment.FromName(valueName, CursorAssignmentType.WindowsReg);
35 | cursorPath = @$"C:\Windows\Cursors\{assignment?.Windows}.cur";
36 | }
37 |
38 | if (File.Exists(cursorPath))
39 | {
40 | var ccursor = ConvertCursorFile(cursorPath, valueName);
41 | if (ccursor is not null)
42 | ccursors.Add(ccursor);
43 | }
44 | }
45 | }
46 |
47 | // Add missing cursors from CursorAssignment
48 | foreach (var assignment in CursorAssignment.CursorAssignments)
49 | {
50 | var ccursor = ccursors.FirstOrDefault(x => x.Assignment.ID == assignment.Key);
51 | if (ccursor is null)
52 | {
53 | ccursor = new CCursor
54 | {
55 | Assignment = assignment.Value,
56 | CursorPath = @$"C:\Windows\Cursors\{assignment.Value.Windows}.cur",
57 | };
58 | ccursor.CursorPath = ConvertCursorFile(ccursor.CursorPath, ccursor.Assignment)?.CursorPath ?? ccursor.CursorPath;
59 | if (File.Exists(ccursor.CursorPath))
60 | ccursors.Add(ccursor);
61 | }
62 | }
63 |
64 | return [.. ccursors.OrderBy(x => x.Assignment.ID)];
65 | }
66 |
67 | public static CCursor? GetSelectedCursor(CursorAssignment assignment)
68 | {
69 | using var key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Cursors");
70 | if (key is not null)
71 | {
72 | var cursorPath = key.GetValue(assignment.WindowsReg)?.ToString();
73 | if (!File.Exists(cursorPath))
74 | cursorPath = @$"C:\Windows\Cursors\{assignment.Windows}.cur";
75 |
76 | return ConvertCursorFile(cursorPath, assignment.ID);
77 | }
78 |
79 | return null;
80 | }
81 |
82 | private static Dictionary ParseInstallerInfStrings(string filePath)
83 | {
84 | var stringsDictionary = new Dictionary();
85 | var lines = File.ReadAllLines(filePath);
86 | var isStringsSection = false;
87 |
88 | foreach (var line in lines)
89 | {
90 | if (line.Trim().Equals("[Strings]", StringComparison.OrdinalIgnoreCase))
91 | {
92 | isStringsSection = true;
93 | continue;
94 | }
95 |
96 | if (isStringsSection)
97 | {
98 | var parts = line.Split('=');
99 |
100 | if (parts.Length == 2)
101 | {
102 | var key = parts[0].Trim();
103 | var value = parts[1].Trim().TrimStart('\"').TrimEnd('\"');
104 | var assignment = CursorAssignment.FromName(key, CursorAssignmentType.WindowsInstall);
105 | if (assignment is not null)
106 | stringsDictionary[assignment.WindowsReg] = value;
107 | }
108 | }
109 | }
110 |
111 | return stringsDictionary;
112 | }
113 |
114 | public static IEnumerable CursorsFromInstallerInf(string filePath)
115 | {
116 | var ccursors = new List();
117 | var cursorDictionary = ParseInstallerInfStrings(filePath);
118 | foreach (var kvp in cursorDictionary)
119 | {
120 | var assignment = CursorAssignment.FromName(kvp.Key, CursorAssignmentType.WindowsReg);
121 | if (assignment is not null)
122 | {
123 | var ccursor = ConvertCursorFile(Path.Combine(Path.GetDirectoryName(filePath)!, kvp.Value), assignment);
124 | if (ccursor is not null)
125 | ccursors.Add(ccursor);
126 | }
127 | }
128 | return ccursors;
129 | }
130 |
131 | public static string? CreateCursorImage(CCursor ccursor)
132 | {
133 | try
134 | {
135 | var cursor = GetCursorFromFile(ccursor.CursorPath);
136 | var icon = Icon.FromHandle(cursor.Handle);
137 | var bitmap = icon.ToBitmap();
138 |
139 | if (!Directory.Exists(Program.TempPath))
140 | Directory.CreateDirectory(Program.TempPath);
141 |
142 | var imagePath = Path.Combine(Program.TempPath, $"{ccursor.Assignment.WindowsReg}.png");
143 | bitmap.Save(imagePath, ImageFormat.Png);
144 |
145 | return imagePath;
146 | }
147 | catch
148 | {
149 | return null;
150 | }
151 | }
152 |
153 | public static void RemoveCursorDisplayImage(CCursor ccursor)
154 | {
155 | var prevCursorImagePath = Path.ChangeExtension(ccursor.CursorPath, ".png");
156 | if (File.Exists(prevCursorImagePath))
157 | File.Delete(prevCursorImagePath);
158 | }
159 |
160 | public static CCursor? ConvertCursorFile(string cursorPath, int cursorID) => ConvertCursorFile(cursorPath, CursorAssignment.CursorAssignments[cursorID]);
161 | public static CCursor? ConvertCursorFile(string cursorPath, string cursorName) => ConvertCursorFile(cursorPath, CursorAssignment.FromName(cursorName, CursorAssignmentType.WindowsReg));
162 |
163 | private static CCursor? ConvertCursorFile(string cursorPath, CursorAssignment? assignment)
164 | {
165 | try
166 | {
167 | if (assignment is null)
168 | return null;
169 | var cursor = GetCursorFromFile(cursorPath);
170 |
171 | if (!Directory.Exists(Program.TempPath))
172 | Directory.CreateDirectory(Program.TempPath);
173 |
174 | var destinationFileName = assignment.WindowsReg + Path.GetExtension(cursorPath);
175 | var destinationFullPath = Path.Combine(Program.TempPath, destinationFileName);
176 | File.Copy(cursorPath, destinationFullPath, true);
177 |
178 | var prevCursorImagePath = Path.ChangeExtension(destinationFullPath, ".png");
179 | if (File.Exists(prevCursorImagePath))
180 | File.Delete(prevCursorImagePath);
181 |
182 | var ccursor = new CCursor
183 | {
184 | CursorPath = destinationFullPath,
185 | Assignment = assignment,
186 | };
187 |
188 | return ccursor;
189 | }
190 | catch
191 | {
192 | return null;
193 | }
194 | }
195 |
196 | [DllImport("User32.dll", CharSet = CharSet.Unicode)]
197 | private static extern nint LoadCursorFromFile(string str);
198 | private static Cursor GetCursorFromFile(string filename)
199 | {
200 | var hCursor = LoadCursorFromFile(filename);
201 | return !nint.Zero.Equals(hCursor)
202 | ? new Cursor(hCursor)
203 | : throw new ApplicationException("Could not create cursor from file " + filename);
204 | }
205 |
206 | public static void CreateInstaller(string packageName, string folderPath, IEnumerable ccursors, bool createZip = true)
207 | {
208 | using (var writer = new StreamWriter(@$"{Program.TempPath}\installer.inf"))
209 | {
210 | writer.Write(CreateInstallerInfString(packageName, ccursors));
211 | }
212 |
213 | var files = ccursors.Select(x => x.CursorPath).ToList();
214 | files.Add(@$"{Program.TempPath}\installer.inf");
215 |
216 | if (createZip)
217 | {
218 | var zipPath = Path.Combine(folderPath, $"{packageName}.zip");
219 | CreateZipFile(zipPath, files);
220 | }
221 | else
222 | {
223 | folderPath = Path.Combine(folderPath, packageName);
224 | Directory.CreateDirectory(folderPath);
225 | foreach (var file in files)
226 | {
227 | File.Copy(file, Path.Combine(folderPath, Path.GetFileName(file)), true);
228 | }
229 | }
230 | }
231 |
232 | private static string CreateInstallerInfString(string packageName, IEnumerable ccursors)
233 | {
234 | var sb = new StringBuilder();
235 | ccursors = ccursors.OrderBy(x => x.Assignment.ID);
236 |
237 | sb.AppendLine($" ; {packageName}");
238 | sb.AppendLine("[Version]");
239 | sb.AppendLine("Signature = \"$WINDOWS NT$\"");
240 | sb.AppendLine("Provider = Der_Floh");
241 | sb.AppendLine("Class = Cursor");
242 | sb.AppendLine("ClassGuid = {some-guid}");
243 | sb.AppendLine("CatalogFile = installer.cat");
244 | sb.AppendLine();
245 | sb.AppendLine("[DefaultInstall]");
246 | sb.AppendLine("CopyFiles = Scheme.Cur, Scheme.Txt");
247 | sb.AppendLine("AddReg = Scheme.Reg");
248 | sb.AppendLine();
249 | sb.AppendLine("[DestinationDirs]");
250 | sb.AppendLine("Scheme.Cur = 10,\"%CUR_DIR%\"");
251 | sb.AppendLine("Scheme.Txt = 10,\"%CUR_DIR%\"");
252 | sb.AppendLine();
253 | sb.AppendLine("[Scheme.Reg]");
254 | sb.AppendLine(@$"HKCU,""Control Panel\Cursors\Schemes"",""%SCHEME_NAME%"",,""{string.Join(',', ccursors.OrderBy(x => x.Assignment.Order).Select(x => @$"%10%\%CUR_DIR%\%{x.Assignment.WindowsInstall}%"))}""");
255 | sb.AppendLine();
256 |
257 | sb.AppendLine("[Scheme.Cur]");
258 | foreach (var ccursor in ccursors.OrderBy(x => x.Assignment.ID))
259 | {
260 | var extension = Path.GetExtension(ccursor.CursorPath);
261 | sb.AppendLine($"\"{ccursor.Assignment.WindowsReg}{extension}\"");
262 | }
263 | sb.AppendLine();
264 |
265 | sb.AppendLine("[Strings]");
266 | sb.AppendLine($"CUR_DIR = \"Cursors\\{packageName}\"");
267 | sb.AppendLine($"SCHEME_NAME = \"{packageName}\"");
268 | foreach (var ccursor in ccursors.OrderBy(x => x.Assignment.ID))
269 | {
270 | var extension = Path.GetExtension(ccursor.CursorPath);
271 | var spaceCount = 12 - ccursor.Assignment.WindowsInstall.ToCharArray().Length;
272 | sb.AppendLine($"{ccursor.Assignment.WindowsInstall}{new string(' ', spaceCount + 1)}= \"{ccursor.Assignment.WindowsReg}{extension}\"");
273 | }
274 |
275 | return sb.ToString();
276 | }
277 |
278 | private static void CreateZipFile(string zipPath, IEnumerable files)
279 | {
280 | if (File.Exists(zipPath))
281 | File.Delete(zipPath);
282 | using var archive = ZipFile.Open(zipPath, ZipArchiveMode.Create);
283 | var folder = Path.GetFileNameWithoutExtension(zipPath);
284 | foreach (var file in files)
285 | {
286 | var filePath = Path.Combine(folder, Path.GetFileName(file));
287 | archive.CreateEntryFromFile(file, filePath);
288 | }
289 | }
290 |
291 | public static void InstallCursor(string installerFilePath)
292 | {
293 | var command = @"C:\WINDOWS\System32\rundll32.exe";
294 | var arguments = "setupapi,InstallHinfSection DefaultInstall 132 " + installerFilePath;
295 |
296 | var startInfo = new ProcessStartInfo
297 | {
298 | FileName = "cmd.exe",
299 | Arguments = $"/c \"{command} {arguments}\"",
300 | Verb = "runas",
301 | UseShellExecute = true,
302 | CreateNoWindow = true,
303 | WindowStyle = ProcessWindowStyle.Hidden
304 | };
305 |
306 | var process = new Process
307 | {
308 | StartInfo = startInfo
309 | };
310 |
311 | try
312 | {
313 | process.Start();
314 | process.WaitForExit();
315 | }
316 | catch (System.ComponentModel.Win32Exception ex)
317 | {
318 | if (ex.NativeErrorCode != 1223)
319 | throw new Exception(ex.Message + Environment.NewLine + ex.ErrorCode);
320 | }
321 | }
322 | }
323 |
--------------------------------------------------------------------------------
/Utils/GitHubUpdater.cs:
--------------------------------------------------------------------------------
1 | using Cursor_Installer_Creator.Data;
2 | using System.Net.Http;
3 | using System.Text.Json;
4 | using System.Threading.Tasks;
5 |
6 | namespace Cursor_Installer_Creator.Utils;
7 |
8 | public sealed class GitHubUpdater
9 | {
10 | public const string RepoOwner = "Der-Floh";
11 | public const string RepoName = "Cursor-Installer-Creator";
12 |
13 | public static Version CurrentVersion { get; } = new Version(2, 1, 0);
14 | public static string RepoUrl => $"https://github.com/{RepoOwner}/{RepoName}";
15 | public static string LatestReleaseUrl => $"https://github.com/{RepoOwner}/{RepoName}/releases/latest";
16 |
17 | private static readonly HttpClient _client = new HttpClient();
18 |
19 | public static async Task HasUpdateAsync()
20 | {
21 | try
22 | {
23 | // GitHub API endpoint for the latest release
24 | var url = $"https://api.github.com/repos/{RepoOwner}/{RepoName}/releases/latest";
25 | _client.DefaultRequestHeaders.UserAgent.ParseAdd(RepoName.Replace('-', '_'));
26 |
27 | // Fetch latest release
28 | var response = await _client.GetAsync(url);
29 | response.EnsureSuccessStatusCode();
30 |
31 | // Deserialize response
32 | var jsonString = await response.Content.ReadAsStringAsync();
33 | var jsonDocument = JsonDocument.Parse(jsonString);
34 | var latestVersionString = jsonDocument.RootElement.GetProperty("tag_name").GetString();
35 | var latestVersion = new Version(latestVersionString);
36 |
37 | // Compare versions
38 | return latestVersion > CurrentVersion;
39 | }
40 | catch
41 | {
42 | return false;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Views/CursorInstallerMainView.axaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/Views/CursorInstallerMainView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Platform.Storage;
3 | using Cursor_Installer_Creator.Utils;
4 | using System;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Threading.Tasks;
8 |
9 | namespace Cursor_Installer_Creator.Views;
10 |
11 | public sealed partial class CursorInstallerMainView : UserControl
12 | {
13 | public CursorInstallerMainView()
14 | {
15 | InitializeComponent();
16 |
17 | CursorListViewElem.OnImportInfFile += CursorListViewElem_OnImportInfFile;
18 | Task.Run(CheckUpdate);
19 | }
20 |
21 | private async Task CheckUpdate()
22 | {
23 | var hasUpdate = await UpdateNotifyViewElem.HasUpdateAsync();
24 | if (hasUpdate)
25 | {
26 | await Task.Delay(1000);
27 | await UpdateNotifyViewElem.ShowUpdateNotify();
28 | }
29 | }
30 |
31 | private void CreateCursorInstaller(string packageName, string location)
32 | {
33 | throw new NotImplementedException("Not yet implemented");
34 | }
35 |
36 | private async Task PickFolderLocation()
37 | {
38 | var topLevel = TopLevel.GetTopLevel(this);
39 |
40 | var files = await topLevel!.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
41 | {
42 | Title = "Pick Cursor File",
43 | AllowMultiple = false,
44 | });
45 |
46 | return files is null || files.Count == 0 ? null : files[0].Path;
47 | }
48 |
49 | private void CursorListViewElem_OnImportInfFile(object? sender, string filePath)
50 | {
51 | var lines = File.ReadAllLines(filePath);
52 | if (lines.Length != 0)
53 | {
54 | var parts = lines[0].Split(';');
55 | if (parts.Length >= 1)
56 | {
57 | var packageName = parts[parts.Length - 1].Trim();
58 | CursorPackagenameTextBox.Text = packageName;
59 | }
60 | }
61 | }
62 |
63 | private void CursorInstallButton_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
64 | {
65 | var packageName = CursorPackagenameTextBox.Text;
66 | if (string.IsNullOrWhiteSpace(packageName))
67 | packageName = CursorPackagenameTextBox.Watermark!;
68 |
69 | CursorHelper.CreateInstaller(packageName, Program.TempPath, CursorListViewElem.Cursors.Select(x => x.CCursor), false);
70 | var installerPath = Path.Combine(Program.TempPath, packageName, "installer.inf");
71 | CursorHelper.InstallCursor(installerPath);
72 | }
73 |
74 | private async void CreateCursorPackageButton_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
75 | {
76 | CreateCursorPackageButton.IsEnabled = false;
77 | var packageName = CursorPackagenameTextBox.Text;
78 | if (string.IsNullOrWhiteSpace(packageName))
79 | packageName = CursorPackagenameTextBox.Watermark!;
80 |
81 | var location = await PickFolderLocation();
82 | if (location is null)
83 | return;
84 |
85 | var cursors = CursorListViewElem.Cursors.Select(x => x.CCursor);
86 | switch (CursorPackageTypeComboBox.SelectedIndex)
87 | {
88 | case 0:
89 | CursorHelper.CreateInstaller(packageName, Uri.UnescapeDataString(location.AbsolutePath), cursors, false);
90 | break;
91 | case 1:
92 | CursorHelper.CreateInstaller(packageName, Uri.UnescapeDataString(location.AbsolutePath), cursors, true);
93 | break;
94 | case 2:
95 | CreateCursorInstaller(packageName, Uri.UnescapeDataString(location.AbsolutePath));
96 | break;
97 | }
98 | CreateCursorPackageButton.IsEnabled = true;
99 | OperationSuccessTextBlock.IsVisible = true;
100 | await Task.Delay(3000);
101 | OperationSuccessTextBlock.IsVisible = false;
102 | }
103 | }
--------------------------------------------------------------------------------
/Views/CursorItemView.axaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
22 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Views/CursorItemView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Input;
3 | using Avalonia.Media;
4 | using Avalonia.Media.Imaging;
5 | using Avalonia.Platform.Storage;
6 | using Cursor_Installer_Creator.Data;
7 | using Cursor_Installer_Creator.Utils;
8 | using System;
9 | using System.IO;
10 | using System.Linq;
11 | using System.Text.RegularExpressions;
12 | using System.Threading.Tasks;
13 |
14 | namespace Cursor_Installer_Creator.Views;
15 |
16 | public sealed partial class CursorItemView : UserControl
17 | {
18 | public CCursor CCursor
19 | {
20 | get => _cCursor;
21 | set
22 | {
23 | _cCursor = value;
24 | UpdateCCursorDisplay();
25 | }
26 | }
27 | private CCursor _cCursor;
28 |
29 | private Bitmap? _cursorImage;
30 | private readonly CCursor _defaultCursor = new CCursor
31 | {
32 | Assignment = CursorAssignment.FromName("IDC_ARROW", CursorAssignmentType.Name)!,
33 | CursorPath = @"C:\Windows\Cursors\aero_arrow.cur"
34 | };
35 |
36 | public CursorItemView()
37 | {
38 | InitializeComponent();
39 |
40 | AddHandler(DragDrop.DragOverEvent, DragOver);
41 | AddHandler(DragDrop.DropEvent, Drop);
42 | DragDrop.SetAllowDrop(this, true);
43 |
44 | RenderOptions.SetBitmapInterpolationMode(CursorImage, BitmapInterpolationMode.HighQuality);
45 | RenderOptions.SetBitmapInterpolationMode(ResetImage, BitmapInterpolationMode.HighQuality);
46 | RenderOptions.SetBitmapInterpolationMode(FileOpenImage, BitmapInterpolationMode.HighQuality);
47 |
48 | _cCursor = _defaultCursor;
49 | UpdateCursorFromFile(CCursor.CursorPath);
50 |
51 | UpdateCCursorDisplay();
52 | }
53 |
54 | private void UpdateCCursorDisplay()
55 | {
56 | CursorNameTextBlock.Text = CCursor.Assignment.WindowsReg;
57 |
58 | var avaloniaCursorName = CCursor.Assignment.Avalonia;
59 | if (string.IsNullOrWhiteSpace(avaloniaCursorName))
60 | {
61 | avaloniaCursorName = "Arrow";
62 | }
63 | CursorItemGrid.Cursor = Cursor.Parse(avaloniaCursorName);
64 |
65 | var imagePath = CCursor.GetImagePath();
66 | if (!string.IsNullOrWhiteSpace(imagePath))
67 | {
68 | _cursorImage?.Dispose();
69 | _cursorImage = new Bitmap(imagePath);
70 | CursorImage.Source = _cursorImage;
71 | }
72 | }
73 |
74 | private void UpdateCursorFromFile(string filePath)
75 | {
76 | if (CursorHelper.ConvertCursorFile(filePath, CCursor.Assignment.ID) is CCursor cursor)
77 | {
78 | CCursor = cursor;
79 | }
80 | }
81 |
82 | private async Task GetCursorFile()
83 | {
84 | var topLevel = TopLevel.GetTopLevel(this);
85 |
86 | var files = await topLevel!.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
87 | {
88 | Title = "Pick Cursor File",
89 | AllowMultiple = false,
90 | FileTypeFilter = [CursorAll],
91 | });
92 |
93 | return files is null || files.Count == 0 ? null : files[0].Path;
94 | }
95 |
96 | public static FilePickerFileType CursorAll { get; } = new("Cursor Files")
97 | {
98 | Patterns = ["*.cur", "*.ani"]
99 | };
100 |
101 | public static bool IsFileMatchingPattern(string filePath)
102 | {
103 | return CursorAll.Patterns?.Any(pattern =>
104 | {
105 | var regexPattern = "^" + Regex.Escape(pattern).Replace("\\*", ".*") + "$";
106 | return Regex.IsMatch(Path.GetFileName(filePath), regexPattern, RegexOptions.IgnoreCase);
107 | }) ?? false;
108 | }
109 |
110 | private void DragOver(object? sender, DragEventArgs e)
111 | {
112 | e.Handled = true;
113 |
114 | var files = e.Data.GetFiles()?.ToArray();
115 | e.DragEffects = files is null || files.Length != 1
116 | ? DragDropEffects.None
117 | : IsFileMatchingPattern(files[0].Name) ? DragDropEffects.Copy : DragDropEffects.None;
118 | }
119 |
120 | private void Drop(object? sender, DragEventArgs e)
121 | {
122 | e.Handled = true;
123 |
124 | var files = e.Data.GetFiles()?.ToArray();
125 | if (files is not null && files.Length == 1)
126 | {
127 | UpdateCursorFromFile(Uri.UnescapeDataString(files[0].Path.AbsolutePath));
128 | }
129 | }
130 |
131 | private void CursorResetButton_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
132 | {
133 | var cursor = CursorHelper.GetSelectedCursor(CCursor.Assignment);
134 | cursor ??= _defaultCursor;
135 | CCursor = cursor;
136 | }
137 |
138 | private async void CursorPickButton_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
139 | {
140 | var filePath = await GetCursorFile();
141 | if (filePath is null)
142 | return;
143 | UpdateCursorFromFile(Uri.UnescapeDataString(filePath.AbsolutePath));
144 | }
145 | }
--------------------------------------------------------------------------------
/Views/CursorListView.axaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/Views/CursorListView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Platform.Storage;
3 | using Cursor_Installer_Creator.Extensions;
4 | using Cursor_Installer_Creator.Utils;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Threading.Tasks;
9 | using UserControl = Avalonia.Controls.UserControl;
10 |
11 | namespace Cursor_Installer_Creator.Views;
12 |
13 | public sealed partial class CursorListView : UserControl
14 | {
15 | public event EventHandler? OnImportInfFile;
16 | public List Cursors { get; set; } = [];
17 |
18 | public CursorListView()
19 | {
20 | InitializeComponent();
21 |
22 | var cursors = CursorHelper.GetSelectedCursors();
23 | for (var i = 0; i < cursors.Count; i++)
24 | {
25 | var (row, column) = CursorItemsGrid.GetRowColumnByIndex(i);
26 | if (CursorItemsGrid.GetByRowColumn(row, column) is not CursorItemView cursorItemView)
27 | continue;
28 | cursorItemView.CCursor = cursors[i];
29 | Cursors.Add(cursorItemView);
30 | }
31 | }
32 |
33 | private async Task GetCursorInstallerFile()
34 | {
35 | var topLevel = TopLevel.GetTopLevel(this);
36 |
37 | var files = await topLevel!.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
38 | {
39 | Title = "Pick Cursor File",
40 | AllowMultiple = false,
41 | FileTypeFilter = [CursorInstaller],
42 | });
43 |
44 | return files is null || files.Count == 0 ? null : files[0].Path;
45 | }
46 |
47 | public static FilePickerFileType CursorInstaller { get; } = new("Cursor Installer Files")
48 | {
49 | Patterns = ["*.inf"]
50 | };
51 |
52 | private async void InstallerImportButton_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
53 | {
54 | var filePath = await GetCursorInstallerFile();
55 | if (filePath is null)
56 | return;
57 |
58 | OnImportInfFile?.Invoke(this, Uri.UnescapeDataString(filePath.AbsolutePath));
59 |
60 | var ccursors = CursorHelper.CursorsFromInstallerInf(Uri.UnescapeDataString(filePath.AbsolutePath));
61 | foreach (var ccursor in ccursors)
62 | {
63 | var cursorItemView = Cursors.FirstOrDefault(x => x.CCursor.Assignment.ID == ccursor.Assignment.ID);
64 | if (cursorItemView is not null)
65 | {
66 | //CursorHelper.ConvertCursorFile(cursorItemView.CCursor.CursorPath);
67 | cursorItemView.CCursor = ccursor;
68 | }
69 | }
70 | }
71 | }
--------------------------------------------------------------------------------
/Views/MainView.axaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Views/MainView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 |
3 | namespace Cursor_Installer_Creator.Views;
4 |
5 | public partial class MainView : UserControl
6 | {
7 | public MainView()
8 | {
9 | InitializeComponent();
10 | }
11 | }
--------------------------------------------------------------------------------
/Views/MainWindow.axaml:
--------------------------------------------------------------------------------
1 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Views/MainWindow.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 |
3 | namespace Cursor_Installer_Creator.Views;
4 | public partial class MainWindow : Window
5 | {
6 | public MainWindow()
7 | {
8 | InitializeComponent();
9 | }
10 | }
--------------------------------------------------------------------------------
/Views/UpdateNotifyView.axaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Views/UpdateNotifyView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Threading;
3 | using Cursor_Installer_Creator.Utils;
4 | using System.Diagnostics;
5 | using System.Threading.Tasks;
6 |
7 | namespace Cursor_Installer_Creator.Views;
8 |
9 | public partial class UpdateNotifyView : UserControl
10 | {
11 | public UpdateNotifyView()
12 | {
13 | InitializeComponent();
14 | }
15 |
16 | public async Task HasUpdateAsync() => await GitHubUpdater.HasUpdateAsync();
17 |
18 | public async Task ShowUpdateNotify()
19 | {
20 | await Dispatcher.UIThread.InvokeAsync(() => IsVisible = true);
21 | await Dispatcher.UIThread.InvokeAsync(() => UpdateBorderElem.Classes.Add("update"));
22 | }
23 |
24 | public async Task HideUpdateNotify()
25 | {
26 | await Dispatcher.UIThread.InvokeAsync(() => UpdateBorderElem.Classes.Remove("update"));
27 | await Task.Delay(1000);
28 | await Dispatcher.UIThread.InvokeAsync(() => IsVisible = false);
29 | }
30 |
31 | private void ViewOnGitHubButton_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
32 | {
33 | Process.Start(new ProcessStartInfo
34 | {
35 | FileName = GitHubUpdater.LatestReleaseUrl,
36 | UseShellExecute = true
37 | });
38 | Task.Run(HideUpdateNotify);
39 | }
40 |
41 | private void DismissButton_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
42 | {
43 | Task.Run(HideUpdateNotify);
44 | }
45 | }
--------------------------------------------------------------------------------
/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------