mirror of
https://github.com/ckaczor/WorkIndicator.git
synced 2026-01-13 17:23:18 -05:00
Initial commit
This commit is contained in:
63
.gitattributes
vendored
Normal file
63
.gitattributes
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
###############################################################################
|
||||
# Set default behavior to automatically normalize line endings.
|
||||
###############################################################################
|
||||
* text=auto
|
||||
|
||||
###############################################################################
|
||||
# Set default behavior for command prompt diff.
|
||||
#
|
||||
# This is need for earlier builds of msysgit that does not have it on by
|
||||
# default for csharp files.
|
||||
# Note: This is only used by command line
|
||||
###############################################################################
|
||||
#*.cs diff=csharp
|
||||
|
||||
###############################################################################
|
||||
# Set the merge driver for project and solution files
|
||||
#
|
||||
# Merging from the command prompt will add diff markers to the files if there
|
||||
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||
# the diff markers are never inserted). Diff markers may cause the following
|
||||
# file extensions to fail to load in VS. An alternative would be to treat
|
||||
# these files as binary and thus will always conflict and require user
|
||||
# intervention with every merge. To do so, just uncomment the entries below
|
||||
###############################################################################
|
||||
#*.sln merge=binary
|
||||
#*.csproj merge=binary
|
||||
#*.vbproj merge=binary
|
||||
#*.vcxproj merge=binary
|
||||
#*.vcproj merge=binary
|
||||
#*.dbproj merge=binary
|
||||
#*.fsproj merge=binary
|
||||
#*.lsproj merge=binary
|
||||
#*.wixproj merge=binary
|
||||
#*.modelproj merge=binary
|
||||
#*.sqlproj merge=binary
|
||||
#*.wwaproj merge=binary
|
||||
|
||||
###############################################################################
|
||||
# behavior for image files
|
||||
#
|
||||
# image files are treated as binary by default.
|
||||
###############################################################################
|
||||
#*.jpg binary
|
||||
#*.png binary
|
||||
#*.gif binary
|
||||
|
||||
###############################################################################
|
||||
# diff behavior for common document formats
|
||||
#
|
||||
# Convert binary document formats to text before diffing them. This feature
|
||||
# is only available from the command line. Turn it on by uncommenting the
|
||||
# entries below.
|
||||
###############################################################################
|
||||
#*.doc diff=astextplain
|
||||
#*.DOC diff=astextplain
|
||||
#*.docx diff=astextplain
|
||||
#*.DOCX diff=astextplain
|
||||
#*.dot diff=astextplain
|
||||
#*.DOT diff=astextplain
|
||||
#*.pdf diff=astextplain
|
||||
#*.PDF diff=astextplain
|
||||
#*.rtf diff=astextplain
|
||||
#*.RTF diff=astextplain
|
||||
156
.gitignore
vendored
Normal file
156
.gitignore
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.sln.docstates
|
||||
|
||||
# Build results
|
||||
|
||||
[Dd]ebug/
|
||||
[Rr]elease/
|
||||
x64/
|
||||
build/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
|
||||
!packages/*/build/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.log
|
||||
*.scc
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# NCrunch
|
||||
*.ncrunch*
|
||||
.*crunch*.local.xml
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.Publish.xml
|
||||
|
||||
# NuGet Packages Directory
|
||||
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
|
||||
#packages/
|
||||
|
||||
# Windows Azure Build Output
|
||||
csx
|
||||
*.build.csdef
|
||||
|
||||
# Windows Store app package directory
|
||||
AppPackages/
|
||||
|
||||
# Others
|
||||
sql/
|
||||
*.Cache
|
||||
ClientBin/
|
||||
[Ss]tyle[Cc]op.*
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.[Pp]ublish.xml
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file to a newer
|
||||
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
App_Data/*.mdf
|
||||
App_Data/*.ldf
|
||||
|
||||
|
||||
#LightSwitch generated files
|
||||
GeneratedArtifacts/
|
||||
_Pvt_Extensions/
|
||||
ModelManifest.xml
|
||||
|
||||
# =========================
|
||||
# Windows detritus
|
||||
# =========================
|
||||
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Mac desktop service store files
|
||||
.DS_Store
|
||||
7
App.xaml
Normal file
7
App.xaml
Normal file
@@ -0,0 +1,7 @@
|
||||
<Application x:Class="WorkIndicator.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
55
App.xaml.cs
Normal file
55
App.xaml.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
using Common.Helpers;
|
||||
using Common.IO;
|
||||
using Common.Wpf.Extensions;
|
||||
|
||||
using Settings = WorkIndicator.Properties.Settings;
|
||||
|
||||
namespace WorkIndicator
|
||||
{
|
||||
public partial class App
|
||||
{
|
||||
private IDisposable _isolationHandle;
|
||||
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
base.OnStartup(e);
|
||||
|
||||
// Create an isolation handle to see if we are already running
|
||||
_isolationHandle = ApplicationIsolation.GetIsolationHandle();
|
||||
|
||||
// If there is another copy then pass it the command line and exit
|
||||
if (_isolationHandle == null)
|
||||
{
|
||||
InterprocessMessageSender.SendMessage(Environment.CommandLine);
|
||||
Shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
// Set automatic start into the registry
|
||||
Current.SetStartWithWindows(Settings.Default.StartWithWindows);
|
||||
|
||||
// Initialize the tray icon
|
||||
TrayIcon.Initialize();
|
||||
|
||||
// Initialize the light controller
|
||||
LightController.Initialize();
|
||||
}
|
||||
|
||||
protected override void OnExit(ExitEventArgs e)
|
||||
{
|
||||
// Get rid of the light controller
|
||||
LightController.Dispose();
|
||||
|
||||
// Get rid of the tray icon
|
||||
TrayIcon.Dispose();
|
||||
|
||||
// Get rid of the isolation handle
|
||||
_isolationHandle.Dispose();
|
||||
|
||||
base.OnExit(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
272
Delcom/Delcom.cs
Normal file
272
Delcom/Delcom.cs
Normal file
@@ -0,0 +1,272 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
|
||||
namespace WorkIndicator.Delcom
|
||||
{
|
||||
public class Delcom
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct HidTxPacketStruct
|
||||
{
|
||||
public Byte MajorCmd;
|
||||
public Byte MinorCmd;
|
||||
public Byte LSBData;
|
||||
public Byte MSBData;
|
||||
public Byte HidData0;
|
||||
public Byte HidData1;
|
||||
public Byte HidData2;
|
||||
public Byte HidData3;
|
||||
public Byte ExtData0;
|
||||
public Byte ExtData1;
|
||||
public Byte ExtData2;
|
||||
public Byte ExtData3;
|
||||
public Byte ExtData4;
|
||||
public Byte ExtData5;
|
||||
public Byte ExtData6;
|
||||
public Byte ExtData7;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct HidRxPacketStruct
|
||||
{
|
||||
public Byte Data0;
|
||||
public Byte Data1;
|
||||
public Byte Data2;
|
||||
public Byte Data3;
|
||||
public Byte Data4;
|
||||
public Byte Data5;
|
||||
public Byte Data6;
|
||||
public Byte Data7;
|
||||
}
|
||||
|
||||
private readonly DeviceManagement _deviceManagement = new DeviceManagement();
|
||||
private readonly HID _hid = new HID();
|
||||
|
||||
private SafeFileHandle _deviceHandle;
|
||||
private Boolean _deviceDetected;
|
||||
private String _devicePathName;
|
||||
private UInt32 _matchingDevicesFound;
|
||||
private HidTxPacketStruct _transmitPacket;
|
||||
|
||||
public bool RawCommand(int major, int minor, int lsbData, int msbData)
|
||||
{
|
||||
_transmitPacket.MajorCmd = Convert.ToByte(major);
|
||||
_transmitPacket.MinorCmd = Convert.ToByte(minor);
|
||||
|
||||
_transmitPacket.LSBData = Convert.ToByte(lsbData);
|
||||
_transmitPacket.MSBData = Convert.ToByte(msbData);
|
||||
|
||||
return HID.HidD_SetFeature(_deviceHandle, StructureToByteArray(_transmitPacket), 8);
|
||||
}
|
||||
|
||||
public int WriteBlink(int lsb, int msb)
|
||||
{
|
||||
try
|
||||
{
|
||||
_transmitPacket.MajorCmd = 101;
|
||||
_transmitPacket.MinorCmd = 20;
|
||||
|
||||
_transmitPacket.LSBData = Convert.ToByte(lsb);
|
||||
_transmitPacket.MSBData = Convert.ToByte(msb);
|
||||
|
||||
int r = HID.HidD_SetFeature(_deviceHandle, StructureToByteArray(_transmitPacket), 8) ? 0 : 1;
|
||||
|
||||
_transmitPacket.MajorCmd = 101;
|
||||
_transmitPacket.MinorCmd = 25;
|
||||
|
||||
_transmitPacket.LSBData = Convert.ToByte(msb);
|
||||
_transmitPacket.MSBData = Convert.ToByte(0);
|
||||
|
||||
HID.HidD_SetFeature(_deviceHandle, StructureToByteArray(_transmitPacket), 8);
|
||||
|
||||
return r;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
public int WritePorts(int port0, int port1)
|
||||
{
|
||||
try
|
||||
{
|
||||
_transmitPacket.MajorCmd = 101;
|
||||
_transmitPacket.MinorCmd = 10;
|
||||
|
||||
_transmitPacket.LSBData = Convert.ToByte(port0);
|
||||
_transmitPacket.MSBData = Convert.ToByte(port1);
|
||||
|
||||
return HID.HidD_SetFeature(_deviceHandle, StructureToByteArray(_transmitPacket), 8) ? 0 : 1;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 ReadPort0(ref UInt32 port0)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
Byte[] buffer = new Byte[16];
|
||||
|
||||
buffer[0] = 100; // Read ports command
|
||||
|
||||
if (!HID.HidD_GetFeature(_deviceHandle, buffer, 8))
|
||||
return 1;
|
||||
|
||||
port0 = Convert.ToUInt32(buffer[0]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
public int ReadPorts(ref int port0, ref int port1)
|
||||
{
|
||||
try
|
||||
{
|
||||
Byte[] buffer = new Byte[16];
|
||||
|
||||
buffer[0] = 100; // Read ports command
|
||||
|
||||
if (!HID.HidD_GetFeature(_deviceHandle, buffer, 8))
|
||||
return 1;
|
||||
|
||||
port0 = Convert.ToInt32(buffer[0]);
|
||||
port1 = Convert.ToInt32(buffer[1]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 Close()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_deviceHandle.IsClosed)
|
||||
_deviceHandle.Close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 Open()
|
||||
{
|
||||
return OpenNthDevice(1);
|
||||
}
|
||||
|
||||
public UInt32 OpenNthDevice(UInt32 deviceIndex)
|
||||
{
|
||||
if (_deviceHandle != null)
|
||||
Close();
|
||||
|
||||
if (!FindTheHID(deviceIndex))
|
||||
return 1;
|
||||
|
||||
_deviceHandle = FileIODeclarations.CreateFile(_devicePathName, FileIODeclarations.GenericRead | FileIODeclarations.GenericWrite, FileIODeclarations.FileShareRead | FileIODeclarations.FileShareWrite, IntPtr.Zero, FileIODeclarations.OpenExisting, 0, 0);
|
||||
|
||||
return _deviceHandle.IsInvalid ? 2 : (uint) 0;
|
||||
}
|
||||
|
||||
public string GetDeviceName()
|
||||
{
|
||||
return _devicePathName;
|
||||
}
|
||||
|
||||
public UInt32 GetDevicesCount()
|
||||
{
|
||||
FindTheHID(0);
|
||||
|
||||
return _matchingDevicesFound;
|
||||
}
|
||||
|
||||
private Boolean FindTheHID(UInt32 deviceIndex)
|
||||
{
|
||||
const ushort productId = 0xB080;
|
||||
const ushort vendorId = 0x0FC5;
|
||||
|
||||
String[] devicePathName = new String[128];
|
||||
Guid hidGuid = Guid.Empty;
|
||||
UInt32 matchingDevices = 0;
|
||||
|
||||
_deviceDetected = false;
|
||||
|
||||
HID.HidD_GetHidGuid(ref hidGuid);
|
||||
|
||||
Boolean deviceFound = _deviceManagement.FindDeviceFromGuid(hidGuid, ref devicePathName);
|
||||
|
||||
if (deviceFound)
|
||||
{
|
||||
Int32 memberIndex = 0;
|
||||
do
|
||||
{
|
||||
SafeFileHandle hidHandle = FileIODeclarations.CreateFile(devicePathName[memberIndex], FileIODeclarations.GenericRead | FileIODeclarations.GenericWrite, FileIODeclarations.FileShareRead | FileIODeclarations.FileShareWrite, IntPtr.Zero, FileIODeclarations.OpenExisting, 0, 0);
|
||||
|
||||
if (!hidHandle.IsInvalid)
|
||||
{
|
||||
_hid.DeviceAttributes.Size = Marshal.SizeOf(_hid.DeviceAttributes);
|
||||
|
||||
Boolean success = HID.HidD_GetAttributes(hidHandle, ref _hid.DeviceAttributes);
|
||||
if (success)
|
||||
{
|
||||
if (_hid.DeviceAttributes.VendorID == vendorId && _hid.DeviceAttributes.ProductID == productId)
|
||||
{
|
||||
matchingDevices++;
|
||||
_deviceDetected = true;
|
||||
}
|
||||
|
||||
if (_deviceDetected && matchingDevices == deviceIndex)
|
||||
{
|
||||
_devicePathName = devicePathName[memberIndex];
|
||||
hidHandle.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
_deviceDetected = false;
|
||||
hidHandle.Close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_deviceDetected = false;
|
||||
hidHandle.Close();
|
||||
}
|
||||
}
|
||||
|
||||
memberIndex = memberIndex + 1;
|
||||
}
|
||||
while (!(_deviceDetected || memberIndex == devicePathName.Length));
|
||||
}
|
||||
|
||||
_matchingDevicesFound = matchingDevices;
|
||||
|
||||
return _deviceDetected;
|
||||
}
|
||||
|
||||
private static byte[] StructureToByteArray(object obj)
|
||||
{
|
||||
int length = Marshal.SizeOf(obj);
|
||||
byte[] buffer = new byte[length];
|
||||
IntPtr ptr = Marshal.AllocHGlobal(length);
|
||||
Marshal.StructureToPtr(obj, ptr, true);
|
||||
Marshal.Copy(ptr, buffer, 0, length);
|
||||
Marshal.FreeHGlobal(ptr);
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
357
Delcom/DeviceManagement.cs
Normal file
357
Delcom/DeviceManagement.cs
Normal file
@@ -0,0 +1,357 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WorkIndicator.Delcom
|
||||
{
|
||||
sealed internal partial class DeviceManagement
|
||||
{
|
||||
/// <summary>
|
||||
/// Compares two device path names. Used to find out if the device name
|
||||
/// of a recently attached or removed device matches the name of a
|
||||
/// device the application is communicating with.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="m"> a WM_DEVICECHANGE message. A call to RegisterDeviceNotification
|
||||
/// causes WM_DEVICECHANGE messages to be passed to an OnDeviceChange routine.. </param>
|
||||
/// <param name="mydevicePathName"> a device pathname returned by
|
||||
/// SetupDiGetDeviceInterfaceDetail in an SP_DEVICE_INTERFACE_DETAIL_DATA structure. </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// True if the names match, False if not.
|
||||
/// </returns>
|
||||
///
|
||||
internal Boolean DeviceNameMatch(Message m, String mydevicePathName)
|
||||
{
|
||||
DevBroadcastDeviceInterface1 devBroadcastDeviceInterface = new DevBroadcastDeviceInterface1();
|
||||
DevBroadcastHdr devBroadcastHeader = new DevBroadcastHdr();
|
||||
|
||||
// The LParam parameter of Message is a pointer to a DEV_BROADCAST_HDR structure.
|
||||
|
||||
Marshal.PtrToStructure(m.LParam, devBroadcastHeader);
|
||||
|
||||
if ((devBroadcastHeader.dbch_devicetype == DbtDevTypDeviceInterface))
|
||||
{
|
||||
// The dbch_devicetype parameter indicates that the event applies to a device interface.
|
||||
// So the structure in LParam is actually a DEV_BROADCAST_INTERFACE structure,
|
||||
// which begins with a DEV_BROADCAST_HDR.
|
||||
|
||||
// Obtain the number of characters in dbch_name by subtracting the 32 bytes
|
||||
// in the strucutre that are not part of dbch_name and dividing by 2 because there are
|
||||
// 2 bytes per character.
|
||||
|
||||
Int32 stringSize = Convert.ToInt32((devBroadcastHeader.dbch_size - 32) / 2);
|
||||
|
||||
// The dbcc_name parameter of devBroadcastDeviceInterface contains the device name.
|
||||
// Trim dbcc_name to match the size of the String.
|
||||
|
||||
devBroadcastDeviceInterface.dbcc_name = new Char[stringSize + 1];
|
||||
|
||||
// Marshal data from the unmanaged block pointed to by m.LParam
|
||||
// to the managed object devBroadcastDeviceInterface.
|
||||
|
||||
Marshal.PtrToStructure(m.LParam, devBroadcastDeviceInterface);
|
||||
|
||||
// Store the device name in a String.
|
||||
String deviceNameString = new String(devBroadcastDeviceInterface.dbcc_name, 0, stringSize);
|
||||
|
||||
// Compare the name of the newly attached device with the name of the device
|
||||
// the application is accessing (mydevicePathName).
|
||||
// Set ignorecase True.
|
||||
|
||||
return String.Compare(deviceNameString, mydevicePathName, StringComparison.OrdinalIgnoreCase) == 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use SetupDi API functions to retrieve the device path name of an
|
||||
/// attached device that belongs to a device interface class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="myGuid"> an interface class GUID. </param>
|
||||
/// <param name="devicePathName"> a pointer to the device path name
|
||||
/// of an attached device. </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// True if a device is found, False if not.
|
||||
/// </returns>
|
||||
internal Boolean FindDeviceFromGuid(Guid myGuid, ref String[] devicePathName)
|
||||
{
|
||||
Int32 bufferSize = 0;
|
||||
IntPtr detailDataBuffer = IntPtr.Zero;
|
||||
IntPtr deviceInfoSet = new IntPtr();
|
||||
Boolean lastDevice = false;
|
||||
SpDeviceInterfaceData deviceInterfaceData = new SpDeviceInterfaceData();
|
||||
|
||||
try
|
||||
{
|
||||
// ***
|
||||
// API function
|
||||
|
||||
// summary
|
||||
// Retrieves a device information set for a specified group of devices.
|
||||
// SetupDiEnumDeviceInterfaces uses the device information set.
|
||||
|
||||
// parameters
|
||||
// Interface class GUID.
|
||||
// Null to retrieve information for all device instances.
|
||||
// Optional handle to a top-level window (unused here).
|
||||
// Flags to limit the returned information to currently present devices
|
||||
// and devices that expose interfaces in the class specified by the GUID.
|
||||
|
||||
// Returns
|
||||
// Handle to a device information set for the devices.
|
||||
// ***
|
||||
|
||||
deviceInfoSet = SetupDiGetClassDevs(ref myGuid, IntPtr.Zero, IntPtr.Zero, DigCfPresent | DigCfDeviceInterface);
|
||||
|
||||
Boolean deviceFound = false;
|
||||
Int32 memberIndex = 0;
|
||||
|
||||
// The cbSize element of the MyDeviceInterfaceData structure must be set to
|
||||
// the structure's size in bytes.
|
||||
// The size is 28 bytes for 32-bit code and 32 bits for 64-bit code.
|
||||
|
||||
deviceInterfaceData.CbSize = Marshal.SizeOf(deviceInterfaceData);
|
||||
|
||||
do
|
||||
{
|
||||
// Begin with 0 and increment through the device information set until
|
||||
// no more devices are available.
|
||||
|
||||
// ***
|
||||
// API function
|
||||
|
||||
// summary
|
||||
// Retrieves a handle to a SP_DEVICE_INTERFACE_DATA structure for a device.
|
||||
// On return, MyDeviceInterfaceData contains the handle to a
|
||||
// SP_DEVICE_INTERFACE_DATA structure for a detected device.
|
||||
|
||||
// parameters
|
||||
// DeviceInfoSet returned by SetupDiGetClassDevs.
|
||||
// Optional SP_DEVINFO_DATA structure that defines a device instance
|
||||
// that is a member of a device information set.
|
||||
// Device interface GUID.
|
||||
// Index to specify a device in a device information set.
|
||||
// Pointer to a handle to a SP_DEVICE_INTERFACE_DATA structure for a device.
|
||||
|
||||
// Returns
|
||||
// True on success.
|
||||
// ***
|
||||
|
||||
Boolean success = SetupDiEnumDeviceInterfaces(deviceInfoSet, IntPtr.Zero, ref myGuid, memberIndex, ref deviceInterfaceData);
|
||||
|
||||
// Find out if a device information set was retrieved.
|
||||
|
||||
if (!success)
|
||||
{
|
||||
lastDevice = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// A device is present.
|
||||
|
||||
// ***
|
||||
// API function:
|
||||
|
||||
// summary:
|
||||
// Retrieves an SP_DEVICE_INTERFACE_DETAIL_DATA structure
|
||||
// containing information about a device.
|
||||
// To retrieve the information, call this function twice.
|
||||
// The first time returns the size of the structure.
|
||||
// The second time returns a pointer to the data.
|
||||
|
||||
// parameters
|
||||
// DeviceInfoSet returned by SetupDiGetClassDevs
|
||||
// SP_DEVICE_INTERFACE_DATA structure returned by SetupDiEnumDeviceInterfaces
|
||||
// A returned pointer to an SP_DEVICE_INTERFACE_DETAIL_DATA
|
||||
// Structure to receive information about the specified interface.
|
||||
// The size of the SP_DEVICE_INTERFACE_DETAIL_DATA structure.
|
||||
// Pointer to a variable that will receive the returned required size of the
|
||||
// SP_DEVICE_INTERFACE_DETAIL_DATA structure.
|
||||
// Returned pointer to an SP_DEVINFO_DATA structure to receive information about the device.
|
||||
|
||||
// Returns
|
||||
// True on success.
|
||||
// ***
|
||||
|
||||
SetupDiGetDeviceInterfaceDetail(deviceInfoSet, ref deviceInterfaceData, IntPtr.Zero, 0, ref bufferSize, IntPtr.Zero);
|
||||
|
||||
// Allocate memory for the SP_DEVICE_INTERFACE_DETAIL_DATA structure using the returned buffer size.
|
||||
|
||||
detailDataBuffer = Marshal.AllocHGlobal(bufferSize);
|
||||
|
||||
// Store cbSize in the first bytes of the array. The number of bytes varies with 32- and 64-bit systems.
|
||||
|
||||
Marshal.WriteInt32(detailDataBuffer, (IntPtr.Size == 4) ? (4 + Marshal.SystemDefaultCharSize) : 8);
|
||||
|
||||
// Call SetupDiGetDeviceInterfaceDetail again.
|
||||
// This time, pass a pointer to DetailDataBuffer
|
||||
// and the returned required buffer size.
|
||||
|
||||
SetupDiGetDeviceInterfaceDetail(deviceInfoSet, ref deviceInterfaceData, detailDataBuffer, bufferSize, ref bufferSize, IntPtr.Zero);
|
||||
|
||||
// Skip over cbsize (4 bytes) to get the address of the devicePathName.
|
||||
|
||||
IntPtr pDevicePathName = new IntPtr(detailDataBuffer.ToInt32() + 4);
|
||||
|
||||
// Get the String containing the devicePathName.
|
||||
|
||||
devicePathName[memberIndex] = Marshal.PtrToStringAuto(pDevicePathName);
|
||||
|
||||
deviceFound = true;
|
||||
}
|
||||
memberIndex = memberIndex + 1;
|
||||
}
|
||||
while (lastDevice != true);
|
||||
|
||||
return deviceFound;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (detailDataBuffer != IntPtr.Zero)
|
||||
{
|
||||
// Free the memory allocated previously by AllocHGlobal.
|
||||
|
||||
Marshal.FreeHGlobal(detailDataBuffer);
|
||||
}
|
||||
// ***
|
||||
// API function
|
||||
|
||||
// summary
|
||||
// Frees the memory reserved for the DeviceInfoSet returned by SetupDiGetClassDevs.
|
||||
|
||||
// parameters
|
||||
// DeviceInfoSet returned by SetupDiGetClassDevs.
|
||||
|
||||
// returns
|
||||
// True on success.
|
||||
// ***
|
||||
|
||||
if (deviceInfoSet != IntPtr.Zero)
|
||||
{
|
||||
SetupDiDestroyDeviceInfoList(deviceInfoSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests to receive a notification when a device is attached or removed.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="devicePathName"> handle to a device. </param>
|
||||
/// <param name="formHandle"> handle to the window that will receive device events. </param>
|
||||
/// <param name="classGuid"> device interface GUID. </param>
|
||||
/// <param name="deviceNotificationHandle"> returned device notification handle. </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// True on success.
|
||||
/// </returns>
|
||||
///
|
||||
internal Boolean RegisterForDeviceNotifications(String devicePathName, IntPtr formHandle, Guid classGuid, ref IntPtr deviceNotificationHandle)
|
||||
{
|
||||
// A DEV_BROADCAST_DEVICEINTERFACE header holds information about the request.
|
||||
|
||||
DevBroadcastDeviceInterface devBroadcastDeviceInterface = new DevBroadcastDeviceInterface();
|
||||
IntPtr devBroadcastDeviceInterfaceBuffer = IntPtr.Zero;
|
||||
|
||||
try
|
||||
{
|
||||
// Set the parameters in the DEV_BROADCAST_DEVICEINTERFACE structure.
|
||||
|
||||
// Set the size.
|
||||
|
||||
Int32 size = Marshal.SizeOf(devBroadcastDeviceInterface);
|
||||
devBroadcastDeviceInterface.dbcc_size = size;
|
||||
|
||||
// Request to receive notifications about a class of devices.
|
||||
|
||||
devBroadcastDeviceInterface.dbcc_devicetype = DbtDevTypDeviceInterface;
|
||||
|
||||
devBroadcastDeviceInterface.dbcc_reserved = 0;
|
||||
|
||||
// Specify the interface class to receive notifications about.
|
||||
|
||||
devBroadcastDeviceInterface.dbcc_classguid = classGuid;
|
||||
|
||||
// Allocate memory for the buffer that holds the DEV_BROADCAST_DEVICEINTERFACE structure.
|
||||
|
||||
devBroadcastDeviceInterfaceBuffer = Marshal.AllocHGlobal(size);
|
||||
|
||||
// Copy the DEV_BROADCAST_DEVICEINTERFACE structure to the buffer.
|
||||
// Set fDeleteOld True to prevent memory leaks.
|
||||
|
||||
Marshal.StructureToPtr(devBroadcastDeviceInterface, devBroadcastDeviceInterfaceBuffer, true);
|
||||
|
||||
// ***
|
||||
// API function
|
||||
|
||||
// summary
|
||||
// Request to receive notification messages when a device in an interface class
|
||||
// is attached or removed.
|
||||
|
||||
// parameters
|
||||
// Handle to the window that will receive device events.
|
||||
// Pointer to a DEV_BROADCAST_DEVICEINTERFACE to specify the type of
|
||||
// device to send notifications for.
|
||||
// DEVICE_NOTIFY_WINDOW_HANDLE indicates the handle is a window handle.
|
||||
|
||||
// Returns
|
||||
// Device notification handle or NULL on failure.
|
||||
// ***
|
||||
|
||||
deviceNotificationHandle = RegisterDeviceNotification(formHandle, devBroadcastDeviceInterfaceBuffer, DeviceNotifyWindowHandle);
|
||||
|
||||
// Marshal data from the unmanaged block devBroadcastDeviceInterfaceBuffer to
|
||||
// the managed object devBroadcastDeviceInterface
|
||||
|
||||
Marshal.PtrToStructure(devBroadcastDeviceInterfaceBuffer, devBroadcastDeviceInterface);
|
||||
|
||||
return deviceNotificationHandle.ToInt32() != IntPtr.Zero.ToInt32();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (devBroadcastDeviceInterfaceBuffer != IntPtr.Zero)
|
||||
{
|
||||
// Free the memory allocated previously by AllocHGlobal.
|
||||
|
||||
Marshal.FreeHGlobal(devBroadcastDeviceInterfaceBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests to stop receiving notification messages when a device in an
|
||||
/// interface class is attached or removed.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="deviceNotificationHandle"> handle returned previously by
|
||||
/// RegisterDeviceNotification. </param>
|
||||
internal void StopReceivingDeviceNotifications(IntPtr deviceNotificationHandle)
|
||||
{
|
||||
// ***
|
||||
// API function
|
||||
|
||||
// summary
|
||||
// Stop receiving notification messages.
|
||||
|
||||
// parameters
|
||||
// Handle returned previously by RegisterDeviceNotification.
|
||||
|
||||
// returns
|
||||
// True on success.
|
||||
// ***
|
||||
|
||||
// Ignore failures.
|
||||
|
||||
UnregisterDeviceNotification(deviceNotificationHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
95
Delcom/DeviceManagementDeclarations.cs
Normal file
95
Delcom/DeviceManagementDeclarations.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace WorkIndicator.Delcom
|
||||
{
|
||||
internal sealed partial class DeviceManagement
|
||||
{
|
||||
///<summary >
|
||||
// API declarations relating to device management (SetupDixxx and
|
||||
// RegisterDeviceNotification functions).
|
||||
/// </summary>
|
||||
|
||||
// from dbt.h
|
||||
|
||||
internal const Int32 DbtDeviceArrival = 0x8000;
|
||||
internal const Int32 DbtDeviceRemoveComplete = 0x8004;
|
||||
internal const Int32 DbtDevTypDeviceInterface = 5;
|
||||
internal const Int32 DbtDevTypHandle = 6;
|
||||
internal const Int32 DeviceNotifyAllInterfaceClasses = 4;
|
||||
internal const Int32 DeviceNotifyServiceHandle = 1;
|
||||
internal const Int32 DeviceNotifyWindowHandle = 0;
|
||||
internal const Int32 WmDeviceChange = 0x219;
|
||||
|
||||
// from setupapi.h
|
||||
|
||||
internal const Int32 DigCfPresent = 2;
|
||||
internal const Int32 DigCfDeviceInterface = 0X10;
|
||||
|
||||
// Two declarations for the DEV_BROADCAST_DEVICEINTERFACE structure.
|
||||
|
||||
// Use this one in the call to RegisterDeviceNotification() and
|
||||
// in checking dbch_devicetype in a DEV_BROADCAST_HDR structure:
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class DevBroadcastDeviceInterface
|
||||
{
|
||||
internal Int32 dbcc_size;
|
||||
internal Int32 dbcc_devicetype;
|
||||
internal Int32 dbcc_reserved;
|
||||
internal Guid dbcc_classguid;
|
||||
internal Int16 dbcc_name;
|
||||
}
|
||||
|
||||
// Use this to read the dbcc_name String and classguid:
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
internal class DevBroadcastDeviceInterface1
|
||||
{
|
||||
internal Int32 dbcc_size;
|
||||
internal Int32 dbcc_devicetype;
|
||||
internal Int32 dbcc_reserved;
|
||||
[MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.U1, SizeConst = 16)]
|
||||
internal Byte[] dbcc_classguid;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 255)]
|
||||
internal Char[] dbcc_name;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class DevBroadcastHdr
|
||||
{
|
||||
internal Int32 dbch_size;
|
||||
internal Int32 dbch_devicetype;
|
||||
internal Int32 dbch_reserved;
|
||||
}
|
||||
|
||||
internal struct SpDeviceInterfaceData
|
||||
{
|
||||
internal Int32 CbSize;
|
||||
internal Guid InterfaceClassGuid;
|
||||
internal Int32 Flags;
|
||||
internal IntPtr Reserved;
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
internal static extern IntPtr RegisterDeviceNotification(IntPtr hRecipient, IntPtr notificationFilter, Int32 flags);
|
||||
|
||||
[DllImport("setupapi.dll", SetLastError = true)]
|
||||
internal static extern Int32 SetupDiCreateDeviceInfoList(ref Guid classGuid, Int32 hwndParent);
|
||||
|
||||
[DllImport("setupapi.dll", SetLastError = true)]
|
||||
internal static extern Int32 SetupDiDestroyDeviceInfoList(IntPtr deviceInfoSet);
|
||||
|
||||
[DllImport("setupapi.dll", SetLastError = true)]
|
||||
internal static extern Boolean SetupDiEnumDeviceInterfaces(IntPtr deviceInfoSet, IntPtr deviceInfoData, ref Guid interfaceClassGuid, Int32 memberIndex, ref SpDeviceInterfaceData spDeviceInterfaceData);
|
||||
|
||||
[DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
internal static extern IntPtr SetupDiGetClassDevs(ref Guid classGuid, IntPtr enumerator, IntPtr hwndParent, Int32 flags);
|
||||
|
||||
[DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
internal static extern Boolean SetupDiGetDeviceInterfaceDetail(IntPtr deviceInfoSet, ref SpDeviceInterfaceData spDeviceInterfaceData, IntPtr deviceInterfaceDetailData, Int32 deviceInterfaceDetailDataSize, ref Int32 requiredSize, IntPtr deviceInfoData);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
internal static extern Boolean UnregisterDeviceNotification(IntPtr handle);
|
||||
}
|
||||
}
|
||||
53
Delcom/FileIODeclarations.cs
Normal file
53
Delcom/FileIODeclarations.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
|
||||
namespace WorkIndicator.Delcom
|
||||
{
|
||||
internal sealed class FileIODeclarations
|
||||
{
|
||||
internal const Int32 FileFlagOverlapped = 0x40000000;
|
||||
|
||||
internal const Int32 FileShareRead = 1;
|
||||
internal const Int32 FileShareWrite = 2;
|
||||
|
||||
internal const UInt32 GenericRead = 0x80000000;
|
||||
internal const UInt32 GenericWrite = 0x40000000;
|
||||
|
||||
internal const Int32 InvalidHandleValue = -1;
|
||||
|
||||
internal const Int32 OpenExisting = 3;
|
||||
|
||||
internal const Int32 WaitTimeout = 0x102;
|
||||
internal const Int32 WaitObject0 = 0;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class SecurityAttributes
|
||||
{
|
||||
internal Int32 nLength;
|
||||
internal Int32 lpSecurityDescriptor;
|
||||
internal Int32 bInheritHandle;
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
internal static extern Int32 CancelIo(SafeFileHandle hFile);
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
internal static extern IntPtr CreateEvent(IntPtr securityAttributes, Boolean bManualReset, Boolean bInitialState, String lpName);
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
internal static extern SafeFileHandle CreateFile(String lpFileName, UInt32 dwDesiredAccess, Int32 dwShareMode, IntPtr lpSecurityAttributes, Int32 dwCreationDisposition, Int32 dwFlagsAndAttributes, Int32 hTemplateFile);
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
internal static extern Boolean GetOverlappedResult(SafeFileHandle hFile, IntPtr lpOverlapped, ref Int32 lpNumberOfBytesTransferred, Boolean bWait);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
internal static extern Boolean ReadFile(SafeFileHandle hFile, IntPtr lpBuffer, Int32 nNumberOfBytesToRead, ref Int32 lpNumberOfBytesRead, IntPtr lpOverlapped);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
internal static extern Int32 WaitForSingleObject(IntPtr hHandle, Int32 dwMilliseconds);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
internal static extern Boolean WriteFile(SafeFileHandle hFile, Byte[] lpBuffer, Int32 nNumberOfBytesToWrite, ref Int32 lpNumberOfBytesWritten, IntPtr lpOverlapped);
|
||||
}
|
||||
}
|
||||
851
Delcom/HID.cs
Normal file
851
Delcom/HID.cs
Normal file
@@ -0,0 +1,851 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
|
||||
namespace WorkIndicator.Delcom
|
||||
{
|
||||
internal sealed partial class HID
|
||||
{
|
||||
private const String ModuleName = "Hid";
|
||||
|
||||
internal HidpCaps Capabilities;
|
||||
internal HiddAttributes DeviceAttributes;
|
||||
|
||||
internal abstract class ReportIn
|
||||
{
|
||||
internal abstract void Read(SafeFileHandle hidHandle, SafeFileHandle readHandle, SafeFileHandle writeHandle, ref Boolean myDeviceDetected, ref Byte[] readBuffer, ref Boolean success);
|
||||
}
|
||||
|
||||
internal class InFeatureReport : ReportIn
|
||||
{
|
||||
internal override void Read(SafeFileHandle hidHandle, SafeFileHandle readHandle, SafeFileHandle writeHandle, ref Boolean myDeviceDetected, ref Byte[] inFeatureReportBuffer, ref Boolean success)
|
||||
{
|
||||
try
|
||||
{
|
||||
success = HidD_GetFeature(hidHandle, inFeatureReportBuffer, inFeatureReportBuffer.Length);
|
||||
|
||||
Debug.Print("HidD_GetFeature success = " + success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DisplayException(ModuleName, ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class InputReportViaControlTransfer : ReportIn
|
||||
{
|
||||
internal override void Read(SafeFileHandle hidHandle, SafeFileHandle readHandle, SafeFileHandle writeHandle, ref Boolean myDeviceDetected, ref Byte[] inputReportBuffer, ref Boolean success)
|
||||
{
|
||||
try
|
||||
{
|
||||
success = HidD_GetInputReport(hidHandle, inputReportBuffer, inputReportBuffer.Length + 1);
|
||||
|
||||
Debug.Print("HidD_GetInputReport success = " + success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DisplayException(ModuleName, ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For reading Input reports.
|
||||
/// </summary>
|
||||
|
||||
internal class InputReportViaInterruptTransfer : ReportIn
|
||||
{
|
||||
internal void CancelTransfer(SafeFileHandle hidHandle, SafeFileHandle readHandle, SafeFileHandle writeHandle, IntPtr eventObject)
|
||||
{
|
||||
try
|
||||
{
|
||||
// ***
|
||||
// API function: CancelIo
|
||||
|
||||
// Purpose: Cancels a call to ReadFile
|
||||
|
||||
// Accepts: the device handle.
|
||||
|
||||
// Returns: True on success, False on failure.
|
||||
// ***
|
||||
|
||||
FileIODeclarations.CancelIo(readHandle);
|
||||
|
||||
Debug.WriteLine("************ReadFile error*************");
|
||||
//String functionName = "CancelIo";
|
||||
//Debug.WriteLine(MyDebugging.ResultOfAPICall(functionName));
|
||||
Debug.WriteLine("");
|
||||
|
||||
// The failure may have been because the device was removed,
|
||||
// so close any open handles and
|
||||
// set myDeviceDetected=False to cause the application to
|
||||
// look for the device on the next attempt.
|
||||
|
||||
if ((!(hidHandle.IsInvalid)))
|
||||
{
|
||||
hidHandle.Close();
|
||||
}
|
||||
|
||||
if ((!(readHandle.IsInvalid)))
|
||||
{
|
||||
readHandle.Close();
|
||||
}
|
||||
|
||||
if ((!(writeHandle.IsInvalid)))
|
||||
{
|
||||
writeHandle.Close();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DisplayException(ModuleName, ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an event object for the overlapped structure used with ReadFile.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="hidOverlapped"> the overlapped structure </param>
|
||||
/// <param name="eventObject"> the event object </param>
|
||||
|
||||
internal void PrepareForOverlappedTransfer(ref NativeOverlapped hidOverlapped, ref IntPtr eventObject)
|
||||
{
|
||||
try
|
||||
{
|
||||
// ***
|
||||
// API function: CreateEvent
|
||||
|
||||
// Purpose: Creates an event object for the overlapped structure used with ReadFile.
|
||||
|
||||
// Accepts:
|
||||
// A security attributes structure or IntPtr.Zero.
|
||||
// Manual Reset = False (The system automatically resets the state to nonsignaled
|
||||
// after a waiting thread has been released.)
|
||||
// Initial state = False (not signaled)
|
||||
// An event object name (optional)
|
||||
|
||||
// Returns: a handle to the event object
|
||||
// ***
|
||||
|
||||
eventObject = FileIODeclarations.CreateEvent(IntPtr.Zero, false, false, "");
|
||||
|
||||
// Set the members of the overlapped structure.
|
||||
|
||||
hidOverlapped.OffsetLow = 0;
|
||||
hidOverlapped.OffsetHigh = 0;
|
||||
hidOverlapped.EventHandle = eventObject;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DisplayException(ModuleName, ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// reads an Input report from the device using interrupt transfers.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="hidHandle"> the handle for learning about the device and exchanging Feature reports. </param>
|
||||
/// <param name="readHandle"> the handle for reading Input reports from the device. </param>
|
||||
/// <param name="writeHandle"> the handle for writing Output reports to the device. </param>
|
||||
/// <param name="myDeviceDetected"> tells whether the device is currently attached. </param>
|
||||
/// <param name="inputReportBuffer"> contains the requested report. </param>
|
||||
/// <param name="success"> read success </param>
|
||||
|
||||
internal override void Read(SafeFileHandle hidHandle, SafeFileHandle readHandle, SafeFileHandle writeHandle, ref Boolean myDeviceDetected, ref Byte[] inputReportBuffer, ref Boolean success)
|
||||
{
|
||||
IntPtr eventObject = IntPtr.Zero;
|
||||
NativeOverlapped hidOverlapped = new NativeOverlapped();
|
||||
Int32 numberOfBytesRead = 0;
|
||||
|
||||
try
|
||||
{
|
||||
// Set up the overlapped structure for ReadFile.
|
||||
|
||||
PrepareForOverlappedTransfer(ref hidOverlapped, ref eventObject);
|
||||
|
||||
// Allocate memory for the input buffer and overlapped structure.
|
||||
|
||||
IntPtr nonManagedBuffer = Marshal.AllocHGlobal(inputReportBuffer.Length);
|
||||
IntPtr nonManagedOverlapped = Marshal.AllocHGlobal(Marshal.SizeOf(hidOverlapped));
|
||||
Marshal.StructureToPtr(hidOverlapped, nonManagedOverlapped, false);
|
||||
|
||||
// ***
|
||||
// API function: ReadFile
|
||||
// Purpose: Attempts to read an Input report from the device.
|
||||
|
||||
// Accepts:
|
||||
// A device handle returned by CreateFile
|
||||
// (for overlapped I/O, CreateFile must have been called with FILE_FLAG_OVERLAPPED),
|
||||
// A pointer to a buffer for storing the report.
|
||||
// The Input report length in bytes returned by HidP_GetCaps,
|
||||
// A pointer to a variable that will hold the number of bytes read.
|
||||
// An overlapped structure whose hEvent member is set to an event object.
|
||||
|
||||
// Returns: the report in ReadBuffer.
|
||||
|
||||
// The overlapped call returns immediately, even if the data hasn't been received yet.
|
||||
|
||||
// To read multiple reports with one ReadFile, increase the size of ReadBuffer
|
||||
// and use NumberOfBytesRead to determine how many reports were returned.
|
||||
// Use a larger buffer if the application can't keep up with reading each report
|
||||
// individually.
|
||||
// ***
|
||||
|
||||
success = FileIODeclarations.ReadFile(readHandle, nonManagedBuffer, inputReportBuffer.Length, ref numberOfBytesRead, nonManagedOverlapped);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
Debug.WriteLine("waiting for ReadFile");
|
||||
|
||||
// API function: WaitForSingleObject
|
||||
|
||||
// Purpose: waits for at least one report or a timeout.
|
||||
// Used with overlapped ReadFile.
|
||||
|
||||
// Accepts:
|
||||
// An event object created with CreateEvent
|
||||
// A timeout value in milliseconds.
|
||||
|
||||
// Returns: A result code.
|
||||
|
||||
Int32 result = FileIODeclarations.WaitForSingleObject(eventObject, 3000);
|
||||
|
||||
// Find out if ReadFile completed or timeout.
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case FileIODeclarations.WaitObject0:
|
||||
|
||||
// ReadFile has completed
|
||||
|
||||
success = true;
|
||||
Debug.WriteLine("ReadFile completed successfully.");
|
||||
|
||||
// Get the number of bytes read.
|
||||
|
||||
// API function: GetOverlappedResult
|
||||
|
||||
// Purpose: gets the result of an overlapped operation.
|
||||
|
||||
// Accepts:
|
||||
// A device handle returned by CreateFile.
|
||||
// A pointer to an overlapped structure.
|
||||
// A pointer to a variable to hold the number of bytes read.
|
||||
// False to return immediately.
|
||||
|
||||
// Returns: non-zero on success and the number of bytes read.
|
||||
|
||||
FileIODeclarations.GetOverlappedResult(readHandle, nonManagedOverlapped, ref numberOfBytesRead, false);
|
||||
|
||||
break;
|
||||
|
||||
case FileIODeclarations.WaitTimeout:
|
||||
|
||||
// Cancel the operation on timeout
|
||||
|
||||
CancelTransfer(hidHandle, readHandle, writeHandle, eventObject);
|
||||
Debug.WriteLine("Readfile timeout");
|
||||
success = false;
|
||||
myDeviceDetected = false;
|
||||
break;
|
||||
default:
|
||||
|
||||
// Cancel the operation on other error.
|
||||
|
||||
CancelTransfer(hidHandle, readHandle, writeHandle, eventObject);
|
||||
Debug.WriteLine("Readfile undefined error");
|
||||
success = false;
|
||||
myDeviceDetected = false;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
// A report was received.
|
||||
// Copy the received data to inputReportBuffer for the application to use.
|
||||
|
||||
Marshal.Copy(nonManagedBuffer, inputReportBuffer, 0, numberOfBytesRead);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DisplayException(ModuleName, ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For reports the host sends to the device.
|
||||
/// </summary>
|
||||
|
||||
internal abstract class ReportOut
|
||||
{
|
||||
/// <summary>
|
||||
/// Each class that handles writing reports defines a Write method for
|
||||
/// writing a type of report.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="reportBuffer"> contains the report ID and report data. </param>
|
||||
/// <param name="deviceHandle"> handle to the device. </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// True on success. False on failure.
|
||||
/// </returns>
|
||||
|
||||
internal abstract Boolean Write(Byte[] reportBuffer, SafeFileHandle deviceHandle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For Feature reports the host sends to the device.
|
||||
/// </summary>
|
||||
|
||||
internal class OutFeatureReport : ReportOut
|
||||
{
|
||||
/// <summary>
|
||||
/// writes a Feature report to the device.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="outFeatureReportBuffer"> contains the report ID and report data. </param>
|
||||
/// <param name="hidHandle"> handle to the device. </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// True on success. False on failure.
|
||||
/// </returns>
|
||||
|
||||
internal override Boolean Write(Byte[] outFeatureReportBuffer, SafeFileHandle hidHandle)
|
||||
{
|
||||
try
|
||||
{
|
||||
// ***
|
||||
// API function: HidD_SetFeature
|
||||
|
||||
// Purpose: Attempts to send a Feature report to the device.
|
||||
|
||||
// Accepts:
|
||||
// A handle to a HID
|
||||
// A pointer to a buffer containing the report ID and report
|
||||
// The size of the buffer.
|
||||
|
||||
// Returns: true on success, false on failure.
|
||||
// ***
|
||||
|
||||
Boolean success = HidD_SetFeature(hidHandle, outFeatureReportBuffer, outFeatureReportBuffer.Length);
|
||||
|
||||
Debug.Print("HidD_SetFeature success = " + success);
|
||||
|
||||
return success;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DisplayException(ModuleName, ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For writing Output reports via control transfers
|
||||
/// </summary>
|
||||
|
||||
internal class OutputReportViaControlTransfer : ReportOut
|
||||
{
|
||||
/// <summary>
|
||||
/// writes an Output report to the device using a control transfer.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="outputReportBuffer"> contains the report ID and report data. </param>
|
||||
/// <param name="hidHandle"> handle to the device. </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// True on success. False on failure.
|
||||
/// </returns>
|
||||
|
||||
internal override Boolean Write(Byte[] outputReportBuffer, SafeFileHandle hidHandle)
|
||||
{
|
||||
try
|
||||
{
|
||||
// ***
|
||||
// API function: HidD_SetOutputReport
|
||||
|
||||
// Purpose:
|
||||
// Attempts to send an Output report to the device using a control transfer.
|
||||
// Requires Windows XP or later.
|
||||
|
||||
// Accepts:
|
||||
// A handle to a HID
|
||||
// A pointer to a buffer containing the report ID and report
|
||||
// The size of the buffer.
|
||||
|
||||
// Returns: true on success, false on failure.
|
||||
// ***
|
||||
|
||||
Boolean success = HidD_SetOutputReport(hidHandle, outputReportBuffer, outputReportBuffer.Length + 1);
|
||||
|
||||
Debug.Print("HidD_SetOutputReport success = " + success);
|
||||
|
||||
return success;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DisplayException(ModuleName, ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For Output reports the host sends to the device.
|
||||
/// Uses interrupt or control transfers depending on the device and OS.
|
||||
/// </summary>
|
||||
|
||||
internal class OutputReportViaInterruptTransfer : ReportOut
|
||||
{
|
||||
/// <summary>
|
||||
/// writes an Output report to the device.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="outputReportBuffer"> contains the report ID and report data. </param>
|
||||
/// <param name="writeHandle"> handle to the device. </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// True on success. False on failure.
|
||||
/// </returns>
|
||||
|
||||
internal override Boolean Write(Byte[] outputReportBuffer, SafeFileHandle writeHandle)
|
||||
{
|
||||
try
|
||||
{
|
||||
// The host will use an interrupt transfer if the the HID has an interrupt OUT
|
||||
// endpoint (requires USB 1.1 or later) AND the OS is NOT Windows 98 Gold (original version).
|
||||
// Otherwise the the host will use a control transfer.
|
||||
// The application doesn't have to know or care which type of transfer is used.
|
||||
|
||||
Int32 numberOfBytesWritten = 0;
|
||||
|
||||
// ***
|
||||
// API function: WriteFile
|
||||
|
||||
// Purpose: writes an Output report to the device.
|
||||
|
||||
// Accepts:
|
||||
// A handle returned by CreateFile
|
||||
// An integer to hold the number of bytes written.
|
||||
|
||||
// Returns: True on success, False on failure.
|
||||
// ***
|
||||
|
||||
Boolean success = FileIODeclarations.WriteFile(writeHandle, outputReportBuffer, outputReportBuffer.Length, ref numberOfBytesWritten, IntPtr.Zero);
|
||||
|
||||
Debug.Print("WriteFile success = " + success);
|
||||
|
||||
if (!((success)))
|
||||
{
|
||||
|
||||
if ((!(writeHandle.IsInvalid)))
|
||||
{
|
||||
writeHandle.Close();
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DisplayException(ModuleName, ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove any Input reports waiting in the buffer.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="hidHandle"> a handle to a device. </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// True on success, False on failure.
|
||||
/// </returns>
|
||||
|
||||
internal Boolean FlushQueue(SafeFileHandle hidHandle)
|
||||
{
|
||||
try
|
||||
{
|
||||
// ***
|
||||
// API function: HidD_FlushQueue
|
||||
|
||||
// Purpose: Removes any Input reports waiting in the buffer.
|
||||
|
||||
// Accepts: a handle to the device.
|
||||
|
||||
// Returns: True on success, False on failure.
|
||||
// ***
|
||||
|
||||
Boolean success = HidD_FlushQueue(hidHandle);
|
||||
|
||||
return success;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DisplayException(ModuleName, ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a structure with information about a device's capabilities.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="hidHandle"> a handle to a device. </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// An HIDP_CAPS structure.
|
||||
/// </returns>
|
||||
|
||||
internal HidpCaps GetDeviceCapabilities(SafeFileHandle hidHandle)
|
||||
{
|
||||
IntPtr preparsedData = new IntPtr();
|
||||
|
||||
try
|
||||
{
|
||||
// ***
|
||||
// API function: HidD_GetPreparsedData
|
||||
|
||||
// Purpose: retrieves a pointer to a buffer containing information about the device's capabilities.
|
||||
// HidP_GetCaps and other API functions require a pointer to the buffer.
|
||||
|
||||
// Requires:
|
||||
// A handle returned by CreateFile.
|
||||
// A pointer to a buffer.
|
||||
|
||||
// Returns:
|
||||
// True on success, False on failure.
|
||||
// ***
|
||||
|
||||
HidD_GetPreparsedData(hidHandle, ref preparsedData);
|
||||
|
||||
// ***
|
||||
// API function: HidP_GetCaps
|
||||
|
||||
// Purpose: find out a device's capabilities.
|
||||
// For standard devices such as joysticks, you can find out the specific
|
||||
// capabilities of the device.
|
||||
// For a custom device where the software knows what the device is capable of,
|
||||
// this call may be unneeded.
|
||||
|
||||
// Accepts:
|
||||
// A pointer returned by HidD_GetPreparsedData
|
||||
// A pointer to a HIDP_CAPS structure.
|
||||
|
||||
// Returns: True on success, False on failure.
|
||||
// ***
|
||||
|
||||
Int32 result = HidP_GetCaps(preparsedData, ref Capabilities);
|
||||
if ((result != 0))
|
||||
{
|
||||
Debug.WriteLine("");
|
||||
Debug.WriteLine(" Usage: " + Convert.ToString(Capabilities.Usage, 16));
|
||||
Debug.WriteLine(" Usage Page: " + Convert.ToString(Capabilities.UsagePage, 16));
|
||||
Debug.WriteLine(" Input Report Byte Length: " + Capabilities.InputReportByteLength);
|
||||
Debug.WriteLine(" Output Report Byte Length: " + Capabilities.OutputReportByteLength);
|
||||
Debug.WriteLine(" Feature Report Byte Length: " + Capabilities.FeatureReportByteLength);
|
||||
Debug.WriteLine(" Number of Link Collection Nodes: " + Capabilities.NumberLinkCollectionNodes);
|
||||
Debug.WriteLine(" Number of Input Button Caps: " + Capabilities.NumberInputButtonCaps);
|
||||
Debug.WriteLine(" Number of Input Value Caps: " + Capabilities.NumberInputValueCaps);
|
||||
Debug.WriteLine(" Number of Input Data Indices: " + Capabilities.NumberInputDataIndices);
|
||||
Debug.WriteLine(" Number of Output Button Caps: " + Capabilities.NumberOutputButtonCaps);
|
||||
Debug.WriteLine(" Number of Output Value Caps: " + Capabilities.NumberOutputValueCaps);
|
||||
Debug.WriteLine(" Number of Output Data Indices: " + Capabilities.NumberOutputDataIndices);
|
||||
Debug.WriteLine(" Number of Feature Button Caps: " + Capabilities.NumberFeatureButtonCaps);
|
||||
Debug.WriteLine(" Number of Feature Value Caps: " + Capabilities.NumberFeatureValueCaps);
|
||||
Debug.WriteLine(" Number of Feature Data Indices: " + Capabilities.NumberFeatureDataIndices);
|
||||
|
||||
// ***
|
||||
// API function: HidP_GetValueCaps
|
||||
|
||||
// Purpose: retrieves a buffer containing an array of HidP_ValueCaps structures.
|
||||
// Each structure defines the capabilities of one value.
|
||||
// This application doesn't use this data.
|
||||
|
||||
// Accepts:
|
||||
// A report type enumerator from hidpi.h,
|
||||
// A pointer to a buffer for the returned array,
|
||||
// The NumberInputValueCaps member of the device's HidP_Caps structure,
|
||||
// A pointer to the PreparsedData structure returned by HidD_GetPreparsedData.
|
||||
|
||||
// Returns: True on success, False on failure.
|
||||
// ***
|
||||
|
||||
|
||||
Int32 vcSize = Capabilities.NumberInputValueCaps;
|
||||
Byte[] valueCaps = new Byte[vcSize];
|
||||
HidP_GetValueCaps(HidPInput, valueCaps, ref vcSize, preparsedData);
|
||||
|
||||
//result = HidP_GetValueCaps(HidP_Input, ref valueCaps[0], ref Capabilities.NumberInputValueCaps, preparsedData);
|
||||
|
||||
// (To use this data, copy the ValueCaps byte array into an array of structures.)
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DisplayException(ModuleName, ex);
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
// ***
|
||||
// API function: HidD_FreePreparsedData
|
||||
|
||||
// Purpose: frees the buffer reserved by HidD_GetPreparsedData.
|
||||
|
||||
// Accepts: A pointer to the PreparsedData structure returned by HidD_GetPreparsedData.
|
||||
|
||||
// Returns: True on success, False on failure.
|
||||
// ***
|
||||
|
||||
if (preparsedData != IntPtr.Zero)
|
||||
{
|
||||
HidD_FreePreparsedData(preparsedData);
|
||||
}
|
||||
}
|
||||
|
||||
return Capabilities;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a 32-bit Usage from the Usage Page and Usage ID.
|
||||
/// Determines whether the Usage is a system mouse or keyboard.
|
||||
/// Can be modified to detect other Usages.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="capabilities"> a HIDP_CAPS structure retrieved with HidP_GetCaps. </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// A String describing the Usage.
|
||||
/// </returns>
|
||||
|
||||
internal String GetHidUsage(HidpCaps capabilities)
|
||||
{
|
||||
String usageDescription = "";
|
||||
|
||||
try
|
||||
{
|
||||
// Create32-bit Usage from Usage Page and Usage ID.
|
||||
|
||||
Int32 usage = capabilities.UsagePage * 256 + capabilities.Usage;
|
||||
|
||||
if (usage == Convert.ToInt32(0X102))
|
||||
{
|
||||
usageDescription = "mouse";
|
||||
}
|
||||
|
||||
if (usage == Convert.ToInt32(0X106))
|
||||
{
|
||||
usageDescription = "keyboard";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DisplayException(ModuleName, ex);
|
||||
throw;
|
||||
}
|
||||
|
||||
return usageDescription;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the number of Input reports the host can store.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="hidDeviceObject"> a handle to a device </param>
|
||||
/// <param name="numberOfInputBuffers"> an integer to hold the returned value. </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// True on success, False on failure.
|
||||
/// </returns>
|
||||
|
||||
internal Boolean GetNumberOfInputBuffers(SafeFileHandle hidDeviceObject, ref Int32 numberOfInputBuffers)
|
||||
{
|
||||
try
|
||||
{
|
||||
Boolean success;
|
||||
if (!IsWindows98Gold())
|
||||
{
|
||||
// ***
|
||||
// API function: HidD_GetNumInputBuffers
|
||||
|
||||
// Purpose: retrieves the number of Input reports the host can store.
|
||||
// Not supported by Windows 98 Gold.
|
||||
// If the buffer is full and another report arrives, the host drops the
|
||||
// ldest report.
|
||||
|
||||
// Accepts: a handle to a device and an integer to hold the number of buffers.
|
||||
|
||||
// Returns: True on success, False on failure.
|
||||
// ***
|
||||
|
||||
success = HidD_GetNumInputBuffers(hidDeviceObject, ref numberOfInputBuffers);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Under Windows 98 Gold, the number of buffers is fixed at 2.
|
||||
|
||||
numberOfInputBuffers = 2;
|
||||
success = true;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DisplayException(ModuleName, ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// sets the number of input reports the host will store.
|
||||
/// Requires Windows XP or later.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="hidDeviceObject"> a handle to the device.</param>
|
||||
/// <param name="numberBuffers"> the requested number of input reports. </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// True on success. False on failure.
|
||||
/// </returns>
|
||||
|
||||
internal Boolean SetNumberOfInputBuffers(SafeFileHandle hidDeviceObject, Int32 numberBuffers)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!IsWindows98Gold())
|
||||
{
|
||||
// ***
|
||||
// API function: HidD_SetNumInputBuffers
|
||||
|
||||
// Purpose: Sets the number of Input reports the host can store.
|
||||
// If the buffer is full and another report arrives, the host drops the
|
||||
// oldest report.
|
||||
|
||||
// Requires:
|
||||
// A handle to a HID
|
||||
// An integer to hold the number of buffers.
|
||||
|
||||
// Returns: true on success, false on failure.
|
||||
// ***
|
||||
|
||||
HidD_SetNumInputBuffers(hidDeviceObject, numberBuffers);
|
||||
return true;
|
||||
}
|
||||
// Not supported under Windows 98 Gold.
|
||||
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DisplayException(ModuleName, ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find out if the current operating system is Windows XP or later.
|
||||
/// (Windows XP or later is required for HidD_GetInputReport and HidD_SetInputReport.)
|
||||
/// </summary>
|
||||
|
||||
internal Boolean IsWindowsXpOrLater()
|
||||
{
|
||||
try
|
||||
{
|
||||
OperatingSystem myEnvironment = Environment.OSVersion;
|
||||
|
||||
// Windows XP is version 5.1.
|
||||
|
||||
Version versionXP = new Version(5, 1);
|
||||
|
||||
if (myEnvironment.Version >= versionXP)
|
||||
{
|
||||
Debug.Write("The OS is Windows XP or later.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Debug.Write("The OS is earlier than Windows XP.");
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DisplayException(ModuleName, ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find out if the current operating system is Windows 98 Gold (original version).
|
||||
/// Windows 98 Gold does not support the following:
|
||||
/// Interrupt OUT transfers (WriteFile uses control transfers and Set_Report).
|
||||
/// HidD_GetNumInputBuffers and HidD_SetNumInputBuffers
|
||||
/// (Not yet tested on a Windows 98 Gold system.)
|
||||
/// </summary>
|
||||
|
||||
internal Boolean IsWindows98Gold()
|
||||
{
|
||||
try
|
||||
{
|
||||
OperatingSystem myEnvironment = Environment.OSVersion;
|
||||
|
||||
// Windows 98 Gold is version 4.10 with a build number less than 2183.
|
||||
|
||||
Version version98Se = new Version(4, 10, 2183);
|
||||
|
||||
Boolean result;
|
||||
if (myEnvironment.Version < version98Se)
|
||||
{
|
||||
Debug.Write("The OS is Windows 98 Gold.");
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Write("The OS is more recent than Windows 98 Gold.");
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DisplayException(ModuleName, ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides a central mechanism for exception handling.
|
||||
/// Displays a message box that describes the exception.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="moduleName"> the module where the exception occurred. </param>
|
||||
/// <param name="e"> the exception </param>
|
||||
|
||||
internal static void DisplayException(String moduleName, Exception e)
|
||||
{
|
||||
// Create an error message.
|
||||
|
||||
string message = "Exception: " + e.Message + "\r\n" + "Module: " + moduleName + "\r\n" + "Method: " + e.TargetSite.Name;
|
||||
|
||||
//MessageBox.Show(message, caption, MessageBoxButtons.OK);
|
||||
Debug.Write(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
87
Delcom/HIDDeclarations.cs
Normal file
87
Delcom/HIDDeclarations.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
|
||||
namespace WorkIndicator.Delcom
|
||||
{
|
||||
internal sealed partial class HID
|
||||
{
|
||||
// API declarations for HID communications.
|
||||
|
||||
// from hidpi.h
|
||||
// Typedef enum defines a set of integer constants for HidP_Report_Type
|
||||
|
||||
internal const Int16 HidPInput = 0;
|
||||
internal const Int16 HidPOutput = 1;
|
||||
internal const Int16 HidPFeature = 2;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct HiddAttributes
|
||||
{
|
||||
internal Int32 Size;
|
||||
internal UInt16 VendorID;
|
||||
internal UInt16 ProductID;
|
||||
internal UInt16 VersionNumber;
|
||||
}
|
||||
|
||||
internal struct HidpCaps
|
||||
{
|
||||
internal Int16 Usage;
|
||||
internal Int16 UsagePage;
|
||||
internal Int16 InputReportByteLength;
|
||||
internal Int16 OutputReportByteLength;
|
||||
internal Int16 FeatureReportByteLength;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)]
|
||||
internal Int16[] Reserved;
|
||||
internal Int16 NumberLinkCollectionNodes;
|
||||
internal Int16 NumberInputButtonCaps;
|
||||
internal Int16 NumberInputValueCaps;
|
||||
internal Int16 NumberInputDataIndices;
|
||||
internal Int16 NumberOutputButtonCaps;
|
||||
internal Int16 NumberOutputValueCaps;
|
||||
internal Int16 NumberOutputDataIndices;
|
||||
internal Int16 NumberFeatureButtonCaps;
|
||||
internal Int16 NumberFeatureValueCaps;
|
||||
internal Int16 NumberFeatureDataIndices;
|
||||
}
|
||||
|
||||
[DllImport("hid.dll", SetLastError = true)]
|
||||
internal static extern Boolean HidD_FlushQueue(SafeFileHandle hidDeviceObject);
|
||||
|
||||
[DllImport("hid.dll", SetLastError = true)]
|
||||
internal static extern Boolean HidD_FreePreparsedData(IntPtr preparsedData);
|
||||
|
||||
[DllImport("hid.dll", SetLastError = true)]
|
||||
internal static extern Boolean HidD_GetAttributes(SafeFileHandle hidDeviceObject, ref HiddAttributes hiddAttributes);
|
||||
|
||||
[DllImport("hid.dll", SetLastError = true)]
|
||||
internal static extern Boolean HidD_GetFeature(SafeFileHandle hidDeviceObject, Byte[] lpReportBuffer, Int32 reportBufferLength);
|
||||
|
||||
[DllImport("hid.dll", SetLastError = true)]
|
||||
internal static extern Boolean HidD_GetInputReport(SafeFileHandle hidDeviceObject, Byte[] lpReportBuffer, Int32 reportBufferLength);
|
||||
|
||||
[DllImport("hid.dll", SetLastError = true)]
|
||||
internal static extern void HidD_GetHidGuid(ref Guid hidGuid);
|
||||
|
||||
[DllImport("hid.dll", SetLastError = true)]
|
||||
internal static extern Boolean HidD_GetNumInputBuffers(SafeFileHandle hidDeviceObject, ref Int32 numberBuffers);
|
||||
|
||||
[DllImport("hid.dll", SetLastError = true)]
|
||||
internal static extern Boolean HidD_GetPreparsedData(SafeFileHandle hidDeviceObject, ref IntPtr preparsedData);
|
||||
|
||||
[DllImport("hid.dll", SetLastError = true)]
|
||||
internal static extern Boolean HidD_SetFeature(SafeFileHandle hidDeviceObject, Byte[] lpReportBuffer, Int32 reportBufferLength);
|
||||
|
||||
[DllImport("hid.dll", SetLastError = true)]
|
||||
internal static extern Boolean HidD_SetNumInputBuffers(SafeFileHandle hidDeviceObject, Int32 numberBuffers);
|
||||
|
||||
[DllImport("hid.dll", SetLastError = true)]
|
||||
internal static extern Boolean HidD_SetOutputReport(SafeFileHandle hidDeviceObject, Byte[] lpReportBuffer, Int32 reportBufferLength);
|
||||
|
||||
[DllImport("hid.dll", SetLastError = true)]
|
||||
internal static extern Int32 HidP_GetCaps(IntPtr preparsedData, ref HidpCaps capabilities);
|
||||
|
||||
[DllImport("hid.dll", SetLastError = true)]
|
||||
internal static extern Int32 HidP_GetValueCaps(Int32 reportType, Byte[] valueCaps, ref Int32 valueCapsLength, IntPtr preparsedData);
|
||||
}
|
||||
}
|
||||
130
Delcom/StoplightIndicator.cs
Normal file
130
Delcom/StoplightIndicator.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
using System;
|
||||
|
||||
using Common.Extensions;
|
||||
|
||||
namespace WorkIndicator.Delcom
|
||||
{
|
||||
public class StoplightIndicator : IDisposable
|
||||
{
|
||||
public enum Light
|
||||
{
|
||||
Green,
|
||||
Yellow,
|
||||
Red
|
||||
}
|
||||
|
||||
public enum LightState
|
||||
{
|
||||
Off,
|
||||
On,
|
||||
Blink
|
||||
}
|
||||
|
||||
private readonly Delcom _delcom;
|
||||
|
||||
private LightState _green = LightState.Off;
|
||||
private LightState _yellow = LightState.Off;
|
||||
private LightState _red = LightState.Off;
|
||||
|
||||
public StoplightIndicator()
|
||||
{
|
||||
_delcom = new Delcom();
|
||||
_delcom.Open();
|
||||
|
||||
SetLights(_red, _yellow, _green);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_delcom.Close();
|
||||
}
|
||||
|
||||
public Delcom Device
|
||||
{
|
||||
get { return _delcom; }
|
||||
}
|
||||
|
||||
public void GetLights(out LightState red, out LightState yellow, out LightState green)
|
||||
{
|
||||
red = _red;
|
||||
yellow = _yellow;
|
||||
green = _green;
|
||||
}
|
||||
|
||||
public LightState GetLight(Light light)
|
||||
{
|
||||
switch (light)
|
||||
{
|
||||
case Light.Red:
|
||||
return _red;
|
||||
|
||||
case Light.Yellow:
|
||||
return _yellow;
|
||||
|
||||
case Light.Green:
|
||||
return _green;
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException("light");
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLights(LightState red, LightState yellow, LightState green)
|
||||
{
|
||||
int port1 = 0;
|
||||
|
||||
_red = red;
|
||||
_yellow = yellow;
|
||||
_green = green;
|
||||
|
||||
port1 = port1.SetBitValue((int) Light.Green, green == LightState.Off);
|
||||
port1 = port1.SetBitValue((int) Light.Yellow, yellow == LightState.Off);
|
||||
port1 = port1.SetBitValue((int) Light.Red, red == LightState.Off);
|
||||
|
||||
_delcom.WritePorts(0, port1);
|
||||
|
||||
int blinkEnable = 0;
|
||||
int blinkDisable = 0;
|
||||
|
||||
if (red == LightState.Blink)
|
||||
blinkEnable = blinkEnable.SetBitValue((int) Light.Red, true);
|
||||
else
|
||||
blinkDisable = blinkDisable.SetBitValue((int) Light.Red, true);
|
||||
|
||||
if (yellow == LightState.Blink)
|
||||
blinkEnable = blinkEnable.SetBitValue((int) Light.Yellow, true);
|
||||
else
|
||||
blinkDisable = blinkDisable.SetBitValue((int) Light.Yellow, true);
|
||||
|
||||
if (green == LightState.Blink)
|
||||
blinkEnable = blinkEnable.SetBitValue((int) Light.Green, true);
|
||||
else
|
||||
blinkDisable = blinkDisable.SetBitValue((int) Light.Green, true);
|
||||
|
||||
_delcom.WriteBlink(blinkDisable, blinkEnable);
|
||||
}
|
||||
|
||||
public void SetLight(Light light, LightState state)
|
||||
{
|
||||
switch (light)
|
||||
{
|
||||
case Light.Red:
|
||||
_red = state;
|
||||
break;
|
||||
|
||||
case Light.Yellow:
|
||||
_yellow = state;
|
||||
break;
|
||||
|
||||
case Light.Green:
|
||||
_green = state;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException("light");
|
||||
}
|
||||
|
||||
SetLights(_red, _yellow, _green);
|
||||
}
|
||||
}
|
||||
}
|
||||
217
LightController.cs
Normal file
217
LightController.cs
Normal file
@@ -0,0 +1,217 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using Common.Native;
|
||||
using SKYPE4COMLib;
|
||||
using WorkIndicator.Delcom;
|
||||
|
||||
namespace WorkIndicator
|
||||
{
|
||||
public enum Status
|
||||
{
|
||||
Auto,
|
||||
Free,
|
||||
Working,
|
||||
OnPhone,
|
||||
Talking
|
||||
}
|
||||
|
||||
public static class LightController
|
||||
{
|
||||
private static StoplightIndicator _stoplightIndicator;
|
||||
private static bool _initialized;
|
||||
private static Status _status = Status.Auto;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
_stoplightIndicator = new StoplightIndicator();
|
||||
_stoplightIndicator.SetLight(StoplightIndicator.Light.Green, StoplightIndicator.LightState.On);
|
||||
|
||||
InitializeWindowDetection();
|
||||
InitializeSkypeDetection();
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
public static void Dispose()
|
||||
{
|
||||
if (!_initialized)
|
||||
return;
|
||||
|
||||
TerminateWindowDetection();
|
||||
TerminateSkypeDetection();
|
||||
|
||||
_stoplightIndicator.SetLights(StoplightIndicator.LightState.Off, StoplightIndicator.LightState.Off, StoplightIndicator.LightState.Off);
|
||||
_stoplightIndicator.Dispose();
|
||||
|
||||
_initialized = false;
|
||||
}
|
||||
|
||||
public static Status Status
|
||||
{
|
||||
get { return _status; }
|
||||
set
|
||||
{
|
||||
_status = value;
|
||||
UpdateLights();
|
||||
}
|
||||
}
|
||||
|
||||
private static void UpdateLights()
|
||||
{
|
||||
StoplightIndicator.LightState red = StoplightIndicator.LightState.Off;
|
||||
StoplightIndicator.LightState yellow = StoplightIndicator.LightState.Off;
|
||||
StoplightIndicator.LightState green = StoplightIndicator.LightState.Off;
|
||||
|
||||
if (_status == Status.Auto)
|
||||
{
|
||||
ISkype skype = _skype;
|
||||
|
||||
if (skype != null && skype.ActiveCalls.Count > 0)
|
||||
{
|
||||
red = skype.Mute ? StoplightIndicator.LightState.On : StoplightIndicator.LightState.Blink;
|
||||
}
|
||||
else if (WindowHandles.Count > 0)
|
||||
{
|
||||
yellow = StoplightIndicator.LightState.On;
|
||||
}
|
||||
else
|
||||
{
|
||||
green = StoplightIndicator.LightState.On;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (_status)
|
||||
{
|
||||
case Status.Free:
|
||||
green = StoplightIndicator.LightState.On;
|
||||
break;
|
||||
case Status.Working:
|
||||
yellow = StoplightIndicator.LightState.On;
|
||||
break;
|
||||
case Status.OnPhone:
|
||||
red = StoplightIndicator.LightState.On;
|
||||
break;
|
||||
case Status.Talking:
|
||||
red = StoplightIndicator.LightState.Blink;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
_stoplightIndicator.SetLights(red, yellow, green);
|
||||
}
|
||||
|
||||
#region Skype detection
|
||||
|
||||
private static Skype _skype;
|
||||
|
||||
public static void InitializeSkypeDetection()
|
||||
{
|
||||
_skype = new Skype();
|
||||
_skype.Attach();
|
||||
|
||||
_ISkypeEvents_Event skypeEvents = _skype;
|
||||
|
||||
skypeEvents.CallStatus += HandleSkypeCallStatus;
|
||||
skypeEvents.Mute += HandleSkypeEventsMute;
|
||||
}
|
||||
|
||||
static void HandleSkypeEventsMute(bool mute)
|
||||
{
|
||||
UpdateLights();
|
||||
}
|
||||
|
||||
static void HandleSkypeCallStatus(Call call, TCallStatus status)
|
||||
{
|
||||
UpdateLights();
|
||||
}
|
||||
|
||||
public static void TerminateSkypeDetection()
|
||||
{
|
||||
_ISkypeEvents_Event skypeEvents = _skype;
|
||||
|
||||
skypeEvents.CallStatus -= HandleSkypeCallStatus;
|
||||
skypeEvents.Mute -= HandleSkypeEventsMute;
|
||||
|
||||
Marshal.ReleaseComObject(_skype);
|
||||
|
||||
_skype = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Window detection
|
||||
|
||||
private static readonly WinEvent.WinEventDelegate ProcDelegate = WinEventProc;
|
||||
|
||||
private static readonly List<IntPtr> WindowEventHooks = new List<IntPtr>();
|
||||
private static readonly List<IntPtr> WindowHandles = new List<IntPtr>();
|
||||
|
||||
private static readonly Regex WindowMatchRegex = new Regex(Properties.Settings.Default.WindowPattern);
|
||||
|
||||
private static void InitializeWindowDetection()
|
||||
{
|
||||
Functions.User32.EnumWindows(EnumWindowProc, IntPtr.Zero);
|
||||
|
||||
IntPtr hook = WinEvent.SetWinEventHook(WinEvent.Event.ObjectCreate, WinEvent.Event.ObjectDestroy, IntPtr.Zero, ProcDelegate, 0, 0, WinEvent.SetWinEventHookFlags.OutOfContext | WinEvent.SetWinEventHookFlags.SkipOwnProcess);
|
||||
if (hook != IntPtr.Zero)
|
||||
WindowEventHooks.Add(hook);
|
||||
|
||||
hook = WinEvent.SetWinEventHook(WinEvent.Event.ObjectNameChange, WinEvent.Event.ObjectNameChange, IntPtr.Zero, ProcDelegate, 0, 0, WinEvent.SetWinEventHookFlags.OutOfContext | WinEvent.SetWinEventHookFlags.SkipOwnProcess);
|
||||
if (hook != IntPtr.Zero)
|
||||
WindowEventHooks.Add(hook);
|
||||
}
|
||||
|
||||
public static void TerminateWindowDetection()
|
||||
{
|
||||
WindowEventHooks.ForEach(h => WinEvent.UnhookWinEvent(h));
|
||||
}
|
||||
|
||||
private static bool EnumWindowProc(IntPtr hWnd, IntPtr lParam)
|
||||
{
|
||||
WinEventProc(IntPtr.Zero, WinEvent.Event.ObjectCreate, hWnd, WinEvent.ObjectIdentifier.Window, 0, 0, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void WinEventProc(IntPtr hWinEventHook, WinEvent.Event eventType, IntPtr hwnd, WinEvent.ObjectIdentifier idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
|
||||
{
|
||||
if (idObject == WinEvent.ObjectIdentifier.Window && idChild == (int) WinEvent.ChildIdentifier.Self)
|
||||
{
|
||||
switch (eventType)
|
||||
{
|
||||
case WinEvent.Event.ObjectCreate:
|
||||
case WinEvent.Event.ObjectNameChange:
|
||||
|
||||
if (WindowHandles.Contains(hwnd))
|
||||
WindowHandles.Remove(hwnd);
|
||||
|
||||
if (WindowMatchRegex.IsMatch(Functions.Window.GetText(hwnd)))
|
||||
{
|
||||
WindowHandles.Add(hwnd);
|
||||
UpdateLights();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case WinEvent.Event.ObjectDestroy:
|
||||
if (WindowHandles.Contains(hwnd))
|
||||
WindowHandles.Remove(hwnd);
|
||||
|
||||
if (WindowMatchRegex.IsMatch(Functions.Window.GetText(hwnd)))
|
||||
{
|
||||
UpdateLights();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
55
Properties/AssemblyInfo.cs
Normal file
55
Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("WorkIndicator")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("WorkIndicator")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2012")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//In order to begin building localizable applications, set
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
//the line below to match the UICulture setting in the project file.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
136
Properties/Resources.Designer.cs
generated
Normal file
136
Properties/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,136 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17626
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace WorkIndicator.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WorkIndicator.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Work Indicator.
|
||||
/// </summary>
|
||||
internal static string ApplicationName {
|
||||
get {
|
||||
return ResourceManager.GetString("ApplicationName", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Auto.
|
||||
/// </summary>
|
||||
internal static string Auto {
|
||||
get {
|
||||
return ResourceManager.GetString("Auto", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Free.
|
||||
/// </summary>
|
||||
internal static string Free {
|
||||
get {
|
||||
return ResourceManager.GetString("Free", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon MainIcon {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("MainIcon", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to On Phone.
|
||||
/// </summary>
|
||||
internal static string OnPhone {
|
||||
get {
|
||||
return ResourceManager.GetString("OnPhone", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Talking.
|
||||
/// </summary>
|
||||
internal static string Talking {
|
||||
get {
|
||||
return ResourceManager.GetString("Talking", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Exit.
|
||||
/// </summary>
|
||||
internal static string TrayIconContextMenuExit {
|
||||
get {
|
||||
return ResourceManager.GetString("TrayIconContextMenuExit", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Working.
|
||||
/// </summary>
|
||||
internal static string Working {
|
||||
get {
|
||||
return ResourceManager.GetString("Working", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
145
Properties/Resources.resx
Normal file
145
Properties/Resources.resx
Normal file
@@ -0,0 +1,145 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="ApplicationName" xml:space="preserve">
|
||||
<value>Work Indicator</value>
|
||||
</data>
|
||||
<data name="Auto" xml:space="preserve">
|
||||
<value>Auto</value>
|
||||
</data>
|
||||
<data name="Free" xml:space="preserve">
|
||||
<value>Free</value>
|
||||
</data>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="MainIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\MainIcon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="OnPhone" xml:space="preserve">
|
||||
<value>On Phone</value>
|
||||
</data>
|
||||
<data name="Talking" xml:space="preserve">
|
||||
<value>Talking</value>
|
||||
</data>
|
||||
<data name="TrayIconContextMenuExit" xml:space="preserve">
|
||||
<value>Exit</value>
|
||||
</data>
|
||||
<data name="Working" xml:space="preserve">
|
||||
<value>Working</value>
|
||||
</data>
|
||||
</root>
|
||||
50
Properties/Settings.Designer.cs
generated
Normal file
50
Properties/Settings.Designer.cs
generated
Normal file
@@ -0,0 +1,50 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.34011
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace WorkIndicator.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool StartWithWindows {
|
||||
get {
|
||||
return ((bool)(this["StartWithWindows"]));
|
||||
}
|
||||
set {
|
||||
this["StartWithWindows"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute(".* - CKACZOR - Remote Desktop Connection")]
|
||||
public string WindowPattern {
|
||||
get {
|
||||
return ((string)(this["WindowPattern"]));
|
||||
}
|
||||
set {
|
||||
this["WindowPattern"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Properties/Settings.settings
Normal file
12
Properties/Settings.settings
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="WorkIndicator.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="StartWithWindows" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="WindowPattern" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">.* - CKACZOR - Remote Desktop Connection</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
BIN
Resources/MainIcon.ico
Normal file
BIN
Resources/MainIcon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
101
TrayIcon.cs
Normal file
101
TrayIcon.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using System.Windows.Forms;
|
||||
using WorkIndicator.Properties;
|
||||
|
||||
using Application = System.Windows.Application;
|
||||
|
||||
namespace WorkIndicator
|
||||
{
|
||||
internal static class TrayIcon
|
||||
{
|
||||
private static NotifyIcon _trayIcon;
|
||||
|
||||
private static bool _initialized;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
// Create the tray icon
|
||||
_trayIcon = new NotifyIcon { Icon = Resources.MainIcon, Text = Resources.ApplicationName };
|
||||
|
||||
// Setup the menu
|
||||
ContextMenuStrip contextMenuStrip = new ContextMenuStrip();
|
||||
contextMenuStrip.Opening += HandleContextMenuStripOpening;
|
||||
|
||||
// Add the menu items
|
||||
ToolStripMenuItem menuItem = new ToolStripMenuItem(Resources.Auto, null, HandleStatusMenuClick) { Tag = Status.Auto };
|
||||
contextMenuStrip.Items.Add(menuItem);
|
||||
|
||||
// --
|
||||
|
||||
menuItem = new ToolStripMenuItem(Resources.Free, null, HandleStatusMenuClick) { Tag = Status.Free };
|
||||
contextMenuStrip.Items.Add(menuItem);
|
||||
|
||||
// --
|
||||
|
||||
menuItem = new ToolStripMenuItem(Resources.Working, null, HandleStatusMenuClick) { Tag = Status.Working };
|
||||
contextMenuStrip.Items.Add(menuItem);
|
||||
|
||||
// --
|
||||
|
||||
menuItem = new ToolStripMenuItem(Resources.OnPhone, null, HandleStatusMenuClick) { Tag = Status.OnPhone };
|
||||
contextMenuStrip.Items.Add(menuItem);
|
||||
|
||||
// --
|
||||
|
||||
menuItem = new ToolStripMenuItem(Resources.Talking, null, HandleStatusMenuClick) { Tag = Status.Talking };
|
||||
contextMenuStrip.Items.Add(menuItem);
|
||||
|
||||
// --
|
||||
|
||||
contextMenuStrip.Items.Add("-");
|
||||
contextMenuStrip.Items.Add(Resources.TrayIconContextMenuExit, null, HandleContextMenuExitClick);
|
||||
|
||||
// Set the menu into the icon
|
||||
_trayIcon.ContextMenuStrip = contextMenuStrip;
|
||||
|
||||
// Show the icon
|
||||
_trayIcon.Visible = true;
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
static void HandleContextMenuStripOpening(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
foreach (ToolStripItem menuItem in _trayIcon.ContextMenuStrip.Items)
|
||||
{
|
||||
if (menuItem.Tag == null)
|
||||
continue;
|
||||
|
||||
Status status = (Status) menuItem.Tag;
|
||||
|
||||
((ToolStripMenuItem) menuItem).Checked = (LightController.Status == status);
|
||||
}
|
||||
}
|
||||
|
||||
private static void HandleStatusMenuClick(object sender, System.EventArgs e)
|
||||
{
|
||||
ToolStripMenuItem menuItem = (ToolStripMenuItem) sender;
|
||||
|
||||
Status status = (Status) menuItem.Tag;
|
||||
|
||||
LightController.Status = status;
|
||||
}
|
||||
|
||||
private static void HandleContextMenuExitClick(object sender, System.EventArgs e)
|
||||
{
|
||||
// Shutdown the application
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
|
||||
public static void Dispose()
|
||||
{
|
||||
if (!_initialized)
|
||||
return;
|
||||
|
||||
// Get rid of the icon
|
||||
_trayIcon.Visible = false;
|
||||
_trayIcon.Dispose();
|
||||
|
||||
_initialized = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
223
WorkIndicator.csproj
Normal file
223
WorkIndicator.csproj
Normal file
@@ -0,0 +1,223 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{A888FD0E-4A0E-4CAA-BC4D-C17D4AFA5715}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>WorkIndicator</RootNamespace>
|
||||
<AssemblyName>WorkIndicator</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<CodeAnalysisLogFile>bin\Debug\WorkIndicator.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<CodeAnalysisLogFile>bin\Release\WorkIndicator.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<CodeAnalysisLogFile>bin\Debug\WorkIndicator.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<CodeAnalysisLogFile>bin\Release\WorkIndicator.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>Resources\MainIcon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IO">
|
||||
<HintPath>packages\Microsoft.Bcl.1.1.8\lib\net40\System.IO.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime">
|
||||
<HintPath>packages\Microsoft.Bcl.1.1.8\lib\net40\System.Runtime.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks">
|
||||
<HintPath>packages\Microsoft.Bcl.1.1.8\lib\net40\System.Threading.Tasks.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="LightController.cs" />
|
||||
<Compile Include="Delcom\StoplightIndicator.cs" />
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Delcom\Delcom.cs" />
|
||||
<Compile Include="Delcom\DeviceManagement.cs" />
|
||||
<Compile Include="Delcom\DeviceManagementDeclarations.cs" />
|
||||
<Compile Include="Delcom\FileIODeclarations.cs" />
|
||||
<Compile Include="Delcom\HID.cs" />
|
||||
<Compile Include="Delcom\HIDDeclarations.cs" />
|
||||
<Compile Include="TrayIcon.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Common.Native\Common.Native.csproj">
|
||||
<Project>{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}</Project>
|
||||
<Name>Common.Native</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Common.Wpf\Common.Wpf.csproj">
|
||||
<Project>{0074C983-550E-4094-9E8C-F566FB669297}</Project>
|
||||
<Name>Common.Wpf</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Common\Common.csproj">
|
||||
<Project>{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}</Project>
|
||||
<Name>Common</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\MainIcon.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<COMReference Include="SKYPE4COMLib">
|
||||
<Guid>{03282B5D-B38F-469D-849A-09B0A7F4881B}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
<EmbedInteropTypes>False</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="packages\Microsoft.Bcl.Build.1.0.13\tools\Microsoft.Bcl.Build.targets" Condition="Exists('packages\Microsoft.Bcl.Build.1.0.13\tools\Microsoft.Bcl.Build.targets')" />
|
||||
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
|
||||
<Error Condition="!Exists('packages\Microsoft.Bcl.Build.1.0.13\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
|
||||
<Error Condition="Exists('packages\Microsoft.Bcl.Build.1.0.13\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
|
||||
</Target>
|
||||
<Import Project="packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
|
||||
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
|
||||
<Error Condition="!Exists('packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
|
||||
<Error Condition="Exists('packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
2
WorkIndicator.csproj.DotSettings
Normal file
2
WorkIndicator.csproj.DotSettings
Normal file
@@ -0,0 +1,2 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=Delcom/@EntryIndexedValue">False</s:Boolean></wpf:ResourceDictionary>
|
||||
76
WorkIndicator.sln
Normal file
76
WorkIndicator.sln
Normal file
@@ -0,0 +1,76 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.30110.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkIndicator", "WorkIndicator.csproj", "{A888FD0E-4A0E-4CAA-BC4D-C17D4AFA5715}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "..\Common\Common.csproj", "{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Native", "..\Common.Native\Common.Native.csproj", "{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Wpf", "..\Common.Wpf\Common.Wpf.csproj", "{0074C983-550E-4094-9E8C-F566FB669297}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A888FD0E-4A0E-4CAA-BC4D-C17D4AFA5715}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{A888FD0E-4A0E-4CAA-BC4D-C17D4AFA5715}.Debug|Any CPU.Build.0 = Debug|x86
|
||||
{A888FD0E-4A0E-4CAA-BC4D-C17D4AFA5715}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{A888FD0E-4A0E-4CAA-BC4D-C17D4AFA5715}.Debug|x64.Build.0 = Debug|x64
|
||||
{A888FD0E-4A0E-4CAA-BC4D-C17D4AFA5715}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{A888FD0E-4A0E-4CAA-BC4D-C17D4AFA5715}.Debug|x86.Build.0 = Debug|x86
|
||||
{A888FD0E-4A0E-4CAA-BC4D-C17D4AFA5715}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{A888FD0E-4A0E-4CAA-BC4D-C17D4AFA5715}.Release|Any CPU.Build.0 = Release|x86
|
||||
{A888FD0E-4A0E-4CAA-BC4D-C17D4AFA5715}.Release|x64.ActiveCfg = Release|x64
|
||||
{A888FD0E-4A0E-4CAA-BC4D-C17D4AFA5715}.Release|x64.Build.0 = Release|x64
|
||||
{A888FD0E-4A0E-4CAA-BC4D-C17D4AFA5715}.Release|x86.ActiveCfg = Release|x86
|
||||
{A888FD0E-4A0E-4CAA-BC4D-C17D4AFA5715}.Release|x86.Build.0 = Release|x86
|
||||
{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Debug|x64.Build.0 = Debug|x64
|
||||
{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Debug|x86.Build.0 = Debug|x86
|
||||
{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|x64.ActiveCfg = Release|x64
|
||||
{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|x64.Build.0 = Release|x64
|
||||
{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|x86.ActiveCfg = Release|x86
|
||||
{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|x86.Build.0 = Release|x86
|
||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|x64.Build.0 = Debug|x64
|
||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|x86.Build.0 = Debug|x86
|
||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|x64.ActiveCfg = Release|x64
|
||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|x64.Build.0 = Release|x64
|
||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|x86.ActiveCfg = Release|x86
|
||||
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|x86.Build.0 = Release|x86
|
||||
{0074C983-550E-4094-9E8C-F566FB669297}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0074C983-550E-4094-9E8C-F566FB669297}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0074C983-550E-4094-9E8C-F566FB669297}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{0074C983-550E-4094-9E8C-F566FB669297}.Debug|x64.Build.0 = Debug|x64
|
||||
{0074C983-550E-4094-9E8C-F566FB669297}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{0074C983-550E-4094-9E8C-F566FB669297}.Debug|x86.Build.0 = Debug|x86
|
||||
{0074C983-550E-4094-9E8C-F566FB669297}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0074C983-550E-4094-9E8C-F566FB669297}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0074C983-550E-4094-9E8C-F566FB669297}.Release|x64.ActiveCfg = Release|x64
|
||||
{0074C983-550E-4094-9E8C-F566FB669297}.Release|x64.Build.0 = Release|x64
|
||||
{0074C983-550E-4094-9E8C-F566FB669297}.Release|x86.ActiveCfg = Release|x86
|
||||
{0074C983-550E-4094-9E8C-F566FB669297}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
18
app.config
Normal file
18
app.config
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="WorkIndicator.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<userSettings>
|
||||
<WorkIndicator.Properties.Settings>
|
||||
<setting name="StartWithWindows" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="WindowPattern" serializeAs="String">
|
||||
<value>.* - CKACZOR - Remote Desktop Connection</value>
|
||||
</setting>
|
||||
</WorkIndicator.Properties.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
||||
5
packages.config
Normal file
5
packages.config
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Bcl" version="1.1.8" targetFramework="net40-Client" />
|
||||
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40-Client" />
|
||||
</packages>
|
||||
118
packages/Microsoft.Bcl.1.1.8/License-Stable.rtf
vendored
Normal file
118
packages/Microsoft.Bcl.1.1.8/License-Stable.rtf
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Tahoma;}{\f1\froman\fprq2\fcharset0 Times New Roman;}{\f2\fswiss\fprq2\fcharset0 Calibri;}{\f3\fnil\fcharset0 Calibri;}{\f4\fnil\fcharset2 Symbol;}}
|
||||
{\colortbl ;\red31\green73\blue125;\red0\green0\blue255;}
|
||||
{\*\listtable
|
||||
{\list\listhybrid
|
||||
{\listlevel\levelnfc0\leveljc0\levelstartat1{\leveltext\'02\'00.;}{\levelnumbers\'01;}\jclisttab\tx360}
|
||||
{\listlevel\levelnfc4\leveljc0\levelstartat1{\leveltext\'02\'01.;}{\levelnumbers\'01;}\jclisttab\tx363}
|
||||
{\listlevel\levelnfc2\leveljc0\levelstartat1{\leveltext\'02\'02.;}{\levelnumbers\'01;}\jclisttab\tx720}\listid1 }
|
||||
{\list\listhybrid
|
||||
{\listlevel\levelnfc0\leveljc0\levelstartat1{\leveltext\'02\'00.;}{\levelnumbers\'01;}\jclisttab\tx363}
|
||||
{\listlevel\levelnfc4\leveljc0\levelstartat1{\leveltext\'02\'01.;}{\levelnumbers\'01;}\jclisttab\tx363}\listid2 }}
|
||||
{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}{\listoverride\listid2\listoverridecount0\ls2}}
|
||||
{\stylesheet{ Normal;}{\s1 heading 1;}{\s2 heading 2;}{\s3 heading 3;}}
|
||||
{\*\generator Riched20 6.2.9200}\viewkind4\uc1
|
||||
\pard\nowidctlpar\sb120\sa120\b\f0\fs24 MICROSOFT SOFTWARE LICENSE TERMS\par
|
||||
|
||||
\pard\brdrb\brdrs\brdrw10\brsp20 \nowidctlpar\sb120\sa120 MICROSOFT .NET LIBRARY \par
|
||||
|
||||
\pard\nowidctlpar\sb120\sa120\fs19 These license terms are an agreement between Microsoft Corporation (or based on where you live, one of its affiliates) and you. Please read them. They apply to the software named above, which includes the media on which you received it, if any. The terms also apply to any Microsoft\par
|
||||
|
||||
\pard{\pntext\f4\'B7\tab}{\*\pn\pnlvlblt\pnf4\pnindent363{\pntxtb\'B7}}\nowidctlpar\fi-363\li720\sb120\sa120\b0 updates,\par
|
||||
{\pntext\f4\'B7\tab}supplements,\par
|
||||
{\pntext\f4\'B7\tab}Internet-based services, and\par
|
||||
{\pntext\f4\'B7\tab}support services\par
|
||||
|
||||
\pard\nowidctlpar\sb120\sa120\b for this software, unless other terms accompany those items. If so, those terms apply.\par
|
||||
BY USING THE SOFTWARE, YOU ACCEPT THESE TERMS. IF YOU DO NOT ACCEPT THEM, DO NOT USE THE SOFTWARE.\par
|
||||
|
||||
\pard\brdrt\brdrs\brdrw10\brsp20 \nowidctlpar\sb120\sa120 IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE PERPETUAL RIGHTS BELOW.\par
|
||||
|
||||
\pard
|
||||
{\listtext\f0 1.\tab}\jclisttab\tx360\ls1\nowidctlpar\s1\fi-357\li357\sb120\sa120 INSTALLATION AND USE RIGHTS. \par
|
||||
|
||||
\pard
|
||||
{\listtext\f0 a.\tab}\jclisttab\tx363\ls1\ilvl1\nowidctlpar\s2\fi-363\li720\sb120\sa120 Installation and Use.\b0\fs20 You may install and use any number of copies of the software to design, develop and test your programs.\par
|
||||
{\listtext\f0 b.\tab}\b\fs19 Third Party Programs.\b0\fs20 The software may include third party programs that Microsoft, not the third party, licenses to you under this agreement. Notices, if any, for the third party program are included for your information only.\b\fs19\par
|
||||
|
||||
\pard
|
||||
{\listtext\f0 2.\tab}\jclisttab\tx360\ls1\nowidctlpar\s1\fi-357\li357\sb120\sa120\fs20 ADDITIONAL LICENSING REQUIREMENTS AND/OR USE RIGHTS.\par
|
||||
|
||||
\pard
|
||||
{\listtext\f0 a.\tab}\jclisttab\tx363\ls1\ilvl1\nowidctlpar\s2\fi-363\li720\sb120\sa120 DISTRIBUTABLE CODE.\~ \b0 The software is comprised of Distributable Code. \f1\ldblquote\f0 Distributable Code\f1\rdblquote\f0 is code that you are permitted to distribute in programs you develop if you comply with the terms below.\b\par
|
||||
|
||||
\pard
|
||||
{\listtext\f0 i.\tab}\jclisttab\tx720\ls1\ilvl2\nowidctlpar\s3\fi-357\li1077\sb120\sa120\tx1077 Right to Use and Distribute. \par
|
||||
|
||||
\pard{\pntext\f4\'B7\tab}{\*\pn\pnlvlblt\pnf4\pnindent360{\pntxtb\'B7}}\nowidctlpar\fi-357\li1434\sb120\sa120\b0 You may copy and distribute the object code form of the software.\par
|
||||
{\pntext\f4\'B7\tab}Third Party Distribution. You may permit distributors of your programs to copy and distribute the Distributable Code as part of those programs.\par
|
||||
|
||||
\pard\nowidctlpar\s3\fi-357\li1077\sb120\sa120\tx1077\b ii.\tab Distribution Requirements.\b0 \b For any Distributable Code you distribute, you must\par
|
||||
|
||||
\pard{\pntext\f4\'B7\tab}{\*\pn\pnlvlblt\pnf4\pnindent360{\pntxtb\'B7}}\nowidctlpar\fi-357\li1434\sb120\sa120\b0 add significant primary functionality to it in your programs;\par
|
||||
{\pntext\f4\'B7\tab}require distributors and external end users to agree to terms that protect it at least as much as this agreement;\par
|
||||
{\pntext\f4\'B7\tab}display your valid copyright notice on your programs; and\par
|
||||
{\pntext\f4\'B7\tab}indemnify, defend, and hold harmless Microsoft from any claims, including attorneys\rquote fees, related to the distribution or use of your programs.\par
|
||||
|
||||
\pard\nowidctlpar\s3\fi-357\li1077\sb120\sa120\tx1077\b iii.\tab Distribution Restrictions.\b0 \b You may not\par
|
||||
|
||||
\pard{\pntext\f4\'B7\tab}{\*\pn\pnlvlblt\pnf4\pnindent360{\pntxtb\'B7}}\nowidctlpar\fi-357\li1434\sb120\sa120\b0 alter any copyright, trademark or patent notice in the Distributable Code;\par
|
||||
{\pntext\f4\'B7\tab}use Microsoft\rquote s trademarks in your programs\rquote names or in a way that suggests your programs come from or are endorsed by Microsoft;\par
|
||||
{\pntext\f4\'B7\tab}include Distributable Code in malicious, deceptive or unlawful programs; or\par
|
||||
{\pntext\f4\'B7\tab}modify or distribute the source code of any Distributable Code so that any part of it becomes subject to an Excluded License. An Excluded License is one that requires, as a condition of use, modification or distribution, that\par
|
||||
|
||||
\pard{\pntext\f4\'B7\tab}{\*\pn\pnlvlblt\pnf4\pnindent360{\pntxtb\'B7}}\nowidctlpar\fi-358\li1792\sb120\sa120 the code be disclosed or distributed in source code form; or\cf1\f2\par
|
||||
{\pntext\f4\'B7\tab}\cf0\f0 others have the right to modify it.\cf1\f2\par
|
||||
|
||||
\pard\nowidctlpar\s1\fi-357\li357\sb120\sa120\cf0\b\f0 3.\tab\fs19 SCOPE OF LICENSE. \b0 The software is licensed, not sold. This agreement only gives you some rights to use the software. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you may use the software only as expressly permitted in this agreement. In doing so, you must comply with any technical limitations in the software that only allow you to use it in certain ways. You may not\par
|
||||
|
||||
\pard{\pntext\f4\'B7\tab}{\*\pn\pnlvlblt\pnf4\pnindent363{\pntxtb\'B7}}\nowidctlpar\fi-363\li720\sb120\sa120 work around any technical limitations in the software;\par
|
||||
{\pntext\f4\'B7\tab}reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation;\par
|
||||
{\pntext\f4\'B7\tab}publish the software for others to copy;\par
|
||||
{\pntext\f4\'B7\tab}rent, lease or lend the software;\par
|
||||
{\pntext\f4\'B7\tab}transfer the software or this agreement to any third party; or\par
|
||||
{\pntext\f4\'B7\tab}use the software for commercial software hosting services.\par
|
||||
|
||||
\pard\nowidctlpar\s1\fi-357\li357\sb120\sa120\b\fs20 4.\tab\fs19 BACKUP COPY. \b0 You may make one backup copy of the software. You may use it only to reinstall the software.\par
|
||||
\b\fs20 5.\tab\fs19 DOCUMENTATION. \b0 Any person that has valid access to your computer or internal network may copy and use the documentation for your internal, reference purposes.\par
|
||||
\b\fs20 6.\tab\fs19 EXPORT RESTRICTIONS. \b0 The software is subject to United States export laws and regulations. You must comply with all domestic and international export laws and regulations that apply to the software. These laws include restrictions on destinations, end users and end use. For additional information, see {\cf2\ul\fs20{\field{\*\fldinst{HYPERLINK www.microsoft.com/exporting }}{\fldrslt{www.microsoft.com/exporting}}}}\f0\fs19 .\cf2\ul\fs20\par
|
||||
\cf0\ulnone\b 7.\tab\fs19 SUPPORT SERVICES. \b0 Because this software is \ldblquote as is,\rdblquote we may not provide support services for it.\par
|
||||
\b\fs20 8.\tab\fs19 ENTIRE AGREEMENT. \b0 This agreement, and the terms for supplements, updates, Internet-based services and support services that you use, are the entire agreement for the software and support services.\par
|
||||
\b\fs20 9.\tab\fs19 APPLICABLE LAW.\par
|
||||
|
||||
\pard
|
||||
{\listtext\f0 a.\tab}\jclisttab\tx363\ls2\ilvl1\nowidctlpar\s2\fi-363\li720\sb120\sa120 United States. \b0 If you acquired the software in the United States, Washington state law governs the interpretation of this agreement and applies to claims for breach of it, regardless of conflict of laws principles. The laws of the state where you live govern all other claims, including claims under state consumer protection laws, unfair competition laws, and in tort.\par
|
||||
{\listtext\f0 b.\tab}\b Outside the United States. If you acquired the software in any other country, the laws of that country apply.\par
|
||||
|
||||
\pard\nowidctlpar\s1\fi-357\li357\sb120\sa120\fs20 10.\tab\fs19 LEGAL EFFECT. \b0 This agreement describes certain legal rights. You may have other rights under the laws of your country. You may also have rights with respect to the party from whom you acquired the software. This agreement does not change your rights under the laws of your country if the laws of your country do not permit it to do so.\par
|
||||
\b\fs20 11.\tab\fs19 DISCLAIMER OF WARRANTY. THE SOFTWARE IS LICENSED \ldblquote AS-IS.\rdblquote YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES OR CONDITIONS. YOU MAY HAVE ADDITIONAL CONSUMER RIGHTS OR STATUTORY GUARANTEES UNDER YOUR LOCAL LAWS WHICH THIS AGREEMENT CANNOT CHANGE. TO THE EXTENT PERMITTED UNDER YOUR LOCAL LAWS, MICROSOFT EXCLUDES THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.\par
|
||||
|
||||
\pard\nowidctlpar\li357\sb120\sa120 FOR AUSTRALIA \endash YOU HAVE STATUTORY GUARANTEES UNDER THE AUSTRALIAN CONSUMER LAW AND NOTHING IN THESE TERMS IS INTENDED TO AFFECT THOSE RIGHTS.\par
|
||||
|
||||
\pard\nowidctlpar\s1\fi-357\li357\sb120\sa120\fs20 12.\tab\fs19 LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES. YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES.\par
|
||||
|
||||
\pard\nowidctlpar\li357\sb120\sa120\b0 This limitation applies to\par
|
||||
|
||||
\pard{\pntext\f4\'B7\tab}{\*\pn\pnlvlblt\pnf4\pnindent363{\pntxtb\'B7}}\nowidctlpar\fi-363\li720\sb120\sa120 anything related to the software, services, content (including code) on third party Internet sites, or third party programs; and\par
|
||||
{\pntext\f4\'B7\tab}claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence, or other tort to the extent permitted by applicable law.\par
|
||||
|
||||
\pard\nowidctlpar\sb120\sa120 It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your country may not allow the exclusion or limitation of incidental, consequential or other damages.\par
|
||||
\lang9 Please note: As this software is distributed in Quebec, Canada, some of the clauses in this agreement are provided below in French.\par
|
||||
Remarque : Ce logiciel \'e9tant distribu\'e9 au Qu\'e9bec, Canada, certaines des clauses dans ce contrat sont fournies ci-dessous en fran\'e7ais.\par
|
||||
|
||||
\pard\nowidctlpar\s1\sb120\sa120\b\lang1033 EXON\'c9RATION DE GARANTIE. \b0 Le logiciel vis\'e9 par une licence est offert \'ab tel quel \'bb. Toute utilisation de ce logiciel est \'e0 votre seule risque et p\'e9ril. Microsoft n\rquote accorde aucune autre garantie expresse. Vous pouvez b\'e9n\'e9ficier de droits additionnels en vertu du droit local sur la protection des consommateurs, que ce contrat ne peut modifier. La ou elles sont permises par le droit locale, les garanties implicites de qualit\'e9 marchande, d\rquote ad\'e9quation \'e0 un usage particulier et d\rquote absence de contrefa\'e7on sont exclues.\par
|
||||
\b LIMITATION DES DOMMAGES-INT\'c9R\'caTS ET EXCLUSION DE RESPONSABILIT\'c9 POUR LES DOMMAGES. \b0 Vous pouvez obtenir de Microsoft et de ses fournisseurs une indemnisation en cas de dommages directs uniquement \'e0 hauteur de 5,00 $ US. Vous ne pouvez pr\'e9tendre \'e0 aucune indemnisation pour les autres dommages, y compris les dommages sp\'e9ciaux, indirects ou accessoires et pertes de b\'e9n\'e9fices.\par
|
||||
|
||||
\pard\nowidctlpar\sb120\sa120\lang9 Cette limitation concerne :\par
|
||||
|
||||
\pard{\pntext\f4\'B7\tab}{\*\pn\pnlvlblt\pnf4\pnindent360{\pntxtb\'B7}}\nowidctlpar\li720\sb120\sa120 tout ce qui est reli\'e9 au logiciel, aux services ou au contenu (y compris le code) figurant sur des sites Internet tiers ou dans des programmes tiers ; et\par
|
||||
{\pntext\f4\'B7\tab}les r\'e9clamations au titre de violation de contrat ou de garantie, ou au titre de responsabilit\'e9 stricte, de n\'e9gligence ou d\rquote une autre faute dans la limite autoris\'e9e par la loi en vigueur.\par
|
||||
|
||||
\pard\nowidctlpar\sb120\sa120 Elle s\rquote applique \'e9galement, m\'eame si Microsoft connaissait ou devrait conna\'eetre l\rquote\'e9ventualit\'e9 d\rquote un tel dommage. Si votre pays n\rquote autorise pas l\rquote exclusion ou la limitation de responsabilit\'e9 pour les dommages indirects, accessoires ou de quelque nature que ce soit, il se peut que la limitation ou l\rquote exclusion ci-dessus ne s\rquote appliquera pas \'e0 votre \'e9gard.\par
|
||||
|
||||
\pard\nowidctlpar\s1\sb120\sa120\b\lang1033 EFFET JURIDIQUE. \b0 Le pr\'e9sent contrat d\'e9crit certains droits juridiques. Vous pourriez avoir d\rquote autres droits pr\'e9vus par les lois de votre pays. Le pr\'e9sent contrat ne modifie pas les droits que vous conf\'e8rent les lois de votre pays si celles-ci ne le permettent pas.\par
|
||||
|
||||
\pard\nowidctlpar\sb120\sa120\b\fs20\lang1036\par
|
||||
|
||||
\pard\sa200\sl276\slmult1\b0\f3\fs22\lang9\par
|
||||
}
|
||||
| ||||