├── .gitattributes ├── .gitignore ├── App.xaml ├── App.xaml.cs ├── AssemblyInfo.cs ├── DataViewer.cs ├── IRSDKSharperTest.csproj ├── IRSDKSharperTest.sln ├── LICENSE ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Program.cs ├── README.md ├── Screenshot.png └── Themes └── Generic.xaml /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.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/main/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 | [Ll]og/ 33 | [Ll]ogs/ 34 | 35 | # Visual Studio 2015/2017 cache/options directory 36 | .vs/ 37 | # Uncomment if you have tasks that create the project's static files in wwwroot 38 | #wwwroot/ 39 | 40 | # Visual Studio 2017 auto generated files 41 | Generated\ Files/ 42 | 43 | # MSTest test Results 44 | [Tt]est[Rr]esult*/ 45 | [Bb]uild[Ll]og.* 46 | 47 | # NUnit 48 | *.VisualState.xml 49 | TestResult.xml 50 | nunit-*.xml 51 | 52 | # Build Results of an ATL Project 53 | [Dd]ebugPS/ 54 | [Rr]eleasePS/ 55 | dlldata.c 56 | 57 | # Benchmark Results 58 | BenchmarkDotNet.Artifacts/ 59 | 60 | # .NET Core 61 | project.lock.json 62 | project.fragment.lock.json 63 | artifacts/ 64 | 65 | # ASP.NET Scaffolding 66 | ScaffoldingReadMe.txt 67 | 68 | # StyleCop 69 | StyleCopReport.xml 70 | 71 | # Files built by Visual Studio 72 | *_i.c 73 | *_p.c 74 | *_h.h 75 | *.ilk 76 | *.meta 77 | *.obj 78 | *.iobj 79 | *.pch 80 | *.pdb 81 | *.ipdb 82 | *.pgc 83 | *.pgd 84 | *.rsp 85 | *.sbr 86 | *.tlb 87 | *.tli 88 | *.tlh 89 | *.tmp 90 | *.tmp_proj 91 | *_wpftmp.csproj 92 | *.log 93 | *.tlog 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 6 auto-generated project file (contains which files were open etc.) 298 | *.vbp 299 | 300 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 301 | *.dsw 302 | *.dsp 303 | 304 | # Visual Studio 6 technical files 305 | *.ncb 306 | *.aps 307 | 308 | # Visual Studio LightSwitch build output 309 | **/*.HTMLClient/GeneratedArtifacts 310 | **/*.DesktopClient/GeneratedArtifacts 311 | **/*.DesktopClient/ModelManifest.xml 312 | **/*.Server/GeneratedArtifacts 313 | **/*.Server/ModelManifest.xml 314 | _Pvt_Extensions 315 | 316 | # Paket dependency manager 317 | .paket/paket.exe 318 | paket-files/ 319 | 320 | # FAKE - F# Make 321 | .fake/ 322 | 323 | # CodeRush personal settings 324 | .cr/personal 325 | 326 | # Python Tools for Visual Studio (PTVS) 327 | __pycache__/ 328 | *.pyc 329 | 330 | # Cake - Uncomment if you are using it 331 | # tools/** 332 | # !tools/packages.config 333 | 334 | # Tabs Studio 335 | *.tss 336 | 337 | # Telerik's JustMock configuration file 338 | *.jmconfig 339 | 340 | # BizTalk build output 341 | *.btp.cs 342 | *.btm.cs 343 | *.odx.cs 344 | *.xsd.cs 345 | 346 | # OpenCover UI analysis results 347 | OpenCover/ 348 | 349 | # Azure Stream Analytics local run output 350 | ASALocalRun/ 351 | 352 | # MSBuild Binary and Structured Log 353 | *.binlog 354 | 355 | # NVidia Nsight GPU debugger configuration file 356 | *.nvuser 357 | 358 | # MFractors (Xamarin productivity tool) working folder 359 | .mfractor/ 360 | 361 | # Local History for Visual Studio 362 | .localhistory/ 363 | 364 | # Visual Studio History (VSHistory) files 365 | .vshistory/ 366 | 367 | # BeatPulse healthcheck temp database 368 | healthchecksdb 369 | 370 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 371 | MigrationBackup/ 372 | 373 | # Ionide (cross platform F# VS Code tools) working folder 374 | .ionide/ 375 | 376 | # Fody - auto-generated XML schema 377 | FodyWeavers.xsd 378 | 379 | # VS Code files for those working on multiple tools 380 | .vscode/* 381 | !.vscode/settings.json 382 | !.vscode/tasks.json 383 | !.vscode/launch.json 384 | !.vscode/extensions.json 385 | *.code-workspace 386 | 387 | # Local History for Visual Studio Code 388 | .history/ 389 | 390 | # Windows Installer files from build outputs 391 | *.cab 392 | *.msi 393 | *.msix 394 | *.msm 395 | *.msp 396 | 397 | # JetBrains Rider 398 | *.sln.iml 399 | -------------------------------------------------------------------------------- /App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /App.xaml.cs: -------------------------------------------------------------------------------- 1 |  2 | using System.Windows; 3 | 4 | namespace IRSDKSharperTest 5 | { 6 | public partial class App : Application 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Windows; 3 | 4 | [assembly: ThemeInfo( ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly )] 5 | -------------------------------------------------------------------------------- /DataViewer.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.Diagnostics; 6 | using System.Globalization; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Media; 10 | 11 | using IRSDKSharper; 12 | 13 | namespace IRSDKSharperTest 14 | { 15 | public class DataViewer : Control 16 | { 17 | public int NumLines { get; private set; } = 0; 18 | public double RenderTime { get; private set; } = 0; 19 | 20 | private int scrollIndex = 0; 21 | private int mode = 0; 22 | 23 | private readonly CultureInfo cultureInfo = CultureInfo.GetCultureInfo( "en-us" ); 24 | private readonly Typeface typeface = new( "Courier New" ); 25 | 26 | static DataViewer() 27 | { 28 | DefaultStyleKeyProperty.OverrideMetadata( typeof( DataViewer ), new FrameworkPropertyMetadata( typeof( DataViewer ) ) ); 29 | } 30 | 31 | public void SetScrollIndex( int scrollIndex ) 32 | { 33 | this.scrollIndex = scrollIndex; 34 | } 35 | 36 | public void SetMode( int mode ) 37 | { 38 | this.mode = mode; 39 | } 40 | 41 | protected override void OnRender( DrawingContext drawingContext ) 42 | { 43 | var stopWatch = Stopwatch.StartNew(); 44 | 45 | base.OnRender( drawingContext ); 46 | 47 | switch ( mode ) 48 | { 49 | case 0: DrawHeaderData( drawingContext ); break; 50 | case 1: DrawSessionInfo( drawingContext ); break; 51 | case 2: DrawTelemetryData( drawingContext ); break; 52 | } 53 | 54 | stopWatch.Stop(); 55 | 56 | RenderTime = (double) stopWatch.ElapsedTicks / (double) Stopwatch.Frequency; 57 | } 58 | 59 | private void DrawHeaderData( DrawingContext drawingContext ) 60 | { 61 | var irsdk = Program.irsdk; 62 | 63 | if ( irsdk == null ) 64 | { 65 | return; 66 | } 67 | 68 | if ( irsdk.IsConnected ) 69 | { 70 | var dictionary = new Dictionary() 71 | { 72 | { "Version", irsdk.Data.Version }, 73 | { "Status", irsdk.Data.Status }, 74 | { "TickRate", irsdk.Data.TickRate }, 75 | { "SessionInfoUpdate", irsdk.Data.SessionInfoUpdate }, 76 | { "SessionInfoLength", irsdk.Data.SessionInfoLength }, 77 | { "SessionInfoOffset", irsdk.Data.SessionInfoOffset }, 78 | { "VarCount", irsdk.Data.VarCount }, 79 | { "VarHeaderOffset", irsdk.Data.VarHeaderOffset }, 80 | { "BufferCount", irsdk.Data.BufferCount }, 81 | { "BufferLength", irsdk.Data.BufferLength }, 82 | { "TickCount", irsdk.Data.TickCount }, 83 | { "Offset", irsdk.Data.Offset }, 84 | { "FramesDropped", irsdk.Data.FramesDropped } 85 | }; 86 | 87 | var point = new Point( 10, 10 ); 88 | var lineIndex = 0; 89 | 90 | foreach ( var keyValuePair in dictionary ) 91 | { 92 | if ( ( lineIndex & 1 ) == 1 ) 93 | { 94 | drawingContext.DrawRectangle( Brushes.AliceBlue, null, new Rect( 0, point.Y, ActualWidth, 20 ) ); 95 | } 96 | 97 | var formattedText = new FormattedText( keyValuePair.Key, cultureInfo, FlowDirection.LeftToRight, typeface, 12, Brushes.Black, 1.25f ) 98 | { 99 | LineHeight = 20 100 | }; 101 | 102 | drawingContext.DrawText( formattedText, point ); 103 | 104 | point.X += 150; 105 | 106 | formattedText = new FormattedText( keyValuePair.Value.ToString(), cultureInfo, FlowDirection.LeftToRight, typeface, 12, Brushes.Black, 1.25f ) 107 | { 108 | LineHeight = 20 109 | }; 110 | 111 | drawingContext.DrawText( formattedText, point ); 112 | 113 | point.X = 10; 114 | point.Y += 20; 115 | 116 | lineIndex++; 117 | } 118 | 119 | NumLines = lineIndex; 120 | } 121 | else 122 | { 123 | drawingContext.DrawRectangle( Brushes.DarkGray, null, new Rect( 0, 0, ActualWidth, ActualHeight ) ); 124 | } 125 | } 126 | 127 | private void DrawSessionInfo( DrawingContext drawingContext ) 128 | { 129 | var irsdk = Program.irsdk; 130 | 131 | if ( irsdk == null ) 132 | { 133 | return; 134 | } 135 | 136 | var sessionInfo = irsdk.Data.SessionInfo; 137 | 138 | if ( irsdk.IsConnected && ( sessionInfo != null ) ) 139 | { 140 | var point = new Point( 10, 10 ); 141 | var lineIndex = 0; 142 | var stopDrawing = false; 143 | 144 | foreach ( var propertyInfo in sessionInfo.GetType().GetProperties() ) 145 | { 146 | DrawSessionInfo( drawingContext, propertyInfo.Name, propertyInfo.GetValue( sessionInfo ), 0, ref point, ref lineIndex, ref stopDrawing ); 147 | } 148 | 149 | NumLines = lineIndex; 150 | } 151 | else 152 | { 153 | drawingContext.DrawRectangle( Brushes.DarkGray, null, new Rect( 0, 0, ActualWidth, ActualHeight ) ); 154 | } 155 | } 156 | 157 | private void DrawSessionInfo( DrawingContext drawingContext, string propertyName, object? valueAsObject, int indent, ref Point point, ref int lineIndex, ref bool stopDrawing ) 158 | { 159 | var isSimpleValue = ( ( valueAsObject is null ) || ( valueAsObject is string ) || ( valueAsObject is int ) || ( valueAsObject is float ) || ( valueAsObject is double ) ); 160 | 161 | if ( ( lineIndex >= scrollIndex ) && !stopDrawing ) 162 | { 163 | if ( ( lineIndex & 1 ) == 1 ) 164 | { 165 | drawingContext.DrawRectangle( Brushes.AliceBlue, null, new Rect( 0, point.Y, ActualWidth, 20 ) ); 166 | } 167 | 168 | point.X = 10 + indent * 50; 169 | 170 | var formattedText = new FormattedText( propertyName, cultureInfo, FlowDirection.LeftToRight, typeface, 12, Brushes.Black, 1.25f ) 171 | { 172 | LineHeight = 20 173 | }; 174 | 175 | drawingContext.DrawText( formattedText, point ); 176 | 177 | if ( valueAsObject is null ) 178 | { 179 | point.X = 260 + indent * 50; 180 | 181 | formattedText = new FormattedText( "(null)", cultureInfo, FlowDirection.LeftToRight, typeface, 12, Brushes.Black, 1.25f ) 182 | { 183 | LineHeight = 20 184 | }; 185 | 186 | drawingContext.DrawText( formattedText, point ); 187 | } 188 | else if ( isSimpleValue ) 189 | { 190 | point.X = 260 + indent * 50; 191 | 192 | formattedText = new FormattedText( valueAsObject.ToString(), cultureInfo, FlowDirection.LeftToRight, typeface, 12, Brushes.Black, 1.25f ) 193 | { 194 | LineHeight = 20 195 | }; 196 | 197 | drawingContext.DrawText( formattedText, point ); 198 | } 199 | 200 | point.Y += 20; 201 | 202 | if ( ( point.Y + 20 ) > ActualHeight ) 203 | { 204 | stopDrawing = true; 205 | } 206 | } 207 | 208 | lineIndex++; 209 | 210 | if ( !isSimpleValue ) 211 | { 212 | if ( valueAsObject is IList list ) 213 | { 214 | var index = 0; 215 | 216 | foreach ( var item in list ) 217 | { 218 | DrawSessionInfo( drawingContext, index.ToString(), item, indent + 1, ref point, ref lineIndex, ref stopDrawing ); 219 | 220 | index++; 221 | } 222 | } 223 | else 224 | { 225 | #pragma warning disable CS8602 226 | foreach ( var propertyInfo in valueAsObject.GetType().GetProperties() ) 227 | { 228 | DrawSessionInfo( drawingContext, propertyInfo.Name, propertyInfo.GetValue( valueAsObject ), indent + 1, ref point, ref lineIndex, ref stopDrawing ); 229 | } 230 | #pragma warning restore CS8602 231 | } 232 | } 233 | } 234 | 235 | private void DrawTelemetryData( DrawingContext drawingContext ) 236 | { 237 | var irsdk = Program.irsdk; 238 | 239 | if ( irsdk == null ) 240 | { 241 | return; 242 | } 243 | 244 | if ( irsdk.IsConnected ) 245 | { 246 | var point = new Point( 10, 10 ); 247 | var lineIndex = 0; 248 | var stopDrawing = false; 249 | 250 | foreach ( var keyValuePair in irsdk.Data.TelemetryDataProperties ) 251 | { 252 | for ( var valueIndex = 0; valueIndex < keyValuePair.Value.Count; valueIndex++ ) 253 | { 254 | if ( ( lineIndex >= scrollIndex ) && !stopDrawing ) 255 | { 256 | if ( ( lineIndex & 1 ) == 1 ) 257 | { 258 | drawingContext.DrawRectangle( Brushes.AliceBlue, null, new Rect( 0, point.Y, ActualWidth, 20 ) ); 259 | } 260 | 261 | var offset = keyValuePair.Value.Offset + valueIndex * IRacingSdkConst.VarTypeBytes[ (int) keyValuePair.Value.VarType ]; 262 | 263 | var formattedText = new FormattedText( offset.ToString(), cultureInfo, FlowDirection.LeftToRight, typeface, 12, Brushes.Black, 1.25f ) 264 | { 265 | LineHeight = 20 266 | }; 267 | 268 | drawingContext.DrawText( formattedText, point ); 269 | 270 | point.X += 40; 271 | 272 | formattedText = new FormattedText( keyValuePair.Value.Name, cultureInfo, FlowDirection.LeftToRight, typeface, 12, Brushes.Black, 1.25f ) 273 | { 274 | LineHeight = 20 275 | }; 276 | 277 | drawingContext.DrawText( formattedText, point ); 278 | 279 | point.X += 230; 280 | 281 | if ( keyValuePair.Value.Count > 1 ) 282 | { 283 | formattedText = new FormattedText( valueIndex.ToString(), cultureInfo, FlowDirection.LeftToRight, typeface, 12, Brushes.Black, 1.25f ) 284 | { 285 | LineHeight = 20 286 | }; 287 | 288 | drawingContext.DrawText( formattedText, point ); 289 | } 290 | 291 | point.X += 30; 292 | 293 | var valueAsString = string.Empty; 294 | var bitsAsString = string.Empty; 295 | var brush = Brushes.Black; 296 | 297 | switch ( keyValuePair.Value.Unit ) 298 | { 299 | case "irsdk_TrkLoc": 300 | valueAsString = GetString( keyValuePair.Value, valueIndex ); 301 | break; 302 | 303 | case "irsdk_TrkSurf": 304 | valueAsString = GetString( keyValuePair.Value, valueIndex ); 305 | break; 306 | 307 | case "irsdk_SessionState": 308 | valueAsString = GetString( keyValuePair.Value, valueIndex ); 309 | break; 310 | 311 | case "irsdk_CarLeftRight": 312 | valueAsString = GetString( keyValuePair.Value, valueIndex ); 313 | break; 314 | 315 | case "irsdk_PitSvStatus": 316 | valueAsString = GetString( keyValuePair.Value, valueIndex ); 317 | break; 318 | 319 | case "irsdk_PaceMode": 320 | valueAsString = GetString( keyValuePair.Value, valueIndex ); 321 | break; 322 | 323 | default: 324 | 325 | switch ( keyValuePair.Value.VarType ) 326 | { 327 | case IRacingSdkEnum.VarType.Char: 328 | valueAsString = $" {irsdk.Data.GetChar( keyValuePair.Value, valueIndex )}"; 329 | break; 330 | 331 | case IRacingSdkEnum.VarType.Bool: 332 | var valueAsBool = irsdk.Data.GetBool( keyValuePair.Value, valueIndex ); 333 | valueAsString = valueAsBool ? " T" : " F"; 334 | brush = valueAsBool ? Brushes.Green : Brushes.Red; 335 | break; 336 | 337 | case IRacingSdkEnum.VarType.Int: 338 | valueAsString = $"{irsdk.Data.GetInt( keyValuePair.Value, valueIndex ),10:N0}"; 339 | break; 340 | 341 | case IRacingSdkEnum.VarType.BitField: 342 | valueAsString = $"0x{irsdk.Data.GetBitField( keyValuePair.Value, valueIndex ):X8}"; 343 | 344 | switch ( keyValuePair.Value.Unit ) 345 | { 346 | case "irsdk_EngineWarnings": 347 | bitsAsString = GetString( keyValuePair.Value, valueIndex ); 348 | break; 349 | 350 | case "irsdk_Flags": 351 | bitsAsString = GetString( keyValuePair.Value, valueIndex ); 352 | break; 353 | 354 | case "irsdk_CameraState": 355 | bitsAsString = GetString( keyValuePair.Value, valueIndex ); 356 | break; 357 | 358 | case "irsdk_PitSvFlags": 359 | bitsAsString = GetString( keyValuePair.Value, valueIndex ); 360 | break; 361 | 362 | case "irsdk_PaceFlags": 363 | bitsAsString = GetString( keyValuePair.Value, valueIndex ); 364 | break; 365 | } 366 | 367 | break; 368 | 369 | case IRacingSdkEnum.VarType.Float: 370 | valueAsString = $"{irsdk.Data.GetFloat( keyValuePair.Value, valueIndex ),15:N4}"; 371 | break; 372 | 373 | case IRacingSdkEnum.VarType.Double: 374 | valueAsString = $"{irsdk.Data.GetDouble( keyValuePair.Value, valueIndex ),15:N4}"; 375 | break; 376 | } 377 | 378 | break; 379 | } 380 | 381 | formattedText = new FormattedText( valueAsString, cultureInfo, FlowDirection.LeftToRight, typeface, 12, brush, 1.25f ) 382 | { 383 | LineHeight = 20 384 | }; 385 | 386 | drawingContext.DrawText( formattedText, point ); 387 | 388 | point.X += 150; 389 | 390 | formattedText = new FormattedText( keyValuePair.Value.Unit, cultureInfo, FlowDirection.LeftToRight, typeface, 12, Brushes.Black, 1.25f ) 391 | { 392 | LineHeight = 20 393 | }; 394 | 395 | drawingContext.DrawText( formattedText, point ); 396 | 397 | point.X += 160; 398 | 399 | var desc = keyValuePair.Value.Desc; 400 | var originalDescLength = desc.Length; 401 | 402 | if ( bitsAsString != string.Empty ) 403 | { 404 | desc += $" ({bitsAsString})"; 405 | } 406 | 407 | formattedText = new FormattedText( desc, cultureInfo, FlowDirection.LeftToRight, typeface, 12, Brushes.Black, 1.25f ) 408 | { 409 | LineHeight = 20 410 | }; 411 | 412 | if ( bitsAsString != string.Empty ) 413 | { 414 | formattedText.SetForegroundBrush( Brushes.OrangeRed, originalDescLength, desc.Length - originalDescLength ); 415 | } 416 | 417 | drawingContext.DrawText( formattedText, point ); 418 | 419 | point.X = 10; 420 | point.Y += 20; 421 | 422 | if ( ( point.Y + 20 ) > ActualHeight ) 423 | { 424 | stopDrawing = true; 425 | } 426 | } 427 | 428 | lineIndex++; 429 | } 430 | } 431 | 432 | NumLines = lineIndex; 433 | } 434 | else 435 | { 436 | drawingContext.DrawRectangle( Brushes.DarkGray, null, new Rect( 0, 0, ActualWidth, ActualHeight ) ); 437 | } 438 | } 439 | 440 | private static string GetString( IRacingSdkDatum var, int index ) where T : Enum 441 | { 442 | var irsdk = Program.irsdk; 443 | 444 | if ( irsdk == null ) 445 | { 446 | return ""; 447 | } 448 | 449 | if ( var.VarType == IRacingSdkEnum.VarType.Int ) 450 | { 451 | var enumValue = (T) (object) irsdk.Data.GetInt( var, index ); 452 | 453 | return enumValue.ToString(); 454 | } 455 | else 456 | { 457 | var bits = irsdk.Data.GetBitField( var, index ); 458 | 459 | var bitsString = string.Empty; 460 | 461 | foreach ( uint bitMask in Enum.GetValues( typeof( T ) ) ) 462 | { 463 | if ( ( bits & bitMask ) != 0 ) 464 | { 465 | if ( bitsString != string.Empty ) 466 | { 467 | bitsString += " | "; 468 | } 469 | 470 | bitsString += Enum.GetName( typeof( T ), bitMask ); 471 | } 472 | } 473 | 474 | return bitsString; 475 | } 476 | } 477 | } 478 | } 479 | -------------------------------------------------------------------------------- /IRSDKSharperTest.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net6.0-windows 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /IRSDKSharperTest.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.6.33801.468 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IRSDKSharperTest", "IRSDKSharperTest.csproj", "{EEA2D64D-9D28-4694-92CA-059918F5B001}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {EEA2D64D-9D28-4694-92CA-059918F5B001}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {EEA2D64D-9D28-4694-92CA-059918F5B001}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {EEA2D64D-9D28-4694-92CA-059918F5B001}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {EEA2D64D-9D28-4694-92CA-059918F5B001}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {2EB8B6F8-F30D-423A-BA2F-AF9440D8C0F4} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 23 | 24 |