├── .gitattributes ├── .gitignore ├── .vscode ├── launch.json └── tasks.json ├── DRecorder.Core ├── AudioRecorder.cs ├── Contracts │ ├── IDispatcherQueue.cs │ ├── IRecordingObserver.cs │ ├── IResourceManager.cs │ └── ISettings.cs ├── DRecorder.Core.csproj ├── FilenameFormat.cs ├── RecordState.cs ├── Settings.cs └── ViewModels │ └── RecordViewModel.cs ├── DRecorder.Test.Console ├── DRecorder.Test.Console.csproj └── Program.cs ├── DRecorder.sln ├── DRecorder ├── .editorconfig ├── App.xaml ├── App.xaml.cs ├── AppSettings.cs ├── Assets │ ├── Fonts │ │ ├── Font Awesome 6 Brands-Regular-400.otf │ │ ├── Font Awesome 6 Free-Regular-400.otf │ │ └── Font Awesome 6 Free-Solid-900.otf │ ├── LargeTile.scale-100.png │ ├── LargeTile.scale-125.png │ ├── LargeTile.scale-150.png │ ├── LargeTile.scale-200.png │ ├── LargeTile.scale-400.png │ ├── LockScreenLogo.scale-200.png │ ├── SmallTile.scale-100.png │ ├── SmallTile.scale-125.png │ ├── SmallTile.scale-150.png │ ├── SmallTile.scale-200.png │ ├── SmallTile.scale-400.png │ ├── SplashScreen.scale-100.png │ ├── SplashScreen.scale-125.png │ ├── SplashScreen.scale-150.png │ ├── SplashScreen.scale-200.png │ ├── SplashScreen.scale-400.png │ ├── Square150x150Logo.scale-100.png │ ├── Square150x150Logo.scale-125.png │ ├── Square150x150Logo.scale-150.png │ ├── Square150x150Logo.scale-200.png │ ├── Square150x150Logo.scale-400.png │ ├── Square44x44Logo.altform-lightunplated_targetsize-16.png │ ├── Square44x44Logo.altform-lightunplated_targetsize-24.png │ ├── Square44x44Logo.altform-lightunplated_targetsize-256.png │ ├── Square44x44Logo.altform-lightunplated_targetsize-32.png │ ├── Square44x44Logo.altform-lightunplated_targetsize-48.png │ ├── Square44x44Logo.altform-unplated_targetsize-16.png │ ├── Square44x44Logo.altform-unplated_targetsize-256.png │ ├── Square44x44Logo.altform-unplated_targetsize-32.png │ ├── Square44x44Logo.altform-unplated_targetsize-48.png │ ├── Square44x44Logo.scale-100.png │ ├── Square44x44Logo.scale-125.png │ ├── Square44x44Logo.scale-150.png │ ├── Square44x44Logo.scale-200.png │ ├── Square44x44Logo.scale-400.png │ ├── Square44x44Logo.targetsize-16.png │ ├── Square44x44Logo.targetsize-24.png │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ ├── Square44x44Logo.targetsize-256.png │ ├── Square44x44Logo.targetsize-32.png │ ├── Square44x44Logo.targetsize-48.png │ ├── StoreLogo.backup.png │ ├── StoreLogo.scale-100.png │ ├── StoreLogo.scale-125.png │ ├── StoreLogo.scale-150.png │ ├── StoreLogo.scale-200.png │ ├── StoreLogo.scale-400.png │ ├── Wide310x150Logo.scale-100.png │ ├── Wide310x150Logo.scale-125.png │ ├── Wide310x150Logo.scale-150.png │ ├── Wide310x150Logo.scale-200.png │ ├── Wide310x150Logo.scale-400.png │ └── drecorder.ico ├── Converters │ ├── EqualEnumToBooleanConverter.cs │ ├── EqualToVisibilityConverter.cs │ └── StringFormatConverter.cs ├── CustomWindow.cs ├── DRecorder.csproj ├── Extensions │ ├── BooleanValueExtension.cs │ └── ResourceExtension.cs ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── NativeMethods.txt ├── Package.appxmanifest ├── Properties │ └── launchSettings.json ├── RecordPanel.xaml ├── RecordPanel.xaml.cs ├── RecordingVisualizer.xaml ├── RecordingVisualizer.xaml.cs ├── SettingsPanel.xaml ├── SettingsPanel.xaml.cs ├── Strings │ ├── en-US │ │ └── Resources.resw │ └── ko-KR │ │ └── Resources.resw ├── app.manifest └── dmrecorder.png ├── LICENSE ├── README.md └── images ├── dark.png ├── light.png └── profile1.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 | -------------------------------------------------------------------------------- /.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 -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | // Use IntelliSense to find out which attributes exist for C# debugging 6 | // Use hover for the description of the existing attributes 7 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/DMRecorder.Test.Console/bin/Debug/net6.0-windows10.0.19041/DMRecorder.Test.Console.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}/DMRecorder.Test.Console", 16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console 17 | "console": "internalConsole", 18 | "stopAtEntry": false 19 | }, 20 | { 21 | "name": ".NET Core Attach", 22 | "type": "coreclr", 23 | "request": "attach" 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/DMRecorder.Test.Console/DMRecorder.Test.Console.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/DMRecorder.Test.Console/DMRecorder.Test.Console.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "--project", 36 | "${workspaceFolder}/DMRecorder.Test.Console/DMRecorder.Test.Console.csproj" 37 | ], 38 | "problemMatcher": "$msCompile" 39 | } 40 | ] 41 | } -------------------------------------------------------------------------------- /DRecorder.Core/AudioRecorder.cs: -------------------------------------------------------------------------------- 1 |  2 | using NAudio.Wave; 3 | 4 | using System.Diagnostics; 5 | 6 | namespace DRecorder.Core; 7 | 8 | public class AudioRecorder 9 | { 10 | private readonly string _driverName; 11 | private readonly int _sampleRate; 12 | private AsioOut? _asioOut; 13 | private float[]? _buffer; 14 | private WaveFileWriter? _writer; 15 | 16 | private AudioFileReader? _reader; 17 | private WaveOutEvent? _waveOutEvent; 18 | 19 | private RecordState _state = RecordState.Stop; 20 | 21 | public static string[] Drivers => AsioOut.GetDriverNames(); 22 | 23 | 24 | public string? RecordPath { get; set; } 25 | 26 | public string? RecordFilename { get; set; } 27 | public bool IsRecording => _state is RecordState.Record or RecordState.RecordPause; 28 | public bool IsPlaying => _state is RecordState.Play or RecordState.PlayPause; 29 | 30 | public AudioRecorder(string path, string driver, int samplerate) 31 | { 32 | RecordPath = path; 33 | _driverName = driver; 34 | _sampleRate = samplerate; 35 | } 36 | 37 | public void Record(Action onStateCallback) 38 | { 39 | if (IsRecording is true) 40 | { 41 | return; 42 | } 43 | 44 | _asioOut = new(_driverName); 45 | _asioOut.InputChannelOffset = 0; 46 | _asioOut.InitRecordAndPlayback(null, 1, _sampleRate); 47 | _buffer = new float[_asioOut.FramesPerBuffer]; 48 | 49 | if (RecordPath is null) 50 | { 51 | return; 52 | } 53 | 54 | if (Directory.Exists(RecordPath) is false) 55 | { 56 | Directory.CreateDirectory(RecordPath); 57 | } 58 | 59 | if (RecordFilename is null) 60 | { 61 | return; 62 | } 63 | 64 | var filename = Path.Combine(RecordPath, RecordFilename); 65 | _writer = new WaveFileWriter(filename, new WaveFormat(_sampleRate, 1)); 66 | var totalCount = 0; 67 | _asioOut.AudioAvailable += (s, e) => 68 | { 69 | // 일시 중지이면 녹음하지 않음 70 | if (_state is RecordState.RecordPause) 71 | { 72 | return; 73 | } 74 | 75 | var count = e.GetAsInterleavedSamples(_buffer); 76 | 77 | // TODO: 임시로 예외 발생하지 않도록 이후 수정할 것 78 | try 79 | { 80 | _writer?.WriteSamples(_buffer, 0, count); 81 | } 82 | catch { } 83 | 84 | totalCount += count; 85 | var recordTimeSpan = TimeSpan.FromSeconds((double)totalCount / _sampleRate); 86 | onStateCallback?.Invoke(new(_state, TimeSpan.FromSeconds(0), recordTimeSpan, _buffer[0])); 87 | }; 88 | 89 | _asioOut.Play(); 90 | 91 | _state = RecordState.Record; 92 | } 93 | 94 | public void Stop() 95 | { 96 | if (IsRecording is false && IsPlaying is false) 97 | { 98 | return; 99 | } 100 | 101 | if (IsRecording is true) 102 | { 103 | _writer?.Dispose(); 104 | _writer = null; 105 | _asioOut?.Dispose(); 106 | _asioOut = null; 107 | } 108 | else if (IsPlaying is true) 109 | { 110 | _waveOutEvent?.Dispose(); 111 | _waveOutEvent = null; 112 | _reader?.Dispose(); 113 | _reader = null; 114 | } 115 | 116 | _state = RecordState.Stop; 117 | } 118 | 119 | public void Pause() 120 | { 121 | if (IsRecording is false && IsPlaying is false) 122 | { 123 | return; 124 | } 125 | 126 | switch (_state) 127 | { 128 | case RecordState.Record: 129 | _state = RecordState.RecordPause; 130 | break; 131 | case RecordState.RecordPause: 132 | _state = RecordState.Record; 133 | break; 134 | case RecordState.Play: 135 | _state = RecordState.PlayPause; 136 | _waveOutEvent!.Pause(); 137 | break; 138 | case RecordState.PlayPause: 139 | _state = RecordState.Play; 140 | _waveOutEvent!.Play(); 141 | break; 142 | 143 | default: 144 | break; 145 | } 146 | } 147 | 148 | public void Play(Action onStateCallback) 149 | { 150 | if (IsPlaying is true) 151 | { 152 | return; 153 | } 154 | 155 | _reader = new AudioFileReader(Path.Combine(RecordPath!, RecordFilename!)); 156 | 157 | var totalTimeSpan = TimeSpan.FromSeconds(_reader.Length / _sampleRate / 4); 158 | 159 | _waveOutEvent = new WaveOutEvent(); 160 | _waveOutEvent.PlaybackStopped += (s, e) => 161 | { 162 | Stop(); 163 | 164 | var audioRecorderState = new AudioRecorderState(_state, totalTimeSpan, TimeSpan.FromSeconds(0)); 165 | onStateCallback?.Invoke(audioRecorderState); 166 | }; 167 | _waveOutEvent.Init(_reader); 168 | _waveOutEvent.Play(); 169 | 170 | // 플레이가 종료되었는지를 감지한다. 171 | _ = Task.Run(() => 172 | { 173 | var waveOut = _waveOutEvent; 174 | while (waveOut is not null && waveOut.PlaybackState is not PlaybackState.Stopped) 175 | { 176 | var posiiton = waveOut.GetPosition(); 177 | var recordTimeSpan = TimeSpan.FromSeconds((double)posiiton / _sampleRate / 4); 178 | onStateCallback?.Invoke(new(_state, totalTimeSpan, recordTimeSpan)); 179 | 180 | Thread.Sleep(50); 181 | } 182 | }); 183 | 184 | _state = RecordState.Play; 185 | } 186 | } 187 | 188 | public record struct AudioRecorderState(RecordState State, TimeSpan TotalTimeSpan, TimeSpan RunningTimeSpan, float RecordValue = 0f); 189 | -------------------------------------------------------------------------------- /DRecorder.Core/Contracts/IDispatcherQueue.cs: -------------------------------------------------------------------------------- 1 | namespace DRecorder.Core.Contracts 2 | { 3 | public interface IDispatcherQueue 4 | { 5 | void TryEnqueue(Action action); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /DRecorder.Core/Contracts/IRecordingObserver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DRecorder.Core.Contracts 8 | { 9 | public interface IRecordingObserver 10 | { 11 | void SendState(RecordState beforeState, RecordState state); 12 | 13 | void SendValue(float value); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DRecorder.Core/Contracts/IResourceManager.cs: -------------------------------------------------------------------------------- 1 | namespace DRecorder.Core.Contracts 2 | { 3 | public interface IResourceManager 4 | { 5 | string GetLocalized(string resourceKey); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /DRecorder.Core/Contracts/ISettings.cs: -------------------------------------------------------------------------------- 1 | namespace DRecorder.Core.Contracts 2 | { 3 | public interface ISettings 4 | { 5 | string RecordDriver { get; set; } 6 | int RecordSampleRate { get; set; } 7 | 8 | string RecordFileFormat { get; set; } 9 | string RecordPath { get; set; } 10 | 11 | void Save(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DRecorder.Core/DRecorder.Core.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net7.0-windows10.0.19041.0 5 | enable 6 | enable 7 | AnyCPU;x64 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /DRecorder.Core/FilenameFormat.cs: -------------------------------------------------------------------------------- 1 | using System.Text.RegularExpressions; 2 | 3 | namespace DRecorder.Core 4 | { 5 | public class FilenameFormat 6 | { 7 | //private Dictionary _formatParams = new(); 8 | private readonly Regex _regex = new(@"{([^}]+)}"); 9 | 10 | public string FilePath { get; } 11 | public string Format { get; set; } 12 | public string Filename => GetName(); 13 | public string Extension { get; } 14 | 15 | public FilenameFormat(string filePath, string format, string extension) 16 | { 17 | FilePath = filePath; 18 | Format = format; 19 | Extension = extension; 20 | } 21 | private string GetName() 22 | { 23 | var name = _regex.Replace(Format, match => 24 | { 25 | var bResult = Enum.TryParse(match.Groups[1].Value, out var patternParam); 26 | if (bResult is false) 27 | { 28 | return match.Value; 29 | } 30 | 31 | return patternParam switch 32 | { 33 | FilenamePatternParams.DATE => DateTime.Now.ToShortDateString(), 34 | _ => "" 35 | }; 36 | }); 37 | 38 | var filename = $"{name}{Extension}"; 39 | 40 | if (File.Exists(Path.Combine(FilePath, filename)) is false) 41 | { 42 | return filename; 43 | } 44 | 45 | var count = 1; 46 | while (true) 47 | { 48 | filename = $"{name}({count}){Extension}"; 49 | if (File.Exists(Path.Combine(FilePath, filename)) is false) 50 | { 51 | return filename; 52 | } 53 | 54 | count++; 55 | } 56 | } 57 | } 58 | 59 | public enum FilenamePatternParams 60 | { 61 | /// 62 | /// 오늘 날짜 63 | /// 64 | DATE, 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /DRecorder.Core/RecordState.cs: -------------------------------------------------------------------------------- 1 | namespace DRecorder.Core 2 | { 3 | public enum RecordState 4 | { 5 | /// 6 | /// 녹음 중지 상태 7 | /// 8 | Stop, 9 | /// 10 | /// 녹음 중 11 | /// 12 | Record, 13 | /// 14 | /// 녹음 일시 정지 15 | /// 16 | RecordPause, 17 | /// 18 | /// 재생 중 19 | /// 20 | Play, 21 | /// 22 | /// 재생 일시 정지 23 | /// 24 | PlayPause 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DRecorder.Core/Settings.cs: -------------------------------------------------------------------------------- 1 | namespace DRecorder.Core; 2 | 3 | using System.Collections.Concurrent; 4 | 5 | using YamlDotNet.Serialization; 6 | using YamlDotNet.Serialization.NamingConventions; 7 | 8 | public abstract class Settings 9 | where T : Settings, new() 10 | { 11 | private static readonly IDeserializer deserializer = new DeserializerBuilder() 12 | .WithNamingConvention(UnderscoredNamingConvention.Instance) 13 | .IgnoreFields() 14 | .Build(); 15 | private static readonly ISerializer serializer = new SerializerBuilder() 16 | .WithNamingConvention(UnderscoredNamingConvention.Instance) 17 | .IgnoreFields() 18 | .Build(); 19 | private static readonly ConcurrentDictionary cache = new(); 20 | 21 | [YamlIgnore] 22 | public string Filepath { get; private set; } 23 | 24 | 25 | protected Settings() 26 | { 27 | Filepath = string.Empty; 28 | } 29 | 30 | protected abstract void SetDefault(); 31 | 32 | public static T Load(string filepath) 33 | { 34 | T result; 35 | 36 | if (cache.ContainsKey(filepath) is true) 37 | { 38 | return cache[filepath]; 39 | } 40 | 41 | if (File.Exists(filepath) is false) 42 | { 43 | result = new T { Filepath = filepath }; 44 | result.SetDefault(); 45 | } 46 | else 47 | { 48 | var yamlText = File.ReadAllText(filepath); 49 | result = deserializer.Deserialize(yamlText); 50 | result.Filepath = filepath; 51 | } 52 | 53 | cache[filepath] = result; 54 | 55 | return result; 56 | } 57 | 58 | public void Save() 59 | { 60 | var directory = Path.GetDirectoryName(Filepath); 61 | if (directory is not null) 62 | { 63 | if (Directory.Exists(directory) is false) 64 | { 65 | Directory.CreateDirectory(directory); 66 | } 67 | } 68 | 69 | var yamlText = serializer.Serialize(this); 70 | File.WriteAllText(Filepath, yamlText); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /DRecorder.Core/ViewModels/RecordViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace DRecorder.Core.ViewModels; 2 | 3 | using CommunityToolkit.Mvvm.ComponentModel; 4 | using CommunityToolkit.Mvvm.Input; 5 | 6 | using DRecorder.Core.Contracts; 7 | 8 | 9 | public partial class RecordViewModel : ObservableRecipient 10 | { 11 | private AudioRecorder _audioRecorder; 12 | //private readonly IResourceManager _reosurceManager; 13 | private readonly FilenameFormat _filenamePattern; 14 | private readonly ISettings _settings; 15 | private readonly IDispatcherQueue _dispatcherQueue; 16 | 17 | [ObservableProperty] 18 | private bool _isShowErrorMessage; 19 | 20 | [ObservableProperty] 21 | private RecordState _recordState; 22 | 23 | [ObservableProperty] 24 | private string? _lastRecordFilename; 25 | 26 | [ObservableProperty] 27 | private TimeSpan _recordingTime; 28 | 29 | [ObservableProperty] 30 | private double _totalPlayTime; 31 | 32 | public double RecordingTimeValue => RecordingTime.TotalSeconds; 33 | 34 | public bool IsRecording => _audioRecorder.IsRecording; 35 | 36 | public bool CanPlay 37 | { 38 | get => LastRecordFilename is not null && File.Exists(Path.Combine(RecordPath, LastRecordFilename)); 39 | } 40 | 41 | public RelayCommand RecordCommand { get; } 42 | 43 | public ISettings Settings => _settings; 44 | 45 | public IRecordingObserver? RecordingObserver { get; set; } 46 | 47 | public string RecordPath 48 | { 49 | get => _settings.RecordPath; 50 | set => _settings.RecordPath = value; 51 | } 52 | 53 | public string RecrodFileFormat 54 | { 55 | get => _settings.RecordFileFormat; 56 | set 57 | { 58 | _settings.RecordFileFormat = value; 59 | 60 | _filenamePattern.Format = value; 61 | OnPropertyChanged(nameof(RecordFilename)); 62 | } 63 | } 64 | 65 | public string RecordFilename 66 | { 67 | get => _filenamePattern.Filename; 68 | } 69 | 70 | public string[] Drivers => AudioRecorder.Drivers; 71 | public int[] SampleRates { get; } = new[] { 48000, 96000 }; 72 | 73 | public RecordViewModel(/*IResourceManager resourceManager, */ISettings settings, IDispatcherQueue dispatcherQueue) 74 | { 75 | //_reosurceManager = resourceManager; 76 | _settings = settings; 77 | _dispatcherQueue = dispatcherQueue; 78 | 79 | _filenamePattern = new(RecordPath, RecrodFileFormat, ".wav"); 80 | var appData = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); 81 | _audioRecorder = new(RecordPath, settings.RecordDriver, settings.RecordSampleRate); 82 | 83 | RecordCommand = new(stateText => 84 | { 85 | var state = Enum.Parse(stateText!); 86 | 87 | switch (state) 88 | { 89 | case RecordState.Play: 90 | _audioRecorder.Play(recorderState => 91 | { 92 | if (recorderState.State is RecordState.Stop) 93 | { 94 | _dispatcherQueue.TryEnqueue(() => 95 | { 96 | RecordState = RecordState.Stop; 97 | 98 | RecordCommand!.NotifyCanExecuteChanged(); 99 | }); 100 | } 101 | else if (recorderState.State is RecordState.Play) 102 | { 103 | _dispatcherQueue.TryEnqueue(() => 104 | { 105 | TotalPlayTime = recorderState.TotalTimeSpan.TotalSeconds; 106 | RecordingTime = recorderState.RunningTimeSpan; 107 | OnPropertyChanged(nameof(RecordingTimeValue)); 108 | }); 109 | } 110 | }); 111 | 112 | //RestartTimer(); 113 | 114 | break; 115 | 116 | case RecordState.PlayPause: 117 | _audioRecorder.Pause(); 118 | 119 | break; 120 | case RecordState.Record: 121 | OnPropertyChanged(nameof(RecordFilename)); 122 | 123 | LastRecordFilename = RecordFilename; 124 | 125 | _audioRecorder.RecordFilename = LastRecordFilename; 126 | 127 | try 128 | { 129 | _audioRecorder.Record(recorderState => 130 | { 131 | RecordingObserver?.SendValue(recorderState.RecordValue); 132 | 133 | _dispatcherQueue.TryEnqueue(() => 134 | { 135 | RecordingTime = recorderState.RunningTimeSpan; 136 | OnPropertyChanged(nameof(RecordingTimeValue)); 137 | }); 138 | }); 139 | } 140 | catch 141 | { 142 | IsShowErrorMessage = true; 143 | state = RecordState.Stop; 144 | } 145 | 146 | break; 147 | case RecordState.RecordPause: 148 | _audioRecorder.Pause(); 149 | 150 | break; 151 | case RecordState.Stop: 152 | _audioRecorder.Stop(); 153 | 154 | break; 155 | } 156 | 157 | RecordingObserver?.SendState(RecordState, state); 158 | RecordState = state; 159 | 160 | RecordCommand!.NotifyCanExecuteChanged(); 161 | OnPropertyChanged(nameof(IsRecording)); 162 | }, state => Enum.Parse(state!) switch 163 | { 164 | RecordState.Play => RecordState is RecordState.Stop && CanPlay is true, 165 | RecordState.Stop => RecordState is RecordState.Play or RecordState.Record or RecordState.RecordPause or RecordState.PlayPause, 166 | RecordState.Record => RecordState is RecordState.Stop, 167 | RecordState.RecordPause => RecordState is RecordState.Record or RecordState.RecordPause or RecordState.Play or RecordState.PlayPause, 168 | _ => false 169 | }); 170 | } 171 | 172 | public bool DeleteLastRecordFile() 173 | { 174 | if (LastRecordFilename is null) 175 | { 176 | return false; 177 | } 178 | 179 | var filename = Path.Combine(RecordPath, LastRecordFilename); 180 | if (File.Exists(filename) is false) 181 | { 182 | return false; 183 | } 184 | 185 | File.Delete(filename); 186 | 187 | OnPropertyChanged(nameof(RecordFilename)); 188 | 189 | return true; 190 | } 191 | 192 | public void RefreshDriver() 193 | { 194 | _audioRecorder = new(RecordPath, Settings.RecordDriver, Settings.RecordSampleRate); 195 | } 196 | } 197 | -------------------------------------------------------------------------------- /DRecorder.Test.Console/DRecorder.Test.Console.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net7.0-windows10.0.19041.0 6 | enable 7 | enable 8 | True 9 | AnyCPU;x64 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /DRecorder.Test.Console/Program.cs: -------------------------------------------------------------------------------- 1 | //using System.Text.RegularExpressions; 2 | 3 | //var text = $"record({{{FilenamePatternParams.DATE}}})({{{FilenamePatternParams.DUPNUM}}})"; 4 | //Console.WriteLine(text); 5 | 6 | //Regex regex = new(@"{([^}]+)}"); 7 | 8 | //var result = regex.Replace(text, match => 9 | //{ 10 | // var bResult = Enum.TryParse(match.Groups[1].Value, out var patternParam); 11 | // if (bResult == false) 12 | // return match.Value; 13 | 14 | // return patternParam switch 15 | // { 16 | // FilenamePatternParams.DATE => DateTime.Now.ToShortDateString(), 17 | // FilenamePatternParams.DUPNUM => "2", 18 | // _ => match.Value 19 | // }; 20 | //}); 21 | //Console.WriteLine(result); 22 | 23 | //public enum FilenamePatternParams 24 | //{ 25 | // /// 26 | // /// 오늘 날짜 27 | // /// 28 | // DATE, 29 | // /// 30 | // /// 중복 파일이름 순번 31 | // /// 32 | // DUPNUM 33 | //} 34 | 35 | 36 | using NAudio.Wave; 37 | 38 | Thread.CurrentThread.SetApartmentState(ApartmentState.Unknown); 39 | Thread.CurrentThread.SetApartmentState(ApartmentState.STA); 40 | 41 | var drivers = AsioOut.GetDriverNames(); 42 | 43 | foreach (var driver in drivers) 44 | { 45 | Console.WriteLine(driver); 46 | } 47 | 48 | var driverName = "Focusrite USB ASIO"; 49 | var sampleRate = 96000; 50 | 51 | using var asioOut = new AsioOut(driverName); 52 | asioOut.InputChannelOffset = 0; 53 | asioOut.InitRecordAndPlayback(null, 1, sampleRate); 54 | 55 | 56 | var buffer = new float[512]; 57 | using var writer = new WaveFileWriter(@"W:\output.wav", new WaveFormat(sampleRate, 1)); 58 | asioOut.AudioAvailable += (s, e) => 59 | { 60 | var count = e.GetAsInterleavedSamples(buffer); 61 | 62 | writer.WriteSamples(buffer, 0, count); 63 | }; 64 | 65 | asioOut.Play(); 66 | 67 | Console.ReadLine(); 68 | 69 | asioOut.Dispose(); 70 | -------------------------------------------------------------------------------- /DRecorder.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.31717.71 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DRecorder.Test.Console", "DRecorder.Test.Console\DRecorder.Test.Console.csproj", "{8C6887D1-3982-49E7-B885-A4DA74D96608}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DRecorder.Core", "DRecorder.Core\DRecorder.Core.csproj", "{0DAADF91-1899-43E3-9C9C-FB0D1614340E}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DRecorder", "DRecorder\DRecorder.csproj", "{41B54217-98F6-48CF-8AF5-9CFFEA55FCAB}" 11 | EndProject 12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B808DC7F-D69A-486B-BEC1-AF8AE87FE423}" 13 | ProjectSection(SolutionItems) = preProject 14 | README.md = README.md 15 | EndProjectSection 16 | EndProject 17 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "images", "images", "{E3F431BB-550F-4549-9440-DF78B0848CC9}" 18 | ProjectSection(SolutionItems) = preProject 19 | images\profile1.png = images\profile1.png 20 | EndProjectSection 21 | EndProject 22 | Global 23 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 24 | Debug|Any CPU = Debug|Any CPU 25 | Debug|arm64 = Debug|arm64 26 | Debug|x64 = Debug|x64 27 | Debug|x86 = Debug|x86 28 | Release|Any CPU = Release|Any CPU 29 | Release|arm64 = Release|arm64 30 | Release|x64 = Release|x64 31 | Release|x86 = Release|x86 32 | EndGlobalSection 33 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 34 | {8C6887D1-3982-49E7-B885-A4DA74D96608}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {8C6887D1-3982-49E7-B885-A4DA74D96608}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {8C6887D1-3982-49E7-B885-A4DA74D96608}.Debug|arm64.ActiveCfg = Debug|Any CPU 37 | {8C6887D1-3982-49E7-B885-A4DA74D96608}.Debug|arm64.Build.0 = Debug|Any CPU 38 | {8C6887D1-3982-49E7-B885-A4DA74D96608}.Debug|x64.ActiveCfg = Debug|x64 39 | {8C6887D1-3982-49E7-B885-A4DA74D96608}.Debug|x64.Build.0 = Debug|x64 40 | {8C6887D1-3982-49E7-B885-A4DA74D96608}.Debug|x86.ActiveCfg = Debug|Any CPU 41 | {8C6887D1-3982-49E7-B885-A4DA74D96608}.Debug|x86.Build.0 = Debug|Any CPU 42 | {8C6887D1-3982-49E7-B885-A4DA74D96608}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {8C6887D1-3982-49E7-B885-A4DA74D96608}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {8C6887D1-3982-49E7-B885-A4DA74D96608}.Release|arm64.ActiveCfg = Release|Any CPU 45 | {8C6887D1-3982-49E7-B885-A4DA74D96608}.Release|arm64.Build.0 = Release|Any CPU 46 | {8C6887D1-3982-49E7-B885-A4DA74D96608}.Release|x64.ActiveCfg = Release|x64 47 | {8C6887D1-3982-49E7-B885-A4DA74D96608}.Release|x64.Build.0 = Release|x64 48 | {8C6887D1-3982-49E7-B885-A4DA74D96608}.Release|x86.ActiveCfg = Release|Any CPU 49 | {8C6887D1-3982-49E7-B885-A4DA74D96608}.Release|x86.Build.0 = Release|Any CPU 50 | {0DAADF91-1899-43E3-9C9C-FB0D1614340E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 51 | {0DAADF91-1899-43E3-9C9C-FB0D1614340E}.Debug|Any CPU.Build.0 = Debug|Any CPU 52 | {0DAADF91-1899-43E3-9C9C-FB0D1614340E}.Debug|arm64.ActiveCfg = Debug|Any CPU 53 | {0DAADF91-1899-43E3-9C9C-FB0D1614340E}.Debug|arm64.Build.0 = Debug|Any CPU 54 | {0DAADF91-1899-43E3-9C9C-FB0D1614340E}.Debug|x64.ActiveCfg = Debug|x64 55 | {0DAADF91-1899-43E3-9C9C-FB0D1614340E}.Debug|x64.Build.0 = Debug|x64 56 | {0DAADF91-1899-43E3-9C9C-FB0D1614340E}.Debug|x86.ActiveCfg = Debug|Any CPU 57 | {0DAADF91-1899-43E3-9C9C-FB0D1614340E}.Debug|x86.Build.0 = Debug|Any CPU 58 | {0DAADF91-1899-43E3-9C9C-FB0D1614340E}.Release|Any CPU.ActiveCfg = Release|Any CPU 59 | {0DAADF91-1899-43E3-9C9C-FB0D1614340E}.Release|Any CPU.Build.0 = Release|Any CPU 60 | {0DAADF91-1899-43E3-9C9C-FB0D1614340E}.Release|arm64.ActiveCfg = Release|Any CPU 61 | {0DAADF91-1899-43E3-9C9C-FB0D1614340E}.Release|arm64.Build.0 = Release|Any CPU 62 | {0DAADF91-1899-43E3-9C9C-FB0D1614340E}.Release|x64.ActiveCfg = Release|x64 63 | {0DAADF91-1899-43E3-9C9C-FB0D1614340E}.Release|x64.Build.0 = Release|x64 64 | {0DAADF91-1899-43E3-9C9C-FB0D1614340E}.Release|x86.ActiveCfg = Release|Any CPU 65 | {0DAADF91-1899-43E3-9C9C-FB0D1614340E}.Release|x86.Build.0 = Release|Any CPU 66 | {41B54217-98F6-48CF-8AF5-9CFFEA55FCAB}.Debug|Any CPU.ActiveCfg = Debug|x86 67 | {41B54217-98F6-48CF-8AF5-9CFFEA55FCAB}.Debug|arm64.ActiveCfg = Debug|arm64 68 | {41B54217-98F6-48CF-8AF5-9CFFEA55FCAB}.Debug|arm64.Build.0 = Debug|arm64 69 | {41B54217-98F6-48CF-8AF5-9CFFEA55FCAB}.Debug|x64.ActiveCfg = Debug|x64 70 | {41B54217-98F6-48CF-8AF5-9CFFEA55FCAB}.Debug|x64.Build.0 = Debug|x64 71 | {41B54217-98F6-48CF-8AF5-9CFFEA55FCAB}.Debug|x64.Deploy.0 = Debug|x64 72 | {41B54217-98F6-48CF-8AF5-9CFFEA55FCAB}.Debug|x86.ActiveCfg = Debug|x86 73 | {41B54217-98F6-48CF-8AF5-9CFFEA55FCAB}.Debug|x86.Build.0 = Debug|x86 74 | {41B54217-98F6-48CF-8AF5-9CFFEA55FCAB}.Release|Any CPU.ActiveCfg = Release|x86 75 | {41B54217-98F6-48CF-8AF5-9CFFEA55FCAB}.Release|arm64.ActiveCfg = Release|arm64 76 | {41B54217-98F6-48CF-8AF5-9CFFEA55FCAB}.Release|arm64.Build.0 = Release|arm64 77 | {41B54217-98F6-48CF-8AF5-9CFFEA55FCAB}.Release|x64.ActiveCfg = Release|x64 78 | {41B54217-98F6-48CF-8AF5-9CFFEA55FCAB}.Release|x64.Build.0 = Release|x64 79 | {41B54217-98F6-48CF-8AF5-9CFFEA55FCAB}.Release|x64.Deploy.0 = Release|x64 80 | {41B54217-98F6-48CF-8AF5-9CFFEA55FCAB}.Release|x86.ActiveCfg = Release|x86 81 | {41B54217-98F6-48CF-8AF5-9CFFEA55FCAB}.Release|x86.Build.0 = Release|x86 82 | EndGlobalSection 83 | GlobalSection(SolutionProperties) = preSolution 84 | HideSolutionNode = FALSE 85 | EndGlobalSection 86 | GlobalSection(NestedProjects) = preSolution 87 | {E3F431BB-550F-4549-9440-DF78B0848CC9} = {B808DC7F-D69A-486B-BEC1-AF8AE87FE423} 88 | EndGlobalSection 89 | GlobalSection(ExtensibilityGlobals) = postSolution 90 | SolutionGuid = {E9496E1D-DED9-4B2E-9788-FDAF021683D3} 91 | EndGlobalSection 92 | EndGlobal 93 | -------------------------------------------------------------------------------- /DRecorder/.editorconfig: -------------------------------------------------------------------------------- 1 | # Rules in this file were initially inferred by Visual Studio IntelliCode from the W:\MyWorks\DRecorder\DRecorder\ codebase based on best match to current usage at 2021-10-28 2 | # You can modify the rules from these initially generated values to suit your own policies 3 | # You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference 4 | [*.cs] 5 | 6 | 7 | #Core editorconfig formatting - indentation 8 | 9 | #use soft tabs (spaces) for indentation 10 | indent_style = space 11 | 12 | #Formatting - indentation options 13 | 14 | #indent switch case contents. 15 | csharp_indent_case_contents = true 16 | #indent switch labels 17 | csharp_indent_switch_labels = true 18 | 19 | #Formatting - new line options 20 | 21 | #place else statements on a new line 22 | csharp_new_line_before_else = true 23 | #require braces to be on a new line for control_blocks, properties, types, accessors, and methods (also known as "Allman" style) 24 | csharp_new_line_before_open_brace = control_blocks, properties, types, accessors, methods 25 | 26 | #Formatting - organize using options 27 | 28 | #do not place System.* using directives before other using directives 29 | dotnet_sort_system_directives_first = false 30 | 31 | #Formatting - spacing options 32 | 33 | #require a space before the colon for bases or interfaces in a type declaration 34 | csharp_space_after_colon_in_inheritance_clause = true 35 | #require a space after a keyword in a control flow statement such as a for loop 36 | csharp_space_after_keywords_in_control_flow_statements = true 37 | #require a space before the colon for bases or interfaces in a type declaration 38 | csharp_space_before_colon_in_inheritance_clause = true 39 | #remove space within empty argument list parentheses 40 | csharp_space_between_method_call_empty_parameter_list_parentheses = false 41 | #remove space between method call name and opening parenthesis 42 | csharp_space_between_method_call_name_and_opening_parenthesis = false 43 | #do not place space characters after the opening parenthesis and before the closing parenthesis of a method call 44 | csharp_space_between_method_call_parameter_list_parentheses = false 45 | #remove space within empty parameter list parentheses for a method declaration 46 | csharp_space_between_method_declaration_empty_parameter_list_parentheses = false 47 | #place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list. 48 | csharp_space_between_method_declaration_parameter_list_parentheses = false 49 | 50 | #Formatting - wrapping options 51 | 52 | #leave code block on separate lines 53 | csharp_preserve_single_line_blocks = false 54 | 55 | #Style - Code block preferences 56 | 57 | #prefer no curly braces if allowed 58 | csharp_prefer_braces = false:suggestion 59 | 60 | #Style - expression bodied member options 61 | 62 | #prefer expression-bodied members for accessors 63 | csharp_style_expression_bodied_accessors = true:suggestion 64 | #prefer block bodies for methods 65 | csharp_style_expression_bodied_methods = false:suggestion 66 | #prefer expression-bodied members for properties 67 | csharp_style_expression_bodied_properties = true:suggestion 68 | 69 | #Style - Expression-level preferences 70 | 71 | #prefer default over default(T) 72 | csharp_prefer_simple_default_expression = true:suggestion 73 | 74 | #Style - implicit and explicit types 75 | 76 | #prefer var over explicit type in all cases, unless overridden by another code style rule 77 | csharp_style_var_elsewhere = true:suggestion 78 | #prefer var is used to declare variables with built-in system types such as int 79 | csharp_style_var_for_built_in_types = true:suggestion 80 | #prefer var when the type is already mentioned on the right-hand side of a declaration expression 81 | csharp_style_var_when_type_is_apparent = true:suggestion 82 | 83 | #Style - language keyword and framework type options 84 | 85 | #prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them 86 | dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion 87 | 88 | #Style - modifier options 89 | 90 | #prefer accessibility modifiers to be declared except for public interface members. This will currently not differ from always and will act as future proofing for if C# adds default interface methods. 91 | dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion 92 | 93 | #Style - Modifier preferences 94 | 95 | #when this rule is set to a list of modifiers, prefer the specified ordering. 96 | csharp_preferred_modifier_order = public,private,protected,sealed,static,override:suggestion 97 | 98 | #Style - Pattern matching 99 | 100 | #prefer pattern matching instead of is expression with type casts 101 | csharp_style_pattern_matching_over_as_with_null_check = true:suggestion 102 | 103 | #Style - qualification options 104 | 105 | #prefer fields not to be prefaced with this. or Me. in Visual Basic 106 | dotnet_style_qualification_for_field = false:suggestion 107 | #prefer methods not to be prefaced with this. or Me. in Visual Basic 108 | dotnet_style_qualification_for_method = false:suggestion 109 | #prefer properties not to be prefaced with this. or Me. in Visual Basic 110 | dotnet_style_qualification_for_property = false:suggestion 111 | 112 | csharp_style_namespace_declarations = file_scoped:warning -------------------------------------------------------------------------------- /DRecorder/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 21 | 22 | true 23 | 24 | 25 | 26 | 27 | 28 | 0,6,4,0 29 | 30 | 0,3,0,0 31 | 4,3,0,0 32 | 33 | 34 | 4,0,0,0 35 | 36 | 0,0,0,0 37 | 38 | 39 | /Assets/Fonts/Font Awesome 6 Brands-Regular-400.otf#Font Awesome 6 Brands 40 | /Assets/Fonts/Font Awesome 6 Free-Regular-400.otf#Font Awesome 6 Free 41 | /Assets/Fonts/Font Awesome 6 Free-Solid-900.otf#Font Awesome 6 Free Solid 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /DRecorder/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using CommunityToolkit.Mvvm.DependencyInjection; 2 | 3 | using DRecorder.Core.Contracts; 4 | using DRecorder.Core.ViewModels; 5 | 6 | using Microsoft.Extensions.DependencyInjection; 7 | using Microsoft.UI.Xaml; 8 | using Microsoft.Windows.ApplicationModel.Resources; 9 | 10 | using System; 11 | using System.ComponentModel; 12 | using System.IO; 13 | 14 | // To learn more about WinUI, the WinUI project structure, 15 | // and more about our project templates, see: http://aka.ms/winui-project-info. 16 | 17 | namespace DRecorder; 18 | 19 | /// 20 | /// Provides application-specific behavior to supplement the default Application class. 21 | /// 22 | public partial class App : Application 23 | { 24 | private static readonly string AppName = "DRecorder"; 25 | 26 | private Window m_window = default!; 27 | 28 | /// 29 | /// Initializes the singleton application object. This is the first line of authored code 30 | /// executed, and as such is the logical equivalent of main() or WinMain(). 31 | /// 32 | public App() 33 | { 34 | InitializeComponent(); 35 | 36 | Ioc.Default.ConfigureServices(ConfigureServices()); 37 | } 38 | 39 | /// 40 | /// Invoked when the application is launched normally by the end user. Other entry points 41 | /// will be used such as when the application is launched to open a specific file. 42 | /// 43 | /// Details about the launch request and process. 44 | protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args) 45 | { 46 | m_window = new MainWindow { 47 | //Icon = "Assets/DRecorder.ico" 48 | }; 49 | m_window.Activate(); 50 | } 51 | 52 | private IServiceProvider ConfigureServices() 53 | { 54 | var s = new ServiceCollection(); 55 | 56 | s.AddSingleton(new ResourceManager()); 57 | 58 | s.AddSingleton(new DispatcherQueue(() => m_window.DispatcherQueue)); 59 | 60 | 61 | // 설정 파일 위치 62 | var appSettingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), AppName); 63 | if (Directory.Exists(appSettingsPath) is false) 64 | Directory.CreateDirectory(appSettingsPath); 65 | var appSettingsFilename = Path.Combine(appSettingsPath, "settings.config"); 66 | s.AddSingleton(AppSettings.Load(appSettingsFilename)); 67 | 68 | //s.AddTransient(); 69 | // 구조가 단순하므로 ViewModel을 싱글톤으로 유지한다. 70 | s.AddSingleton(); 71 | 72 | 73 | return s.BuildServiceProvider(); 74 | } 75 | } 76 | 77 | 78 | public class ResourceManager : Core.Contracts.IResourceManager 79 | { 80 | private readonly ResourceLoader _resLoader = new(); 81 | 82 | public string GetLocalized(string resourceKey) 83 | { 84 | return _resLoader.GetString(resourceKey); 85 | } 86 | } 87 | 88 | public class DispatcherQueue : IDispatcherQueue 89 | { 90 | private readonly Func _dispoacherQueueFunc; 91 | 92 | public DispatcherQueue(Func dispoacherQueueFunc) 93 | { 94 | _dispoacherQueueFunc = dispoacherQueueFunc; 95 | } 96 | 97 | public void TryEnqueue(Action action) 98 | { 99 | try 100 | { 101 | _dispoacherQueueFunc().TryEnqueue(new Microsoft.UI.Dispatching.DispatcherQueueHandler(action)); 102 | } 103 | catch { } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /DRecorder/AppSettings.cs: -------------------------------------------------------------------------------- 1 | using DRecorder.Core; 2 | using DRecorder.Core.Contracts; 3 | using DRecorder.Extensions; 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.IO; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace DRecorder; 13 | 14 | public class AppSettings : Settings, ISettings 15 | { 16 | private static readonly int DefaultSampleRate = 48000; 17 | private static readonly string DefaultRecordPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Voice Records".GetLocalized()); 18 | private static readonly string DefaultRecordFileFormat = $"{"untitled".GetLocalized()}({{DATE}})"; 19 | 20 | public string RecordDriver { get; set; } = default!; 21 | public int RecordSampleRate { get; set; } = DefaultSampleRate; 22 | public string RecordPath { get; set; } = DefaultRecordPath; 23 | public string RecordFileFormat { get; set; } = DefaultRecordFileFormat; 24 | 25 | protected override void SetDefault() 26 | { 27 | RecordDriver = default!; 28 | RecordSampleRate = DefaultSampleRate; 29 | 30 | RecordPath = DefaultRecordPath; 31 | RecordFileFormat = DefaultRecordFileFormat; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /DRecorder/Assets/Fonts/Font Awesome 6 Brands-Regular-400.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Fonts/Font Awesome 6 Brands-Regular-400.otf -------------------------------------------------------------------------------- /DRecorder/Assets/Fonts/Font Awesome 6 Free-Regular-400.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Fonts/Font Awesome 6 Free-Regular-400.otf -------------------------------------------------------------------------------- /DRecorder/Assets/Fonts/Font Awesome 6 Free-Solid-900.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Fonts/Font Awesome 6 Free-Solid-900.otf -------------------------------------------------------------------------------- /DRecorder/Assets/LargeTile.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/LargeTile.scale-100.png -------------------------------------------------------------------------------- /DRecorder/Assets/LargeTile.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/LargeTile.scale-125.png -------------------------------------------------------------------------------- /DRecorder/Assets/LargeTile.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/LargeTile.scale-150.png -------------------------------------------------------------------------------- /DRecorder/Assets/LargeTile.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/LargeTile.scale-200.png -------------------------------------------------------------------------------- /DRecorder/Assets/LargeTile.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/LargeTile.scale-400.png -------------------------------------------------------------------------------- /DRecorder/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /DRecorder/Assets/SmallTile.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/SmallTile.scale-100.png -------------------------------------------------------------------------------- /DRecorder/Assets/SmallTile.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/SmallTile.scale-125.png -------------------------------------------------------------------------------- /DRecorder/Assets/SmallTile.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/SmallTile.scale-150.png -------------------------------------------------------------------------------- /DRecorder/Assets/SmallTile.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/SmallTile.scale-200.png -------------------------------------------------------------------------------- /DRecorder/Assets/SmallTile.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/SmallTile.scale-400.png -------------------------------------------------------------------------------- /DRecorder/Assets/SplashScreen.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/SplashScreen.scale-100.png -------------------------------------------------------------------------------- /DRecorder/Assets/SplashScreen.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/SplashScreen.scale-125.png -------------------------------------------------------------------------------- /DRecorder/Assets/SplashScreen.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/SplashScreen.scale-150.png -------------------------------------------------------------------------------- /DRecorder/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /DRecorder/Assets/SplashScreen.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/SplashScreen.scale-400.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square150x150Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square150x150Logo.scale-100.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square150x150Logo.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square150x150Logo.scale-125.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square150x150Logo.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square150x150Logo.scale-150.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square150x150Logo.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square150x150Logo.scale-400.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square44x44Logo.altform-lightunplated_targetsize-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square44x44Logo.altform-lightunplated_targetsize-16.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square44x44Logo.altform-lightunplated_targetsize-24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square44x44Logo.altform-lightunplated_targetsize-24.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square44x44Logo.altform-lightunplated_targetsize-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square44x44Logo.altform-lightunplated_targetsize-256.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square44x44Logo.altform-lightunplated_targetsize-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square44x44Logo.altform-lightunplated_targetsize-32.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square44x44Logo.altform-lightunplated_targetsize-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square44x44Logo.altform-lightunplated_targetsize-48.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square44x44Logo.altform-unplated_targetsize-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square44x44Logo.altform-unplated_targetsize-16.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square44x44Logo.altform-unplated_targetsize-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square44x44Logo.altform-unplated_targetsize-256.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square44x44Logo.altform-unplated_targetsize-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square44x44Logo.altform-unplated_targetsize-32.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square44x44Logo.altform-unplated_targetsize-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square44x44Logo.altform-unplated_targetsize-48.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square44x44Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square44x44Logo.scale-100.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square44x44Logo.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square44x44Logo.scale-125.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square44x44Logo.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square44x44Logo.scale-150.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square44x44Logo.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square44x44Logo.scale-400.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square44x44Logo.targetsize-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square44x44Logo.targetsize-16.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square44x44Logo.targetsize-24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square44x44Logo.targetsize-24.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square44x44Logo.targetsize-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square44x44Logo.targetsize-256.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square44x44Logo.targetsize-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square44x44Logo.targetsize-32.png -------------------------------------------------------------------------------- /DRecorder/Assets/Square44x44Logo.targetsize-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Square44x44Logo.targetsize-48.png -------------------------------------------------------------------------------- /DRecorder/Assets/StoreLogo.backup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/StoreLogo.backup.png -------------------------------------------------------------------------------- /DRecorder/Assets/StoreLogo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/StoreLogo.scale-100.png -------------------------------------------------------------------------------- /DRecorder/Assets/StoreLogo.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/StoreLogo.scale-125.png -------------------------------------------------------------------------------- /DRecorder/Assets/StoreLogo.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/StoreLogo.scale-150.png -------------------------------------------------------------------------------- /DRecorder/Assets/StoreLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/StoreLogo.scale-200.png -------------------------------------------------------------------------------- /DRecorder/Assets/StoreLogo.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/StoreLogo.scale-400.png -------------------------------------------------------------------------------- /DRecorder/Assets/Wide310x150Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Wide310x150Logo.scale-100.png -------------------------------------------------------------------------------- /DRecorder/Assets/Wide310x150Logo.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Wide310x150Logo.scale-125.png -------------------------------------------------------------------------------- /DRecorder/Assets/Wide310x150Logo.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Wide310x150Logo.scale-150.png -------------------------------------------------------------------------------- /DRecorder/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /DRecorder/Assets/Wide310x150Logo.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/Wide310x150Logo.scale-400.png -------------------------------------------------------------------------------- /DRecorder/Assets/drecorder.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/Assets/drecorder.ico -------------------------------------------------------------------------------- /DRecorder/Converters/EqualEnumToBooleanConverter.cs: -------------------------------------------------------------------------------- 1 | using DRecorder.Core; 2 | 3 | using Microsoft.UI.Xaml.Data; 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace DRecorder.Converters; 12 | 13 | public class RecordStateEqualToBooleanConverter : IValueConverter 14 | { 15 | public object Convert(object value, Type targetType, object parameter, string language) 16 | { 17 | if (value is null || parameter is null) 18 | return false; 19 | 20 | var parameterString = $"{parameter?.ToString()}"; 21 | var @params = parameterString.Split('|', StringSplitOptions.TrimEntries); 22 | return @params.Any(x => value.Equals(Enum.Parse(x)) is true); 23 | } 24 | 25 | public object ConvertBack(object value, Type targetType, object parameter, string language) 26 | { 27 | if (value is null) 28 | return null!; 29 | 30 | var param = Enum.Parse(parameter.ToString()!); 31 | return param; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /DRecorder/Converters/EqualToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.UI.Xaml; 2 | using Microsoft.UI.Xaml.Data; 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace DRecorder.Converters; 11 | 12 | public class EqualToVisibilityConverter : IValueConverter 13 | { 14 | public object? Value 15 | { 16 | get; set; 17 | } 18 | 19 | public Visibility EqualVisibility 20 | { 21 | get; set; 22 | } 23 | 24 | public Visibility NotEqualVisibility 25 | { 26 | get; set; 27 | } 28 | 29 | public object Convert(object value, Type targetType, object parameter, string language) 30 | { 31 | if (value?.Equals(Value) == true) 32 | return EqualVisibility; 33 | 34 | return NotEqualVisibility; 35 | } 36 | 37 | public object ConvertBack(object value, Type targetType, object parameter, string language) 38 | { 39 | if (value is not Visibility v) 40 | return null!; 41 | 42 | if (Value is bool bValue) 43 | { 44 | return v == EqualVisibility ? bValue : !bValue; 45 | } 46 | else 47 | return null!; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /DRecorder/Converters/StringFormatConverter.cs: -------------------------------------------------------------------------------- 1 |  2 | using Microsoft.UI.Xaml.Data; 3 | 4 | using System; 5 | 6 | namespace DRecorder.Converters; 7 | 8 | public class StringFormatConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, string language) 11 | { 12 | if (value is null) 13 | return null!; 14 | 15 | if (parameter is not string stringParameter) 16 | return value; 17 | 18 | return string.Format(stringParameter, value); 19 | } 20 | 21 | public object ConvertBack(object value, Type targetType, object parameter, string language) 22 | { 23 | throw new NotImplementedException(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /DRecorder/CustomWindow.cs: -------------------------------------------------------------------------------- 1 | namespace DRecorder; 2 | 3 | using Microsoft.UI.Windowing; 4 | using Microsoft.UI.Xaml; 5 | 6 | using WinRT.Interop; 7 | 8 | using Windows.UI; 9 | using Microsoft.UI; 10 | 11 | //using Windows.Win32.Foundation; 12 | //using Windows.Win32.UI.WindowsAndMessaging; 13 | //using Windows.Win32; 14 | using Windows.Foundation; 15 | 16 | 17 | public class CustomWindow : Window 18 | { 19 | private WindowLocationKind _windowLocation; 20 | private ElementTheme _appTheme; 21 | private AppWindow _appWindow; 22 | 23 | public event TypedEventHandler Closing 24 | { 25 | add 26 | { 27 | _appWindow.Closing += value; 28 | } 29 | remove 30 | { 31 | _appWindow.Closing -= value; 32 | } 33 | } 34 | 35 | public int Width 36 | { 37 | get => _appWindow.Size.Width; 38 | set => _appWindow.Resize(new(value, Height)); 39 | } 40 | 41 | public int Height 42 | { 43 | get => _appWindow.Size.Height; 44 | set => _appWindow.Resize(new(Width, value)); 45 | } 46 | 47 | public AppWindowPresenterKind Presenter 48 | { 49 | get => _appWindow.Presenter.Kind; 50 | set => _appWindow.SetPresenter(value); 51 | } 52 | 53 | public bool IsMaximize 54 | { 55 | get 56 | { 57 | var presneter = _appWindow.Presenter; 58 | if (presneter is not OverlappedPresenter olPresenter) 59 | return false; 60 | 61 | return olPresenter.IsMaximizable; 62 | } 63 | 64 | set 65 | { 66 | var presneter = _appWindow.Presenter; 67 | if (presneter is not OverlappedPresenter olPresenter) 68 | return; 69 | 70 | if (value is true) 71 | DispatcherQueue.TryEnqueue(() => olPresenter.Maximize()); 72 | } 73 | } 74 | 75 | public string Icon 76 | { 77 | set 78 | { 79 | _appWindow.SetIcon(value); 80 | //ModifyIcon(value); 81 | } 82 | } 83 | 84 | /// 85 | /// TODO: AppWindow.TitleBar를 통한 TitleBar 색 변경은 Windows App SDK 버젼이 올라가면 다르게 동작할 수 있다. 86 | /// 87 | public ElementTheme Theme 88 | { 89 | get => _appTheme; 90 | set 91 | { 92 | if (value == default) 93 | value = (Content as FrameworkElement)!.ActualTheme is ElementTheme.Light ? ElementTheme.Light : ElementTheme.Dark; 94 | 95 | if (_appTheme == value) 96 | return; 97 | _appTheme = value; 98 | 99 | var titleBar = _appWindow.TitleBar; 100 | if (titleBar is null) 101 | return; 102 | 103 | if (_appTheme is ElementTheme.Light) 104 | { 105 | titleBar.ForegroundColor = Colors.Black; 106 | titleBar.BackgroundColor = Colors.White; 107 | titleBar.InactiveForegroundColor = Colors.Gray; 108 | titleBar.InactiveBackgroundColor = Colors.White; 109 | 110 | titleBar.ButtonForegroundColor = Colors.Black; 111 | titleBar.ButtonBackgroundColor = Colors.White; 112 | titleBar.ButtonInactiveForegroundColor = Colors.Gray; 113 | titleBar.ButtonInactiveBackgroundColor = Colors.White; 114 | 115 | titleBar.ButtonHoverForegroundColor = Colors.Black; 116 | titleBar.ButtonHoverBackgroundColor = Color.FromArgb(255, 245, 245, 245); 117 | titleBar.ButtonPressedForegroundColor = Colors.Black; 118 | titleBar.ButtonPressedBackgroundColor = Colors.White; 119 | } 120 | else if (_appTheme is ElementTheme.Dark) 121 | { 122 | titleBar.ForegroundColor = Colors.White; 123 | titleBar.BackgroundColor = Color.FromArgb(255, 31, 31, 31); 124 | titleBar.InactiveForegroundColor = Colors.Gray; 125 | titleBar.InactiveBackgroundColor = Color.FromArgb(255, 31, 31, 31); 126 | 127 | titleBar.ButtonForegroundColor = Colors.White; 128 | titleBar.ButtonBackgroundColor = Color.FromArgb(255, 31, 31, 31); 129 | titleBar.ButtonInactiveForegroundColor = Colors.Gray; 130 | titleBar.ButtonInactiveBackgroundColor = Color.FromArgb(255, 31, 31, 31); 131 | 132 | titleBar.ButtonHoverForegroundColor = Colors.White; 133 | titleBar.ButtonHoverBackgroundColor = Color.FromArgb(255, 51, 51, 51); 134 | titleBar.ButtonPressedForegroundColor = Colors.White; 135 | titleBar.ButtonPressedBackgroundColor = Colors.Gray; 136 | } 137 | 138 | // 아이콘 배경 색이 적용 안되는 버그 수정 139 | titleBar.IconShowOptions = IconShowOptions.HideIconAndSystemMenu; 140 | titleBar.IconShowOptions = IconShowOptions.ShowIconAndSystemMenu; 141 | } 142 | } 143 | 144 | public WindowLocationKind WindowLocation 145 | { 146 | get => _windowLocation; 147 | set 148 | { 149 | if (value == _windowLocation) 150 | return; 151 | 152 | _windowLocation = value; 153 | switch (value) 154 | { 155 | case WindowLocationKind.Default: 156 | break; 157 | case WindowLocationKind.PrimaryCenter: 158 | var displayArea = DisplayArea.Primary; 159 | var x = (displayArea.WorkArea.Width - Width) / 2; 160 | var y = (displayArea.WorkArea.Height - Height) / 2; 161 | _appWindow.MoveAndResize(new(x, y, Width, Height), displayArea); 162 | break; 163 | } 164 | } 165 | } 166 | 167 | //private unsafe void ModifyIcon(string iconPath) 168 | //{ 169 | // var hwnd = (HWND)WindowNative.GetWindowHandle(this); 170 | 171 | // const int ICON_SMALL = 0; 172 | // const int ICON_BIG = 1; 173 | 174 | // fixed (char* nameLocal = iconPath) 175 | // { 176 | // var imageHandle = PInvoke.LoadImage(default, 177 | // nameLocal, 178 | // GDI_IMAGE_TYPE.IMAGE_ICON, 179 | // PInvoke.GetSystemMetrics(SYSTEM_METRICS_INDEX.SM_CXSMICON), 180 | // PInvoke.GetSystemMetrics(SYSTEM_METRICS_INDEX.SM_CYSMICON), 181 | // IMAGE_FLAGS.LR_LOADFROMFILE | IMAGE_FLAGS.LR_SHARED); 182 | // PInvoke.SendMessage(hwnd, PInvoke.WM_SETICON, ICON_SMALL, imageHandle.Value); 183 | // } 184 | 185 | // fixed (char* nameLocal = iconPath) 186 | // { 187 | // var imageHandle = PInvoke.LoadImage(default, 188 | // nameLocal, 189 | // GDI_IMAGE_TYPE.IMAGE_ICON, 190 | // PInvoke.GetSystemMetrics(SYSTEM_METRICS_INDEX.SM_CXSMICON), 191 | // PInvoke.GetSystemMetrics(SYSTEM_METRICS_INDEX.SM_CYSMICON), 192 | // IMAGE_FLAGS.LR_LOADFROMFILE | IMAGE_FLAGS.LR_SHARED); 193 | // PInvoke.SendMessage(hwnd, PInvoke.WM_SETICON, ICON_BIG, imageHandle.Value); 194 | // } 195 | //} 196 | 197 | public CustomWindow() 198 | { 199 | _appWindow = GetAppWindowForCurrentWidow(); 200 | } 201 | 202 | private AppWindow GetAppWindowForCurrentWidow() 203 | { 204 | var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this); 205 | var winId = Win32Interop.GetWindowIdFromWindow(hWnd); 206 | return AppWindow.GetFromWindowId(winId); 207 | } 208 | } 209 | 210 | public enum WindowLocationKind 211 | { 212 | Default, 213 | PrimaryCenter, 214 | } 215 | -------------------------------------------------------------------------------- /DRecorder/DRecorder.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | WinExe 4 | net7.0-windows10.0.19041.0 5 | 6 | enable 7 | 10.0.17763.0 8 | DRecorder 9 | app.manifest 10 | x86;x64;arm64 11 | win10-x86;win10-x64;win10-arm64 12 | win10-$(Platform).pubxml 13 | true 14 | true 15 | 16 | 17 | true 18 | Assets\DRecorder.ico 19 | true 20 | False 21 | True 22 | SHA256 23 | False 24 | False 25 | False 26 | Never 27 | 0 28 | W:\MyWorks\DRecorder\DRecorder\bin\AppPackages\ 29 | x64 30 | True 31 | DRecorder_TemporaryKey.pfx 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | PreserveNewest 68 | 69 | 70 | PreserveNewest 71 | 72 | 73 | PreserveNewest 74 | 75 | 76 | PreserveNewest 77 | 78 | 79 | 80 | 81 | 82 | MSBuild:Compile 83 | 84 | 85 | 86 | 87 | 88 | MSBuild:Compile 89 | 90 | 91 | 92 | 93 | 94 | MSBuild:Compile 95 | 96 | 97 | 98 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /DRecorder/Extensions/BooleanValueExtension.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.UI.Xaml.Markup; 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace DRecorder.Extensions; 10 | 11 | public sealed class BooleanValueExtension : MarkupExtension 12 | { 13 | public bool Value 14 | { 15 | get; set; 16 | } 17 | 18 | public BooleanValueExtension() 19 | { 20 | } 21 | 22 | public BooleanValueExtension(bool value) => Value = value; 23 | 24 | 25 | protected override object ProvideValue() => Value!; 26 | } 27 | -------------------------------------------------------------------------------- /DRecorder/Extensions/ResourceExtension.cs: -------------------------------------------------------------------------------- 1 | namespace DRecorder.Extensions; 2 | 3 | using Microsoft.Windows.ApplicationModel.Resources; 4 | 5 | public static class ResourceExtension 6 | { 7 | private static readonly ResourceLoader _resLoader = new(); 8 | 9 | public static string GetLocalized(this string resourceKey) 10 | { 11 | return _resLoader.GetString(resourceKey); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DRecorder/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 27 | 37 | 47 | 57 | 58 | 59 | 60 | 61 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 81 | 82 | 83 | 84 | 85 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /DRecorder/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace DRecorder; 2 | 3 | using CommunityToolkit.Mvvm.DependencyInjection; 4 | 5 | using DRecorder.Core.ViewModels; 6 | using DRecorder.Extensions; 7 | 8 | using Microsoft.UI.Windowing; 9 | using Microsoft.UI.Xaml; 10 | using Microsoft.UI.Xaml.Controls; 11 | 12 | using System; 13 | using System.IO; 14 | 15 | using Windows.Storage; 16 | using Windows.System; 17 | 18 | /// 19 | /// An empty window that can be used on its own or navigated to within a Frame. 20 | /// 21 | public sealed partial class MainWindow : Window 22 | { 23 | public RecordViewModel ViewModel { get; } 24 | 25 | public MainWindow() 26 | { 27 | this.InitializeComponent(); 28 | 29 | ViewModel = Ioc.Default.GetRequiredService(); 30 | 31 | //var content = (Content as FrameworkElement)!; 32 | //this.Theme = content.ActualTheme; 33 | //content.ActualThemeChanged += (s, e) => this.Theme = content.ActualTheme; 34 | 35 | Title = "ApplicationTitle".GetLocalized(); 36 | 37 | AppWindow.SetPresenter(AppWindowPresenterKind.CompactOverlay); 38 | var width = 210; 39 | var height = 180; 40 | var workArea = DisplayArea.Primary.WorkArea; 41 | AppWindow.MoveAndResize(new((workArea.Width - width) / 2, (workArea.Height - height) / 2, width, height), DisplayArea.Primary); 42 | AppWindow.Closing += MainWindow_Closing; 43 | //AppWindow.SetIcon() 44 | } 45 | 46 | private async void openFolderButton_Click(object sender, RoutedEventArgs e) 47 | { 48 | var path = ViewModel.RecordPath; 49 | 50 | var folder = await StorageFolder.GetFolderFromPathAsync(path); 51 | await Launcher.LaunchFolderAsync(folder); 52 | } 53 | 54 | private void settingCloseButton_Click(object sender, RoutedEventArgs e) 55 | { 56 | ViewModel.Settings.Save(); 57 | ViewModel.RefreshDriver(); 58 | 59 | recordPanel.Visibility = Visibility.Visible; 60 | settingPanel.Visibility = Visibility.Collapsed; 61 | } 62 | 63 | private void settingButton_Click(object sender, RoutedEventArgs e) 64 | { 65 | recordPanel.Visibility = Visibility.Collapsed; 66 | settingPanel.Visibility = Visibility.Visible; 67 | } 68 | 69 | private void deleteFileButton_Click(object sender, RoutedEventArgs e) 70 | { 71 | var bResult = ViewModel.DeleteLastRecordFile(); 72 | 73 | if (bResult is true) 74 | { 75 | 76 | } 77 | } 78 | 79 | private void MainWindow_Closing(Microsoft.UI.Windowing.AppWindow sender, Microsoft.UI.Windowing.AppWindowClosingEventArgs args) 80 | { 81 | //args.Cancel = true; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /DRecorder/NativeMethods.txt: -------------------------------------------------------------------------------- 1 | LoadImage 2 | SendMessage 3 | WM_SETICON 4 | GetSystemMetrics 5 | 6 | 7 | -------------------------------------------------------------------------------- /DRecorder/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 9 | 10 | 14 | 15 | 16 | DRecorder 17 | dimohy 18 | Assets\StoreLogo.png 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /DRecorder/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Package": { 4 | "commandName": "MsixPackage" 5 | }, 6 | "Unpackaged": { 7 | "commandName": "Project" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /DRecorder/RecordPanel.xaml: -------------------------------------------------------------------------------- 1 |  13 | 14 | 15 | 16 | 17 | 22 | 23 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 43 | 44 | 49 | 50 | 51 | 52 | 53 | 54 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 71 | 72 | 76 | 77 | 78 | 79 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 99 | 105 | 109 | 114 | 115 | 121 | 122 | 128 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /DRecorder/RecordPanel.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace DRecorder; 2 | 3 | using CommunityToolkit.Mvvm.DependencyInjection; 4 | 5 | using DRecorder.Core; 6 | using DRecorder.Core.Contracts; 7 | using DRecorder.Core.ViewModels; 8 | 9 | using Microsoft.UI.Xaml.Controls; 10 | 11 | public sealed partial class RecordPanel : UserControl, IRecordingObserver 12 | { 13 | public RecordViewModel ViewModel { get; } 14 | 15 | 16 | public RecordPanel() 17 | { 18 | ViewModel = Ioc.Default.GetRequiredService(); 19 | ViewModel.RecordingObserver = this; 20 | 21 | this.InitializeComponent(); 22 | } 23 | 24 | public void SendValue(float value) 25 | { 26 | recordingVisualizer.AddValue(value); 27 | } 28 | 29 | public void SendState(RecordState beforeState, RecordState state) 30 | { 31 | if (beforeState is RecordState.Stop && state is RecordState.Record) 32 | recordingVisualizer.ClearValues(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /DRecorder/RecordingVisualizer.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /DRecorder/RecordingVisualizer.xaml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Graphics.Canvas; 2 | using Microsoft.UI; 3 | using Microsoft.UI.Xaml; 4 | using Microsoft.UI.Xaml.Controls; 5 | using Microsoft.UI.Xaml.Controls.Primitives; 6 | using Microsoft.UI.Xaml.Data; 7 | using Microsoft.UI.Xaml.Input; 8 | using Microsoft.UI.Xaml.Media; 9 | using Microsoft.UI.Xaml.Navigation; 10 | 11 | using System; 12 | using System.Collections.Generic; 13 | using System.Diagnostics; 14 | using System.IO; 15 | using System.Linq; 16 | using System.Runtime.InteropServices.WindowsRuntime; 17 | using System.Threading; 18 | using System.Threading.Tasks; 19 | 20 | using Windows.Foundation; 21 | using Windows.Foundation.Collections; 22 | using Windows.UI; 23 | 24 | // To learn more about WinUI, the WinUI project structure, 25 | // and more about our project templates, see: http://aka.ms/winui-project-info. 26 | 27 | namespace DRecorder; 28 | public sealed partial class RecordingVisualizer : UserControl 29 | { 30 | private readonly Queue _valueQueue = new(); 31 | private readonly object _queueLock = new(); 32 | 33 | private Size _size; 34 | 35 | // 렌더링 관련 필드 {{{ 36 | private bool _isRendererTask; 37 | private CancellationTokenSource? _renderTaskCts; 38 | private readonly ManualResetEventSlim _renderTaskEvent = new(); 39 | private Task? _renderTask; 40 | // }}} 41 | 42 | private int MaxQueueCount => (int)_size.Width; 43 | 44 | public RecordingVisualizer() 45 | { 46 | InitializeComponent(); 47 | 48 | Unloaded += (s, e) => 49 | { 50 | if (_renderTaskCts is not null) 51 | { 52 | _renderTaskCts.Cancel(); 53 | _renderTask!.Wait(); 54 | } 55 | 56 | canvas.RemoveFromVisualTree(); 57 | canvas = null; 58 | }; 59 | } 60 | 61 | public void ClearValues() 62 | { 63 | lock (_queueLock) 64 | { 65 | _valueQueue.Clear(); 66 | } 67 | 68 | Invalidate(); 69 | } 70 | 71 | public void AddValue(float value) 72 | { 73 | lock (_queueLock) 74 | { 75 | _valueQueue.Enqueue(value); 76 | 77 | while (_valueQueue.Count > MaxQueueCount) 78 | _valueQueue.Dequeue(); 79 | } 80 | 81 | Invalidate(); 82 | } 83 | 84 | public void Invalidate() 85 | { 86 | _renderTaskEvent.Set(); 87 | } 88 | 89 | private void canvas_SizeChanged(object sender, SizeChangedEventArgs e) 90 | { 91 | _size = e.NewSize; 92 | 93 | if (_isRendererTask == false) 94 | { 95 | Render(_size, 0); 96 | 97 | _isRendererTask = true; 98 | 99 | _renderTaskCts = new(); 100 | _renderTask = Task.Run(() => { 101 | while (_renderTaskCts.Token.IsCancellationRequested == false) 102 | { 103 | try 104 | { 105 | _renderTaskEvent.Wait(_renderTaskCts.Token); 106 | _renderTaskEvent.Reset(); 107 | 108 | Render(_size, 0); 109 | } 110 | catch (OperationCanceledException) 111 | { 112 | return; 113 | } 114 | } 115 | 116 | // Canvas 자원 해제 117 | Render(new(0, 0), 0); 118 | }, _renderTaskCts.Token); 119 | } 120 | } 121 | 122 | private bool Render(Windows.Foundation.Size size, int syncInterval) 123 | { 124 | var bResult = false; 125 | 126 | // 보이지 않는 사이즈면 SwapChain 정리 127 | if (size.Width <= 0 || size.Height <= 0) 128 | { 129 | canvas.SwapChain?.Dispose(); 130 | //canvas.SwapChain = null; 131 | 132 | return false; 133 | } 134 | // SwapChain이 없으면 생성 135 | else if (canvas.SwapChain is null) 136 | { 137 | var device = CanvasDevice.GetSharedDevice(); 138 | var swapChain = new CanvasSwapChain(device, (float)size.Width, (float)size.Height, 96); 139 | canvas.SwapChain = swapChain; 140 | } 141 | // 사이즈가 변경되었으면 버퍼 재조정 142 | else if (canvas.SwapChain.Size != size) 143 | { 144 | canvas.SwapChain.ResizeBuffers(size); 145 | } 146 | 147 | // 그리기 148 | using (var ds = canvas.SwapChain!.CreateDrawingSession(Colors.Transparent)) 149 | { 150 | var x = (float)_size.Width; 151 | var oX = x; 152 | var centerY = (float)_size.Height / 2; 153 | var oY = centerY; 154 | 155 | lock (_queueLock) 156 | { 157 | foreach (var value in _valueQueue.Reverse()) 158 | { 159 | 160 | var y = (float)(value * 50 + centerY); 161 | 162 | ds.DrawLine(oX, oY, x, y, Colors.Red); 163 | 164 | (oX, oY) = (x, y); 165 | x--; 166 | } 167 | } 168 | } 169 | 170 | // 1 = 모니터 주사율에 맞춤, 0 = 최대 속도 171 | canvas.SwapChain.Present(syncInterval); 172 | 173 | return bResult; 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /DRecorder/SettingsPanel.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 15 | 16 | 21 | 22 | 23 | 27 | 31 | 32 | 44100 33 | 96000 34 | 35 | 36 | Hz 37 | 38 | 39 | 40 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /DRecorder/SettingsPanel.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace DRecorder; 2 | 3 | using Microsoft.UI.Xaml.Controls; 4 | 5 | using DRecorder.Core.ViewModels; 6 | using CommunityToolkit.Mvvm.DependencyInjection; 7 | 8 | public sealed partial class SettingsPanel : UserControl 9 | { 10 | public RecordViewModel ViewModel { get; } 11 | 12 | public SettingsPanel() 13 | { 14 | ViewModel = Ioc.Default.GetRequiredService(); 15 | 16 | this.InitializeComponent(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /DRecorder/Strings/en-US/Resources.resw: -------------------------------------------------------------------------------- 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 | 121 | DRecorder 122 | 123 | 124 | Input Device 125 | 126 | 127 | Error 128 | 129 | 130 | Input 131 | 132 | 133 | Record Filename 134 | 135 | 136 | Record Name 137 | 138 | 139 | Sample Rate 140 | 141 | 142 | Settings 143 | 144 | 145 | untitled 146 | 147 | 148 | Voice Records 149 | 150 | -------------------------------------------------------------------------------- /DRecorder/Strings/ko-KR/Resources.resw: -------------------------------------------------------------------------------- 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 | 121 | DRecorder 122 | 123 | 124 | 입력 장치 125 | 126 | 127 | 오류 128 | 129 | 130 | 입력 131 | 132 | 133 | 녹음 파일명 134 | 135 | 136 | 녹음 이름 137 | 138 | 139 | 샘플링 속도 140 | 141 | 142 | 설정 143 | 144 | 145 | 제목없음 146 | 147 | 148 | 음성 녹음 149 | 150 | -------------------------------------------------------------------------------- /DRecorder/app.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | true/PM 12 | PerMonitorV2, PerMonitor 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /DRecorder/dmrecorder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/DRecorder/dmrecorder.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 dimohy 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![image](https://user-images.githubusercontent.com/58620778/153425356-f81520e3-4761-4544-a8a3-39a873943f3d.png) 2 | 3 | # DRecorder 4 | 5 | DRecorder는 Windows App SDK 및 WinUI 3을 학습하기 위해 만든 간단한 녹음기 애플리케이션입니다. DRecorder를 통해 다음의 Windows App SDK 및 WinUI 3의 기능을 확인할 수 있습니다. 6 | 7 | 8 | ## 컴파일 환경 9 | 10 | - Windows 10 (19041) 이상 실행 가능 11 | - .NET 6 12 | - Visual Studio 2022 13 | - Windows App SDK 1.0 14 | - Single-project MSIX Packaging Tool for VS 2022 15 | 16 | 17 | ## 단일 패키지 18 | 19 | 원래 WinUI 3 프로젝트는 단일 패키지를 지원하지 않았습니다. 기본 프로젝트 구성은 애플리케이션 프로젝트와 패키지 프로젝트로 놔눠져 있었습니다. 이제 Windows App SDK의 단일 패키지 기능으로 응용 애플리케이션이면서 배포할 수 있는 단일 프로젝트로 구성할 수 있습니다. 20 | 21 | ![단일패키지](https://docs.microsoft.com/ko-kr/windows/apps/windows-app-sdk/images/single-project-overview.png) 22 | 23 | 단일 패키지는 이제 프로젝트 템플릿을 통해 쉽게 구성할 수 있습니다. `확장 관리`를 통해 `Single-project MSIX Packaging Tool for VS 2022`를 설치해야 합니다. 24 | 25 | 단일 패키지 지원은 아직 `Preview` 상태이므로 csproj 파일에 다음의 설정이 포함되어 있어야 합니다. 26 | 27 | ```xaml 28 | true 29 | ``` 30 | 31 | 32 | ## 패키지, 비패키지 실행 33 | 34 | Windows App SDK는 이제 `패키지` 실행과 `비패키지` 실행 모두 지원합니다. 패키지는 기존 MSIX으로 패키징 해서 설치하는 방식인데 Microsoft Store에 배포할 때 사용할 수 있습니다. 또한 비패키징 방식도 지원하는데 기존 설치툴을 그대로 이용하거나 개발시 `배포 시간`이 단축되므로 좀 더 빠르게 개발을 진행할 수 있습니다. 35 | 36 | `패키지`와 `비패키지`은 프로파일을 선택해서 실행할 수 있는데 프로파일 설정은 다음과 같습니다. 37 | 38 | | Properties/launchSettings.json 39 | ```json 40 | { 41 | "profiles": { 42 | "Package": { 43 | "commandName": "MsixPackage" 44 | }, 45 | "Unpackaged": { 46 | "commandName": "Project" 47 | } 48 | } 49 | } 50 | ``` 51 | 52 | 화면 상단의 다음의 영역으로 프로파일을 선택하고 실행할 수 있습니다. 53 | 54 | ![프로파일 선택](images/profile1.png) 55 | 56 | `패키지`, `비패키지`를 선택할 때 csproj 파일의 설정도 변경을 해줘야 합니다. 57 | 58 | - 패키지일 경우, 59 | ```xaml 60 | ... 61 | false 62 | ... 63 | ``` 64 | 65 | - 비패키지일 경우, 66 | ```xaml 67 | ... 68 | true 69 | ... 70 | ``` 71 | 72 | 비패키지일 경우 부트스트렙에서 Windows App SDK의 사용할 버젼을 선택하고 초기화 하는 코드가 필요한데 `WindowsAppSdkBootstrapInitialize` 설정에 의해 코드가 자동으로 생성이 됩니다. 하지만 패키지에는 필요하지 않으므로 이 값을 `false`로 해야 실행이 됩니다. 73 | 74 | 75 | ## 다국어 지원 76 | 77 | Windows App SDK에서는 패키지 리소스를 이용해 다국어를 지원합니다. 리소스는 기존과 동일한 `.resw` 확장자를 가지지만 `PRIResource`에 의해 pri 파일로 변환됩니다. `ResourceManager`나 `ResourceLoader`를 통해 리소스에 접근할 수 있으며 XAML에 `x:Uid`를 이용하면 `이름.속성` 형태로 리소스에 접근할 수 있습니다. 78 | 79 | | 리소스 "Input.Text" 이름의 값이 TextBlock의 `Text`속성에 적용 됨 80 | ```xaml 81 | ... 82 | 83 | ... 84 | ``` 85 | 86 | 소스코드에서는 다음 처럼 확장을 만든 후 87 | 88 | ```csharp 89 | public static class ResourceExtension 90 | { 91 | private static ResourceLoader _resLoader = new(); 92 | 93 | public static string GetLocalized(this string resourceKey) 94 | { 95 | return _resLoader.GetString(resourceKey); 96 | } 97 | } 98 | ``` 99 | 100 | `"Name".GetLocalized()` 형태로 코드에서 사용할 수 있습니다. 101 | 102 | 103 | ## 윈도 테마 대응 104 | 105 | 윈도우는 `밝게`, `어둡게` 테마 컬러를 지원합니다. WinUI 3는 기본적으로 테마 컬러를 대응합니다. 106 | 107 | | 테마 컬러가 `밝게`일 경우 108 | 109 | ![밝은 테마](images/light.png) 110 | 111 | | 테마 컬러가 `어둡게`일 경우 112 | 113 | ![어두운 테마](images/dark.png) 114 | 115 | 116 | ### 윈도 테마 컬러 변경 감지 117 | 118 | WinUI 3는 윈도 테마 컬러가 변경되었을 떄 이를 알 수 있도록 이벤트를 제공합니다. 119 | 120 | | `FrameworkElement`의 `ActualThemeChanged` 이벤트를 통해 테마 변경 감지 121 | ```csharp 122 | content.ActualThemeChanged += (s, e) => this.Theme = content.ActualTheme; 123 | ``` 124 | 125 | 126 | ## 윈도 타이틀바 제어 127 | 128 | WinUI 3은 타이틀바의 접근을 직접 할 수 없습니다. 전신이 UWP였기 때문인데 윈도 타이틀바에 접근하려면 `AppWindow`를 이용해야 합니다. `AppWindow`를 이용해 타이틀바 아이콘 및 제목, 각족 스타일을 설정할 수 있습니다. 129 | 130 | `AppWindow` 인스턴스를 얻는 방법은 다음과 같습니다. 131 | 132 | ```csharp 133 | private AppWindow GetAppWindowForCurrentWidow() 134 | { 135 | var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this); 136 | var winId = Win32Interop.GetWindowIdFromWindow(hWnd); 137 | return AppWindow.GetFromWindowId(winId); 138 | } 139 | ``` 140 | 141 | DRecorder는 `Window`를 재정의한 `CustomWindow`로 쉽게 `AppWindow`에 접근하는 코드를 보여줍니다. 142 | 143 | 144 | ## WinUI 3 XAML 컨트롤 145 | 146 | WinUI 3에서 제공하는 XAML 컨트롤은 UWP WinUI 2.7의 XAML 컨트롤과 거의 동일합니다. UWP 개발자는 거의 동일한 감각으로 바로 WinUI 3를 개발할 수 있고 `Grid`나 `StackPanel`등의 패널 및 기본 컨트롤들이 WPF의 그것과 매우 유사하기 때문에 WPF 개발자도 금방 화면 개발이 가능합니다. 147 | 148 | ```xaml 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 161 | 164 | 167 | 168 | 169 | ``` 170 | -------------------------------------------------------------------------------- /images/dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/images/dark.png -------------------------------------------------------------------------------- /images/light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/images/light.png -------------------------------------------------------------------------------- /images/profile1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimohy/DRecorder/6bcf7a9952ff5f4a2f452ae89bd975b2fcfd997a/images/profile1.png --------------------------------------------------------------------------------