├── .gitattributes
├── .gitignore
├── ArduinoInterfaces
├── ArduinoInterfaces.csproj
├── ArduinoLink.cs
├── Constants.cs
└── Properties
│ └── AssemblyInfo.cs
├── License.txt
├── README.md
├── ShiftData
├── Properties
│ └── AssemblyInfo.cs
├── ShiftData.csproj
├── ShiftDataSchema.cs
├── ShiftDataSchema.xsd
└── ShiftLightData.xml
├── iRacingSdkWrapper
├── Bitfields
│ ├── BitfieldBase.cs
│ ├── CameraState.cs
│ ├── EngineWarning.cs
│ └── SessionFlag.cs
├── Drivers.cs
├── Enums.cs
├── Properties
│ └── AssemblyInfo.cs
├── Readme.md
├── SdkWrapper.cs
├── TelemetryInfo.cs
├── TelemetryValue.cs
├── iRacingSdkWrapper.csproj
├── iracingvars.csv
└── sessioninfo_example.txt
├── iRduino Development Guide v1.pdf
├── iRduino.sln
├── iRduino.sln.DotSettings
├── iRduino
├── App.config
├── App.xaml
├── App.xaml.cs
├── ArduinoTemplates
│ ├── ArduinoSketchT4.cs
│ ├── ArduinoSketchT4.tt
│ ├── ArduinoSketchT4Code.cs
│ └── SampleArduinoSketch.ino
├── Classes
│ ├── AdvancedOptions.cs
│ ├── ArduinoMessagesReceiving.cs
│ ├── ArduinoMessagesSending.cs
│ ├── ArduinoSketch.cs
│ ├── ButtonFunctions.cs
│ ├── Configuration.cs
│ ├── ConfigurationOptions.cs
│ ├── ControllerDevice.cs
│ ├── DCVariables.cs
│ ├── Dictionarys.cs
│ ├── DisplayManager.cs
│ ├── DisplayVariables.cs
│ ├── ErrorReporting.cs
│ ├── LEDs.cs
│ ├── LapDisplays.cs
│ ├── OptionPages.cs
│ └── ShiftLightData.cs
├── Commands
│ ├── CommandBase.cs
│ └── ShowMainWindow.cs
├── MahApps.Metro
│ ├── Entypo-license.txt
│ ├── Information.txt
│ ├── MahApps.Metro.dll
│ └── System.Windows.Interactivity.dll
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── Resources
│ ├── Configuration-Settings-icon.png
│ ├── Entypo.ttf
│ ├── ErrorBig.png
│ ├── Icons.xaml
│ ├── Motorsport-Helmet.ico
│ ├── MyControls.xaml
│ ├── MyTabStyle.xaml
│ ├── appbar.close32W.png
│ ├── appbar.cog.png
│ ├── appbar.control.play.png
│ ├── appbar.control.stop.png
│ ├── appbar.information.circle32W.png
│ ├── appbar.lifesaver32W.png
│ ├── appbar.minus32W.png
│ ├── arduinoTemp.png
│ ├── arrow_divide.png
│ ├── arrow_inout.png
│ ├── arrow_left.png
│ ├── arrow_right.png
│ ├── brick.png
│ ├── brickBlue.png
│ ├── bricks.png
│ ├── controller.png
│ ├── error.png
│ ├── ftTemp.png
│ ├── iRduino.png
│ ├── iRduinoAbout.png
│ ├── iRdunio-ICON.ico
│ ├── iRdunio-Logo32.png
│ ├── iRdunio-Logo64.png
│ ├── joystick.png
│ ├── layers.png
│ ├── lightbulb.png
│ ├── lightbulb_off.png
│ ├── octobrite.png
│ ├── page_gear.png
│ ├── picture_empty.png
│ ├── plugin.png
│ ├── script_gear.png
│ ├── simwind.png
│ └── wrench_orange.png
├── Windows
│ ├── AboutBox.xaml
│ ├── AboutBox.xaml.cs
│ ├── ErrorWindow.xaml
│ ├── ErrorWindow.xaml.cs
│ ├── GenerateArduinoWizard.xaml
│ ├── GenerateArduinoWizard.xaml.cs
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ ├── OptionsWindow.xaml
│ ├── OptionsWindow.xaml.cs
│ ├── Pages
│ │ ├── AdvancedOptions.xaml
│ │ ├── AdvancedOptions.xaml.cs
│ │ ├── Arduino.xaml
│ │ ├── Arduino.xaml.cs
│ │ ├── BlankPage.xaml
│ │ ├── BlankPage.xaml.cs
│ │ ├── ButtonsPage.xaml
│ │ ├── ButtonsPage.xaml.cs
│ │ ├── ConfigurationPage.xaml
│ │ ├── ConfigurationPage.xaml.cs
│ │ ├── CurrentConfiguration.xaml
│ │ ├── CurrentConfiguration.xaml.cs
│ │ ├── DigitalInputs.xaml
│ │ ├── DigitalInputs.xaml.cs
│ │ ├── DigitalOutputs.xaml
│ │ ├── DigitalOutputs.xaml.cs
│ │ ├── Expander.xaml
│ │ ├── Expander.xaml.cs
│ │ ├── FergoTech.xaml
│ │ ├── FergoTech.xaml.cs
│ │ ├── JoystickButtonsPage.xaml
│ │ ├── JoystickButtonsPage.xaml.cs
│ │ ├── LEDsPage.xaml
│ │ ├── LEDsPage.xaml.cs
│ │ ├── PageHelper.cs
│ │ ├── ScreenPage.xaml
│ │ ├── ScreenPage.xaml.cs
│ │ ├── TM1640ScreenPage.xaml
│ │ ├── TM1640ScreenPage.xaml.cs
│ │ ├── TMUnits.xaml
│ │ ├── TMUnits.xaml.cs
│ │ ├── UnitPage.xaml
│ │ └── UnitPage.xaml.cs
│ ├── UploaderDialog.xaml
│ └── UploaderDialog.xaml.cs
└── iRduino.csproj
├── irsdkSharp
├── CVarBuf.cs
├── CVarHeader.cs
├── CiRSDKHeader.cs
├── Properties
│ └── AssemblyInfo.cs
├── YamlParser.cs
├── iRSDKSharp.csproj
├── iRacingSDK.cs
└── readme.md
└── nicon
├── BalloonIcon.cs
├── Diagrams
└── TaskbarIcon Overview.cd
├── Interop
├── BalloonFlags.cs
├── IconDataMembers.cs
├── IconState.cs
├── MouseEvent.cs
├── NotifyCommand.cs
├── NotifyIconData.cs
├── NotifyIconVersion.cs
├── Point.cs
├── TrayInfo.cs
├── WinApi.cs
├── WindowClass.cs
└── WindowMessageSink.cs
├── NotifyIconWpf.csproj
├── PopupActivationMode.cs
├── Properties
└── AssemblyInfo.cs
├── RoutedEventHelper.cs
├── TaskbarIcon.Declarations.cs
├── TaskbarIcon.cs
└── Util.cs
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
2 | [Bb]in/
3 | [Oo]bj/
4 |
5 | # mstest test results
6 | TestResults
7 |
8 | ## Ignore Visual Studio temporary files, build results, and
9 | ## files generated by popular Visual Studio add-ons.
10 |
11 | # User-specific files
12 | *.suo
13 | *.user
14 | *.sln.docstates
15 | *.ide
16 | *.ide.*
17 |
18 | # Build results
19 | [Dd]ebug/
20 | [Rr]elease/
21 | x64/
22 | *_i.c
23 | *_p.c
24 | *.ilk
25 | *.meta
26 | *.obj
27 | *.pch
28 | *.pdb
29 | *.pgc
30 | *.pgd
31 | *.rsp
32 | *.sbr
33 | *.tlb
34 | *.tli
35 | *.tlh
36 | *.tmp
37 | *.log
38 | *.vspscc
39 | *.vssscc
40 | .builds
41 |
42 | # Visual C++ cache files
43 | ipch/
44 | *.aps
45 | *.ncb
46 | *.opensdf
47 | *.sdf
48 |
49 | # Visual Studio profiler
50 | *.psess
51 | *.vsp
52 | *.vspx
53 |
54 | # Guidance Automation Toolkit
55 | *.gpState
56 |
57 | # ReSharper is a .NET coding add-in
58 | _ReSharper*
59 |
60 | # NCrunch
61 | *.ncrunch*
62 | .*crunch*.local.xml
63 |
64 | # Installshield output folder
65 | [Ee]xpress
66 |
67 | # DocProject is a documentation generator add-in
68 | DocProject/buildhelp/
69 | DocProject/Help/*.HxT
70 | DocProject/Help/*.HxC
71 | DocProject/Help/*.hhc
72 | DocProject/Help/*.hhk
73 | DocProject/Help/*.hhp
74 | DocProject/Help/Html2
75 | DocProject/Help/html
76 |
77 | # Click-Once directory
78 | publish
79 |
80 | # Publish Web Output
81 | *.Publish.xml
82 |
83 | # NuGet Packages Directory
84 | packages
85 |
86 | # Windows Azure Build Output
87 | csx
88 | *.build.csdef
89 |
90 | # Windows Store app package directory
91 | AppPackages/
92 |
93 | # Others
94 | [Bb]in
95 | [Oo]bj
96 | sql
97 | TestResults
98 | [Tt]est[Rr]esult*
99 | *.Cache
100 | ClientBin
101 | [Ss]tyle[Cc]op.*
102 | ~$*
103 | *.dbmdl
104 | Generated_Code #added for RIA/Silverlight projects
105 |
106 | # Backup & report files from converting an old project file to a newer
107 | # Visual Studio version. Backup files are not needed, because we have git ;-)
108 | _UpgradeReport_Files/
109 | Backup*/
110 | UpgradeLog*.XML
111 |
112 | # =========================
113 | # Windows detritus
114 | # =========================
115 |
116 | # Windows image file caches
117 | Thumbs.db
118 | ehthumbs.db
119 |
120 | # Folder config file
121 | Desktop.ini
122 |
123 | # Recycle Bin used on file shares
124 | $RECYCLE.BIN/
125 |
126 | # Mac crap
127 | .DS_Store
128 |
--------------------------------------------------------------------------------
/ArduinoInterfaces/ArduinoInterfaces.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {00583770-D937-40CD-BDCC-B1692D74D392}
8 | Library
9 | Properties
10 | ArduinoInterfaces
11 | ArduinoInterfaces
12 | v4.0
13 | 512
14 |
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 | ..\packages\MahApps.Metro.0.10.0.0\lib\net40\MahApps.Metro.dll
36 |
37 |
38 |
39 |
40 |
41 | ..\packages\MahApps.Metro.0.10.0.0\lib\net40\System.Windows.Interactivity.dll
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
67 |
--------------------------------------------------------------------------------
/ArduinoInterfaces/Constants.cs:
--------------------------------------------------------------------------------
1 | //========================================//
2 | // iRduino - Created by Mark Silverwood //
3 | //======================================//
4 |
5 | namespace ArduinoInterfaces
6 | {
7 |
8 | public class Constants
9 | {
10 | public const int MaxNumberTM1638Units = 6;
11 |
12 | public const int NumberButtonsOnTm1638 = 8;
13 |
14 | public const int NumberPinsArduinoBoard = 54;
15 |
16 | public const int MaxNumberTm1640Units = 3;
17 |
18 | public const int MaxNumberJoystickButtons = 32;
19 |
20 | public const byte MessageStartByte1 = 255;
21 |
22 | //public const byte MessageStartByte2 = 37;
23 |
24 | public const byte MessageEndByte = 180;
25 |
26 | public const int MaxIntensityTM = 7;
27 |
28 | public const int MaxDisplayLengthTM1638 = 8;
29 |
30 | public const int MaxDisplayLengthTM1640 = 16;
31 |
32 | public const int MaxNumberScreensPerUnit = 20;
33 |
34 | public const int MaxDCDisplayLength = 5;
35 |
36 | public const int MessageHeaderLength = 3; //start bytes and intensity
37 |
38 | public const int MessageFooterLength = 3; //checksum & end byte
39 |
40 | public const int TM1638MessageLength = 8;
41 |
42 | public const int TM1638LEDMessageLength = 2;
43 |
44 | public const int TM1640MessageLength = TM1638MessageLength + 8;
45 |
46 | // ReSharper disable InconsistentNaming
47 | public const byte MessageID_TMString = 37;
48 |
49 | public const byte MessageID_TMLED = 42;
50 |
51 | public const byte MessageID_Clear = 170;
52 |
53 | public const byte MessageID_TM1638Buttons = 55;
54 |
55 | // ReSharper restore InconsistentNaming
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/ArduinoInterfaces/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 |
8 | [assembly: AssemblyTitle("ArduinoInterface")]
9 | [assembly: AssemblyDescription("Arduino Interface Class for iRduino")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Mark Silverwood")]
12 | [assembly: AssemblyProduct("ArduinoInterface")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 |
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 |
25 | [assembly: Guid("21d50e8e-d446-4e4b-b28d-1356793a9b6f")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Build and Revision Numbers
35 | // by using the '*' as shown below:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 |
38 | [assembly: AssemblyVersion("2.0.0.0")]
39 | [assembly: AssemblyFileVersion("2.0.0.0")]
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # iRduino
2 |
3 | Interfaces between the iRacing API and an Arduino board. Can control displays, LEDs, buttons and much more. Supports custom iRacing Arduino projects.
4 |
5 | ## License
6 |
7 | :scroll: License: [GNU General Public License version 3 (GPLv3)](http://www.gnu.org/licenses/gpl.html)
8 |
9 | ## Website
10 |
11 | :earth_africa: Link: [slicedsilver.github.com/iRduino](http://slicedsilver.github.com/iRduino)
:octocat: Hosted by: [GitHub Pages](http://pages.github.com)
12 |
13 | ## iRacing Foum Topic
14 |
15 | (requires iRacing subscription to read)
16 | :car: [Link to iRacing forum topic] (http://members.iracing.com/jforum/posts/list/1847021.page)
17 |
18 | ## Author
19 |
20 | :bust_in_silhouette: Created and Maintained by [Mark Silverwood](https://github.com/SlicedSilver).
21 |
22 | ## Increments
23 | :bust_in_silhouette: by [Alex Montoanelli](https://github.com/alexmontoanelli)
24 |
25 | ## ShiftData Updates
26 |
27 | :bust_in_silhouette: by Jody Moffett
28 | :bust_in_silhouette: by [Evan A. Matwijejko](https://github.com/MADJIHADx)
29 |
--------------------------------------------------------------------------------
/ShiftData/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ShiftData")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ShiftData")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("c2b85a39-4f2a-4806-a923-4499ae1205e7")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ShiftData/ShiftData.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {E00EE3A4-6BAD-469B-9CA0-F829C37C3A2F}
8 | Library
9 | Properties
10 | ShiftData
11 | ShiftData
12 | v4.0
13 | 512
14 |
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | ShiftDataSchema.xsd
46 |
47 |
48 |
49 |
50 | Designer
51 | Always
52 |
53 |
54 |
55 |
56 | Designer
57 |
58 |
59 |
60 |
67 |
--------------------------------------------------------------------------------
/ShiftData/ShiftDataSchema.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/iRacingSdkWrapper/Bitfields/BitfieldBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace iRacingSdkWrapper.Bitfields
4 | {
5 | public abstract class BitfieldBase
6 | where T : struct, IConvertible, IComparable
7 | {
8 | protected BitfieldBase(int value)
9 | {
10 | _Value = (uint)value;
11 | }
12 |
13 | private readonly uint _Value;
14 | public uint Value { get { return _Value; } }
15 |
16 | public bool Contains(T bit)
17 | {
18 | var bitValue = (uint) Convert.ChangeType(bit, bit.GetTypeCode());
19 | return (this.Value & bitValue) == bitValue;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/iRacingSdkWrapper/Bitfields/CameraState.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace iRacingSdkWrapper.Bitfields
4 | {
5 | public class CameraState : BitfieldBase
6 | {
7 | public CameraState(int value) : base(value)
8 | {
9 | }
10 | }
11 |
12 | [Flags]
13 | public enum CameraStates : uint
14 | {
15 | IsSessionScreen = 0x0001, // the camera tool can only be activated if viewing the session screen (out of car)
16 | IsScenicActive = 0x0002, // the scenic camera is active (no focus car)
17 | CamToolActive = 0x0004,
18 | UIHidden = 0x0008,
19 | UseAutoShotSelection = 0x0010,
20 | UseTemporaryEdits = 0x0020,
21 | UseKeyAcceleration = 0x0040,
22 | UseKey10xAcceleration = 0x0080,
23 | UseMouseAimMode = 0x0100
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/iRacingSdkWrapper/Bitfields/EngineWarning.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace iRacingSdkWrapper.Bitfields
4 | {
5 | public class EngineWarning : BitfieldBase
6 | {
7 | public EngineWarning(int value)
8 | : base(value)
9 | {
10 | }
11 | }
12 |
13 | [Flags]
14 | public enum EngineWarnings : uint
15 | {
16 | WaterTemperatureWarning = 0x01,
17 | FuelPressureWarning = 0x02,
18 | OilPressureWarning = 0x04,
19 | EngineStalled = 0x08,
20 | PitSpeedLimiter = 0x10,
21 | RevLimiterActive = 0x20
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/iRacingSdkWrapper/Bitfields/SessionFlag.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace iRacingSdkWrapper.Bitfields
4 | {
5 | public class SessionFlag : BitfieldBase
6 | {
7 | public SessionFlag(int value) : base(value)
8 | {
9 | }
10 | }
11 |
12 | [Flags]
13 | public enum SessionFlags : uint
14 | {
15 | Checkered = 0x00000001,
16 | White = 0x00000002,
17 | Green = 0x00000004,
18 | Yellow = 0x00000008,
19 | Red = 0x00000010,
20 | Blue = 0x00000020,
21 | Debris = 0x00000040,
22 | Crossed = 0x00000080,
23 | YellowWaving = 0x00000100,
24 | OneLapToGreen = 0x00000200,
25 | GreenHeld = 0x00000400,
26 | TenToGo = 0x00000800,
27 | FiveToGo = 0x00001000,
28 | RandomWaving = 0x00002000,
29 | Caution = 0x00004000,
30 | CautionWaving = 0x00008000,
31 |
32 | Black = 0x00010000,
33 | Disqualify = 0x00020000,
34 | Servicible = 0x00040000, // car is allowed service (not a flag)
35 | Furled = 0x00080000,
36 | Repair = 0x00100000,
37 |
38 | StartHidden = 0x10000000,
39 | StartReady = 0x20000000,
40 | StartSet = 0x40000000,
41 | StartGo = 0x80000000,
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/iRacingSdkWrapper/Drivers.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using iRacingSdkWrapper;
7 | using iRacingSdkWrapper.Bitfields;
8 |
9 | namespace iRacingSdkWrapper
10 | {
11 | ///
12 | /// Represents a driver in the current session.
13 | ///
14 | public class Driver
15 | {
16 | public Driver()
17 | {
18 | }
19 |
20 | ///
21 | /// The identifier (CarIdx) of this driver (unique to this session)
22 | ///
23 | public int Id { get; set; }
24 |
25 | ///
26 | /// The current position of the driver
27 | ///
28 | public int Position { get; set; }
29 |
30 | ///
31 | /// The name of the driver
32 | ///
33 | public string Name { get; set; }
34 |
35 | ///
36 | /// The customer ID (custid) of the driver, used to identify GoT drivers.
37 | ///
38 | public int CustomerId { get; set; }
39 |
40 | ///
41 | /// The car number of this driver
42 | ///
43 | public string Number { get; set; }
44 |
45 | ///
46 | /// A unique identifier for the car class this driver is using
47 | ///
48 | public int ClassId { get; set; }
49 |
50 | ///
51 | /// The name of the car of this driver
52 | ///
53 | public string CarPath { get; set; }
54 |
55 | ///
56 | /// The relative speed of this class in a multiclass session
57 | ///
58 | public int CarClassRelSpeed { get; set; }
59 |
60 | ///
61 | /// Used to determine if a driver is in the pits, off or on track
62 | ///
63 | public TrackSurfaces TrackSurface { get; set; }
64 |
65 | ///
66 | /// Whether or not the driver is currently in or approaching the pit stall
67 | ///
68 | public bool IsInPits
69 | {
70 | get { return this.TrackSurface == TrackSurfaces.AproachingPits || this.TrackSurface == TrackSurfaces.InPitStall; }
71 | }
72 |
73 | ///
74 | /// The lap this driver is currently in
75 | ///
76 | public int Lap { get; set; }
77 |
78 | ///
79 | /// The distance along the current lap of this driver (in percentage)
80 | ///
81 | public float LapDistance { get; set; }
82 |
83 | ///
84 | /// The relative distance between you and this driver (in percentage).
85 | ///
86 | public float RelativeLapDistance { get; set; }
87 |
88 | ///
89 | /// The fastest lap time of this driver
90 | ///
91 | public float FastestLapTime { get; set; }
92 |
93 | ///
94 | /// The last lap time of this driver
95 | ///
96 | public float LastLapTime { get; set; }
97 |
98 | ///
99 | /// The iRating of this driver
100 | ///
101 | public int Rating { get; set; }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/iRacingSdkWrapper/Enums.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace iRacingSdkWrapper
7 | {
8 | public enum TrackSurfaces
9 | {
10 | NotInWorld = -1,
11 | OffTrack,
12 | InPitStall,
13 | AproachingPits,
14 | OnTrack
15 | }
16 |
17 | public enum SessionStates
18 | {
19 | Invalid,
20 | GetInCar,
21 | Warmup,
22 | ParadeLaps,
23 | Racing,
24 | Checkered,
25 | CoolDown
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/iRacingSdkWrapper/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("iRacingSdkWrapper")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("iRacingSdkWrapper")]
13 | [assembly: AssemblyCopyright("Copyright © 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("cd8abd82-04f7-4757-b479-7cd2d0f2572b")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/iRacingSdkWrapper/Readme.md:
--------------------------------------------------------------------------------
1 | iRacingSdkWrapper
2 | =================
3 |
4 | Created by Nick Thissen
5 | http://members.iracing.com/jforum/posts/list/1826390.page
6 |
7 | Modified by Mark Silverwood for the iRduino application.
8 |
--------------------------------------------------------------------------------
/iRacingSdkWrapper/TelemetryValue.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using iRSDKSharp;
6 | using iRacingSdkWrapper.Bitfields;
7 |
8 | namespace iRacingSdkWrapper
9 | {
10 | public abstract class TelemetryValue
11 | {
12 | protected TelemetryValue(iRSDKSharp.iRacingSDK sdk, string name)
13 | {
14 | if (sdk == null) throw new ArgumentNullException("sdk");
15 | if (!sdk.VarHeaders.ContainsKey(name))
16 | throw new ArgumentException("No telemetry value with the specified name exists.");
17 |
18 |
19 | var header = sdk.VarHeaders[name];
20 | _Name = name;
21 | _Description = header.Desc;
22 | _Unit = header.Unit;
23 | }
24 |
25 | private readonly string _Name;
26 | ///
27 | /// The name of this telemetry value parameter.
28 | ///
29 | public string Name { get { return _Name; } }
30 |
31 | private readonly string _Description;
32 | ///
33 | /// The description of this parameter.
34 | ///
35 | public string Description { get { return _Description; } }
36 |
37 | private readonly string _Unit;
38 | ///
39 | /// The real world unit for this parameter.
40 | ///
41 | public string Unit { get { return _Unit; } }
42 |
43 | public abstract object GetValue();
44 | }
45 |
46 | ///
47 | /// Represents a telemetry parameter of the specified type.
48 | ///
49 | /// The .NET type of this parameter (int, char, float, double, bool, or arrays)
50 | public sealed class TelemetryValue : TelemetryValue
51 | {
52 | public TelemetryValue(iRSDKSharp.iRacingSDK sdk, string name)
53 | : base(sdk, name)
54 | {
55 | this.GetData(sdk);
56 | }
57 |
58 | private void GetData(iRacingSDK sdk)
59 | {
60 | var data = sdk.GetData(this.Name);
61 |
62 | var type = typeof (T);
63 | if (type.BaseType != null && type.BaseType.IsGenericType && type.BaseType.GetGenericTypeDefinition() == typeof(BitfieldBase<>))
64 | {
65 | _Value = (T) Activator.CreateInstance(type, new [] {data});
66 | }
67 | else
68 | {
69 | _Value = (T) data;
70 | }
71 | }
72 |
73 | private T _Value;
74 | ///
75 | /// The value of this parameter.
76 | ///
77 | public T Value { get { return _Value; } }
78 |
79 | public override object GetValue()
80 | {
81 | return this.Value;
82 | }
83 |
84 | public override string ToString()
85 | {
86 | return string.Format("{0} {1}", this.Value, this.Unit);
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/iRacingSdkWrapper/iRacingSdkWrapper.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {D6DB568B-35B3-49EB-8CB3-E4E5F1424247}
9 | Library
10 | Properties
11 | iRacingSdkWrapper
12 | iRacingSdkWrapper
13 | v4.0
14 | 512
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 | ManagedMinimumRules.ruleset
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | {72631B85-EB9A-473E-9B4C-65B355A9000D}
59 | iRSDKSharp
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
79 |
--------------------------------------------------------------------------------
/iRacingSdkWrapper/iracingvars.csv:
--------------------------------------------------------------------------------
1 | Name,Desc,Unit,Type,Length
2 | SessionTime,Seconds since session start,s,double,1
3 | SessionNum,Session number,,int,1
4 | SessionState,Session state,irsdk_SessionState,int,1
5 | SessionUniqueID,Session ID,,int,1
6 | SessionFlags,Session flags,irsdk_Flags,bitfield,1
7 | DriverMarker,Driver activated flag,,bool,1
8 | IsReplayPlaying,0=replay not playing 1=replay playing,,bool,1
9 | ReplayFrameNum,Integer replay frame number (60 per second),,int,1
10 | CarIdxLap,Lap count by car index,,int,64
11 | CarIdxLapDistPct,Percentage distance around lap by car index,%,float,64
12 | CarIdxTrackSurface,Track surface type by car index,irsdk_TrkLoc,int,64
13 | CarIdxSteer,Steering wheel angle by car index,rad,float,64
14 | CarIdxRPM,Engine rpm by car index,revs/min,float,64
15 | CarIdxGear,-1=reverse 0=neutral 1..n=current gear by car index,,int,64
16 | SteeringWheelAngle,Steering wheel angle,rad,float,1
17 | Throttle,0=off throttle to 1=full throttle,%,float,1
18 | Brake,0=brake released to 1=max pedal force,%,float,1
19 | Clutch,0=disengaged to 1=fully engaged,%,float,1
20 | Gear,-1=reverse 0=neutral 1..n=current gear,,int,1
21 | RPM,Engine rpm,revs/min,float,1
22 | Lap,Lap count,,int,1
23 | LapDist,Meters traveled from S/F this lap,m,float,1
24 | LapDistPct,Percentage distance around lap,%,float,1
25 | RaceLaps,Laps completed in race,,int,1
26 | LongAccel,Longitudinal acceleration (including gravity),m/s^2,float,1
27 | LatAccel,Lateral acceleration (including gravity),m/s^2,float,1
28 | VertAccel,Vertical acceleration (including gravity),m/s^2,float,1
29 | RollRate,Roll rate,rad/s,float,1
30 | PitchRate,Pitch rate,rad/s,float,1
31 | YawRate,Yaw rate,rad/s,float,1
32 | Speed,GPS vehicle speed,m/s,float,1
33 | VelocityX,X velocity,m/s,float,1
34 | VelocityY,Y velocity,m/s,float,1
35 | VelocityZ,Z velocity,m/s,float,1
36 | Yaw,Yaw orientation,rad,float,1
37 | Pitch,Pitch orientation,rad,float,1
38 | Roll,Roll orientation,rad,float,1
39 | CamCarIdx,Active camera's focus car index,,int,1
40 | CamCameraNumber,Active camera number,,int,1
41 | CamGroupNumber,Active camera group number,,int,1
42 | CamCameraState,State of camera system,irsdk_CameraState,bitfield,1
43 | IsOnTrack,1=Car on track physics running,,bool,1
44 | IsInGarage,1=Car in garage physics running,,bool,1
45 | SteeringWheelTorque,Output torque on steering shaft,N*m,float,1
46 | SteeringWheelPctTorque,Force feedback % max torque on steering shaft,%,float,1
47 | ShiftIndicatorPct,Percent of shift indicator to light up,%,float,1
48 | EngineWarnings,Bitfield for warning lights,irsdk_EngineWarnings,bitfield,1
49 | FuelLevel,Liters of fuel remaining,l,float,1
50 | FuelLevelPct,Percent fuel remaining,%,float,1
51 | ReplayPlaySpeed,Replay playback speed,,int,1
52 | ReplayPlaySlowMotion,0=not slow motion 1=replay is in slow motion,,bool,1
53 | ReplaySessionTime,Seconds since replay session start,s,double,1
54 | ReplaySessionNum,Replay session number,,int,1
55 | WaterTemp,Engine coolant temp,C,float,1
56 | WaterLevel,Engine coolant level,l,float,1
57 | FuelPress,Engine fuel pressure,bar,float,1
58 | OilTemp,Engine oil temperature,C,float,1
59 | OilPress,Engine oil pressure,bar,float,1
60 | OilLevel,Engine oil level,l,float,1
61 | Voltage,Engine voltage,V,float,1
62 |
--------------------------------------------------------------------------------
/iRacingSdkWrapper/sessioninfo_example.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRacingSdkWrapper/sessioninfo_example.txt
--------------------------------------------------------------------------------
/iRduino Development Guide v1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino Development Guide v1.pdf
--------------------------------------------------------------------------------
/iRduino.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.21005.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArduinoInterfaces", "ArduinoInterfaces\ArduinoInterfaces.csproj", "{00583770-D937-40CD-BDCC-B1692D74D392}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "iRacingSdkWrapper", "iRacingSdkWrapper\iRacingSdkWrapper.csproj", "{D6DB568B-35B3-49EB-8CB3-E4E5F1424247}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "iRduino", "iRduino\iRduino.csproj", "{1EC172EA-586B-471D-B94A-C175F38C48C0}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "iRSDKSharp", "irsdkSharp\iRSDKSharp.csproj", "{72631B85-EB9A-473E-9B4C-65B355A9000D}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShiftData", "ShiftData\ShiftData.csproj", "{E00EE3A4-6BAD-469B-9CA0-F829C37C3A2F}"
15 | EndProject
16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NotifyIconWpf", "nicon\NotifyIconWpf.csproj", "{7AC63864-7638-41C4-969C-D3197EF2BED9}"
17 | EndProject
18 | Global
19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
20 | Debug|Any CPU = Debug|Any CPU
21 | Release|Any CPU = Release|Any CPU
22 | EndGlobalSection
23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
24 | {00583770-D937-40CD-BDCC-B1692D74D392}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {00583770-D937-40CD-BDCC-B1692D74D392}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {00583770-D937-40CD-BDCC-B1692D74D392}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {00583770-D937-40CD-BDCC-B1692D74D392}.Release|Any CPU.Build.0 = Release|Any CPU
28 | {D6DB568B-35B3-49EB-8CB3-E4E5F1424247}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {D6DB568B-35B3-49EB-8CB3-E4E5F1424247}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {D6DB568B-35B3-49EB-8CB3-E4E5F1424247}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {D6DB568B-35B3-49EB-8CB3-E4E5F1424247}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {1EC172EA-586B-471D-B94A-C175F38C48C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33 | {1EC172EA-586B-471D-B94A-C175F38C48C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
34 | {1EC172EA-586B-471D-B94A-C175F38C48C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
35 | {1EC172EA-586B-471D-B94A-C175F38C48C0}.Release|Any CPU.Build.0 = Release|Any CPU
36 | {72631B85-EB9A-473E-9B4C-65B355A9000D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37 | {72631B85-EB9A-473E-9B4C-65B355A9000D}.Debug|Any CPU.Build.0 = Debug|Any CPU
38 | {72631B85-EB9A-473E-9B4C-65B355A9000D}.Release|Any CPU.ActiveCfg = Release|Any CPU
39 | {72631B85-EB9A-473E-9B4C-65B355A9000D}.Release|Any CPU.Build.0 = Release|Any CPU
40 | {E00EE3A4-6BAD-469B-9CA0-F829C37C3A2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
41 | {E00EE3A4-6BAD-469B-9CA0-F829C37C3A2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
42 | {E00EE3A4-6BAD-469B-9CA0-F829C37C3A2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
43 | {E00EE3A4-6BAD-469B-9CA0-F829C37C3A2F}.Release|Any CPU.Build.0 = Release|Any CPU
44 | {7AC63864-7638-41C4-969C-D3197EF2BED9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45 | {7AC63864-7638-41C4-969C-D3197EF2BED9}.Debug|Any CPU.Build.0 = Debug|Any CPU
46 | {7AC63864-7638-41C4-969C-D3197EF2BED9}.Release|Any CPU.ActiveCfg = Release|Any CPU
47 | {7AC63864-7638-41C4-969C-D3197EF2BED9}.Release|Any CPU.Build.0 = Release|Any CPU
48 | EndGlobalSection
49 | GlobalSection(SolutionProperties) = preSolution
50 | HideSolutionNode = FALSE
51 | EndGlobalSection
52 | EndGlobal
53 |
--------------------------------------------------------------------------------
/iRduino/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/iRduino/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/iRduino/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace iRduino
4 | {
5 | ///
6 | /// Interaction logic for App.xaml
7 | ///
8 | public partial class App : Application
9 | {
10 | }
11 | }
--------------------------------------------------------------------------------
/iRduino/ArduinoTemplates/ArduinoSketchT4Code.cs:
--------------------------------------------------------------------------------
1 | //========================================//
2 | // iRduino - Created by Mark Silverwood //
3 | //======================================//
4 | namespace iRduino.ArduinoTemplates
5 | {
6 | using iRduino.Classes;
7 |
8 | partial class ArduinoSketchT4
9 | {
10 | private readonly ConfigurationOptions configurationOptions;
11 | private readonly ArduinoPins pins;
12 | public ArduinoSketchT4(ConfigurationOptions configurationOptions, ArduinoPins pins)
13 | {
14 | this.configurationOptions = configurationOptions;
15 | this.pins = pins;
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/iRduino/ArduinoTemplates/SampleArduinoSketch.ino:
--------------------------------------------------------------------------------
1 | /*
2 | iRduino - Arduino Sketch
3 | Author: Mark Silverwood
4 |
5 | Using TM1638 library from Ricardo Batista
6 |
7 | This Arduino Sketch interfaces to the iRduino windows application.
8 | This Sketch was generated on: 2/13/2013
9 | This Sketch is for a double (2) Display Unit Configuration
10 |
11 | */
12 |
13 | #include
14 | #include
15 |
16 | //////Setup Here
17 | #define dataPin 4
18 | #define clockPin 3
19 | #define strobePin1 2
20 | #define TM1640dataPin2 1
21 | #define TM1640clockPin2 0
22 | #define NumberUnits 2
23 | #define NumberTM1638Units 1
24 | //////Setup Finished
25 |
26 | #define startByte1 255
27 | #define startByte2 37
28 | #define endByte 180
29 | #define messageLength 33
30 |
31 | TM1638 module1(dataPin,clockPin,strobePin1,false,0);
32 | TM1640 module2(TM1640dataPin2,TM1640clockPin2,false,0);
33 |
34 | //// Variable Declarations
35 | word leds;
36 | byte segments[8], TM1640segments[16], redLeds, greenLeds, intensity, unit, sum, i, readCount, checkerPosition;
37 | byte buttons[NumberTM1638Units], oldbuttons[NumberTM1638Units], lastButtonSend[NumberTM1638Units];
38 | long lastCheck, debounceDelay = 100;
39 | boolean sendButtons = false;
40 | byte messageHolder[messageLength], message[messageLength-4], messagePosition = -1;
41 |
42 | void setup() {
43 | Serial.begin(0);
44 | for(int u = 0; u < NumberTM1638Units; u++)
45 | {
46 | oldbuttons[u] = 0;
47 | }
48 | intensity = 0;
49 | lastCheck = millis();
50 | }
51 |
52 | void loop() {
53 | buttonsCheck();
54 | if (Serial.available() > 0){
55 | messagePosition++;
56 | if(messagePosition == messageLength) messagePosition = 0;
57 | messageHolder[messagePosition] = Serial.read();
58 | messageChecker();
59 | }
60 | }
61 |
62 | void messageChecker()
63 | {
64 | checkerPosition = (messagePosition == 0) ? messageLength-1 : messagePosition - 1;
65 | if(messageHolder[checkerPosition] != endByte) return; //end byte
66 | checkerPosition = (messagePosition == messageLength -1) ? 0 : messagePosition + 1;
67 | if(messageHolder[checkerPosition]!= startByte1) return; //start byte1
68 | checkerPosition = (checkerPosition == messageLength - 1) ? 0 : checkerPosition+1;
69 | if(messageHolder[checkerPosition]!= startByte2) return; // start byte 2
70 | checkerPosition++;
71 | readCount = 0;
72 | sum = 0;
73 | while (readCount < messageLength-4)
74 | {
75 | if(checkerPosition == messageLength) checkerPosition = 0;
76 | message[readCount] = messageHolder[checkerPosition];
77 | sum += messageHolder[checkerPosition];
78 | readCount++;
79 | checkerPosition++;
80 | }
81 | if(sum == messageHolder[messagePosition]) messageRead(message);
82 | }
83 |
84 | void messageRead(byte _message[]){
85 | i = 0;
86 | intensity = _message[i++];
87 | for(int u = 1; u <= NumberUnits; u++)
88 | {
89 | unit = _message[i++];
90 | if(u==2)
91 | {
92 | for(int x = 0;x<16;x++){
93 | TM1640segments[x] = _message[i++];
94 | }
95 | updateDisplay(unit,word(0,0),TM1640segments,intensity);
96 | }
97 | else
98 | {
99 | greenLeds = _message[i++];
100 | redLeds = _message[i++];
101 | for(int x = 0;x<8;x++){
102 | segments[x] = _message[i++];
103 | }
104 | updateDisplay(unit,word(greenLeds,redLeds),segments,intensity);
105 | }
106 | }
107 | }
108 |
109 | void buttonsCheck(){
110 | if ((millis() - lastCheck) SerialSpeeds = new List {9600, 14400, 19200, 28800, 38400, 57600, 115200 };
13 |
14 | internal static List RefreshRates = new List { 30, 15, 10, 5, 1 };
15 |
16 | public static int ParseSerialSpeedString(string input)
17 | {
18 | int temp;
19 | int.TryParse(input, out temp);
20 | foreach (var speed in SerialSpeeds)
21 | {
22 | if (speed == temp)
23 | {
24 | return speed;
25 | }
26 | }
27 | return SerialSpeeds[SerialSpeeds.Count - 1];
28 | }
29 |
30 | public static int ParseRefreshRatesString(string input)
31 | {
32 | int temp;
33 | int.TryParse(input, out temp);
34 | foreach (var refresh in RefreshRates)
35 | {
36 | if (refresh == temp)
37 | {
38 | return refresh;
39 | }
40 | }
41 | return RefreshRates[0];
42 | }
43 |
44 | public static int CalculateRecommendSerialSpeed(int displayRefreshRate, int ledRefreshRate, int numberTM1638, int numberTM1640)
45 | {
46 | //calculate message length
47 | var messageBytes = displayRefreshRate
48 | * ((Constants.MessageFooterLength + Constants.MessageHeaderLength
49 | + Constants.TM1638MessageLength) * numberTM1638
50 | + (Constants.MessageFooterLength + Constants.MessageHeaderLength
51 | + Constants.TM1640MessageLength) * numberTM1640) + ledRefreshRate * ((Constants.MessageFooterLength + Constants.MessageHeaderLength
52 | + Constants.TM1638LEDMessageLength) * numberTM1638);
53 | //calculate mininum speed required
54 | double minSpeedDouble = messageBytes * 1.2f * 8 * 2f; //100% extra overhead
55 | var minSpeed = Convert.ToInt32(minSpeedDouble);
56 | //select from SerialSpeeds
57 | foreach (var speed in SerialSpeeds)
58 | {
59 | if (speed >= minSpeed)
60 | {
61 | return speed;
62 | }
63 | }
64 | return SerialSpeeds[SerialSpeeds.Count - 1];
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/iRduino/Classes/ArduinoMessagesReceiving.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace iRduino.Classes
5 | {
6 | using System.Collections;
7 |
8 | using ArduinoInterfaces;
9 |
10 | public class ArduinoMessagesReceiving
11 | {
12 | private BitArray buttons;
13 | private int buttonsRead;
14 | private int numberUnits = 1;
15 | private readonly byte[] butByte = new byte[1];
16 | private List tm1640Units;
17 |
18 | public event ButtonPressEventHandler ButtonPress;
19 | public delegate void ButtonPressEventHandler(int unit, int button);
20 |
21 | public void UpdateInternalVariables(List tm1640UnitsIn, int numberUnitsIn)
22 | {
23 | if (tm1640UnitsIn != null)
24 | {
25 | this.tm1640Units = tm1640UnitsIn;
26 | }
27 | this.numberUnits = numberUnitsIn;
28 | }
29 |
30 | public void SerialMessageReceiver(int[] message)
31 | {
32 | switch (message[0])
33 | {
34 | case 55: TM1638ButtonsMessageReader(message);
35 | break;
36 | }
37 | }
38 |
39 | private void TM1638ButtonsMessageReader(IList messageData)
40 | {
41 | int readPos = 1;
42 | for (int u = 1; u <= this.numberUnits; u++)
43 | {
44 | if (this.tm1640Units[u - 1])
45 | {
46 | continue;
47 | }
48 | this.buttonsRead = messageData[readPos++];
49 | if (this.buttonsRead != -1)
50 | {
51 | this.butByte[0] = Convert.ToByte(this.buttonsRead);
52 | this.buttons = new BitArray(this.butByte);
53 | for (var i = 0; i < Constants.NumberButtonsOnTm1638; i++)
54 | {
55 | if (this.buttons[i])
56 | {
57 | if (this.ButtonPress == null) throw new ArgumentNullException();
58 | ButtonPressEventHandler temp = this.ButtonPress;
59 | if (temp != null)
60 | {
61 | temp(u, i+1);
62 | }
63 | }
64 | }
65 | }
66 | }
67 | }
68 |
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/iRduino/Classes/ArduinoSketch.cs:
--------------------------------------------------------------------------------
1 | //========================================//
2 | // iRduino - Created by Mark Silverwood //
3 | //======================================//
4 | namespace iRduino.Classes
5 | {
6 | using System.IO;
7 | using System.Windows;
8 | using System;
9 | using System.Collections.Generic;
10 | using Microsoft.Win32;
11 |
12 | using iRduino.ArduinoTemplates;
13 |
14 | public class ArduinoPins
15 | {
16 | public int DataPin;
17 |
18 | public int ClockPin;
19 |
20 | public List UnitStrobePins;
21 |
22 | public List TM1640DataPins;
23 |
24 | public List TM1640ClockPins;
25 | }
26 |
27 | public class ArduinoSketch
28 | {
29 |
30 | public static void GenerateSketch(ConfigurationOptions configurationOptions, ArduinoPins pins)
31 | {
32 | string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
33 | + "\\iRduino\\";
34 | // Configure save file dialog box
35 | var dlg = new SaveFileDialog
36 | {
37 | FileName = configurationOptions.Name,
38 | DefaultExt = ".ino",
39 | InitialDirectory = documentsPath,
40 | Filter = "Arduino Sketch (.ino)|*.ino"
41 | };
42 |
43 | // Show save file dialog box
44 | bool? result = dlg.ShowDialog();
45 |
46 | // Process save file dialog box results
47 | if (result != true) return;
48 | // Save document
49 | string fileLocation = dlg.FileName;
50 | int startOfName = fileLocation.LastIndexOf("\\", StringComparison.Ordinal);
51 | int startOfExtension = fileLocation.LastIndexOf('.');
52 | if (startOfName < startOfExtension)
53 | {
54 | string name = fileLocation.Substring(startOfName+1,startOfExtension-startOfName-1);
55 | if (name.Length < startOfName - 1)
56 | {
57 | if (fileLocation.Substring(startOfName - name.Length, name.Length) != name)
58 | {
59 | //directory not valid
60 | fileLocation = fileLocation.Insert(startOfName + 1, String.Format("{0}\\",name));
61 | }
62 |
63 | }
64 | }
65 |
66 | FileInfo file = new FileInfo(fileLocation);
67 | if (file.Directory != null)
68 | {
69 | file.Directory.Create(); // If the directory already exists, this method does nothing.
70 | }
71 |
72 | ArduinoSketchT4 sketch = new ArduinoSketchT4(configurationOptions, pins);
73 | String sketchContent = sketch.TransformText();
74 | File.WriteAllText(fileLocation, sketchContent);
75 |
76 | MessageBox.Show("Finished Saving Arduino Sketch");
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/iRduino/Classes/ControllerDevice.cs:
--------------------------------------------------------------------------------
1 | //========================================//
2 | // iRduino - Created by Mark Silverwood //
3 | //======================================//
4 |
5 | namespace iRduino.Classes
6 | {
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq;
10 | using System.Windows.Forms;
11 | using SlimDX;
12 | using SlimDX.DirectInput;
13 |
14 | public class ControllerDevice : IDisposable
15 | {
16 | public int ButtonCount;
17 | public Guid Guid;
18 | public string Name;
19 | public Joystick Pad;
20 | public JoystickState State;
21 |
22 | public void Dispose()
23 | {
24 | Dispose(true);
25 | GC.SuppressFinalize(this);
26 | }
27 | protected virtual void Dispose(bool disposing)
28 | {
29 | if (disposing)
30 | if (Pad != null)
31 | {
32 | Pad.Dispose();
33 | Pad = null;
34 | }
35 | }
36 | ~ControllerDevice()
37 | {
38 | Dispose(false);
39 | }
40 | public void Acquire(Form parent)
41 | {
42 | var dinput = new DirectInput();
43 |
44 | Pad = new Joystick(dinput, Guid);
45 | foreach (DeviceObjectInstance doi in Pad.GetObjects(ObjectDeviceType.Axis))
46 | {
47 | Pad.GetObjectPropertiesById((int) doi.ObjectType).SetRange(-5000, 5000);
48 | }
49 |
50 | Pad.Properties.AxisMode = DeviceAxisMode.Absolute;
51 | Pad.SetCooperativeLevel(parent, (CooperativeLevel.Nonexclusive | CooperativeLevel.Background));
52 | ButtonCount = Pad.Capabilities.ButtonCount;
53 | Pad.Acquire();
54 | }
55 |
56 | public List GetButtons()
57 | {
58 | if (Pad.Acquire().IsFailure)
59 | return null;
60 |
61 | if (Pad.Poll().IsFailure)
62 | return null;
63 |
64 | State = Pad.GetCurrentState();
65 | if (Result.Last.IsFailure)
66 | return null;
67 |
68 | var answer = new List();
69 |
70 | bool[] buttons = State.GetButtons();
71 | for (int b = 0; b < buttons.Length; b++)
72 | {
73 | if (buttons[b])
74 | answer.Add(b);
75 | }
76 | return answer;
77 | }
78 |
79 | public static IList Available()
80 | {
81 | var dinput = new DirectInput();
82 | return
83 | dinput.GetDevices(DeviceClass.GameController, DeviceEnumerationFlags.AttachedOnly)
84 | .Select(di => new ControllerDevice {Guid = di.InstanceGuid, Name = di.InstanceName})
85 | .ToList();
86 | }
87 | }
88 | }
--------------------------------------------------------------------------------
/iRduino/Classes/Dictionarys.cs:
--------------------------------------------------------------------------------
1 | //========================================//
2 | // iRduino - Created by Mark Silverwood //
3 | //======================================//
4 |
5 | namespace iRduino.Classes
6 | {
7 | using System.Collections.Generic;
8 |
9 | ///
10 | /// Container class for all the Dictionaries used in the Application
11 | ///
12 | public class Dictionarys
13 | {
14 | public Dictionary ButtonFunctions;
15 |
16 | public Dictionary ComPorts = new Dictionary
17 | {
18 | {0, "COM1"},
19 | {1, "COM2"},
20 | {2, "COM3"},
21 | {3, "COM4"},
22 | {4, "COM5"},
23 | {5, "COM6"},
24 | {6, "COM7"},
25 | {7, "COM8"},
26 | {8, "COM9"},
27 | {9, "COM10"},
28 | {10, "COM11"},
29 | {11, "COM12"},
30 | {12, "COM13"},
31 | {13, "COM14"},
32 | {14, "COM15"},
33 | {15, "COM16"},
34 | {16, "COM17"},
35 | {17, "COM18"},
36 | {18, "COM19"},
37 | {19, "COM20"},
38 | {20, "COM21"},
39 | {21, "COM22"},
40 | {22, "COM23"},
41 | {23, "COM24"},
42 | {24, "COM25"},
43 | {25, "COM26"},
44 | {26, "COM27"},
45 | {27, "COM28"},
46 | {28, "COM29"},
47 | {29, "COM30"},
48 | {30, "COM31"},
49 | {31, "COM32"}
50 | };
51 |
52 | public Dictionary WarningTypes = new Dictionary
53 | {
54 | {"Text Only",WarningTypesEnum.Text},
55 | {"Lights Only",WarningTypesEnum.Lights},
56 | {"Both Lights and Text",WarningTypesEnum.Both}
57 | };
58 |
59 | public Dictionary DisplayVariables;
60 | public Dictionary LapDisplayStyles;
61 | public Dictionary PitFlashSpeeds;
62 | public Dictionary PitFlashStyles;
63 | public Dictionary PitStyles;
64 | public Dictionary RPMStyles;
65 | public Dictionary RevFlashStyles;
66 | public Dictionary RevLimStyles;
67 | public Dictionary ShiftStyles;
68 | public Dictionary MatchCarShiftOptions;
69 | public Dictionary DeltaLightsPositionOptions;
70 |
71 | public Dictionarys()
72 | {
73 | this.ButtonFunctions = ButtonFunctionsClass.FillButtonFunctions();
74 | this.DisplayVariables = DisplayVariablesClass.FillDisplayVariables();
75 | LEDs.LEDUserInterfaceNames(out this.ShiftStyles, out this.PitFlashStyles, out this.RevFlashStyles, out this.PitFlashSpeeds, out this.MatchCarShiftOptions, out this.DeltaLightsPositionOptions);
76 | this.RPMStyles = LEDs.FillRPMStyles();
77 | this.PitStyles = LEDs.FillPitStyles();
78 | this.RevLimStyles = LEDs.FillRevLimStyles();
79 | this.LapDisplayStyles = LapDisplays.LapDisplayStylesFill();
80 | }
81 |
82 | }
83 | }
--------------------------------------------------------------------------------
/iRduino/Classes/ErrorReporting.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace iRduino.Classes
4 | {
5 | using iRduino.Windows;
6 |
7 | class ErrorReporting
8 | {
9 | public static void MyHandler(object sender, UnhandledExceptionEventArgs args)
10 | {
11 | Exception e = (Exception)args.ExceptionObject;
12 | if (e.Source != "iRacingSdkWrapper")
13 | {
14 | #if !DEBUG
15 | string error =
16 | String.Format(
17 | "{0}\n{1}\n{2}\n{3}",
18 | e.Message,
19 | e.Source,
20 | e.TargetSite,
21 | e.StackTrace);
22 | ErrorWindow window = new ErrorWindow(error);
23 | window.ShowDialog();
24 | #endif
25 | }
26 | }
27 |
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/iRduino/Classes/OptionPages.cs:
--------------------------------------------------------------------------------
1 | //========================================//
2 | // iRduino - Created by Mark Silverwood //
3 | //======================================//
4 |
5 | namespace iRduino.Classes
6 | {
7 | using System;
8 | using System.Globalization;
9 | using System.Reflection;
10 | using System.Xml;
11 |
12 | public enum PageTypes
13 | {
14 | Configuration,
15 | CurrentConfiguration,
16 | AdvancedOptions,
17 | TMUnits,
18 | Unit,
19 | Buttons,
20 | LEDs,
21 | Screen,
22 | TM1640Screen,
23 | JoystickButtons,
24 | Arduino,
25 | FergoTech,
26 | DigitalInputs,
27 | DigitalOutputs,
28 | Expander,
29 | Blank,
30 | None
31 | }
32 |
33 | class OptionPages
34 | {
35 | public static Version GetPublishedVersion()
36 | {
37 | XmlDocument xmlDoc = new XmlDocument();
38 | Assembly asmCurrent = Assembly.GetExecutingAssembly();
39 | string executePath = new Uri(asmCurrent.GetName().CodeBase).LocalPath;
40 |
41 | xmlDoc.Load(executePath + ".manifest");
42 | string retval = string.Empty;
43 | if (xmlDoc.HasChildNodes)
44 | {
45 | var attributes = xmlDoc.ChildNodes[1].ChildNodes[0].Attributes;
46 | if (attributes != null)
47 | {
48 | retval = attributes.GetNamedItem("version").Value.ToString(CultureInfo.InvariantCulture);
49 | }
50 | }
51 | return new Version(retval);
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/iRduino/Classes/ShiftLightData.cs:
--------------------------------------------------------------------------------
1 | //========================================//
2 | // iRduino - Created by Mark Silverwood //
3 | //======================================//
4 |
5 | namespace iRduino.Classes
6 | {
7 | using System.IO;
8 | using System.Xml.Serialization;
9 |
10 | public class ShiftLightData
11 | {
12 | public static ShiftData LoadShiftData(string path)
13 | {
14 | var xRoot = new XmlRootAttribute { ElementName = "ShiftData", IsNullable = true };
15 | var ser = new XmlSerializer(typeof(ShiftData),xRoot);
16 | return ser.Deserialize(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) as ShiftData;
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/iRduino/Commands/ShowMainWindow.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | using System.Windows;
7 | using System.Windows.Input;
8 |
9 | namespace iRduino.Commands
10 | {
11 |
12 | public class ShowMainWindow : CommandBase
13 | {
14 | public override void Execute(object parameter)
15 | {
16 | GetTaskbarWindow(parameter).Show();
17 | GetTaskbarWindow(parameter).WindowState = WindowState.Normal;
18 | CommandManager.InvalidateRequerySuggested();
19 | }
20 |
21 |
22 | public override bool CanExecute(object parameter)
23 | {
24 |
25 | return true;
26 | //Window win = GetTaskbarWindow(parameter);
27 | //return win != null && !win.IsVisible;
28 |
29 | }
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/iRduino/MahApps.Metro/Entypo-license.txt:
--------------------------------------------------------------------------------
1 | Entypo (http://www.entypo.com/) is created by Daniel Bruce and released under the Creative Commons, Share Alike/Attribution license.
2 |
3 | http://creativecommons.org/licenses/by-sa/3.0/
--------------------------------------------------------------------------------
/iRduino/MahApps.Metro/Information.txt:
--------------------------------------------------------------------------------
1 | http://mahapps.com/MahApps.Metro/
2 | https://github.com/MahApps/MahApps.Metro
--------------------------------------------------------------------------------
/iRduino/MahApps.Metro/MahApps.Metro.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/MahApps.Metro/MahApps.Metro.dll
--------------------------------------------------------------------------------
/iRduino/MahApps.Metro/System.Windows.Interactivity.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/MahApps.Metro/System.Windows.Interactivity.dll
--------------------------------------------------------------------------------
/iRduino/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 | using System.Windows;
4 | using System.Resources;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 |
10 | [assembly: AssemblyTitle("iRduino")]
11 | [assembly:
12 | AssemblyDescription(
13 | "An application for interfacing with iRacing's API to an Arduino board.")]
14 | [assembly: AssemblyConfiguration("")]
15 | [assembly: AssemblyCompany("Mark Silverwood")]
16 | [assembly: AssemblyProduct("iRduino")]
17 | [assembly: AssemblyCopyright("Copyright © 2013")]
18 | [assembly: AssemblyTrademark("")]
19 | [assembly: AssemblyCulture("")]
20 |
21 | // Setting ComVisible to false makes the types in this assembly not visible
22 | // to COM components. If you need to access a type in this assembly from
23 | // COM, set the ComVisible attribute to true on that type.
24 |
25 | [assembly: ComVisible(false)]
26 |
27 | //In order to begin building localizable applications, set
28 | //CultureYouAreCodingWith in your .csproj file
29 | //inside a . For example, if you are using US english
30 | //in your source files, set the to en-US. Then uncomment
31 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
32 | //the line below to match the UICulture setting in the project file.
33 |
34 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
35 |
36 |
37 | [assembly: ThemeInfo(
38 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
39 | //(used if a resource is not found in the page,
40 | // or application resource dictionaries)
41 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
42 | //(used if a resource is not found in the page,
43 | // app, or any theme specific resource dictionaries)
44 | )]
45 |
46 |
47 | // Version information for an assembly consists of the following four values:
48 | //
49 | // Major Version
50 | // Minor Version
51 | // Build Number
52 | // Revision
53 | //
54 | // You can specify all the values or you can default the Build and Revision Numbers
55 | // by using the '*' as shown below:
56 | // [assembly: AssemblyVersion("1.0.*")]
57 |
58 | [assembly: AssemblyVersion("1.8.5.1")]
59 | [assembly: AssemblyFileVersion("1.8.5.1")]
60 | [assembly: NeutralResourcesLanguageAttribute("en-GB")]
--------------------------------------------------------------------------------
/iRduino/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.17929
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace iRduino.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/iRduino/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/iRduino/Resources/Configuration-Settings-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/Configuration-Settings-icon.png
--------------------------------------------------------------------------------
/iRduino/Resources/Entypo.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/Entypo.ttf
--------------------------------------------------------------------------------
/iRduino/Resources/ErrorBig.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/ErrorBig.png
--------------------------------------------------------------------------------
/iRduino/Resources/Motorsport-Helmet.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/Motorsport-Helmet.ico
--------------------------------------------------------------------------------
/iRduino/Resources/MyTabStyle.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
61 |
--------------------------------------------------------------------------------
/iRduino/Resources/appbar.close32W.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/appbar.close32W.png
--------------------------------------------------------------------------------
/iRduino/Resources/appbar.cog.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/appbar.cog.png
--------------------------------------------------------------------------------
/iRduino/Resources/appbar.control.play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/appbar.control.play.png
--------------------------------------------------------------------------------
/iRduino/Resources/appbar.control.stop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/appbar.control.stop.png
--------------------------------------------------------------------------------
/iRduino/Resources/appbar.information.circle32W.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/appbar.information.circle32W.png
--------------------------------------------------------------------------------
/iRduino/Resources/appbar.lifesaver32W.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/appbar.lifesaver32W.png
--------------------------------------------------------------------------------
/iRduino/Resources/appbar.minus32W.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/appbar.minus32W.png
--------------------------------------------------------------------------------
/iRduino/Resources/arduinoTemp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/arduinoTemp.png
--------------------------------------------------------------------------------
/iRduino/Resources/arrow_divide.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/arrow_divide.png
--------------------------------------------------------------------------------
/iRduino/Resources/arrow_inout.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/arrow_inout.png
--------------------------------------------------------------------------------
/iRduino/Resources/arrow_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/arrow_left.png
--------------------------------------------------------------------------------
/iRduino/Resources/arrow_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/arrow_right.png
--------------------------------------------------------------------------------
/iRduino/Resources/brick.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/brick.png
--------------------------------------------------------------------------------
/iRduino/Resources/brickBlue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/brickBlue.png
--------------------------------------------------------------------------------
/iRduino/Resources/bricks.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/bricks.png
--------------------------------------------------------------------------------
/iRduino/Resources/controller.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/controller.png
--------------------------------------------------------------------------------
/iRduino/Resources/error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/error.png
--------------------------------------------------------------------------------
/iRduino/Resources/ftTemp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/ftTemp.png
--------------------------------------------------------------------------------
/iRduino/Resources/iRduino.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/iRduino.png
--------------------------------------------------------------------------------
/iRduino/Resources/iRduinoAbout.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/iRduinoAbout.png
--------------------------------------------------------------------------------
/iRduino/Resources/iRdunio-ICON.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/iRdunio-ICON.ico
--------------------------------------------------------------------------------
/iRduino/Resources/iRdunio-Logo32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/iRdunio-Logo32.png
--------------------------------------------------------------------------------
/iRduino/Resources/iRdunio-Logo64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/iRdunio-Logo64.png
--------------------------------------------------------------------------------
/iRduino/Resources/joystick.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/joystick.png
--------------------------------------------------------------------------------
/iRduino/Resources/layers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/layers.png
--------------------------------------------------------------------------------
/iRduino/Resources/lightbulb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/lightbulb.png
--------------------------------------------------------------------------------
/iRduino/Resources/lightbulb_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/lightbulb_off.png
--------------------------------------------------------------------------------
/iRduino/Resources/octobrite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/octobrite.png
--------------------------------------------------------------------------------
/iRduino/Resources/page_gear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/page_gear.png
--------------------------------------------------------------------------------
/iRduino/Resources/picture_empty.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/picture_empty.png
--------------------------------------------------------------------------------
/iRduino/Resources/plugin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/plugin.png
--------------------------------------------------------------------------------
/iRduino/Resources/script_gear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/script_gear.png
--------------------------------------------------------------------------------
/iRduino/Resources/simwind.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/simwind.png
--------------------------------------------------------------------------------
/iRduino/Resources/wrench_orange.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Resources/wrench_orange.png
--------------------------------------------------------------------------------
/iRduino/Windows/AboutBox.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/iRduino/Windows/AboutBox.xaml.cs:
--------------------------------------------------------------------------------
1 | //========================================//
2 | // iRduino - Created by Mark Silverwood //
3 | //======================================//
4 |
5 | namespace iRduino.Windows
6 | {
7 | using System.Reflection;
8 | using System;
9 |
10 | ///
11 | /// Interaction logic for AboutBox.xaml
12 | ///
13 | public partial class AboutBox
14 | {
15 | public AboutBox()
16 | {
17 | InitializeComponent();
18 | VersionNumberLabel.Content = AssemblyVersion;
19 | BuildDateLabel.Content = RetrieveLinkerTimestamp().ToLongDateString();
20 | }
21 |
22 | public string AssemblyVersion
23 | {
24 | get { return Assembly.GetExecutingAssembly().GetName().Version.ToString(); }
25 | }
26 |
27 | private static DateTime RetrieveLinkerTimestamp()
28 | {
29 | string filePath = Assembly.GetCallingAssembly().Location;
30 | const int CPeHeaderOffset = 60;
31 | const int CLinkerTimestampOffset = 8;
32 | var b = new byte[2048];
33 | System.IO.Stream s = null;
34 |
35 | try
36 | {
37 | s = new System.IO.FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
38 | s.Read(b, 0, 2048);
39 | }
40 | finally
41 | {
42 | if (s != null)
43 | {
44 | s.Close();
45 | }
46 | }
47 |
48 | int i = BitConverter.ToInt32(b, CPeHeaderOffset);
49 | int secondsSince1970 = BitConverter.ToInt32(b, i + CLinkerTimestampOffset);
50 | var dt = new DateTime(1970, 1, 1, 0, 0, 0);
51 | dt = dt.AddSeconds(secondsSince1970);
52 | dt = dt.AddHours(TimeZone.CurrentTimeZone.GetUtcOffset(dt).Hours);
53 | return dt;
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/iRduino/Windows/ErrorWindow.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/iRduino/Windows/ErrorWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | //========================================//
2 | // iRduino - Created by Mark Silverwood //
3 | //======================================//
4 |
5 | namespace iRduino.Windows
6 | {
7 | ///
8 | /// Interaction logic for ErrorWindow.xaml
9 | ///
10 | public partial class ErrorWindow
11 | {
12 | public ErrorWindow(string errorText)
13 | {
14 | InitializeComponent();
15 | ErrorTextBox.Text = errorText;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/iRduino/Windows/OptionsWindow.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
26 |
28 |
30 |
32 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
43 |
44 |
45 |
47 |
48 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
72 |
73 |
74 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/iRduino/Windows/OptionsWindow.xaml.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SlicedSilver/iRduino/4607dadb57546fdf93d0befc7c2734e3700df400/iRduino/Windows/OptionsWindow.xaml.cs
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/AdvancedOptions.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/AdvancedOptions.xaml.cs:
--------------------------------------------------------------------------------
1 | //========================================//
2 | // iRduino - Created by Mark Silverwood //
3 | //======================================//
4 |
5 | namespace iRduino.Windows.Pages
6 | {
7 | using iRduino.Classes;
8 |
9 | using System.Globalization;
10 | using System.Windows.Controls.Primitives;
11 | using System.Windows.Data;
12 | using System.Windows;
13 |
14 | ///
15 | /// Interaction logic for AdvancedOptions.xaml
16 | ///
17 | public partial class AdvancedOptions
18 | {
19 | private ConfigurationOptions temp;
20 |
21 | private int numberTM1638;
22 | private int numberTM1640;
23 |
24 | public AdvancedOptions()
25 | {
26 | this.InitializeComponent();
27 | }
28 |
29 | private void SerialSpeedCheckBoxUnchecked1(object sender, RoutedEventArgs e)
30 | {
31 | this.SerialSpeedCBox.IsEnabled = false;
32 | this.SerialPortSpeedLabel.IsEnabled = false;
33 | }
34 |
35 | private void SerialSpeedCheckBoxChecked1(object sender, RoutedEventArgs e)
36 | {
37 | this.SerialSpeedCBox.IsEnabled = true;
38 | this.SerialPortSpeedLabel.IsEnabled = true;
39 | }
40 |
41 | private void PageLoaded1(object sender, RoutedEventArgs e)
42 | {
43 | this.SerialPortSpeedLabel.IsEnabled = false;
44 | this.temp = (ConfigurationOptions)this.DataContext;
45 | this.numberTM1640 = 0;
46 | this.numberTM1638 = 0;
47 | for (var x = 2; x <= 50; x++)
48 | {
49 | this.FuelLapsCBox.Items.Add(x.ToString(CultureInfo.InvariantCulture));
50 | }
51 | foreach (var item in Classes.AdvancedOptions.SerialSpeeds)
52 | {
53 | this.SerialSpeedCBox.Items.Add(item.ToString(CultureInfo.InvariantCulture));
54 | }
55 | foreach (var unit in this.temp.DisplayUnitConfigurations)
56 | {
57 | if (unit.IsTM1640)
58 | {
59 | this.numberTM1640++;
60 | }
61 | else
62 | {
63 | this.numberTM1638++;
64 | }
65 | }
66 | this.RecommendSpeed.Content = Classes.AdvancedOptions.CalculateRecommendSerialSpeed(Classes.AdvancedOptions.ParseRefreshRatesString(temp.DisplayRefreshRate), Classes.AdvancedOptions.ParseRefreshRatesString(temp.LEDRefreshRate),
67 | this.numberTM1638, this.numberTM1640);
68 | //databinding
69 | var useCustomSpeedBinding = new Binding("UseCustomSerialSpeed") { Mode = BindingMode.TwoWay };
70 | BindingOperations.SetBinding(this.UseCustomSpeedCheck, ToggleButton.IsCheckedProperty, useCustomSpeedBinding);
71 | var serialSpeedBinding = new Binding("SerialPortSpeed") { Mode = BindingMode.TwoWay };
72 | BindingOperations.SetBinding(this.SerialSpeedCBox, Selector.SelectedValueProperty, serialSpeedBinding);
73 | var logMessagesBinding = new Binding("LogArduinoMessages") { Mode = BindingMode.TwoWay };
74 | BindingOperations.SetBinding(this.LogMessagesCheck, ToggleButton.IsCheckedProperty, logMessagesBinding);
75 | var useCustomFuelOptionsBinding = new Binding("UseCustomFuelCalculationOptions") { Mode = BindingMode.TwoWay };
76 | BindingOperations.SetBinding(this.UseCustomFuelOptionsCheck, ToggleButton.IsCheckedProperty, useCustomFuelOptionsBinding);
77 | var useWeightedFuelBinding = new Binding("UseWeightedFuelCalculations") { Mode = BindingMode.TwoWay };
78 | BindingOperations.SetBinding(this.WeightedFuelCheck, ToggleButton.IsCheckedProperty, useWeightedFuelBinding);
79 | var fuelLapsBinding = new Binding("FuelCalculationLaps") { Mode = BindingMode.TwoWay };
80 | BindingOperations.SetBinding(this.FuelLapsCBox, Selector.SelectedIndexProperty, fuelLapsBinding);
81 | }
82 |
83 | private void UseCustomFuelOptionsCheckChecked(object sender, RoutedEventArgs e)
84 | {
85 | FuelLapsCBox.IsEnabled = true;
86 | WeightedFuelCheck.IsEnabled = true;
87 | }
88 |
89 | private void UseCustomFuelOptionsCheckUnchecked(object sender, RoutedEventArgs e)
90 | {
91 | FuelLapsCBox.SelectedIndex = 1;
92 | FuelLapsCBox.IsEnabled = false;
93 | WeightedFuelCheck.IsChecked = true;
94 | WeightedFuelCheck.IsEnabled = false;
95 | }
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/Arduino.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/Arduino.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace iRduino.Windows.Pages
2 | {
3 | using System.Globalization;
4 |
5 | using ArduinoInterfaces;
6 |
7 | using iRduino.Classes;
8 |
9 | ///
10 | /// Interaction logic for Arduino.xaml
11 | ///
12 | public partial class Arduino
13 | {
14 | private bool startingUp = true;
15 |
16 | public Arduino()
17 | {
18 | InitializeComponent();
19 | }
20 |
21 | private void PageLoaded1(object sender, System.Windows.RoutedEventArgs e)
22 | {
23 | var temp = (ConfigurationOptions) this.DataContext;
24 | for (int i = 0; i <= Constants.MaxIntensityTM; i++)
25 | {
26 | this.ExpanderNumCBox.Items.Add(i.ToString(CultureInfo.InvariantCulture));
27 | }
28 | this.UseExpandersCheck.IsChecked = temp.ArduinoIOConfiguration.UseExpanders;
29 | this.ExpanderNumCBox.SelectedIndex = temp.ArduinoIOConfiguration.NumberExpanders;
30 | this.UseDigitalInputsCheck.IsChecked = temp.ArduinoIOConfiguration.Inputs.UseDigitalInputs;
31 | this.UseAnalogInputsCheck.IsChecked = temp.ArduinoIOConfiguration.Inputs.UseAnalogInputs;
32 | this.UseDigitalOutputsCheck.IsChecked = temp.ArduinoIOConfiguration.Outputs.UseDigitalOutputs;
33 | this.UseAnalogOutputsCheck.IsChecked = temp.ArduinoIOConfiguration.Outputs.UseAnalogOutputs;
34 | this.startingUp = false;
35 | }
36 |
37 | private void Checker(object sender, System.Windows.RoutedEventArgs e)
38 | {
39 | if (this.startingUp) //prevents event from travelling further
40 | {
41 | e.Handled = true;
42 | }
43 | }
44 |
45 | private void UseExpandersCheckChecked(object sender, System.Windows.RoutedEventArgs e)
46 | {
47 | this.ExpanderNumCBox.IsEnabled = true;
48 | this.NumberExpandersLabel.IsEnabled = true;
49 | if (!this.startingUp)
50 | {
51 | this.ExpanderNumCBox.SelectedIndex = 0;
52 | //e.Handled = true;
53 | }
54 | }
55 |
56 | private void UseExpandersCheckUnchecked(object sender, System.Windows.RoutedEventArgs e)
57 | {
58 | if (!this.startingUp)
59 | {
60 | this.ExpanderNumCBox.SelectedIndex = 0;
61 | //e.Handled = true;
62 | }
63 | this.NumberExpandersLabel.IsEnabled = false;
64 | this.ExpanderNumCBox.IsEnabled = false;
65 | }
66 |
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/BlankPage.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/BlankPage.xaml.cs:
--------------------------------------------------------------------------------
1 | //========================================//
2 | // iRduino - Created by Mark Silverwood //
3 | //======================================//
4 |
5 | namespace iRduino.Windows.Pages
6 | {
7 | ///
8 | /// Interaction logic for BlankPage.xaml
9 | ///
10 | public partial class BlankPage
11 | {
12 | public BlankPage()
13 | {
14 | this.InitializeComponent();
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/ConfigurationPage.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
31 |
40 |
49 |
58 |
66 |
68 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/ConfigurationPage.xaml.cs:
--------------------------------------------------------------------------------
1 | //========================================//
2 | // iRduino - Created by Mark Silverwood //
3 | //======================================//
4 |
5 | namespace iRduino.Windows.Pages
6 | {
7 | ///
8 | /// Interaction logic for ConfigurationPage.xaml
9 | ///
10 | public partial class ConfigurationPage
11 | {
12 | public ConfigurationPage()
13 | {
14 | this.InitializeComponent();
15 | }
16 |
17 | }
18 | }
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/CurrentConfiguration.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
24 |
25 |
27 |
28 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/CurrentConfiguration.xaml.cs:
--------------------------------------------------------------------------------
1 | //========================================//
2 | // iRduino - Created by Mark Silverwood //
3 | //======================================//
4 |
5 | namespace iRduino.Windows.Pages
6 | {
7 | using ArduinoInterfaces;
8 |
9 | using iRduino.Classes;
10 |
11 | using System.Globalization;
12 | using System.Windows;
13 | using System.Windows.Controls;
14 | using System.Windows.Controls.Primitives;
15 | using System.Windows.Data;
16 |
17 | ///
18 | /// Interaction logic for CurrentConfiguration.xaml
19 | ///
20 | public partial class CurrentConfiguration
21 | {
22 | private bool startingUp = true;
23 |
24 | public CurrentConfiguration()
25 | {
26 | this.InitializeComponent();
27 | }
28 |
29 | private void PageLoaded1(object sender, RoutedEventArgs e)
30 | {
31 | this.NumberControllersLabel.IsEnabled = false;
32 | for (int i = 0; i <= Constants.MaxIntensityTM; i++)
33 | {
34 | this.ControllerNumCBox.Items.Add(i.ToString(CultureInfo.InvariantCulture));
35 | }
36 | var temp = (ConfigurationOptions) this.DataContext;
37 | foreach (var com in temp.Dictionarys.ComPorts)
38 | {
39 | this.PrefComPortCBox.Items.Add(com.Value);
40 | }
41 | this.UseDXUnitsCheck.IsChecked = temp.DisplayUnitConfigurations.Count != 0;
42 | this.UseArduinoIOCheck.IsChecked = temp.ArduinoIOConfiguration.UseArduinoIO;
43 | this.UseFergoTechCheck.IsChecked = temp.FergoTechConfiguration.UseFergoTechComponents;
44 | //Setup Data Binding
45 | var nameBinding = new Binding("Name") {Mode = BindingMode.TwoWay};
46 | BindingOperations.SetBinding(this.NameTextBox, TextBox.TextProperty, nameBinding);
47 | var prefComBinding = new Binding("PreferredComPort") {Mode = BindingMode.TwoWay};
48 | BindingOperations.SetBinding(this.PrefComPortCBox, Selector.SelectedIndexProperty, prefComBinding);
49 | var contNumBinding = new Binding("NumberControllers") {Mode = BindingMode.TwoWay};
50 | BindingOperations.SetBinding(this.ControllerNumCBox, Selector.SelectedIndexProperty, contNumBinding);
51 | this.UseControllersCheck.IsChecked = this.ControllerNumCBox.SelectedIndex > 0;
52 | this.startingUp = false;
53 | }
54 |
55 | private void UseDxUnitsCheckChecked(object sender, RoutedEventArgs e)
56 | {
57 | if (this.startingUp) //prevents event from travelling further
58 | {
59 | e.Handled = true;
60 | }
61 | }
62 |
63 | private void UseDxUnitsCheckUnchecked(object sender, RoutedEventArgs e)
64 | {
65 | if (this.startingUp)
66 | {
67 | e.Handled = true;
68 | }
69 | }
70 |
71 | private void UseControllersCheckUnchecked(object sender, RoutedEventArgs e)
72 | {
73 | if (!this.startingUp)
74 | {
75 | this.ControllerNumCBox.SelectedIndex = 0;
76 | //e.Handled = true;
77 | }
78 | this.ControllerNumCBox.IsEnabled = false;
79 | this.NumberControllersLabel.IsEnabled = false;
80 | }
81 |
82 | private void UseControllersCheckChecked(object sender, RoutedEventArgs e)
83 | {
84 | this.ControllerNumCBox.IsEnabled = true;
85 | this.NumberControllersLabel.IsEnabled = true;
86 | if (!this.startingUp)
87 | {
88 | this.ControllerNumCBox.SelectedIndex = 0;
89 | //e.Handled = true;
90 | }
91 | }
92 |
93 | private void ControllerNumCBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
94 | {
95 | if (this.startingUp)
96 | {
97 | e.Handled = true;
98 | }
99 | }
100 |
101 | private void UseArduinoIOChecked(object sender, RoutedEventArgs e)
102 | {
103 | if (this.startingUp)
104 | {
105 | e.Handled = true;
106 | }
107 | }
108 |
109 | private void UseArduinoIOUnChecked(object sender, RoutedEventArgs e)
110 | {
111 | if (this.startingUp)
112 | {
113 | e.Handled = true;
114 | }
115 | }
116 |
117 | private void UseFergoTechUnChecked(object sender, RoutedEventArgs e)
118 | {
119 | if (this.startingUp)
120 | {
121 | e.Handled = true;
122 | }
123 | }
124 |
125 | private void UseFergoTechChecked(object sender, RoutedEventArgs e)
126 | {
127 | if (this.startingUp)
128 | {
129 | e.Handled = true;
130 | }
131 | }
132 |
133 | }
134 | }
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/DigitalInputs.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/DigitalInputs.xaml.cs:
--------------------------------------------------------------------------------
1 | //========================================//
2 | // iRduino - Created by Mark Silverwood //
3 | //======================================//
4 | namespace iRduino.Windows.Pages
5 | {
6 | ///
7 | /// Interaction logic for Inputs.xaml
8 | ///
9 | public partial class DigitalInputs
10 | {
11 | public DigitalInputs()
12 | {
13 | InitializeComponent();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/DigitalOutputs.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/DigitalOutputs.xaml.cs:
--------------------------------------------------------------------------------
1 | //========================================//
2 | // iRduino - Created by Mark Silverwood //
3 | //======================================//
4 | namespace iRduino.Windows.Pages
5 | {
6 | ///
7 | /// Interaction logic for Outputs.xaml
8 | ///
9 | public partial class DigitalOutputs
10 | {
11 | public DigitalOutputs()
12 | {
13 | InitializeComponent();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/Expander.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/Expander.xaml.cs:
--------------------------------------------------------------------------------
1 | //========================================//
2 | // iRduino - Created by Mark Silverwood //
3 | //======================================//
4 | namespace iRduino.Windows.Pages
5 | {
6 | ///
7 | /// Interaction logic for Inputs.xaml
8 | ///
9 | public partial class Expander
10 | {
11 | public Expander()
12 | {
13 | InitializeComponent();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/FergoTech.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/FergoTech.xaml.cs:
--------------------------------------------------------------------------------
1 | //========================================//
2 | // iRduino - Created by Mark Silverwood //
3 | //======================================//
4 | namespace iRduino.Windows.Pages
5 | {
6 | ///
7 | /// Interaction logic for FergoTech.xaml
8 | ///
9 | public partial class FergoTech
10 | {
11 | public FergoTech()
12 | {
13 | InitializeComponent();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/PageHelper.cs:
--------------------------------------------------------------------------------
1 | using iRduino.Classes;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Windows.Controls;
6 |
7 | namespace iRduino.Windows.Pages
8 | {
9 | public class PageHelper
10 | {
11 | public static void StartLoading1(List scv, ref int screen, DisplayUnitConfiguration temp, CheckBox useCustomHeaderCheck, TextBox headerTextBox, ref bool firstLoad)
12 | {
13 | foreach (ComboBox cbox in scv)
14 | {
15 | cbox.SelectedIndex = -1;
16 | cbox.IsEnabled = false;
17 | }
18 | scv[0].IsEnabled = true;
19 | screen = temp.ScreenToEdit;
20 | if (temp.Screens[screen].Variables.Count > 0)
21 | {
22 | for (int i = 0; i < temp.Screens[screen].Variables.Count; i++)
23 | {
24 | scv[i].IsEnabled = true;
25 | DisplayVarsEnum temp222;
26 | if (Enum.TryParse(temp.Screens[screen].Variables[i], out temp222))
27 | {
28 | scv[i].SelectedItem = temp.HostApp.DisplayMngr.Dictionarys.DisplayVariables[temp222].Name;
29 | }
30 | else
31 | {
32 | scv[i].SelectedIndex = -1;
33 | }
34 | }
35 | }
36 | else
37 | {
38 | scv[0].IsEnabled = true;
39 | scv[0].SelectedIndex = -1;
40 | }
41 | useCustomHeaderCheck.IsChecked = temp.Screens[screen].UseCustomHeader;
42 | headerTextBox.Text = temp.Screens[screen].CustomHeader;
43 | firstLoad = false;
44 | }
45 |
46 | public static void ScreenVariablesUpdatedExtracted(int maxDisplayLengthTM1638, string format, int param, List scvIn, DisplayUnitConfiguration temp, Label spaceUsedLabel, bool firstLoadIn)
47 | {
48 | int count = 0;
49 | int i = 0;
50 | int stop = 0;
51 | while (count < maxDisplayLengthTM1638 && i < scvIn.Count)
52 | {
53 | stop = i + 1;
54 | if (scvIn[i].SelectedIndex >= 0)
55 | {
56 | count += temp.HostApp.DisplayMngr.Dictionarys.DisplayVariables.Where(item => item.Value.Name == scvIn[i].SelectedItem.ToString()).Sum(item => item.Value.Length);
57 | spaceUsedLabel.Content = String.Format(format, count);
58 | if (count > maxDisplayLengthTM1638)
59 | {
60 | stop = i;
61 | i = scvIn.Count;
62 | }
63 | i++;
64 | }
65 | else
66 | {
67 | scvIn[i].IsEnabled = true;
68 | scvIn[i].Items.Clear();
69 | foreach (var variable in temp.HostApp.DisplayMngr.Dictionarys.DisplayVariables)
70 | {
71 | if (variable.Value.Length <= maxDisplayLengthTM1638 - count)
72 | {
73 | scvIn[i].Items.Add(variable.Value.Name);
74 | }
75 | }
76 | i = scvIn.Count;
77 | }
78 | }
79 | for (int j = stop; j < scvIn.Count; j++)
80 | {
81 | scvIn[j].Items.Clear();
82 | scvIn[j].SelectedIndex = -1;
83 | scvIn[j].IsEnabled = false;
84 | }
85 | //save to config
86 | if (!firstLoadIn)
87 | {
88 | for (int p = 0; p < param; p++)
89 | {
90 | if (scvIn[p].SelectedValue != null)
91 | {
92 | string tempV = scvIn[p].SelectedValue.ToString();
93 | var temp2 = new DisplayVarsEnum();
94 | bool found = false;
95 | foreach (var disVar in temp.HostApp.DisplayMngr.Dictionarys.DisplayVariables)
96 | {
97 | if (disVar.Value.Name == tempV)
98 | {
99 | temp2 = disVar.Key;
100 | found = true;
101 | }
102 | }
103 | if (found)
104 | {
105 | if (temp.Screens[temp.ScreenToEdit].Variables.Count - 1 < p)
106 | {
107 | temp.Screens[temp.ScreenToEdit].Variables.Add("");
108 | }
109 | temp.Screens[temp.ScreenToEdit].Variables[p] = temp2.ToString();
110 | }
111 | }
112 | }
113 | }
114 | }
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/ScreenPage.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/ScreenPage.xaml.cs:
--------------------------------------------------------------------------------
1 | //========================================//
2 | // iRduino - Created by Mark Silverwood //
3 | //======================================//
4 |
5 | namespace iRduino.Windows.Pages
6 | {
7 | using ArduinoInterfaces;
8 |
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Windows;
13 | using System.Windows.Controls;
14 |
15 | using iRduino.Classes;
16 |
17 | ///
18 | /// Interaction logic for ScreenPage.xaml
19 | ///
20 | public partial class ScreenPage
21 | {
22 | public DisplayUnitConfiguration Temp;
23 | private bool firstLoad = true;
24 | private List scv;
25 |
26 | private int screen;
27 |
28 | public ScreenPage()
29 | {
30 | this.InitializeComponent();
31 | }
32 |
33 | private void StartLoading()
34 | {
35 | this.firstLoad = true;
36 | this.Temp = (DisplayUnitConfiguration) this.DataContext;
37 | this.scv = new List
38 | {
39 | this.ScreenVariable1CBox,
40 | this.ScreenVariable2CBox,
41 | this.ScreenVariable3CBox,
42 | this.ScreenVariable4CBox,
43 | this.ScreenVariable5CBox,
44 | this.ScreenVariable6CBox
45 | };
46 | foreach (var variable in this.Temp.HostApp.DisplayMngr.Dictionarys.DisplayVariables)
47 | {
48 | foreach (ComboBox comboBox in this.scv)
49 | {
50 | comboBox.Items.Add(variable.Value.Name);
51 | }
52 | }
53 | PageHelper.StartLoading1(this.scv, ref this.screen, this.Temp, this.UseCustomHeaderCheck, this.HeaderTextBox, ref this.firstLoad);
54 | }
55 |
56 | private void ScreenVariablesUpdated(object sender, SelectionChangedEventArgs e)
57 | {
58 | PageHelper.ScreenVariablesUpdatedExtracted(Constants.MaxDisplayLengthTM1638, "{0} / 8", 6, this.scv, this.Temp, this.SpaceUsedLabel, this.firstLoad);
59 | }
60 |
61 | private void PageDataContextChanged1(object sender, DependencyPropertyChangedEventArgs e)
62 | {
63 | if (this.DataContext != null)
64 | {
65 | this.StartLoading();
66 | }
67 | else
68 | {
69 | MessageBox.Show("Error Loading... Please Try Again.");
70 | }
71 | }
72 |
73 | private void ClearButtonClick(object sender, RoutedEventArgs e)
74 | {
75 | foreach (var cb in this.scv)
76 | {
77 | cb.SelectedIndex = -1;
78 | }
79 | }
80 |
81 | private void UseCustomHeaderCheckUnchecked(object sender, RoutedEventArgs e)
82 | {
83 | this.HeaderTextBox.Text = "";
84 | this.HeaderTextBox.IsEnabled = false;
85 | this.Temp.Screens[this.screen].UseCustomHeader = false;
86 | }
87 |
88 | private void UseCustomHeaderCheckChecked(object sender, RoutedEventArgs e)
89 | {
90 | this.HeaderTextBox.IsEnabled = true;
91 | this.Temp.Screens[this.screen].UseCustomHeader = true;
92 | }
93 |
94 | private void HeaderTextBoxTextChanged(object sender, TextChangedEventArgs e)
95 | {
96 | this.Temp.Screens[this.screen].CustomHeader = this.HeaderTextBox.Text;
97 | }
98 | }
99 | }
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/TM1640ScreenPage.xaml.cs:
--------------------------------------------------------------------------------
1 | //========================================//
2 | // iRduino - Created by Mark Silverwood //
3 | //======================================//
4 |
5 | namespace iRduino.Windows.Pages
6 | {
7 | using ArduinoInterfaces;
8 |
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Windows;
13 | using System.Windows.Controls;
14 |
15 | using iRduino.Classes;
16 |
17 | ///
18 | /// Interaction logic for TM1640ScreenPage.xaml
19 | ///
20 | public partial class TM1640ScreenPage
21 | {
22 | public DisplayUnitConfiguration Temp;
23 | private bool firstLoad = true;
24 | private List scv;
25 |
26 | private int screen;
27 |
28 | public TM1640ScreenPage()
29 | {
30 | this.InitializeComponent();
31 | }
32 |
33 | private void StartLoading()
34 | {
35 | this.firstLoad = true;
36 | this.Temp = (DisplayUnitConfiguration) this.DataContext;
37 | this.scv = new List
38 | {
39 | this.ScreenVariable1CBox,
40 | this.ScreenVariable2CBox,
41 | this.ScreenVariable3CBox,
42 | this.ScreenVariable4CBox,
43 | this.ScreenVariable5CBox,
44 | this.ScreenVariable6CBox,
45 | this.ScreenVariable7CBox,
46 | this.ScreenVariable8CBox,
47 | this.ScreenVariable9CBox
48 | };
49 | foreach (var variable in this.Temp.HostApp.DisplayMngr.Dictionarys.DisplayVariables)
50 | {
51 | foreach (ComboBox comboBox in this.scv)
52 | {
53 | comboBox.Items.Add(variable.Value.Name);
54 | }
55 | }
56 | PageHelper.StartLoading1(this.scv, ref this.screen, this.Temp, this.UseCustomHeaderCheck, this.HeaderTextBox, ref this.firstLoad);
57 | this.firstLoad = false;
58 | }
59 |
60 | private void ScreenVariablesUpdated(object sender, SelectionChangedEventArgs e)
61 | {
62 | PageHelper.ScreenVariablesUpdatedExtracted(Constants.MaxDisplayLengthTM1640, "{0} / 16", 9, this.scv, this.Temp, this.SpaceUsedLabel, this.firstLoad);
63 | }
64 |
65 | private void PageDataContextChanged1(object sender, DependencyPropertyChangedEventArgs e)
66 | {
67 | if (this.DataContext != null)
68 | {
69 | this.StartLoading();
70 | }
71 | else
72 | {
73 | MessageBox.Show("Error Loading... Please Try Again.");
74 | }
75 | }
76 |
77 | private void ClearButtonClick(object sender, RoutedEventArgs e)
78 | {
79 | foreach (var cb in this.scv)
80 | {
81 | cb.SelectedIndex = -1;
82 | }
83 | }
84 |
85 | private void UseCustomHeaderCheckUnchecked(object sender, RoutedEventArgs e)
86 | {
87 | this.HeaderTextBox.Text = "";
88 | this.HeaderTextBox.IsEnabled = false;
89 | this.Temp.Screens[this.screen].UseCustomHeader = false;
90 | }
91 |
92 | private void UseCustomHeaderCheckChecked(object sender, RoutedEventArgs e)
93 | {
94 | this.HeaderTextBox.IsEnabled = true;
95 | this.Temp.Screens[this.screen].UseCustomHeader = true;
96 | }
97 |
98 | private void HeaderTextBoxTextChanged(object sender, TextChangedEventArgs e)
99 | {
100 | this.Temp.Screens[this.screen].CustomHeader = this.HeaderTextBox.Text;
101 | }
102 | }
103 | }
--------------------------------------------------------------------------------
/iRduino/Windows/Pages/UnitPage.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
24 |
25 |
26 |
28 |
30 |
31 |
33 |
36 |
37 |
39 |
41 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/iRduino/Windows/UploaderDialog.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/iRduino/Windows/UploaderDialog.xaml.cs:
--------------------------------------------------------------------------------
1 | //========================================//
2 | // iRduino - Created by Mark Silverwood //
3 | //======================================//
4 |
5 | namespace iRduino.Windows
6 | {
7 | using System;
8 | using System.Diagnostics;
9 | using System.Globalization;
10 | using System.Windows;
11 | using System.Windows.Controls;
12 |
13 | ///
14 | /// Interaction logic for UploaderDialog.xaml
15 | ///
16 | public partial class UploaderDialog
17 | {
18 | private readonly string fileLocation;
19 |
20 | public UploaderDialog(string fileLocationIn)
21 | {
22 | InitializeComponent();
23 | fileLocation = fileLocationIn;
24 | }
25 |
26 | private void WindowLoaded1(object sender, RoutedEventArgs e)
27 | {
28 | fileLocationLabel.Content = fileLocation;
29 | this.Height = 175;
30 |
31 | arduinoBoardCBox.Items.Add("Arduino Uno");
32 | arduinoBoardCBox.Items.Add("Arduino Leonardo");
33 | arduinoBoardCBox.Items.Add("Arduino Duemilanove (328)");
34 | arduinoBoardCBox.Items.Add("Arduino Duemilanove (168)");
35 | arduinoBoardCBox.Items.Add("Arduino Nano (328)");
36 | arduinoBoardCBox.Items.Add("Arduino Nano (168)");
37 | arduinoBoardCBox.Items.Add("Arduino Mini (328)");
38 | arduinoBoardCBox.Items.Add("Arduino Mini (168)");
39 | arduinoBoardCBox.Items.Add("Arduino Pro Mini (328)");
40 | arduinoBoardCBox.Items.Add("Arduino Pro Mini (168)");
41 | arduinoBoardCBox.Items.Add("Arduino Mega 2560/ADK");
42 | arduinoBoardCBox.Items.Add("Arduino Mega");
43 |
44 | string[] ports = ArduinoInterfaces.ArduinoLink.CheckComPorts();
45 | foreach (var p in ports)
46 | {
47 | comPortCBox.Items.Add(p);
48 | }
49 | }
50 |
51 | public void Checker()
52 | {
53 | if (arduinoBoardCBox.SelectedIndex >= 0 && comPortCBox.SelectedIndex >= 0)
54 | {
55 | uploadButton.IsEnabled = true;
56 | }
57 | else
58 | {
59 | uploadButton.IsEnabled = false;
60 | }
61 | }
62 |
63 | private void YesButtonClick(object sender, RoutedEventArgs e)
64 | {
65 | this.Height = 300;
66 | }
67 |
68 | private void NoButtonClick(object sender, RoutedEventArgs e)
69 | {
70 | this.Close();
71 | }
72 |
73 | private void ArduinoBoardCBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
74 | {
75 | this.Checker();
76 | }
77 |
78 | private void ComPortCBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
79 | {
80 | this.Checker();
81 | }
82 |
83 | private void UploadButtonClick(object sender, RoutedEventArgs e)
84 | {
85 | string arguments = "";
86 | arguments += "\"" + fileLocation + "\" ";
87 | arguments += (arduinoBoardCBox.SelectedIndex + 1).ToString(CultureInfo.InvariantCulture);
88 | arguments += " ";
89 | arguments += comPortCBox.SelectedValue.ToString();
90 | string uploaderLocation = AppDomain.CurrentDomain.BaseDirectory + "ArduinoUploader\\ArduinoUploader.exe";
91 | MessageBox.Show("cmd /K \"" + uploaderLocation + "\" " + arguments);
92 | Process.Start("cmd", "/K \"" + uploaderLocation + "\" " + arguments);
93 | //Process.Start(
94 | //System.Diagnostics.Process process = new System.Diagnostics.Process();
95 | //System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
96 | //startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
97 | //startInfo.FileName = "cmd.exe";
98 | //startInfo.Arguments = "/K /t:09 \"" + uploaderLocation + "\" " + arguments;
99 | //MessageBox.Show(startInfo.Arguments);
100 | //process.StartInfo = startInfo;
101 | //process.Start();
102 |
103 | this.Close();
104 | }
105 | }
106 | }
--------------------------------------------------------------------------------
/irsdkSharp/CVarBuf.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.IO.MemoryMappedFiles;
6 | using System.Runtime.InteropServices;
7 |
8 | namespace iRSDKSharp
9 | {
10 | public class CVarBuf
11 | {
12 | public const int VarHeaderOffset = 56;
13 | public int VarHeaderSize = 144;
14 | //VarBuf offsets
15 | public int VarBufOffset = 48;
16 | public const int VarTickCountOffset = 0;
17 | public const int VarBufOffsetOffset = 4;
18 | public int VarBufSize = 32;
19 |
20 | MemoryMappedViewAccessor FileMapView = null;
21 | CiRSDKHeader Header = null;
22 |
23 | public CVarBuf(MemoryMappedViewAccessor mapView, CiRSDKHeader header)
24 | {
25 | FileMapView = mapView;
26 | Header = header;
27 | VarHeaderSize = Marshal.SizeOf(typeof(VarHeader));
28 | VarBufSize = Marshal.SizeOf(typeof(VarBuf));
29 | }
30 |
31 | public int OffsetLatest
32 | {
33 | get
34 | {
35 | int bufCount = Header.BufferCount;
36 | int[] ticks = new int[Header.BufferCount];
37 | for (int i = 0; i < bufCount; i++)
38 | {
39 | ticks[i] = FileMapView.ReadInt32(VarBufOffset + ((i * VarBufSize) + VarTickCountOffset));
40 | }
41 | int latestTick = ticks[0];
42 | int latest = 0;
43 | for (int i = 0; i < bufCount; i++)
44 | {
45 | if (latestTick < ticks[i])
46 | {
47 | latest = i;
48 | }
49 | }
50 | return FileMapView.ReadInt32(VarBufOffset + ((latest * VarBufSize) + VarBufOffsetOffset));
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/irsdkSharp/CVarHeader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace iRSDKSharp
7 | {
8 | public class CVarHeader
9 | {
10 | public enum VarType { irChar, irBool, irInt, irBitField, irFloat, irDouble };
11 | VarType type;
12 | int offset;
13 | int count;
14 | string name;
15 | string desc;
16 | string unit;
17 |
18 | public CVarHeader(int type, int offset, int count, string name, string desc, string unit)
19 | {
20 | this.type = (VarType)type;
21 | this.offset = offset;
22 | this.count = count;
23 | this.name = name;
24 | this.desc = desc;
25 | this.unit = unit;
26 | }
27 |
28 | public VarType Type
29 | {
30 | get { return type; }
31 | //set { type = value; }
32 | }
33 |
34 | public int Offset
35 | {
36 | get { return offset; }
37 | //set { offset = value; }
38 | }
39 |
40 | public int Count
41 | {
42 | get { return count; }
43 | //set { count = value; }
44 | }
45 |
46 | public string Name
47 | {
48 | get { return name; }
49 | //set { name = value; }
50 | }
51 |
52 | public string Desc
53 | {
54 | get { return desc; }
55 | //set { desc = value; }
56 | }
57 |
58 | public string Unit
59 | {
60 | get { return unit; }
61 | //set { unit = value; }
62 | }
63 |
64 | public int Bytes
65 | {
66 | get
67 | {
68 | if (this.type == VarType.irChar || this.type == VarType.irBool)
69 | return 1;
70 | else if (this.type == VarType.irInt || this.type == VarType.irBitField || this.type == VarType.irFloat)
71 | return 4;
72 | else if (this.type == VarType.irDouble)
73 | return 8;
74 |
75 | return 0;
76 | }
77 | }
78 |
79 | public int Length
80 | {
81 | get
82 | {
83 | return Bytes * Count;
84 | }
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/irsdkSharp/CiRSDKHeader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.IO.MemoryMappedFiles;
6 |
7 | namespace iRSDKSharp
8 | {
9 | public class CiRSDKHeader
10 | {
11 | //Header offsets
12 | public const int HVerOffset = 0;
13 | public const int HStatusOffset = 4;
14 | public const int HTickRateOffset = 8;
15 | public const int HSesInfoUpdateOffset = 12;
16 | public const int HSesInfoLenOffset = 16;
17 | public const int HSesInfoOffsetOffset = 20;
18 | public const int HNumVarsOffset = 24;
19 | public const int HVarHeaderOffsetOffset = 28;
20 | public const int HNumBufOffset = 32;
21 | public const int HBufLenOffset = 36;
22 |
23 | MemoryMappedViewAccessor FileMapView = null;
24 |
25 | CVarBuf buffer = null;
26 |
27 | public CiRSDKHeader(MemoryMappedViewAccessor mapView)
28 | {
29 | FileMapView = mapView;
30 | buffer = new CVarBuf(mapView, this);
31 | }
32 |
33 | public int Version
34 | {
35 | get { return FileMapView.ReadInt32(HVerOffset); }
36 | }
37 |
38 | public int Status
39 | {
40 | get { return FileMapView.ReadInt32(HStatusOffset); }
41 | }
42 |
43 | public int TickRate
44 | {
45 | get { return FileMapView.ReadInt32(HTickRateOffset); }
46 | }
47 |
48 | public int SessionInfoUpdate
49 | {
50 | get { return FileMapView.ReadInt32(HSesInfoUpdateOffset); }
51 | }
52 |
53 | public int SessionInfoLength
54 | {
55 | get { return FileMapView.ReadInt32(HSesInfoLenOffset); }
56 | }
57 |
58 | public int SessionInfoOffset
59 | {
60 | get { return FileMapView.ReadInt32(HSesInfoOffsetOffset); }
61 | }
62 |
63 | public int VarCount
64 | {
65 | get { return FileMapView.ReadInt32(HNumVarsOffset); }
66 | }
67 |
68 | public int VarHeaderOffset
69 | {
70 | get { return FileMapView.ReadInt32(HVarHeaderOffsetOffset); }
71 | }
72 |
73 | public int BufferCount
74 | {
75 | get { return FileMapView.ReadInt32(HNumBufOffset); }
76 | }
77 |
78 | public int BufferLength
79 | {
80 | get { return FileMapView.ReadInt32(HBufLenOffset); }
81 | }
82 |
83 | public int Buffer
84 | {
85 | get
86 | {
87 | return buffer.OffsetLatest;
88 | }
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/irsdkSharp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("irsdkSharp")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("irsdkSharp")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("cbf14610-6c31-4e17-955f-78a66206e1e0")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/irsdkSharp/iRSDKSharp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {72631B85-EB9A-473E-9B4C-65B355A9000D}
9 | Library
10 | Properties
11 | iRSDKSharp
12 | iRSDKSharp
13 | v4.0
14 | 512
15 |
16 |
17 |
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 | true
26 | ManagedMinimumRules.ruleset
27 |
28 |
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 | true
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
61 |
--------------------------------------------------------------------------------
/irsdkSharp/readme.md:
--------------------------------------------------------------------------------
1 | iRacing SDK Sharp
2 | =================
3 |
4 | Created by Scott Przybylski
5 | http://members.iracing.com/jforum/posts/list/1474031.page
6 |
--------------------------------------------------------------------------------
/nicon/BalloonIcon.cs:
--------------------------------------------------------------------------------
1 | // hardcodet.net NotifyIcon for WPF
2 | // Copyright (c) 2009 - 2013 Philipp Sumi
3 | // Contact and Information: http://www.hardcodet.net
4 | //
5 | // This library is free software; you can redistribute it and/or
6 | // modify it under the terms of the Code Project Open License (CPOL);
7 | // either version 1.0 of the License, or (at your option) any later
8 | // version.
9 | //
10 | // The above copyright notice and this permission notice shall be
11 | // included in all copies or substantial portions of the Software.
12 | //
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 | // OTHER DEALINGS IN THE SOFTWARE.
21 | //
22 | // THIS COPYRIGHT NOTICE MAY NOT BE REMOVED FROM THIS FILE
23 |
24 |
25 | namespace Hardcodet.Wpf.TaskbarNotification
26 | {
27 | ///
28 | /// Supported icons for the tray's balloon messages.
29 | ///
30 | public enum BalloonIcon
31 | {
32 | ///
33 | /// The balloon message is displayed without an icon.
34 | ///
35 | None,
36 |
37 | ///
38 | /// An information is displayed.
39 | ///
40 | Info,
41 |
42 | ///
43 | /// A warning is displayed.
44 | ///
45 | Warning,
46 |
47 | ///
48 | /// An error is displayed.
49 | ///
50 | Error
51 | }
52 | }
--------------------------------------------------------------------------------
/nicon/Diagrams/TaskbarIcon Overview.cd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | N6qdVIeUdLmQtSUbiJhEGdYRjvJYXlhbEVBDKuPRO5s=
11 | TaskbarIcon.cs
12 |
13 |
14 |
15 |
16 |
17 |
18 | ABAEAAAAAAAAAAABAAAAAAAAAAAAAAAAAIAKAIAAAAA=
19 | PopupActivationMode.cs
20 |
21 |
22 |
23 |
24 |
25 | AAAAAAAAAAAAAQAAAAAAABAAAAAAAAAAAAAAAEEAAAA=
26 | BalloonIcon.cs
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/nicon/Interop/BalloonFlags.cs:
--------------------------------------------------------------------------------
1 | namespace Hardcodet.Wpf.TaskbarNotification.Interop
2 | {
3 | ///
4 | /// Flags that define the icon that is shown on a balloon
5 | /// tooltip.
6 | ///
7 | public enum BalloonFlags
8 | {
9 | ///
10 | /// No icon is displayed.
11 | ///
12 | None = 0x00,
13 |
14 | ///
15 | /// An information icon is displayed.
16 | ///
17 | Info = 0x01,
18 |
19 | ///
20 | /// A warning icon is displayed.
21 | ///
22 | Warning = 0x02,
23 |
24 | ///
25 | /// An error icon is displayed.
26 | ///
27 | Error = 0x03,
28 |
29 | ///
30 | /// Windows XP Service Pack 2 (SP2) and later.
31 | /// Use a custom icon as the title icon.
32 | ///
33 | User = 0x04,
34 |
35 | ///
36 | /// Windows XP (Shell32.dll version 6.0) and later.
37 | /// Do not play the associated sound. Applies only to balloon ToolTips.
38 | ///
39 | NoSound = 0x10,
40 |
41 | ///
42 | /// Windows Vista (Shell32.dll version 6.0.6) and later. The large version
43 | /// of the icon should be used as the balloon icon. This corresponds to the
44 | /// icon with dimensions SM_CXICON x SM_CYICON. If this flag is not set,
45 | /// the icon with dimensions XM_CXSMICON x SM_CYSMICON is used.
46 | /// - This flag can be used with all stock icons.
47 | /// - Applications that use older customized icons (NIIF_USER with hIcon) must
48 | /// provide a new SM_CXICON x SM_CYICON version in the tray icon (hIcon). These
49 | /// icons are scaled down when they are displayed in the System Tray or
50 | /// System Control Area (SCA).
51 | /// - New customized icons (NIIF_USER with hBalloonIcon) must supply an
52 | /// SM_CXICON x SM_CYICON version in the supplied icon (hBalloonIcon).
53 | ///
54 | LargeIcon = 0x20,
55 |
56 | ///
57 | /// Windows 7 and later.
58 | ///
59 | RespectQuietTime = 0x80
60 | }
61 | }
--------------------------------------------------------------------------------
/nicon/Interop/IconDataMembers.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Hardcodet.Wpf.TaskbarNotification.Interop
4 | {
5 | ///
6 | /// Indicates which members of a structure
7 | /// were set, and thus contain valid data or provide additional information
8 | /// to the ToolTip as to how it should display.
9 | ///
10 | [Flags]
11 | public enum IconDataMembers
12 | {
13 | ///
14 | /// The message ID is set.
15 | ///
16 | Message = 0x01,
17 |
18 | ///
19 | /// The notification icon is set.
20 | ///
21 | Icon = 0x02,
22 |
23 | ///
24 | /// The tooltip is set.
25 | ///
26 | Tip = 0x04,
27 |
28 | ///
29 | /// State information () is set. This
30 | /// applies to both and
31 | /// .
32 | ///
33 | State = 0x08,
34 |
35 | ///
36 | /// The balloon ToolTip is set. Accordingly, the following
37 | /// members are set: ,
38 | /// , ,
39 | /// and .
40 | ///
41 | Info = 0x10,
42 |
43 | // Internal identifier is set. Reserved, thus commented out.
44 | //Guid = 0x20,
45 |
46 | ///
47 | /// Windows Vista (Shell32.dll version 6.0.6) and later. If the ToolTip
48 | /// cannot be displayed immediately, discard it.
49 | /// Use this flag for ToolTips that represent real-time information which
50 | /// would be meaningless or misleading if displayed at a later time.
51 | /// For example, a message that states "Your telephone is ringing."
52 | /// This modifies and must be combined with the flag.
53 | ///
54 | Realtime = 0x40,
55 |
56 | ///
57 | /// Windows Vista (Shell32.dll version 6.0.6) and later.
58 | /// Use the standard ToolTip. Normally, when uVersion is set
59 | /// to NOTIFYICON_VERSION_4, the standard ToolTip is replaced
60 | /// by the application-drawn pop-up user interface (UI).
61 | /// If the application wants to show the standard tooltip
62 | /// in that case, regardless of whether the on-hover UI is showing,
63 | /// it can specify NIF_SHOWTIP to indicate the standard tooltip
64 | /// should still be shown.
65 | /// Note that the NIF_SHOWTIP flag is effective until the next call
66 | /// to Shell_NotifyIcon.
67 | ///
68 | UseLegacyToolTips = 0x80
69 | }
70 | }
--------------------------------------------------------------------------------
/nicon/Interop/IconState.cs:
--------------------------------------------------------------------------------
1 | namespace Hardcodet.Wpf.TaskbarNotification.Interop
2 | {
3 | ///
4 | /// The state of the icon - can be set to
5 | /// hide the icon.
6 | ///
7 | public enum IconState
8 | {
9 | ///
10 | /// The icon is visible.
11 | ///
12 | Visible = 0x00,
13 |
14 | ///
15 | /// Hide the icon.
16 | ///
17 | Hidden = 0x01,
18 |
19 | // The icon is shared - currently not supported, thus commented out.
20 | //Shared = 0x02
21 | }
22 | }
--------------------------------------------------------------------------------
/nicon/Interop/MouseEvent.cs:
--------------------------------------------------------------------------------
1 | namespace Hardcodet.Wpf.TaskbarNotification.Interop
2 | {
3 | ///
4 | /// Event flags for clicked events.
5 | ///
6 | public enum MouseEvent
7 | {
8 | ///
9 | /// The mouse was moved withing the
10 | /// taskbar icon's area.
11 | ///
12 | MouseMove,
13 |
14 | ///
15 | /// The right mouse button was clicked.
16 | ///
17 | IconRightMouseDown,
18 |
19 | ///
20 | /// The left mouse button was clicked.
21 | ///
22 | IconLeftMouseDown,
23 |
24 | ///
25 | /// The right mouse button was released.
26 | ///
27 | IconRightMouseUp,
28 |
29 | ///
30 | /// The left mouse button was released.
31 | ///
32 | IconLeftMouseUp,
33 |
34 | ///
35 | /// The middle mouse button was clicked.
36 | ///
37 | IconMiddleMouseDown,
38 |
39 | ///
40 | /// The middle mouse button was released.
41 | ///
42 | IconMiddleMouseUp,
43 |
44 | ///
45 | /// The taskbar icon was double clicked.
46 | ///
47 | IconDoubleClick,
48 |
49 | ///
50 | /// The balloon tip was clicked.
51 | ///
52 | BalloonToolTipClicked
53 | }
54 | }
--------------------------------------------------------------------------------
/nicon/Interop/NotifyCommand.cs:
--------------------------------------------------------------------------------
1 | namespace Hardcodet.Wpf.TaskbarNotification.Interop
2 | {
3 | ///
4 | /// Main operations performed on the
5 | /// function.
6 | ///
7 | public enum NotifyCommand
8 | {
9 | ///
10 | /// The taskbar icon is being created.
11 | ///
12 | Add = 0x00,
13 |
14 | ///
15 | /// The settings of the taskbar icon are being updated.
16 | ///
17 | Modify = 0x01,
18 |
19 | ///
20 | /// The taskbar icon is deleted.
21 | ///
22 | Delete = 0x02,
23 |
24 | ///
25 | /// Focus is returned to the taskbar icon. Currently not in use.
26 | ///
27 | SetFocus = 0x03,
28 |
29 | ///
30 | /// Shell32.dll version 5.0 and later only. Instructs the taskbar
31 | /// to behave according to the version number specified in the
32 | /// uVersion member of the structure pointed to by lpdata.
33 | /// This message allows you to specify whether you want the version
34 | /// 5.0 behavior found on Microsoft Windows 2000 systems, or the
35 | /// behavior found on earlier Shell versions. The default value for
36 | /// uVersion is zero, indicating that the original Windows 95 notify
37 | /// icon behavior should be used.
38 | ///
39 | SetVersion = 0x04
40 | }
41 | }
--------------------------------------------------------------------------------
/nicon/Interop/NotifyIconVersion.cs:
--------------------------------------------------------------------------------
1 | namespace Hardcodet.Wpf.TaskbarNotification.Interop
2 | {
3 | ///
4 | /// The notify icon version that is used. The higher
5 | /// the version, the more capabilities are available.
6 | ///
7 | public enum NotifyIconVersion
8 | {
9 | ///
10 | /// Default behavior (legacy Win95). Expects
11 | /// a size of 488.
12 | ///
13 | Win95 = 0x0,
14 |
15 | ///
16 | /// Behavior representing Win2000 an higher. Expects
17 | /// a size of 504.
18 | ///
19 | Win2000 = 0x3,
20 |
21 | ///
22 | /// Extended tooltip support, which is available
23 | /// for Vista and later.
24 | ///
25 | Vista = 0x4
26 | }
27 | }
--------------------------------------------------------------------------------
/nicon/Interop/Point.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace Hardcodet.Wpf.TaskbarNotification.Interop
4 | {
5 | ///
6 | /// Win API struct providing coordinates for a single point.
7 | ///
8 | [StructLayout(LayoutKind.Sequential)]
9 | public struct Point
10 | {
11 | ///
12 | /// X coordinate.
13 | ///
14 | public int X;
15 | ///
16 | /// Y coordinate.
17 | ///
18 | public int Y;
19 | }
20 | }
--------------------------------------------------------------------------------
/nicon/Interop/TrayInfo.cs:
--------------------------------------------------------------------------------
1 | // Some interop code taken from Mike Marshall's AnyForm
2 |
3 | using System;
4 | using System.Drawing;
5 | using System.Runtime.InteropServices;
6 |
7 |
8 | namespace Hardcodet.Wpf.TaskbarNotification.Interop
9 | {
10 | ///
11 | /// Resolves the current tray position.
12 | ///
13 | public static class TrayInfo
14 | {
15 | ///
16 | /// Gets the position of the system tray.
17 | ///
18 | /// Tray coordinates.
19 | public static Point GetTrayLocation()
20 | {
21 | var info = new AppBarInfo();
22 | info.GetSystemTaskBarPosition();
23 |
24 | Rectangle rcWorkArea = info.WorkArea;
25 |
26 | int x = 0, y = 0;
27 | if (info.Edge == AppBarInfo.ScreenEdge.Left)
28 | {
29 | x = rcWorkArea.Left + 2;
30 | y = rcWorkArea.Bottom;
31 | }
32 | else if (info.Edge == AppBarInfo.ScreenEdge.Bottom)
33 | {
34 | x = rcWorkArea.Right;
35 | y = rcWorkArea.Bottom;
36 | }
37 | else if (info.Edge == AppBarInfo.ScreenEdge.Top)
38 | {
39 | x = rcWorkArea.Right;
40 | y = rcWorkArea.Top;
41 | }
42 | else if (info.Edge == AppBarInfo.ScreenEdge.Right)
43 | {
44 | x = rcWorkArea.Right;
45 | y = rcWorkArea.Bottom;
46 | }
47 |
48 | return new Point {X = x, Y = y};
49 | }
50 | }
51 |
52 |
53 | internal class AppBarInfo
54 | {
55 | [DllImport("user32.dll")]
56 | private static extern IntPtr FindWindow(String lpClassName, String lpWindowName);
57 |
58 | [DllImport("shell32.dll")]
59 | private static extern UInt32 SHAppBarMessage(UInt32 dwMessage, ref APPBARDATA data);
60 |
61 | [DllImport("user32.dll")]
62 | private static extern Int32 SystemParametersInfo(UInt32 uiAction, UInt32 uiParam,
63 | IntPtr pvParam, UInt32 fWinIni);
64 |
65 |
66 | private const int ABE_BOTTOM = 3;
67 | private const int ABE_LEFT = 0;
68 | private const int ABE_RIGHT = 2;
69 | private const int ABE_TOP = 1;
70 |
71 | private const int ABM_GETTASKBARPOS = 0x00000005;
72 |
73 | // SystemParametersInfo constants
74 | private const UInt32 SPI_GETWORKAREA = 0x0030;
75 |
76 | private APPBARDATA m_data;
77 |
78 | public ScreenEdge Edge
79 | {
80 | get { return (ScreenEdge) m_data.uEdge; }
81 | }
82 |
83 |
84 | public Rectangle WorkArea
85 | {
86 | get
87 | {
88 | Int32 bResult = 0;
89 | var rc = new RECT();
90 | IntPtr rawRect = Marshal.AllocHGlobal(Marshal.SizeOf(rc));
91 | bResult = SystemParametersInfo(SPI_GETWORKAREA, 0, rawRect, 0);
92 | rc = (RECT) Marshal.PtrToStructure(rawRect, rc.GetType());
93 |
94 | if (bResult == 1)
95 | {
96 | Marshal.FreeHGlobal(rawRect);
97 | return new Rectangle(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
98 | }
99 |
100 | return new Rectangle(0, 0, 0, 0);
101 | }
102 | }
103 |
104 |
105 | public void GetPosition(string strClassName, string strWindowName)
106 | {
107 | m_data = new APPBARDATA();
108 | m_data.cbSize = (UInt32) Marshal.SizeOf(m_data.GetType());
109 |
110 | IntPtr hWnd = FindWindow(strClassName, strWindowName);
111 |
112 | if (hWnd != IntPtr.Zero)
113 | {
114 | UInt32 uResult = SHAppBarMessage(ABM_GETTASKBARPOS, ref m_data);
115 |
116 | if (uResult != 1)
117 | {
118 | throw new Exception("Failed to communicate with the given AppBar");
119 | }
120 | }
121 | else
122 | {
123 | throw new Exception("Failed to find an AppBar that matched the given criteria");
124 | }
125 | }
126 |
127 |
128 | public void GetSystemTaskBarPosition()
129 | {
130 | GetPosition("Shell_TrayWnd", null);
131 | }
132 |
133 |
134 | public enum ScreenEdge
135 | {
136 | Undefined = -1,
137 | Left = ABE_LEFT,
138 | Top = ABE_TOP,
139 | Right = ABE_RIGHT,
140 | Bottom = ABE_BOTTOM
141 | }
142 |
143 |
144 | [StructLayout(LayoutKind.Sequential)]
145 | private struct APPBARDATA
146 | {
147 | public UInt32 cbSize;
148 | public IntPtr hWnd;
149 | public UInt32 uCallbackMessage;
150 | public UInt32 uEdge;
151 | public RECT rc;
152 | public Int32 lParam;
153 | }
154 |
155 | [StructLayout(LayoutKind.Sequential)]
156 | private struct RECT
157 | {
158 | public Int32 left;
159 | public Int32 top;
160 | public Int32 right;
161 | public Int32 bottom;
162 | }
163 | }
164 | }
--------------------------------------------------------------------------------
/nicon/Interop/WinApi.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace Hardcodet.Wpf.TaskbarNotification.Interop
5 | {
6 | ///
7 | /// Win32 API imports.
8 | ///
9 | internal static class WinApi
10 | {
11 | ///
12 | /// Creates, updates or deletes the taskbar icon.
13 | ///
14 | [DllImport("shell32.Dll", CharSet = CharSet.Unicode)]
15 | public static extern bool Shell_NotifyIcon(NotifyCommand cmd, [In] ref NotifyIconData data);
16 |
17 |
18 | ///
19 | /// Creates the helper window that receives messages from the taskar icon.
20 | ///
21 | [DllImport("USER32.DLL", EntryPoint = "CreateWindowExW", SetLastError = true)]
22 | public static extern IntPtr CreateWindowEx(int dwExStyle, [MarshalAs(UnmanagedType.LPWStr)] string lpClassName,
23 | [MarshalAs(UnmanagedType.LPWStr)] string lpWindowName, int dwStyle, int x, int y,
24 | int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance,
25 | IntPtr lpParam);
26 |
27 |
28 | ///
29 | /// Processes a default windows procedure.
30 | ///
31 | [DllImport("USER32.DLL")]
32 | public static extern IntPtr DefWindowProc(IntPtr hWnd, uint msg, IntPtr wparam, IntPtr lparam);
33 |
34 | ///
35 | /// Registers the helper window class.
36 | ///
37 | [DllImport("USER32.DLL", EntryPoint = "RegisterClassW", SetLastError = true)]
38 | public static extern short RegisterClass(ref WindowClass lpWndClass);
39 |
40 | ///
41 | /// Registers a listener for a window message.
42 | ///
43 | ///
44 | ///
45 | [DllImport("User32.Dll", EntryPoint = "RegisterWindowMessageW")]
46 | public static extern uint RegisterWindowMessage([MarshalAs(UnmanagedType.LPWStr)] string lpString);
47 |
48 | ///
49 | /// Used to destroy the hidden helper window that receives messages from the
50 | /// taskbar icon.
51 | ///
52 | ///
53 | ///
54 | [DllImport("USER32.DLL", SetLastError = true)]
55 | public static extern bool DestroyWindow(IntPtr hWnd);
56 |
57 |
58 | ///
59 | /// Gives focus to a given window.
60 | ///
61 | ///
62 | ///
63 | [DllImport("USER32.DLL")]
64 | public static extern bool SetForegroundWindow(IntPtr hWnd);
65 |
66 |
67 | ///
68 | /// Gets the maximum number of milliseconds that can elapse between a
69 | /// first click and a second click for the OS to consider the
70 | /// mouse action a double-click.
71 | ///
72 | /// The maximum amount of time, in milliseconds, that can
73 | /// elapse between a first click and a second click for the OS to
74 | /// consider the mouse action a double-click.
75 | [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
76 | public static extern int GetDoubleClickTime();
77 |
78 |
79 | ///
80 | /// Gets the screen coordinates of the current mouse position.
81 | ///
82 | [DllImport("USER32.DLL", SetLastError = true)]
83 | public static extern bool GetPhysicalCursorPos(ref Point lpPoint);
84 |
85 |
86 | [DllImport("USER32.DLL", SetLastError = true)]
87 | public static extern bool GetCursorPos(ref Point lpPoint);
88 | }
89 | }
--------------------------------------------------------------------------------
/nicon/Interop/WindowClass.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace Hardcodet.Wpf.TaskbarNotification.Interop
5 | {
6 | ///
7 | /// Callback delegate which is used by the Windows API to
8 | /// submit window messages.
9 | ///
10 | public delegate IntPtr WindowProcedureHandler(IntPtr hwnd, uint uMsg, IntPtr wparam, IntPtr lparam);
11 |
12 |
13 | ///
14 | /// Win API WNDCLASS struct - represents a single window.
15 | /// Used to receive window messages.
16 | ///
17 | [StructLayout(LayoutKind.Sequential)]
18 | public struct WindowClass
19 | {
20 | #pragma warning disable 1591
21 |
22 | public uint style;
23 | public WindowProcedureHandler lpfnWndProc;
24 | public int cbClsExtra;
25 | public int cbWndExtra;
26 | public IntPtr hInstance;
27 | public IntPtr hIcon;
28 | public IntPtr hCursor;
29 | public IntPtr hbrBackground;
30 | [MarshalAs(UnmanagedType.LPWStr)] public string lpszMenuName;
31 | [MarshalAs(UnmanagedType.LPWStr)] public string lpszClassName;
32 |
33 | #pragma warning restore 1591
34 | }
35 | }
--------------------------------------------------------------------------------
/nicon/NotifyIconWpf.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 9.0.30729
7 | 2.0
8 | {7AC63864-7638-41C4-969C-D3197EF2BED9}
9 | library
10 | Properties
11 | Hardcodet.Wpf.TaskbarNotification
12 | Hardcodet.Wpf.TaskbarNotification
13 | v4.0
14 | 512
15 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
16 | 4
17 | Client
18 |
19 |
20 | true
21 | full
22 | false
23 | bin\Debug\
24 | DEBUG;TRACE
25 | prompt
26 | 4
27 | AnyCPU
28 | AllRules.ruleset
29 |
30 |
31 | pdbonly
32 | true
33 | bin\Release\
34 | TRACE
35 | prompt
36 | 4
37 | bin\Release\Hardcodet.Wpf.TaskbarNotification.xml
38 | AllRules.ruleset
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | Code
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | Code
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
83 |
--------------------------------------------------------------------------------
/nicon/PopupActivationMode.cs:
--------------------------------------------------------------------------------
1 | // hardcodet.net NotifyIcon for WPF
2 | // Copyright (c) 2009 - 2013 Philipp Sumi
3 | // Contact and Information: http://www.hardcodet.net
4 | //
5 | // This library is free software; you can redistribute it and/or
6 | // modify it under the terms of the Code Project Open License (CPOL);
7 | // either version 1.0 of the License, or (at your option) any later
8 | // version.
9 | //
10 | // The above copyright notice and this permission notice shall be
11 | // included in all copies or substantial portions of the Software.
12 | //
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 | // OTHER DEALINGS IN THE SOFTWARE.
21 | //
22 | // THIS COPYRIGHT NOTICE MAY NOT BE REMOVED FROM THIS FILE
23 |
24 |
25 | namespace Hardcodet.Wpf.TaskbarNotification
26 | {
27 | ///
28 | /// Defines flags that define when a popup
29 | /// is being displyed.
30 | ///
31 | public enum PopupActivationMode
32 | {
33 | ///
34 | /// The item is displayed if the user clicks the
35 | /// tray icon with the left mouse button.
36 | ///
37 | LeftClick,
38 |
39 | ///
40 | /// The item is displayed if the user clicks the
41 | /// tray icon with the right mouse button.
42 | ///
43 | RightClick,
44 |
45 | ///
46 | /// The item is displayed if the user double-clicks the
47 | /// tray icon.
48 | ///
49 | DoubleClick,
50 |
51 | ///
52 | /// The item is displayed if the user clicks the
53 | /// tray icon with the left or the right mouse button.
54 | ///
55 | LeftOrRightClick,
56 |
57 | ///
58 | /// The item is displayed if the user clicks the
59 | /// tray icon with the left mouse button or if a
60 | /// double-click is being performed.
61 | ///
62 | LeftOrDoubleClick,
63 |
64 | ///
65 | /// The item is displayed if the user clicks the
66 | /// tray icon with the middle mouse button.
67 | ///
68 | MiddleClick,
69 |
70 | ///
71 | /// The item is displayed whenever a click occurs.
72 | ///
73 | All
74 | }
75 | }
--------------------------------------------------------------------------------
/nicon/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Runtime.InteropServices;
4 | using System.Windows;
5 | using System.Windows.Markup;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 |
11 | [assembly: AssemblyTitle("NotifyIcon for WPF")]
12 | [assembly: AssemblyDescription("NotifyIcon implementation for the WPF platform.")]
13 | [assembly: AssemblyConfiguration("")]
14 | [assembly: AssemblyCompany("hardcodet.net")]
15 | [assembly: AssemblyProduct("NotifyIcon WPF")]
16 | [assembly: AssemblyCopyright("Copyright © Philipp Sumi 2013")]
17 | [assembly: AssemblyTrademark("")]
18 | [assembly: AssemblyCulture("")]
19 |
20 |
21 | [assembly: AssemblyVersion("1.0.5.0")]
22 | [assembly: AssemblyFileVersion("1.0.5.0")]
23 |
24 |
25 | //provides simplified declaration in XAML
26 | [assembly: XmlnsPrefix("http://www.hardcodet.net/taskbar", "tb")]
27 | [assembly: XmlnsDefinition("http://www.hardcodet.net/taskbar", "Hardcodet.Wpf.TaskbarNotification")]
28 |
29 | // Setting ComVisible to false makes the types in this assembly not visible
30 | // to COM components. If you need to access a type in this assembly from
31 | // COM, set the ComVisible attribute to true on that type.
32 |
33 | [assembly: ComVisible(false)]
34 |
35 | //In order to begin building localizable applications, set
36 | //CultureYouAreCodingWith in your .csproj file
37 | //inside a . For example, if you are using US english
38 | //in your source files, set the to en-US. Then uncomment
39 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
40 | //the line below to match the UICulture setting in the project file.
41 |
42 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
43 |
44 | [assembly: ThemeInfo(
45 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
46 | //(used if a resource is not found in the page,
47 | // or application resource dictionaries)
48 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
49 | //(used if a resource is not found in the page,
50 | // app, or any theme specific resource dictionaries)
51 | )]
52 |
53 |
54 | // Version information for an assembly consists of the following four values:
55 | //
56 | // Major Version
57 | // Minor Version
58 | // Build Number
59 | // Revision
60 | //
61 | // You can specify all the values or you can default the Build and Revision Numbers
62 | // by using the '*' as shown below:
63 | // [assembly: AssemblyVersion("1.0.*")]
64 |
65 |
--------------------------------------------------------------------------------
/nicon/RoutedEventHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 |
4 | namespace Hardcodet.Wpf.TaskbarNotification
5 | {
6 | ///
7 | /// Helper class used by routed events of the
8 | /// class.
9 | ///
10 | internal static class RoutedEventHelper
11 | {
12 | #region RoutedEvent Helper Methods
13 |
14 | ///
15 | /// A static helper method to raise a routed event on a target UIElement or ContentElement.
16 | ///
17 | /// UIElement or ContentElement on which to raise the event
18 | /// RoutedEventArgs to use when raising the event
19 | internal static void RaiseEvent(DependencyObject target, RoutedEventArgs args)
20 | {
21 | if (target is UIElement)
22 | {
23 | (target as UIElement).RaiseEvent(args);
24 | }
25 | else if (target is ContentElement)
26 | {
27 | (target as ContentElement).RaiseEvent(args);
28 | }
29 | }
30 |
31 | ///
32 | /// A static helper method that adds a handler for a routed event
33 | /// to a target UIElement or ContentElement.
34 | ///
35 | /// UIElement or ContentElement that listens to the event
36 | /// Event that will be handled
37 | /// Event handler to be added
38 | internal static void AddHandler(DependencyObject element, RoutedEvent routedEvent, Delegate handler)
39 | {
40 | UIElement uie = element as UIElement;
41 | if (uie != null)
42 | {
43 | uie.AddHandler(routedEvent, handler);
44 | }
45 | else
46 | {
47 | ContentElement ce = element as ContentElement;
48 | if (ce != null)
49 | {
50 | ce.AddHandler(routedEvent, handler);
51 | }
52 | }
53 | }
54 |
55 | ///
56 | /// A static helper method that removes a handler for a routed event
57 | /// from a target UIElement or ContentElement.
58 | ///
59 | /// UIElement or ContentElement that listens to the event
60 | /// Event that will no longer be handled
61 | /// Event handler to be removed
62 | internal static void RemoveHandler(DependencyObject element, RoutedEvent routedEvent, Delegate handler)
63 | {
64 | UIElement uie = element as UIElement;
65 | if (uie != null)
66 | {
67 | uie.RemoveHandler(routedEvent, handler);
68 | }
69 | else
70 | {
71 | ContentElement ce = element as ContentElement;
72 | if (ce != null)
73 | {
74 | ce.RemoveHandler(routedEvent, handler);
75 | }
76 | }
77 | }
78 |
79 | #endregion
80 | }
81 | }
--------------------------------------------------------------------------------