diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..abbb301 --- /dev/null +++ b/.gitignore @@ -0,0 +1,324 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +deploy + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# 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 +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# 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 +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# TypeScript v1 declaration files +typings/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog diff --git a/FTDI USB Drivers/Application Notes.url b/FTDI USB Drivers/Application Notes.url new file mode 100644 index 0000000..604e60b --- /dev/null +++ b/FTDI USB Drivers/Application Notes.url @@ -0,0 +1,7 @@ +[DEFAULT] +BASEURL=http://www.ftdichip.com/Documents/AppNotes.htm +[InternetShortcut] +URL=http://www.ftdichip.com/Documents/AppNotes.htm +Modified=C055946F4AF7C5011F +IconFile=C:\WINNT\system32\url.dll +IconIndex=0 diff --git a/FTDI USB Drivers/FTBUSUI.dll b/FTDI USB Drivers/FTBUSUI.dll new file mode 100644 index 0000000..2bc6663 Binary files /dev/null and b/FTDI USB Drivers/FTBUSUI.dll differ diff --git a/FTDI USB Drivers/FTD2XX.H b/FTDI USB Drivers/FTD2XX.H new file mode 100644 index 0000000..9cfe171 --- /dev/null +++ b/FTDI USB Drivers/FTD2XX.H @@ -0,0 +1,875 @@ +/*++ + +Copyright (c) 2001-2005 Future Technology Devices International Ltd. + +Module Name: + + ftd2xx.h + +Abstract: + + Native USB device driver for FTDI FT8U232/245 + FTD2XX library definitions + +Environment: + + kernel & user mode + +Revision History: + + 13/03/01 awm Created. + 13/01/03 awm Added device information support. + 19/03/03 awm Added FT_W32_CancelIo. + 12/06/03 awm Added FT_StopInTask and FT_RestartInTask. + 18/09/03 awm Added FT_SetResetPipeRetryCount. + 10/10/03 awm Added FT_ResetPort. + 23/01/04 awm Added support for open-by-location. + 16/03/04 awm Added support for FT2232C. + 23/09/04 awm Added support for FT232R. + 20/10/04 awm Added FT_CyclePort. + 18/01/05 awm Added FT_DEVICE_LIST_INFO_NODE type. + 11/02/05 awm Added LocId to FT_DEVICE_LIST_INFO_NODE. + 25/08/05 awm Added FT_SetDeadmanTimeout. + 02/12/05 awm Removed obsolete references. + 05/12/05 awm Added FT_GetVersion, FT_GetVersionEx. + + +--*/ + + +#ifndef FTD2XX_H +#define FTD2XX_H + +// The following ifdef block is the standard way of creating macros +// which make exporting from a DLL simpler. All files within this DLL +// are compiled with the FTD2XX_EXPORTS symbol defined on the command line. +// This symbol should not be defined on any project that uses this DLL. +// This way any other project whose source files include this file see +// FTD2XX_API functions as being imported from a DLL, whereas this DLL +// sees symbols defined with this macro as being exported. + +#ifdef FTD2XX_EXPORTS +#define FTD2XX_API __declspec(dllexport) +#else +#define FTD2XX_API __declspec(dllimport) +#endif + + +typedef PVOID FT_HANDLE; +typedef ULONG FT_STATUS; + +// +// Device status +// +enum { + FT_OK, + FT_INVALID_HANDLE, + FT_DEVICE_NOT_FOUND, + FT_DEVICE_NOT_OPENED, + FT_IO_ERROR, + FT_INSUFFICIENT_RESOURCES, + FT_INVALID_PARAMETER, + FT_INVALID_BAUD_RATE, + + FT_DEVICE_NOT_OPENED_FOR_ERASE, + FT_DEVICE_NOT_OPENED_FOR_WRITE, + FT_FAILED_TO_WRITE_DEVICE, + FT_EEPROM_READ_FAILED, + FT_EEPROM_WRITE_FAILED, + FT_EEPROM_ERASE_FAILED, + FT_EEPROM_NOT_PRESENT, + FT_EEPROM_NOT_PROGRAMMED, + FT_INVALID_ARGS, + FT_NOT_SUPPORTED, + FT_OTHER_ERROR +}; + + +#define FT_SUCCESS(status) ((status) == FT_OK) + +// +// FT_OpenEx Flags +// + +#define FT_OPEN_BY_SERIAL_NUMBER 1 +#define FT_OPEN_BY_DESCRIPTION 2 +#define FT_OPEN_BY_LOCATION 4 + +// +// FT_ListDevices Flags (used in conjunction with FT_OpenEx Flags +// + +#define FT_LIST_NUMBER_ONLY 0x80000000 +#define FT_LIST_BY_INDEX 0x40000000 +#define FT_LIST_ALL 0x20000000 + +#define FT_LIST_MASK (FT_LIST_NUMBER_ONLY|FT_LIST_BY_INDEX|FT_LIST_ALL) + +// +// Baud Rates +// + +#define FT_BAUD_300 300 +#define FT_BAUD_600 600 +#define FT_BAUD_1200 1200 +#define FT_BAUD_2400 2400 +#define FT_BAUD_4800 4800 +#define FT_BAUD_9600 9600 +#define FT_BAUD_14400 14400 +#define FT_BAUD_19200 19200 +#define FT_BAUD_38400 38400 +#define FT_BAUD_57600 57600 +#define FT_BAUD_115200 115200 +#define FT_BAUD_230400 230400 +#define FT_BAUD_460800 460800 +#define FT_BAUD_921600 921600 + +// +// Word Lengths +// + +#define FT_BITS_8 (UCHAR) 8 +#define FT_BITS_7 (UCHAR) 7 +#define FT_BITS_6 (UCHAR) 6 +#define FT_BITS_5 (UCHAR) 5 + +// +// Stop Bits +// + +#define FT_STOP_BITS_1 (UCHAR) 0 +#define FT_STOP_BITS_1_5 (UCHAR) 1 +#define FT_STOP_BITS_2 (UCHAR) 2 + +// +// Parity +// + +#define FT_PARITY_NONE (UCHAR) 0 +#define FT_PARITY_ODD (UCHAR) 1 +#define FT_PARITY_EVEN (UCHAR) 2 +#define FT_PARITY_MARK (UCHAR) 3 +#define FT_PARITY_SPACE (UCHAR) 4 + +// +// Flow Control +// + +#define FT_FLOW_NONE 0x0000 +#define FT_FLOW_RTS_CTS 0x0100 +#define FT_FLOW_DTR_DSR 0x0200 +#define FT_FLOW_XON_XOFF 0x0400 + +// +// Purge rx and tx buffers +// +#define FT_PURGE_RX 1 +#define FT_PURGE_TX 2 + +// +// Events +// + +typedef void (*PFT_EVENT_HANDLER)(DWORD,DWORD); + +#define FT_EVENT_RXCHAR 1 +#define FT_EVENT_MODEM_STATUS 2 + +// +// Timeouts +// + +#define FT_DEFAULT_RX_TIMEOUT 300 +#define FT_DEFAULT_TX_TIMEOUT 300 + +// +// Device types +// + +typedef ULONG FT_DEVICE; + +enum { + FT_DEVICE_BM, + FT_DEVICE_AM, + FT_DEVICE_100AX, + FT_DEVICE_UNKNOWN, + FT_DEVICE_2232C, + FT_DEVICE_232R +}; + + +#ifdef __cplusplus +extern "C" { +#endif + + +FTD2XX_API +FT_STATUS WINAPI FT_Open( + int deviceNumber, + FT_HANDLE *pHandle + ); + +FTD2XX_API +FT_STATUS WINAPI FT_OpenEx( + PVOID pArg1, + DWORD Flags, + FT_HANDLE *pHandle + ); + +FTD2XX_API +FT_STATUS WINAPI FT_ListDevices( + PVOID pArg1, + PVOID pArg2, + DWORD Flags + ); + +FTD2XX_API +FT_STATUS WINAPI FT_Close( + FT_HANDLE ftHandle + ); + +FTD2XX_API +FT_STATUS WINAPI FT_Read( + FT_HANDLE ftHandle, + LPVOID lpBuffer, + DWORD nBufferSize, + LPDWORD lpBytesReturned + ); + +FTD2XX_API +FT_STATUS WINAPI FT_Write( + FT_HANDLE ftHandle, + LPVOID lpBuffer, + DWORD nBufferSize, + LPDWORD lpBytesWritten + ); + +FTD2XX_API +FT_STATUS WINAPI FT_IoCtl( + FT_HANDLE ftHandle, + DWORD dwIoControlCode, + LPVOID lpInBuf, + DWORD nInBufSize, + LPVOID lpOutBuf, + DWORD nOutBufSize, + LPDWORD lpBytesReturned, + LPOVERLAPPED lpOverlapped + ); + +FTD2XX_API +FT_STATUS WINAPI FT_SetBaudRate( + FT_HANDLE ftHandle, + ULONG BaudRate + ); + +FTD2XX_API +FT_STATUS WINAPI FT_SetDivisor( + FT_HANDLE ftHandle, + USHORT Divisor + ); + +FTD2XX_API +FT_STATUS WINAPI FT_SetDataCharacteristics( + FT_HANDLE ftHandle, + UCHAR WordLength, + UCHAR StopBits, + UCHAR Parity + ); + +FTD2XX_API +FT_STATUS WINAPI FT_SetFlowControl( + FT_HANDLE ftHandle, + USHORT FlowControl, + UCHAR XonChar, + UCHAR XoffChar + ); + +FTD2XX_API +FT_STATUS WINAPI FT_ResetDevice( + FT_HANDLE ftHandle + ); + +FTD2XX_API +FT_STATUS WINAPI FT_SetDtr( + FT_HANDLE ftHandle + ); + +FTD2XX_API +FT_STATUS WINAPI FT_ClrDtr( + FT_HANDLE ftHandle + ); + +FTD2XX_API +FT_STATUS WINAPI FT_SetRts( + FT_HANDLE ftHandle + ); + +FTD2XX_API +FT_STATUS WINAPI FT_ClrRts( + FT_HANDLE ftHandle + ); + +FTD2XX_API +FT_STATUS WINAPI FT_GetModemStatus( + FT_HANDLE ftHandle, + ULONG *pModemStatus + ); + +FTD2XX_API +FT_STATUS WINAPI FT_SetChars( + FT_HANDLE ftHandle, + UCHAR EventChar, + UCHAR EventCharEnabled, + UCHAR ErrorChar, + UCHAR ErrorCharEnabled + ); + +FTD2XX_API +FT_STATUS WINAPI FT_Purge( + FT_HANDLE ftHandle, + ULONG Mask + ); + +FTD2XX_API +FT_STATUS WINAPI FT_SetTimeouts( + FT_HANDLE ftHandle, + ULONG ReadTimeout, + ULONG WriteTimeout + ); + +FTD2XX_API +FT_STATUS WINAPI FT_GetQueueStatus( + FT_HANDLE ftHandle, + DWORD *dwRxBytes + ); + +FTD2XX_API +FT_STATUS WINAPI FT_SetEventNotification( + FT_HANDLE ftHandle, + DWORD Mask, + PVOID Param + ); + +FTD2XX_API +FT_STATUS WINAPI FT_GetStatus( + FT_HANDLE ftHandle, + DWORD *dwRxBytes, + DWORD *dwTxBytes, + DWORD *dwEventDWord + ); + +FTD2XX_API +FT_STATUS WINAPI FT_SetBreakOn( + FT_HANDLE ftHandle + ); + +FTD2XX_API +FT_STATUS WINAPI FT_SetBreakOff( + FT_HANDLE ftHandle + ); + +FTD2XX_API +FT_STATUS WINAPI FT_SetWaitMask( + FT_HANDLE ftHandle, + DWORD Mask + ); + +FTD2XX_API +FT_STATUS WINAPI FT_WaitOnMask( + FT_HANDLE ftHandle, + DWORD *Mask + ); + +FTD2XX_API +FT_STATUS WINAPI FT_GetEventStatus( + FT_HANDLE ftHandle, + DWORD *dwEventDWord + ); + +FTD2XX_API +FT_STATUS WINAPI FT_ReadEE( + FT_HANDLE ftHandle, + DWORD dwWordOffset, + LPWORD lpwValue + ); + +FTD2XX_API +FT_STATUS WINAPI FT_WriteEE( + FT_HANDLE ftHandle, + DWORD dwWordOffset, + WORD wValue + ); + +FTD2XX_API +FT_STATUS WINAPI FT_EraseEE( + FT_HANDLE ftHandle + ); + +// +// structure to hold program data for FT_Program function +// +typedef struct ft_program_data { + + DWORD Signature1; // Header - must be 0x00000000 + DWORD Signature2; // Header - must be 0xffffffff + DWORD Version; // Header - FT_PROGRAM_DATA version + // 0 = original + // 1 = FT2232C extensions + // 2 = FT232R extensions + + WORD VendorId; // 0x0403 + WORD ProductId; // 0x6001 + char *Manufacturer; // "FTDI" + char *ManufacturerId; // "FT" + char *Description; // "USB HS Serial Converter" + char *SerialNumber; // "FT000001" if fixed, or NULL + WORD MaxPower; // 0 < MaxPower <= 500 + WORD PnP; // 0 = disabled, 1 = enabled + WORD SelfPowered; // 0 = bus powered, 1 = self powered + WORD RemoteWakeup; // 0 = not capable, 1 = capable + // + // Rev4 extensions + // + UCHAR Rev4; // non-zero if Rev4 chip, zero otherwise + UCHAR IsoIn; // non-zero if in endpoint is isochronous + UCHAR IsoOut; // non-zero if out endpoint is isochronous + UCHAR PullDownEnable; // non-zero if pull down enabled + UCHAR SerNumEnable; // non-zero if serial number to be used + UCHAR USBVersionEnable; // non-zero if chip uses USBVersion + WORD USBVersion; // BCD (0x0200 => USB2) + // + // FT2232C extensions + // + UCHAR Rev5; // non-zero if Rev5 chip, zero otherwise + UCHAR IsoInA; // non-zero if in endpoint is isochronous + UCHAR IsoInB; // non-zero if in endpoint is isochronous + UCHAR IsoOutA; // non-zero if out endpoint is isochronous + UCHAR IsoOutB; // non-zero if out endpoint is isochronous + UCHAR PullDownEnable5; // non-zero if pull down enabled + UCHAR SerNumEnable5; // non-zero if serial number to be used + UCHAR USBVersionEnable5; // non-zero if chip uses USBVersion + WORD USBVersion5; // BCD (0x0200 => USB2) + UCHAR AIsHighCurrent; // non-zero if interface is high current + UCHAR BIsHighCurrent; // non-zero if interface is high current + UCHAR IFAIsFifo; // non-zero if interface is 245 FIFO + UCHAR IFAIsFifoTar; // non-zero if interface is 245 FIFO CPU target + UCHAR IFAIsFastSer; // non-zero if interface is Fast serial + UCHAR AIsVCP; // non-zero if interface is to use VCP drivers + UCHAR IFBIsFifo; // non-zero if interface is 245 FIFO + UCHAR IFBIsFifoTar; // non-zero if interface is 245 FIFO CPU target + UCHAR IFBIsFastSer; // non-zero if interface is Fast serial + UCHAR BIsVCP; // non-zero if interface is to use VCP drivers + // + // FT232R extensions + // + UCHAR UseExtOsc; // Use External Oscillator + UCHAR HighDriveIOs; // High Drive I/Os + UCHAR EndpointSize; // Endpoint size + + UCHAR PullDownEnableR; // non-zero if pull down enabled + UCHAR SerNumEnableR; // non-zero if serial number to be used + + UCHAR InvertTXD; // non-zero if invert TXD + UCHAR InvertRXD; // non-zero if invert RXD + UCHAR InvertRTS; // non-zero if invert RTS + UCHAR InvertCTS; // non-zero if invert CTS + UCHAR InvertDTR; // non-zero if invert DTR + UCHAR InvertDSR; // non-zero if invert DSR + UCHAR InvertDCD; // non-zero if invert DCD + UCHAR InvertRI; // non-zero if invert RI + + UCHAR Cbus0; // Cbus Mux control + UCHAR Cbus1; // Cbus Mux control + UCHAR Cbus2; // Cbus Mux control + UCHAR Cbus3; // Cbus Mux control + UCHAR Cbus4; // Cbus Mux control + + UCHAR RIsVCP; // non-zero if using VCP drivers + +} FT_PROGRAM_DATA, *PFT_PROGRAM_DATA; + +FTD2XX_API +FT_STATUS WINAPI FT_EE_Program( + FT_HANDLE ftHandle, + PFT_PROGRAM_DATA pData + ); + +FTD2XX_API +FT_STATUS WINAPI FT_EE_ProgramEx( + FT_HANDLE ftHandle, + PFT_PROGRAM_DATA pData, + char *Manufacturer, + char *ManufacturerId, + char *Description, + char *SerialNumber + ); + +FTD2XX_API +FT_STATUS WINAPI FT_EE_Read( + FT_HANDLE ftHandle, + PFT_PROGRAM_DATA pData + ); + +FTD2XX_API +FT_STATUS WINAPI FT_EE_ReadEx( + FT_HANDLE ftHandle, + PFT_PROGRAM_DATA pData, + char *Manufacturer, + char *ManufacturerId, + char *Description, + char *SerialNumber + ); + +FTD2XX_API +FT_STATUS WINAPI FT_EE_UASize( + FT_HANDLE ftHandle, + LPDWORD lpdwSize + ); + +FTD2XX_API +FT_STATUS WINAPI FT_EE_UAWrite( + FT_HANDLE ftHandle, + PUCHAR pucData, + DWORD dwDataLen + ); + +FTD2XX_API +FT_STATUS WINAPI FT_EE_UARead( + FT_HANDLE ftHandle, + PUCHAR pucData, + DWORD dwDataLen, + LPDWORD lpdwBytesRead + ); + +FTD2XX_API +FT_STATUS WINAPI FT_SetLatencyTimer( + FT_HANDLE ftHandle, + UCHAR ucLatency + ); + +FTD2XX_API +FT_STATUS WINAPI FT_GetLatencyTimer( + FT_HANDLE ftHandle, + PUCHAR pucLatency + ); + +FTD2XX_API +FT_STATUS WINAPI FT_SetBitMode( + FT_HANDLE ftHandle, + UCHAR ucMask, + UCHAR ucEnable + ); + +FTD2XX_API +FT_STATUS WINAPI FT_GetBitMode( + FT_HANDLE ftHandle, + PUCHAR pucMode + ); + +FTD2XX_API +FT_STATUS WINAPI FT_SetUSBParameters( + FT_HANDLE ftHandle, + ULONG ulInTransferSize, + ULONG ulOutTransferSize + ); + +FTD2XX_API +FT_STATUS WINAPI FT_SetDeadmanTimeout( + FT_HANDLE ftHandle, + ULONG ulDeadmanTimeout + ); + +FTD2XX_API +FT_STATUS WINAPI FT_GetDeviceInfo( + FT_HANDLE ftHandle, + FT_DEVICE *lpftDevice, + LPDWORD lpdwID, + PCHAR SerialNumber, + PCHAR Description, + LPVOID Dummy + ); + +FTD2XX_API +FT_STATUS WINAPI FT_StopInTask( + FT_HANDLE ftHandle + ); + +FTD2XX_API +FT_STATUS WINAPI FT_RestartInTask( + FT_HANDLE ftHandle + ); + +FTD2XX_API +FT_STATUS WINAPI FT_SetResetPipeRetryCount( + FT_HANDLE ftHandle, + DWORD dwCount + ); + +FTD2XX_API +FT_STATUS WINAPI FT_ResetPort( + FT_HANDLE ftHandle + ); + +FTD2XX_API +FT_STATUS WINAPI FT_CyclePort( + FT_HANDLE ftHandle + ); + + +// +// Win32-type functions +// + +FTD2XX_API +FT_HANDLE WINAPI FT_W32_CreateFile( + LPCSTR lpszName, + DWORD dwAccess, + DWORD dwShareMode, + LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreate, + DWORD dwAttrsAndFlags, + HANDLE hTemplate + ); + +FTD2XX_API +BOOL WINAPI FT_W32_CloseHandle( + FT_HANDLE ftHandle + ); + +FTD2XX_API +BOOL WINAPI FT_W32_ReadFile( + FT_HANDLE ftHandle, + LPVOID lpBuffer, + DWORD nBufferSize, + LPDWORD lpBytesReturned, + LPOVERLAPPED lpOverlapped + ); + +FTD2XX_API +BOOL WINAPI FT_W32_WriteFile( + FT_HANDLE ftHandle, + LPVOID lpBuffer, + DWORD nBufferSize, + LPDWORD lpBytesWritten, + LPOVERLAPPED lpOverlapped + ); + +FTD2XX_API +DWORD WINAPI FT_W32_GetLastError( + FT_HANDLE ftHandle + ); + +FTD2XX_API +BOOL WINAPI FT_W32_GetOverlappedResult( + FT_HANDLE ftHandle, + LPOVERLAPPED lpOverlapped, + LPDWORD lpdwBytesTransferred, + BOOL bWait + ); + +FTD2XX_API +BOOL WINAPI FT_W32_CancelIo( + FT_HANDLE ftHandle + ); + + +// +// Win32 COMM API type functions +// +typedef struct _FTCOMSTAT { + DWORD fCtsHold : 1; + DWORD fDsrHold : 1; + DWORD fRlsdHold : 1; + DWORD fXoffHold : 1; + DWORD fXoffSent : 1; + DWORD fEof : 1; + DWORD fTxim : 1; + DWORD fReserved : 25; + DWORD cbInQue; + DWORD cbOutQue; +} FTCOMSTAT, *LPFTCOMSTAT; + +typedef struct _FTDCB { + DWORD DCBlength; /* sizeof(FTDCB) */ + DWORD BaudRate; /* Baudrate at which running */ + DWORD fBinary: 1; /* Binary Mode (skip EOF check) */ + DWORD fParity: 1; /* Enable parity checking */ + DWORD fOutxCtsFlow:1; /* CTS handshaking on output */ + DWORD fOutxDsrFlow:1; /* DSR handshaking on output */ + DWORD fDtrControl:2; /* DTR Flow control */ + DWORD fDsrSensitivity:1; /* DSR Sensitivity */ + DWORD fTXContinueOnXoff: 1; /* Continue TX when Xoff sent */ + DWORD fOutX: 1; /* Enable output X-ON/X-OFF */ + DWORD fInX: 1; /* Enable input X-ON/X-OFF */ + DWORD fErrorChar: 1; /* Enable Err Replacement */ + DWORD fNull: 1; /* Enable Null stripping */ + DWORD fRtsControl:2; /* Rts Flow control */ + DWORD fAbortOnError:1; /* Abort all reads and writes on Error */ + DWORD fDummy2:17; /* Reserved */ + WORD wReserved; /* Not currently used */ + WORD XonLim; /* Transmit X-ON threshold */ + WORD XoffLim; /* Transmit X-OFF threshold */ + BYTE ByteSize; /* Number of bits/byte, 4-8 */ + BYTE Parity; /* 0-4=None,Odd,Even,Mark,Space */ + BYTE StopBits; /* 0,1,2 = 1, 1.5, 2 */ + char XonChar; /* Tx and Rx X-ON character */ + char XoffChar; /* Tx and Rx X-OFF character */ + char ErrorChar; /* Error replacement char */ + char EofChar; /* End of Input character */ + char EvtChar; /* Received Event character */ + WORD wReserved1; /* Fill for now. */ +} FTDCB, *LPFTDCB; + +typedef struct _FTTIMEOUTS { + DWORD ReadIntervalTimeout; /* Maximum time between read chars. */ + DWORD ReadTotalTimeoutMultiplier; /* Multiplier of characters. */ + DWORD ReadTotalTimeoutConstant; /* Constant in milliseconds. */ + DWORD WriteTotalTimeoutMultiplier; /* Multiplier of characters. */ + DWORD WriteTotalTimeoutConstant; /* Constant in milliseconds. */ +} FTTIMEOUTS,*LPFTTIMEOUTS; + + +FTD2XX_API +BOOL WINAPI FT_W32_ClearCommBreak( + FT_HANDLE ftHandle + ); + +FTD2XX_API +BOOL WINAPI FT_W32_ClearCommError( + FT_HANDLE ftHandle, + LPDWORD lpdwErrors, + LPFTCOMSTAT lpftComstat + ); + +FTD2XX_API +BOOL WINAPI FT_W32_EscapeCommFunction( + FT_HANDLE ftHandle, + DWORD dwFunc + ); + +FTD2XX_API +BOOL WINAPI FT_W32_GetCommModemStatus( + FT_HANDLE ftHandle, + LPDWORD lpdwModemStatus + ); + +FTD2XX_API +BOOL WINAPI FT_W32_GetCommState( + FT_HANDLE ftHandle, + LPFTDCB lpftDcb + ); + +FTD2XX_API +BOOL WINAPI FT_W32_GetCommTimeouts( + FT_HANDLE ftHandle, + FTTIMEOUTS *pTimeouts + ); + +FTD2XX_API +BOOL WINAPI FT_W32_PurgeComm( + FT_HANDLE ftHandle, + DWORD dwMask + ); + +FTD2XX_API +BOOL WINAPI FT_W32_SetCommBreak( + FT_HANDLE ftHandle + ); + +FTD2XX_API +BOOL WINAPI FT_W32_SetCommMask( + FT_HANDLE ftHandle, + ULONG ulEventMask + ); + +FTD2XX_API +BOOL WINAPI FT_W32_SetCommState( + FT_HANDLE ftHandle, + LPFTDCB lpftDcb + ); + +FTD2XX_API +BOOL WINAPI FT_W32_SetCommTimeouts( + FT_HANDLE ftHandle, + FTTIMEOUTS *pTimeouts + ); + +FTD2XX_API +BOOL WINAPI FT_W32_SetupComm( + FT_HANDLE ftHandle, + DWORD dwReadBufferSize, + DWORD dwWriteBufferSize + ); + +FTD2XX_API +BOOL WINAPI FT_W32_WaitCommEvent( + FT_HANDLE ftHandle, + PULONG pulEvent, + LPOVERLAPPED lpOverlapped + ); + + +// +// Device information +// + +typedef struct _ft_device_list_info_node { + ULONG Flags; + ULONG Type; + ULONG ID; + DWORD LocId; + char SerialNumber[16]; + char Description[64]; + FT_HANDLE ftHandle; +} FT_DEVICE_LIST_INFO_NODE; + + +FTD2XX_API +FT_STATUS WINAPI FT_CreateDeviceInfoList( + LPDWORD lpdwNumDevs + ); + +FTD2XX_API +FT_STATUS WINAPI FT_GetDeviceInfoList( + FT_DEVICE_LIST_INFO_NODE *pDest, + LPDWORD lpdwNumDevs + ); + +FTD2XX_API +FT_STATUS WINAPI FT_GetDeviceInfoDetail( + DWORD dwIndex, + LPDWORD lpdwFlags, + LPDWORD lpdwType, + LPDWORD lpdwID, + LPDWORD lpdwLocId, + LPVOID lpSerialNumber, + LPVOID lpDescription, + FT_HANDLE *pftHandle + ); + + +// +// Version information +// + +FTD2XX_API +FT_STATUS WINAPI FT_GetDriverVersion( + FT_HANDLE ftHandle, + LPDWORD lpdwVersion + ); + +FTD2XX_API +FT_STATUS WINAPI FT_GetLibraryVersion( + LPDWORD lpdwVersion + ); + + + + +#ifdef __cplusplus +} +#endif + + +#endif /* FTD2XX_H */ + diff --git a/FTDI USB Drivers/FTD2XX.dll b/FTDI USB Drivers/FTD2XX.dll new file mode 100644 index 0000000..b2b9f0f Binary files /dev/null and b/FTDI USB Drivers/FTD2XX.dll differ diff --git a/FTDI USB Drivers/FTD2XX.lib b/FTDI USB Drivers/FTD2XX.lib new file mode 100644 index 0000000..07451b4 Binary files /dev/null and b/FTDI USB Drivers/FTD2XX.lib differ diff --git a/FTDI USB Drivers/FTDIBUS.INF b/FTDI USB Drivers/FTDIBUS.INF new file mode 100644 index 0000000..46e7e93 --- /dev/null +++ b/FTDI USB Drivers/FTDIBUS.INF @@ -0,0 +1,88 @@ +; FTDIBUS.INF +; Copyright (c) 2000-2006 FTDI Ltd. +; +; USB serial converter driver installation for Windows 2000 and XP. +; + +[Version] +Signature="$Windows NT$" +DriverPackageType=PlugAndPlay +DriverPackageDisplayName=%DESC% +Class=USB +ClassGUID={36fc9e60-c465-11cf-8056-444553540000} +Provider=%FTDI% +CatalogFile=ftdibus.cat +DriverVer=05/19/2006,2.00.00 + +[SourceDisksNames] +1=%DriversDisk%,,, + +[SourceDisksFiles] +ftdibus.sys = 1 +ftdiunin.exe = 1 +ftdiun2k.ini = 1 +ftbusui.dll = 1 +ftd2xx.dll = 1 + +[DestinationDirs] +FtdiBus.NT.Copy = 10,system32\drivers +FtdiBus.NT.Copy2 = 10,system32 + +[Manufacturer] +%Ftdi%=FtdiHw + +[FtdiHw] +%USB\VID_0403&PID_6001.DeviceDesc%=FtdiBus,USB\VID_0403&PID_6001 +%USB\VID_0403&PID_6010&MI_00.DeviceDesc%=FtdiBus,USB\VID_0403&PID_6010&MI_00 +%USB\VID_0403&PID_6010&MI_01.DeviceDesc%=FtdiBus,USB\VID_0403&PID_6010&MI_01 + +[ControlFlags] +ExcludeFromSelect=* + +[FtdiBus.NT] +CopyFiles=FtdiBus.NT.Copy,FtdiBus.NT.Copy2 +AddReg=FtdiBus.NT.AddReg,FtdiBusUnInst.NT.Reg + +[FtdiBus.NT.Services] +AddService = FTDIBUS, 0x00000002, FtdiBus.NT.AddService + +[FtdiBus.NT.AddService] +DisplayName = %SvcDesc% +ServiceType = 1 ; SERVICE_KERNEL_DRIVER +StartType = 3 ; SERVICE_DEMAND_START +ErrorControl = 1 ; SERVICE_ERROR_NORMAL +ServiceBinary = %10%\system32\drivers\ftdibus.sys +LoadOrderGroup = Base + +[FtdiBus.NT.AddReg] +HKR,,DevLoader,,*ntkern +HKR,,NTMPDriver,,ftdibus.sys +HKR,,EnumPropPages32,,"ftbusui.dll,FTBUSUIPropPageProvider" + +[FtdiBus.NT.Copy] +ftdibus.sys + +[FtdiBus.NT.Copy2] +ftdiunin.exe +ftdiun2k.ini +ftbusui.dll +ftd2xx.dll + +[FtdiBusUnInst.NT.Reg] +HKLM,%WINUN%,"FTDICOMM" +HKLM,%WINUN%\FTDICOMM , "UninstallString",,"%11%\ftdiunin.exe %11%\ftdiun2k.ini" +HKLM,%WINUN%\FTDICOMM , "DisplayName",,"FTDI USB Serial Converter Drivers" +HKLM,%WINUN%\FTDICOMM , "URLInfoAbout",,"http://www.ftdichip.com" +HKLM,%WINUN%\FTDICOMM , "Publisher",,"FTDI Ltd" +HKLM,%WINUN%\FTDICOMM , "DisplayVersion",,"2.00.00" + +[Strings] +Ftdi="FTDI" +DESC="CDM Driver Package" +DriversDisk="FTDI USB Drivers Disk" +USB\VID_0403&PID_6001.DeviceDesc="USB Serial Converter" +USB\VID_0403&PID_6010&MI_00.DeviceDesc="USB Serial Converter A" +USB\VID_0403&PID_6010&MI_01.DeviceDesc="USB Serial Converter B" +WINUN="Software\Microsoft\Windows\CurrentVersion\Uninstall" +SvcDesc="USB Serial Converter Driver" +ClassName="USB" diff --git a/FTDI USB Drivers/FTDIBUS.sys b/FTDI USB Drivers/FTDIBUS.sys new file mode 100644 index 0000000..1f091c8 Binary files /dev/null and b/FTDI USB Drivers/FTDIBUS.sys differ diff --git a/FTDI USB Drivers/FTDIPORT.INF b/FTDI USB Drivers/FTDIPORT.INF new file mode 100644 index 0000000..d194f26 --- /dev/null +++ b/FTDI USB Drivers/FTDIPORT.INF @@ -0,0 +1,127 @@ +; FTDIPORT.INF +; Copyright (c) 2000-2006 FTDI Ltd. +; +; USB serial port driver installation for Windows 2000 and XP. +; + +[Version] +Signature="$Windows NT$" +DriverPackageType=PlugAndPlay +DriverPackageDisplayName=%DESC% +Class=Ports +ClassGUID={4d36e978-e325-11ce-bfc1-08002be10318} +Provider=%FTDI% +CatalogFile=ftdiport.cat +DriverVer=05/19/2006,2.00.00 + +[SourceDisksNames] +1=%DriversDisk%,,, + +[SourceDisksFiles] +ftser2k.sys=1 +ftserui2.dll=1 +FTLang.Dll = 1 +ftcserco.dll = 1 + +[DestinationDirs] +FtdiPort.NT.Copy=10,system32\drivers +FtdiPort.NT.CopyUI=10,system32 +FtdiPort2232.NT.CopyCoInst=10,system32 + +[ControlFlags] +ExcludeFromSelect=* + +[Manufacturer] +%FTDI%=FtdiHw + +[FtdiHw] +%VID_0403&PID_6001.DeviceDesc%=FtdiPort232,FTDIBUS\COMPORT&VID_0403&PID_6001 +%VID_0403&PID_6010.DeviceDesc%=FtdiPort2232,FTDIBUS\COMPORT&VID_0403&PID_6010 + +[FtdiPort.NT.AddService] +DisplayName = %SvcDesc% +ServiceType = 1 ; SERVICE_KERNEL_DRIVER +StartType = 3 ; SERVICE_DEMAND_START +ErrorControl = 1 ; SERVICE_ERROR_NORMAL +ServiceBinary = %10%\system32\drivers\ftser2k.sys +LoadOrderGroup = Base + +; -------------- Serenum Driver install section +[SerEnum_AddService] +DisplayName = %SerEnum.SvcDesc% +ServiceType = 1 ; SERVICE_KERNEL_DRIVER +StartType = 3 ; SERVICE_DEMAND_START +ErrorControl = 1 ; SERVICE_ERROR_NORMAL +ServiceBinary = %12%\serenum.sys +LoadOrderGroup = PNP Filter + +[FtdiPort.NT.AddReg] +HKR,,EnumPropPages32,,"ftserui2.dll,SerialPortPropPageProvider" + +[FtdiPort.NT.Copy] +ftser2k.sys +;serenum.sys + +[FtdiPort.NT.CopyUI] +ftserui2.dll +FTLang.dll + +[FtdiPort232.NT] +CopyFiles=FtdiPort.NT.Copy,FtdiPort.NT.CopyUI +AddReg=FtdiPort.NT.AddReg + +[FtdiPort232.NT.HW] +AddReg=FtdiPort232.NT.HW.AddReg + +[FtdiPort232.NT.Services] +AddService = FTSER2K, 0x00000002, FtdiPort.NT.AddService +AddService = Serenum,,SerEnum_AddService +DelService = FTSERIAL + +[FtdiPort232.NT.HW.AddReg] +HKR,,"UpperFilters",0x00010000,"serenum" +;HKR,,"ConfigData",1,01,00,3F,3F,10,27,88,13,C4,09,E2,04,71,02,38,41,9c,80,4E,C0,34,00,1A,00,0D,00,06,40,03,80,00,00,d0,80 +HKR,,"ConfigData",1,11,00,3F,3F,10,27,00,00,88,13,00,00,C4,09,00,00,E2,04,00,00,71,02,00,00,38,41,00,00,9C,80,00,00,4E,C0,00,00,34,00,00,00,1A,00,00,00,0D,00,00,00,06,40,00,00,03,80,00,00,00,00,00,00,D0,80,00,00 +HKR,,"MinReadTimeout",0x00010001,0 +HKR,,"MinWriteTimeout",0x00010001,0 +HKR,,"LatencyTimer",0x00010001,16 + +; ------- +; FT2232C +; ------- + +[FtdiPort2232.NT] +CopyFiles=FtdiPort.NT.Copy,FtdiPort.NT.CopyUI +AddReg=FtdiPort.NT.AddReg + +[FtdiPort2232.NT.HW] +AddReg=FtdiPort232.NT.HW.AddReg + +[FtdiPort2232.NT.CoInstallers] +AddReg=FtdiPort2232.NT.CoInstallers.AddReg +CopyFiles=FtdiPort2232.NT.CopyCoInst + +[FtdiPort2232.NT.Services] +AddService = FTSER2K, 0x00000002, FtdiPort.NT.AddService +AddService = Serenum,,SerEnum_AddService +DelService = FTSERIAL + +[FtdiPort2232.NT.CoInstallers.AddReg] +HKR,,CoInstallers32,0x00010000,"ftcserco.Dll,FTCSERCoInstaller" + +[FtdiPort2232.NT.CopyCoInst] +ftcserco.dll + +;---------------------------------------------------------------; + +[Strings] +FTDI="FTDI" +DESC="CDM Driver Package" +DriversDisk="FTDI USB Drivers Disk" +PortsClassName = "Ports (COM & LPT)" +VID_0403&PID_6001.DeviceDesc="USB Serial Port" +VID_0403&PID_6010.DeviceDesc="USB Serial Port" +SvcDesc="USB Serial Port Driver" +SerEnum.SvcDesc="Serenum Filter Driver" + + diff --git a/FTDI USB Drivers/FTDIUN2K.INI b/FTDI USB Drivers/FTDIUN2K.INI new file mode 100644 index 0000000..2249352 --- /dev/null +++ b/FTDI USB Drivers/FTDIUN2K.INI @@ -0,0 +1,6 @@ +[Uninstall] +Device=VID_0403&PID_6001,VID_0403&PID_6010 +Converter=FTDIBUS +Serial=FTSER2K +InfFiles=FTDIBUS,FTDIPORT +Key=FTDICOMM diff --git a/FTDI USB Drivers/FTDIUNIN.exe b/FTDI USB Drivers/FTDIUNIN.exe new file mode 100644 index 0000000..4cee751 Binary files /dev/null and b/FTDI USB Drivers/FTDIUNIN.exe differ diff --git a/FTDI USB Drivers/FTLang.dll b/FTDI USB Drivers/FTLang.dll new file mode 100644 index 0000000..a64d287 Binary files /dev/null and b/FTDI USB Drivers/FTLang.dll differ diff --git a/FTDI USB Drivers/Installation Guides.url b/FTDI USB Drivers/Installation Guides.url new file mode 100644 index 0000000..f84ebcd --- /dev/null +++ b/FTDI USB Drivers/Installation Guides.url @@ -0,0 +1,7 @@ +[DEFAULT] +BASEURL=http://www.ftdichip.com/Documents/InstallGuides.htm +[InternetShortcut] +URL=http://www.ftdichip.com/Documents/InstallGuides.htm +Modified=606147754AF7C50184 +IconFile=C:\WINNT\system32\url.dll +IconIndex=0 diff --git a/FTDI USB Drivers/ftcserco.dll b/FTDI USB Drivers/ftcserco.dll new file mode 100644 index 0000000..9c493d3 Binary files /dev/null and b/FTDI USB Drivers/ftcserco.dll differ diff --git a/FTDI USB Drivers/ftdibus.cat b/FTDI USB Drivers/ftdibus.cat new file mode 100644 index 0000000..05035ff Binary files /dev/null and b/FTDI USB Drivers/ftdibus.cat differ diff --git a/FTDI USB Drivers/ftdiport.cat b/FTDI USB Drivers/ftdiport.cat new file mode 100644 index 0000000..c84595b Binary files /dev/null and b/FTDI USB Drivers/ftdiport.cat differ diff --git a/FTDI USB Drivers/ftser2k.sys b/FTDI USB Drivers/ftser2k.sys new file mode 100644 index 0000000..a7b47e4 Binary files /dev/null and b/FTDI USB Drivers/ftser2k.sys differ diff --git a/FTDI USB Drivers/ftserui2.dll b/FTDI USB Drivers/ftserui2.dll new file mode 100644 index 0000000..eb97f13 Binary files /dev/null and b/FTDI USB Drivers/ftserui2.dll differ diff --git a/Fonts/carnival.zip b/Fonts/carnival.zip new file mode 100644 index 0000000..7f10abb Binary files /dev/null and b/Fonts/carnival.zip differ diff --git a/PhotoBooth/Debugger.Designer.vb b/PhotoBooth/Debugger.Designer.vb new file mode 100644 index 0000000..ce96da2 --- /dev/null +++ b/PhotoBooth/Debugger.Designer.vb @@ -0,0 +1,49 @@ + _ +Partial Class Debugger + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.DebugMessages = New System.Windows.Forms.ListBox + Me.SuspendLayout() + ' + 'DebugMessages + ' + Me.DebugMessages.Dock = System.Windows.Forms.DockStyle.Fill + Me.DebugMessages.FormattingEnabled = True + Me.DebugMessages.IntegralHeight = False + Me.DebugMessages.Location = New System.Drawing.Point(0, 0) + Me.DebugMessages.Name = "DebugMessages" + Me.DebugMessages.Size = New System.Drawing.Size(441, 190) + Me.DebugMessages.TabIndex = 0 + ' + 'Debugger + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(441, 190) + Me.Controls.Add(Me.DebugMessages) + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "Debugger" + Me.Text = "Debug" + Me.ResumeLayout(False) + + End Sub + Friend WithEvents DebugMessages As System.Windows.Forms.ListBox +End Class diff --git a/PhotoBooth/Debugger.resx b/PhotoBooth/Debugger.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/PhotoBooth/Debugger.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PhotoBooth/Debugger.vb b/PhotoBooth/Debugger.vb new file mode 100644 index 0000000..ecfd15f --- /dev/null +++ b/PhotoBooth/Debugger.vb @@ -0,0 +1,23 @@ +Public Class Debugger + Private WithEvents log As EZLogger + Private bm As BindingManagerBase + Private cm As CurrencyManager + + Private Sub log_Updated() Handles log.Updated + If (cm IsNot Nothing) Then + cm.Refresh() + DebugMessages.SelectedIndex = DebugMessages.Items.Count - 1 + End If + End Sub + + Public Sub BindLogToList(ByRef l As EZLogger) + log = l + + 'Bind the logger to the list box + DebugMessages.DataSource = log.Log + + 'Enable two-way binding + bm = DebugMessages.BindingContext(log.Log) + cm = bm + End Sub +End Class \ No newline at end of file diff --git a/PhotoBooth/EZLogger.vb b/PhotoBooth/EZLogger.vb new file mode 100644 index 0000000..4a386fa --- /dev/null +++ b/PhotoBooth/EZLogger.vb @@ -0,0 +1,408 @@ +Imports System +Imports System.IO + +Public Class EZLogger + + ''/// + ''/// An object that provides basic logging capabilities. + ''/// Copyright (c) 2006 Ravi Bhavnani, ravib@ravib.com + ''/// + ''/// This software may be freely used in any product or + ''/// work, provided this copyright notice is maintained. + ''/// To help ensure a single point of release, please + ''/// email and bug reports, flames and suggestions to + ''/// ravib@ravib.com. + ''/// + +#Region "Events" + Event Updated() +#End Region + +#Region "Attributes" + + ''/// + ''/// Log levels. + ''/// + Public Enum Level + ''/// Log debug messages. + Debug = 1 + + ''/// Log informational messages. + Info = 2 + + ''/// Log success messages. + Success = 4 + + ''/// Log warning messages. + Warning = 8 + + ''/// Log error messages. + Errors = 16 + + ''/// Log fatal errors. + Fatal = 32 + + ''/// Log all messages. + All = 65535 ' 0xFFFF + End Enum + + ''/// + ''/// The logger's state. + ''/// + Public Enum State + ''/// The logger is stopped. + Stopped = 0 + ''/// The logger has been started. + Running + ''/// The logger is paused. + Paused + End Enum + +#End Region + +#Region "Construction/destruction" + + ''/// + ''/// Constructs a EZLogger. + ''/// + ''/// Log file to receive output. + ''/// Flag: append to existing file (if any). + ''/// Flag: cache log in memory. + ''/// Mask indicating log levels of interest. + Public Sub New(ByVal logFilename As String, ByVal bAppend As Boolean, ByVal logLevels As UInteger, ByVal bCacheInMemory As Boolean) + _logFilename = logFilename + _bAppend = bAppend + _bCacheInMemory = bCacheInMemory + _levels = logLevels + + _logMem = New ArrayList + End Sub + + ''/// + ''/// Private default constructor. + ''/// + Private Sub New() + ' + End Sub +#End Region + +#Region "Properties" + + ''/// + ''/// Gets and sets the log level. + ''/// + Public Property Levels() As UInteger + Get + Return _levels + End Get + Set(ByVal value As UInteger) + _levels = value + End Set + End Property + + ''/// + ''/// Retrieves the logger's state. + ''/// + Public ReadOnly Property LoggerState() As State + Get + Return _state + End Get + End Property + + ''/// + ''/// Retrieves the log. + ''/// + Public ReadOnly Property Log() As ArrayList + Get + Return _logMem + End Get + End Property +#End Region + +#Region "Operations" + + ''/// + ''/// Starts logging. + ''/// + ''/// true if successful, false otherwise. + Public Function StartLog() As Boolean + SyncLock Me + '// Fail if logging has already been started + If LoggerState <> State.Stopped Then + Return False + End If + + '// Fail if the log file isn't specified + If String.IsNullOrEmpty(_logFilename) Then + Return False + End If + + '// Delete log file if it exists + If Not _bAppend Then + Try + File.Delete(_logFilename) + Catch ex As Exception + Return False + End Try + End If + + '// Open file for writing - return on error + If File.Exists(_logFilename) = False Then + Try + _logFile = File.CreateText(_logFilename) + Catch ex As Exception + _logFile = Nothing + Return False + End Try + Else + Try + _logFile = File.AppendText(_logFilename) + Catch ex As Exception + _logFile = Nothing + Return False + End Try + End If + + _logFile.AutoFlush = True + + '// Return successfully + _state = EZLogger.State.Running + Return True + End SyncLock + End Function + + ''/// + ''/// Temporarily suspends logging. + ''/// + ''/// true if successful, false otherwise. + Public Function PauseLog() As Boolean + SyncLock Me + '// Fail if logging hasn't been started + If LoggerState <> State.Running Then + Return False + End If + + '// Pause the logger + _state = EZLogger.State.Paused + Return True + End SyncLock + End Function + + + ''/// + ''/// Resumes logging. + ''/// + ''/// true if successful, false otherwise. + Public Function ResumeLog() As Boolean + SyncLock Me + '// Fail if logging hasn't been paused + If LoggerState <> State.Paused Then + Return False + End If + + '// Resume logging + _state = EZLogger.State.Running + Return True + End SyncLock + End Function + + ''/// + ''/// Stops logging. + ''/// + ''/// true if successful, false otherwise. + Public Function StopLog() As Boolean + SyncLock Me + '// Fail if logging hasn't been started + If LoggerState <> State.Running Then + Return False + End If + + '// Stop logging + Try + _logFile.Close() + _logFile = Nothing + + Catch ex As Exception + Return False + End Try + + _state = EZLogger.State.Stopped + Return True + End SyncLock + End Function + + ''/// + ''/// Logs a debug message. + ''/// + ''/// The message. + ''/// true if successful, false otherwise. + Public Function Debug(ByVal msg As String) As Boolean + _debugMsgs += 1 + Return WriteLogMsg(Level.Debug, msg) + End Function + + ''/// + ''/// Logs an informational message. + ''/// + ''/// The message. + ''/// true if successful, false otherwise. + Public Function Info(ByVal msg As String) As Boolean + _infoMsgs += 1 + Return WriteLogMsg(Level.Info, msg) + End Function + + ''/// + ''/// Logs a success message. + ''/// + ''/// The message. + ''/// true if successful, false otherwise. + Public Function Success(ByVal msg As String) As Boolean + _successMsgs += 1 + Return WriteLogMsg(Level.Success, msg) + End Function + + ''/// + ''/// Logs a warning message. + ''/// + ''/// The message. + ''/// true if successful, false otherwise. + Public Function Warning(ByVal msg As String) As Boolean + _warningMsgs += 1 + Return WriteLogMsg(Level.Warning, msg) + End Function + + ''/// + ''/// Logs an error message. + ''/// + ''/// The message. + ''/// true if successful, false otherwise. + Public Function Errors(ByVal msg As String) As Boolean + _errorMsgs += 1 + Return WriteLogMsg(Level.Errors, msg) + End Function + + ''/// + ''/// Logs a fatal error message. + ''/// + ''/// The message. + ''/// true if successful, false otherwise. + Public Function Fatal(ByVal msg As String) As Boolean + _fatalMsgs += 1 + Return WriteLogMsg(Level.Fatal, msg) + End Function + + + ''/// + ''/// Retrieves the count of messages logged at one or more levels. + ''/// + ''/// Mask indicating levels of interest. + ''/// + Public Function GetMessageCount(ByVal levelMask As UInteger) As UInteger + Dim uMessages As UInteger = 0 + If ((levelMask & CUInt(Level.Debug)) <> 0) Then + uMessages += _debugMsgs + End If + If ((levelMask & CUInt(Level.Info)) <> 0) Then + uMessages += _infoMsgs + End If + If ((levelMask & CUInt(Level.Success)) <> 0) Then + uMessages += _successMsgs + End If + If ((levelMask & CUInt(Level.Warning)) <> 0) Then + uMessages += _warningMsgs + End If + If ((levelMask & CUInt(Level.Errors)) <> 0) Then + uMessages += _errorMsgs + End If + If ((levelMask & CUInt(Level.Fatal)) <> 0) Then + uMessages += _fatalMsgs + End If + Return uMessages + End Function + +#End Region + +#Region "Helper methods" + + ''/// + ''/// Writes a log message. + ''/// + ''/// + ''/// + ''/// + Private Function WriteLogMsg(ByVal level As Level, ByVal msg As String) As Boolean + SyncLock Me + '// Fail if logger hasn't been started + If (LoggerState = State.Stopped) Then + Return False + End If + + '// Ignore message logging is paused or it doesn't pass the filter + If ((LoggerState = State.Paused) Or ((_levels And CUInt(level)) <> CUInt(level))) Then + Return True + End If + + '// Write log message + Dim tmNow As DateTime = DateTime.Now + Dim logMsg As String = String.Format("{0} {1} {2}: {3}", _ + tmNow.ToShortDateString(), tmNow.ToLongTimeString(), _ + level.ToString().Substring(0, 1), msg) + _logFile.WriteLine(logMsg) + + If _bCacheInMemory Then + _logMem.Add(logMsg) + End If + + RaiseEvent Updated() + + Return True + End SyncLock + End Function + +#End Region + +#Region "Fields" + + ''/// Name of the log file. + Private _logFilename As String + + ''/// Flag: append to existing file (if any). + Private _bAppend As Boolean = True + + ''/// Flag: append to an array list in memory. + Private _bCacheInMemory As Boolean = True + + ''/// The log file. + Private _logFile As StreamWriter = Nothing + + ''/// The log in memory. + Private _logMem As ArrayList = Nothing + + ''/// Levels to be logged. + Private _levels As UInteger = (Level.Warning Or Level.Errors Or Level.Fatal) + + ''/// The logger's state. + Private _state As State = State.Stopped + + ''/// Number of debug messages that have been logged. + Private _debugMsgs As UInteger = 0 + + ''/// Number of informational messages that have been logged. + Private _infoMsgs As UInteger = 0 + + ''/// Number of success messages that have been logged. + Private _successMsgs As UInteger = 0 + + ''/// Number of warning messages that have been logged. + Private _warningMsgs As UInteger = 0 + + ''/// Number of error messages that have been logged. + Private _errorMsgs As UInteger = 0 + + ''/// Number of fatal messages that have been logged. + Private _fatalMsgs As UInteger = 0 + +#End Region + +End Class + diff --git a/PhotoBooth/FaderPanel.vb b/PhotoBooth/FaderPanel.vb new file mode 100644 index 0000000..a33396c --- /dev/null +++ b/PhotoBooth/FaderPanel.vb @@ -0,0 +1,104 @@ +Imports System.Drawing.Imaging + +Public Class FaderPanel + Inherits Panel + + Private Enum MsgState + Delaying + Fading + End Enum + + Private A As Integer + Private msg As Bitmap + Private msgBackGround As Bitmap + Private currentState As MsgState + Private WithEvents tmr As New Timer + Private fadeDelayInSeconds As Single 'Calculate to be a certain percentage of the display duration + + Public DisplayDuration As Single = 2.5F + + Public Sub New() + Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, True) + Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True) + End Sub + + Public Sub FlashMessage(ByVal message As String) + If Me.IsHandleCreated Then + tmr.Stop() + + Me.Visible = True + + msgBackGround = New Bitmap(Me.ClientRectangle.Width, Me.ClientRectangle.Height) + Dim g As Graphics = Graphics.FromImage(msgBackGround) + g.Clear(Me.BackColor) + g.Dispose() + + msg = New Bitmap(msgBackGround.Width, msgBackGround.Height) + g = Graphics.FromImage(msg) + g.Clear(Color.Transparent) + Dim sb As New SolidBrush(Me.ForeColor) + + 'Center the message on screen + Dim xPos As Single + xPos = (Me.Parent.Width - g.MeasureString(message, Me.Font).Width) / 2 + + g.DrawString(message, Me.Font, sb, xPos, 0) + sb.Dispose() + g.Dispose() + + 'Reset the alpha value to full opacity + A = 255 + ShowMessage(A) + + 'Calculate the delay before starting the fade (25% of the display duration) + fadeDelayInSeconds = DisplayDuration * 0.25 + + currentState = MsgState.Delaying + tmr.Interval = fadeDelayInSeconds * 1000 'Convert to milliseconds + tmr.Start() + End If + End Sub + + Private Sub ShowMessage(ByVal alpha As Byte) + Dim cm As ColorMatrix = New ColorMatrix(New Single()() _ + {New Single() {1, 0, 0, 0, 0}, _ + New Single() {0, 1, 0, 0, 0}, _ + New Single() {0, 0, 1, 0, 0}, _ + New Single() {0, 0, 0, (alpha / 255), 0}, _ + New Single() {0, 0, 0, 0, 1}}) + + Dim IA As New ImageAttributes + IA.SetColorMatrix(cm, ColorMatrixFlag.Default, ColorAdjustType.Bitmap) + + Dim tmp As New Bitmap(msgBackGround) + Dim G As Graphics = Graphics.FromImage(tmp) + G.DrawImage(msg, Me.ClientRectangle, 0, 0, Me.Width, Me.Height, GraphicsUnit.Pixel, IA) + G.Dispose() + IA.Dispose() + + Me.BackgroundImage = tmp + End Sub + + Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick + Select Case currentState + Case MsgState.Delaying + tmr.Stop() + + 'Calculate the number of steps to fade out in the remaining display time + '51 = full opacity - the step value (255/5) + tmr.Interval = ((DisplayDuration - fadeDelayInSeconds) * 1000) / 51 + + 'Change the panel state to fade out + currentState = MsgState.Fading + tmr.Start() + + Case MsgState.Fading + A = A - 5 + If A < 0 Then + tmr.Stop() + Else + ShowMessage(A) + End If + End Select + End Sub +End Class \ No newline at end of file diff --git a/PhotoBooth/Main.Designer.vb b/PhotoBooth/Main.Designer.vb new file mode 100644 index 0000000..91be33e --- /dev/null +++ b/PhotoBooth/Main.Designer.vb @@ -0,0 +1,202 @@ + _ +Partial Class Main + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.fsWatcher = New System.IO.FileSystemWatcher + Me.messageDock = New System.Windows.Forms.Panel + Me.tlpFilmstrip = New System.Windows.Forms.TableLayoutPanel + Me.thumb1 = New System.Windows.Forms.PictureBox + Me.thumb2 = New System.Windows.Forms.PictureBox + Me.thumb3 = New System.Windows.Forms.PictureBox + Me.thumb4 = New System.Windows.Forms.PictureBox + Me.thumb5 = New System.Windows.Forms.PictureBox + Me.lblCounterMessage = New System.Windows.Forms.Label + Me.picBox = New System.Windows.Forms.PictureBox + CType(Me.fsWatcher, System.ComponentModel.ISupportInitialize).BeginInit() + Me.tlpFilmstrip.SuspendLayout() + CType(Me.thumb1, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.thumb2, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.thumb3, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.thumb4, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.thumb5, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.picBox, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'fsWatcher + ' + Me.fsWatcher.EnableRaisingEvents = True + Me.fsWatcher.SynchronizingObject = Me + ' + 'messageDock + ' + Me.messageDock.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.messageDock.Location = New System.Drawing.Point(12, 12) + Me.messageDock.Name = "messageDock" + Me.messageDock.Size = New System.Drawing.Size(765, 115) + Me.messageDock.TabIndex = 4 + ' + 'tlpFilmstrip + ' + Me.tlpFilmstrip.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.tlpFilmstrip.ColumnCount = 5 + Me.tlpFilmstrip.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20.0!)) + Me.tlpFilmstrip.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20.0!)) + Me.tlpFilmstrip.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20.0!)) + Me.tlpFilmstrip.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20.0!)) + Me.tlpFilmstrip.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20.0!)) + Me.tlpFilmstrip.Controls.Add(Me.thumb1, 0, 0) + Me.tlpFilmstrip.Controls.Add(Me.thumb2, 1, 0) + Me.tlpFilmstrip.Controls.Add(Me.thumb3, 2, 0) + Me.tlpFilmstrip.Controls.Add(Me.thumb4, 3, 0) + Me.tlpFilmstrip.Controls.Add(Me.thumb5, 4, 0) + Me.tlpFilmstrip.Location = New System.Drawing.Point(12, 293) + Me.tlpFilmstrip.Name = "tlpFilmstrip" + Me.tlpFilmstrip.RowCount = 1 + Me.tlpFilmstrip.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100.0!)) + Me.tlpFilmstrip.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 160.0!)) + Me.tlpFilmstrip.Size = New System.Drawing.Size(765, 160) + Me.tlpFilmstrip.TabIndex = 5 + ' + 'thumb1 + ' + Me.thumb1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.thumb1.Location = New System.Drawing.Point(3, 3) + Me.thumb1.Name = "thumb1" + Me.thumb1.Size = New System.Drawing.Size(147, 154) + Me.thumb1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom + Me.thumb1.TabIndex = 5 + Me.thumb1.TabStop = False + ' + 'thumb2 + ' + Me.thumb2.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.thumb2.Location = New System.Drawing.Point(156, 3) + Me.thumb2.Name = "thumb2" + Me.thumb2.Size = New System.Drawing.Size(147, 154) + Me.thumb2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom + Me.thumb2.TabIndex = 6 + Me.thumb2.TabStop = False + ' + 'thumb3 + ' + Me.thumb3.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.thumb3.Location = New System.Drawing.Point(309, 3) + Me.thumb3.Name = "thumb3" + Me.thumb3.Size = New System.Drawing.Size(147, 154) + Me.thumb3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom + Me.thumb3.TabIndex = 7 + Me.thumb3.TabStop = False + ' + 'thumb4 + ' + Me.thumb4.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.thumb4.Location = New System.Drawing.Point(462, 3) + Me.thumb4.Name = "thumb4" + Me.thumb4.Size = New System.Drawing.Size(147, 154) + Me.thumb4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom + Me.thumb4.TabIndex = 8 + Me.thumb4.TabStop = False + ' + 'thumb5 + ' + Me.thumb5.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.thumb5.Location = New System.Drawing.Point(615, 3) + Me.thumb5.Name = "thumb5" + Me.thumb5.Size = New System.Drawing.Size(147, 154) + Me.thumb5.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom + Me.thumb5.TabIndex = 9 + Me.thumb5.TabStop = False + ' + 'lblCounterMessage + ' + Me.lblCounterMessage.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) + Me.lblCounterMessage.AutoSize = True + Me.lblCounterMessage.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.lblCounterMessage.ForeColor = System.Drawing.Color.White + Me.lblCounterMessage.Location = New System.Drawing.Point(9, 456) + Me.lblCounterMessage.Name = "lblCounterMessage" + Me.lblCounterMessage.Size = New System.Drawing.Size(171, 16) + Me.lblCounterMessage.TabIndex = 2 + Me.lblCounterMessage.Text = "Counter message goes here" + ' + 'picBox + ' + Me.picBox.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.picBox.Location = New System.Drawing.Point(12, 12) + Me.picBox.Name = "picBox" + Me.picBox.Size = New System.Drawing.Size(765, 275) + Me.picBox.TabIndex = 7 + Me.picBox.TabStop = False + ' + 'Main + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.BackColor = System.Drawing.Color.Black + Me.ClientSize = New System.Drawing.Size(789, 481) + Me.Controls.Add(Me.messageDock) + Me.Controls.Add(Me.lblCounterMessage) + Me.Controls.Add(Me.tlpFilmstrip) + Me.Controls.Add(Me.picBox) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog + Me.KeyPreview = True + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "Main" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Photo Booth" + CType(Me.fsWatcher, System.ComponentModel.ISupportInitialize).EndInit() + Me.tlpFilmstrip.ResumeLayout(False) + CType(Me.thumb1, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.thumb2, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.thumb3, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.thumb4, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.thumb5, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.picBox, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents fsWatcher As System.IO.FileSystemWatcher + Friend WithEvents messageDock As System.Windows.Forms.Panel + Friend WithEvents tlpFilmstrip As System.Windows.Forms.TableLayoutPanel + Friend WithEvents lblCounterMessage As System.Windows.Forms.Label + Friend WithEvents thumb1 As System.Windows.Forms.PictureBox + Friend WithEvents thumb2 As System.Windows.Forms.PictureBox + Friend WithEvents thumb3 As System.Windows.Forms.PictureBox + Friend WithEvents thumb4 As System.Windows.Forms.PictureBox + Friend WithEvents thumb5 As System.Windows.Forms.PictureBox + Friend WithEvents picBox As System.Windows.Forms.PictureBox + +End Class diff --git a/PhotoBooth/Main.resx b/PhotoBooth/Main.resx new file mode 100644 index 0000000..9899d25 --- /dev/null +++ b/PhotoBooth/Main.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 56 + + \ No newline at end of file diff --git a/PhotoBooth/Main.vb b/PhotoBooth/Main.vb new file mode 100644 index 0000000..86888d1 --- /dev/null +++ b/PhotoBooth/Main.vb @@ -0,0 +1,339 @@ +Imports System.IO.Ports + +Public Class Main + Private Enum PhotoBoothState + Unknown = 0 'The state when the application is first started + Ready 'The booth is ready to take another photo + Working 'The booth is taking/processing a photo + Stopped 'The booth is stopped (no folder watching, the COM port is closed) + End Enum + + Private BoothState As PhotoBoothState = PhotoBoothState.Unknown + Private photos As Collection + Private input As SerialPort + Private log As EZLogger + Private logWindow As Debugger + Private messagePanel As FaderPanel + + Private Delegate Sub TakePhotoDelegate() + + Private Sub frmMain_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown + Select Case e.KeyCode + Case Keys.D + ToggleDebugWindow() + Case Keys.S + StartPhotoBooth() + Case Keys.T + TakePhoto() + Case Keys.U + ShowUsageMenu() + Case Keys.O + Options.ShowDialog() + LoadSettings() + Case Keys.R + input.Write("R") + Case Keys.G + input.Write("G") + Case Keys.Escape + ExitPhotoBooth() + Case Keys.PageDown + ToggleWindowMode() + End Select + End Sub + + Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + 'Initialize the log + log = New EZLogger(My.Application.Info.DirectoryPath & "\log.txt", True, EZLogger.Level.All, True) + log.StartLog() + + 'Initialize the in-memory list of photos + photos = New Collection() + + 'Initialize the file watcher + log.Info("Initializing the file watcher") + fsWatcher.EnableRaisingEvents = False + fsWatcher.NotifyFilter = (IO.NotifyFilters.CreationTime Or IO.NotifyFilters.LastWrite) + fsWatcher.Filter = "*.jpg" + + 'Initialize the serial port + log.Info("Initializing the serial port") + input = New SerialPort + AddHandler input.DataReceived, AddressOf DataReceived + + 'Initialize the message panel + log.Info("Initializing the message panel") + messagePanel = New FaderPanel + messagePanel.Dock = DockStyle.Fill + messagePanel.BackColor = Color.Black + messagePanel.ForeColor = Color.White + messageDock.Visible = False + messageDock.Controls.Add(messagePanel) + + 'Initialize the informational messages + lblCounterMessage.Text = String.Empty + + 'Initialize the photo booth settings + 'TODO: move this out of here and only load the settings when the booth is started + LoadSettings() + + 'Show the usage screen + Me.Show() 'Be sure the main form is visible before displaying the usage screen + ShowUsageMenu() + + 'TODO: If this is the first time launching the app, show the options screen + End Sub + + Private Sub StartPhotoBooth() + 'Put the photo booth in a ready state + log.Info("Starting the photo booth") + + 'Initialize the photos and cache folder + 'Make sure the folder exists and clear it if there are files in it + Dim fileCounter As Collections.ObjectModel.ReadOnlyCollection(Of String) + + 'Inspect the cache folder + fileCounter = My.Computer.FileSystem.GetFiles( _ + My.Settings.ImageCache, FileIO.SearchOption.SearchTopLevelOnly, "*.jpg") + If fileCounter.Count <> 0 Then + For Each file As String In fileCounter + My.Computer.FileSystem.DeleteFile(file) + Next + End If + + 'Inspect the photos folder + fileCounter = My.Computer.FileSystem.GetFiles( _ + My.Settings.WatchFolder, FileIO.SearchOption.SearchTopLevelOnly, "*.jpg") + If fileCounter.Count <> 0 Then + If MessageBox.Show("There are files in the photos folder. Do you want to empty the folder now?", _ + "Clear photo folders", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then + For Each file As String In fileCounter + My.Computer.FileSystem.DeleteFile(file) + Next + End If + End If + + 'TODO: Verify Cam2COM is running + 'Process.GetProcessesByName("Cam2ComM") + + OpenSerialPort() + fsWatcher.EnableRaisingEvents = True + + 'Toggle the stop and go LEDs on the input device + input.Write("r") + input.Write("G") + + BoothState = PhotoBoothState.Ready + End Sub + + Private Sub ExitPhotoBooth() + 'Shut down the photo booth + log.Info("Shutting down the application") + + 'Close the debugger window + If logWindow IsNot Nothing Then + logWindow.Close() + logWindow = Nothing + End If + + 'Stop watching the photo folder + log.Info("Shutting down the file watcher") + fsWatcher.EnableRaisingEvents = False + + 'Shut down the serial port for the trigger + CloseSerialPort() + + 'Stop logging events + log.StopLog() + + Application.Exit() + End Sub + + Private Sub LoadSettings() + log.Info("Loading settings") + messagePanel.DisplayDuration = My.Settings.MessageDuration + messagePanel.Font = My.Settings.MessageFont + fsWatcher.Path = My.Settings.WatchFolder + End Sub + + Private Sub ToggleDebugWindow() + If logWindow Is Nothing Then + logWindow = New Debugger + logWindow.BindLogToList(log) + End If + logWindow.Visible = Not logWindow.Visible + End Sub + + Private Sub ToggleWindowMode() + If Me.WindowState <> FormWindowState.Maximized Then + Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None + Me.WindowState = FormWindowState.Maximized + Windows.Forms.Cursor.Hide() + Else + Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle + Me.WindowState = FormWindowState.Normal + Windows.Forms.Cursor.Show() + End If + End Sub + + Private Sub ShowUsageMenu() + Using u As New Usage + u.ShowDialog(Me) + End Using + End Sub + + Private Sub CloseSerialPort() + log.Info("Closing the serial port") + If input.IsOpen Then + input.Close() + End If + End Sub + + Private Sub OpenSerialPort() + 'Set up serial communication with the Arduino + log.Info("Opening the serial port") + If input IsNot Nothing Then + If input.IsOpen Then + input.Close() + End If + End If + + Try + input.PortName = My.Settings.COMPort + input.BaudRate = 9600 + input.Parity = Parity.None + input.DataBits = 8 + input.Open() + Catch ex As Exception + log.Errors(ex.Message) + End Try + End Sub + + Private Sub ShowNewPicture(ByVal FullPath As String) + log.Info("Show new photo") + messageDock.Visible = False + messagePanel.Visible = False + Try + With picBox + .SizeMode = PictureBoxSizeMode.Zoom + .Load(FullPath) + .Refresh() + + 'Save a scaled down image in the photo cache + AddPhotoToCache(.Image, FullPath) + End With + Catch ex As Exception + log.Errors(ex.Message) + End Try + End Sub + + Private Sub CycleFilmStrip() + log.Info("Cycling the filmstrip") + + If photos.Count > 1 Then + try + thumb5.Image = thumb4.Image + thumb4.Image = thumb3.Image + thumb3.Image = thumb2.Image + thumb2.Image = thumb1.Image + + thumb1.Image = Image.FromFile(My.Settings.ImageCache & "\" & photos(photos.Count - 1).ToString()) + + tlpFilmstrip.Visible = True + Catch ex As Exception + log.Errors(ex.Message) + End Try + End If + End Sub + + Private Sub AddPhotoToCache(ByVal NewPhoto As Drawing.Image, ByVal FullPath As String) + log.Info("Creating cached version") + + Try + 'Dim f As New IO.FileInfo(IO.Path.GetTempFileName()) + Dim f As New IO.FileInfo(FullPath) + Dim cacheDestination As New Bitmap(CInt(NewPhoto.Size.Width * 0.35), CInt(NewPhoto.Size.Height * 0.35)) + Dim gPhoto As Graphics = Graphics.FromImage(cacheDestination) + gPhoto.DrawImage(NewPhoto, _ + New Rectangle(0, 0, CInt(NewPhoto.Size.Width * 0.35), CInt(NewPhoto.Height * 0.35)), _ + New Rectangle(0, 0, NewPhoto.Width, NewPhoto.Height), _ + GraphicsUnit.Pixel) + cacheDestination.Save(My.Settings.ImageCache & "\" & f.Name.Replace(f.Extension, ".jpg"), _ + Imaging.ImageFormat.Jpeg) + gPhoto.Dispose() + cacheDestination.Dispose() + Catch ex As Exception + log.Errors(ex.Message) + End Try + End Sub + + Private Sub TakePhoto() + If BoothState = PhotoBoothState.Ready Then + BoothState = PhotoBoothState.Working + log.Info("Take photo") + + 'Toggle the stop and go LEDs on the input device + input.Write("g") + input.Write("R") + + 'Clear the display + picBox.Image = Nothing + lblCounterMessage.Text = String.Empty + tlpFilmstrip.Visible = False + + 'Give the application some time to fully clear the image from the screen before flashing the wait message + My.Application.DoEvents() + + 'Display a "Get Ready" message + messageDock.Visible = True + messagePanel.FlashMessage(My.Settings.WaitMessage) + + 'Call the camera control application + Shell(My.Settings.CameraControlEXE) + End If + End Sub + + Public Sub New() + ' This call is required by the Windows Form Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + SetStyle(ControlStyles.SupportsTransparentBackColor, True) + End Sub + + Private Sub fsWatcher_Changed(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles fsWatcher.Changed, fsWatcher.Created + If Not photos.Contains(e.Name) Then + log.Info("New photo found in the watched folder") + photos.Add(e.Name, e.Name) + + ShowNewPicture(My.Settings.WatchFolder & "\" & e.Name) + + CycleFilmStrip() + + 'Update the counter message + lblCounterMessage.Text = String.Format(My.Settings.CounterMessage, photos.Count) + + My.Application.DoEvents() + + 'Toggle the stop and go LEDs on the input device + input.Write("r") + input.Write("G") + + 'The booth is ready to take more photos + BoothState = PhotoBoothState.Ready + End If + End Sub + + Private Sub DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) + Dim newResponse As Integer = input.ReadChar + Select Case newResponse + Case 66 + log.Info("Button pushed") + Me.Invoke(New TakePhotoDelegate(AddressOf TakePhoto), New Object() {}) + Case 80 + log.Info("Pedal pushed") + Me.Invoke(New TakePhotoDelegate(AddressOf TakePhoto), New Object() {}) + Case Else + log.Info("Board responsed with " & Chr(newResponse)) + End Select + End Sub +End Class diff --git a/PhotoBooth/My Project/Application.Designer.vb b/PhotoBooth/My Project/Application.Designer.vb new file mode 100644 index 0000000..56c6d21 --- /dev/null +++ b/PhotoBooth/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + 'NOTE: This file is auto-generated; do not modify it directly. To make changes, + ' or if you encounter build errors in this file, go to the Project Designer + ' (go to Project Properties or double-click the My Project node in + ' Solution Explorer), and make changes on the Application tab. + ' + Partial Friend Class MyApplication + + _ + Public Sub New() + MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) + Me.IsSingleInstance = true + Me.EnableVisualStyles = true + Me.SaveMySettingsOnExit = true + Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses + End Sub + + _ + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = Global.PhotoBooth.Main + End Sub + End Class +End Namespace diff --git a/PhotoBooth/My Project/Application.myapp b/PhotoBooth/My Project/Application.myapp new file mode 100644 index 0000000..6a1b2fa --- /dev/null +++ b/PhotoBooth/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + Main + true + 0 + true + 0 + true + \ No newline at end of file diff --git a/PhotoBooth/My Project/AssemblyInfo.vb b/PhotoBooth/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..0912f50 --- /dev/null +++ b/PhotoBooth/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' 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. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' 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: +' + + + diff --git a/PhotoBooth/My Project/Resources.Designer.vb b/PhotoBooth/My Project/Resources.Designer.vb new file mode 100644 index 0000000..7e2b95b --- /dev/null +++ b/PhotoBooth/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Imports System + +Namespace My.Resources + + '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. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("PhotoBooth.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/PhotoBooth/My Project/Resources.resx b/PhotoBooth/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/PhotoBooth/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PhotoBooth/My Project/Settings.Designer.vb b/PhotoBooth/My Project/Settings.Designer.vb new file mode 100644 index 0000000..764640a --- /dev/null +++ b/PhotoBooth/My Project/Settings.Designer.vb @@ -0,0 +1,169 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.3082 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings),MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + + _ + Public Property WatchFolder() As String + Get + Return CType(Me("WatchFolder"),String) + End Get + Set + Me("WatchFolder") = value + End Set + End Property + + _ + Public Property CameraControlEXE() As String + Get + Return CType(Me("CameraControlEXE"),String) + End Get + Set + Me("CameraControlEXE") = value + End Set + End Property + + _ + Public Property MessageDuration() As Decimal + Get + Return CType(Me("MessageDuration"),Decimal) + End Get + Set + Me("MessageDuration") = value + End Set + End Property + + _ + Public Property COMPort() As String + Get + Return CType(Me("COMPort"),String) + End Get + Set + Me("COMPort") = value + End Set + End Property + + _ + Public Property WaitMessage() As String + Get + Return CType(Me("WaitMessage"),String) + End Get + Set + Me("WaitMessage") = value + End Set + End Property + + _ + Public Property ImageCache() As String + Get + Return CType(Me("ImageCache"),String) + End Get + Set + Me("ImageCache") = value + End Set + End Property + + _ + Public Property MessageFont() As Global.System.Drawing.Font + Get + Return CType(Me("MessageFont"),Global.System.Drawing.Font) + End Get + Set + Me("MessageFont") = value + End Set + End Property + + _ + Public Property CounterMessage() As String + Get + Return CType(Me("CounterMessage"),String) + End Get + Set + Me("CounterMessage") = value + End Set + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.PhotoBooth.My.MySettings + Get + Return Global.PhotoBooth.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/PhotoBooth/My Project/Settings.settings b/PhotoBooth/My Project/Settings.settings new file mode 100644 index 0000000..26b71f1 --- /dev/null +++ b/PhotoBooth/My Project/Settings.settings @@ -0,0 +1,30 @@ + + + + + + + + + + + + 2.5 + + + COM1 + + + Prepare for automagic + + + + + + Arial Black, 18pt + + + {0} kinds of automagic + + + \ No newline at end of file diff --git a/PhotoBooth/Options.Designer.vb b/PhotoBooth/Options.Designer.vb new file mode 100644 index 0000000..f69fc20 --- /dev/null +++ b/PhotoBooth/Options.Designer.vb @@ -0,0 +1,389 @@ + _ +Partial Class Options + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel + Me.OK_Button = New System.Windows.Forms.Button + Me.Cancel_Button = New System.Windows.Forms.Button + Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog + Me.lblCaption = New System.Windows.Forms.Label + Me.Button1 = New System.Windows.Forms.Button + Me.Button2 = New System.Windows.Forms.Button + Me.Label1 = New System.Windows.Forms.Label + Me.FolderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog + Me.Label2 = New System.Windows.Forms.Label + Me.Label3 = New System.Windows.Forms.Label + Me.Label4 = New System.Windows.Forms.Label + Me.Test = New System.Windows.Forms.Button + Me.TestMessage = New System.Windows.Forms.Label + Me.Label5 = New System.Windows.Forms.Label + Me.Button3 = New System.Windows.Forms.Button + Me.Label6 = New System.Windows.Forms.Label + Me.Label7 = New System.Windows.Forms.Label + Me.txtMessageFont = New System.Windows.Forms.TextBox + Me.FontDialog1 = New System.Windows.Forms.FontDialog + Me.Button4 = New System.Windows.Forms.Button + Me.lblVersion = New System.Windows.Forms.Label + Me.txtImageCachePath = New System.Windows.Forms.TextBox + Me.txtWaitMessage = New System.Windows.Forms.TextBox + Me.COMPorts = New System.Windows.Forms.ComboBox + Me.MessageDuration = New System.Windows.Forms.NumericUpDown + Me.txtWatchPath = New System.Windows.Forms.TextBox + Me.txtCamControlPath = New System.Windows.Forms.TextBox + Me.Label8 = New System.Windows.Forms.Label + Me.TextBox1 = New System.Windows.Forms.TextBox + Me.TableLayoutPanel1.SuspendLayout() + CType(Me.MessageDuration, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'TableLayoutPanel1 + ' + Me.TableLayoutPanel1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.TableLayoutPanel1.ColumnCount = 2 + Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) + Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) + Me.TableLayoutPanel1.Controls.Add(Me.OK_Button, 0, 0) + Me.TableLayoutPanel1.Controls.Add(Me.Cancel_Button, 1, 0) + Me.TableLayoutPanel1.Location = New System.Drawing.Point(277, 351) + Me.TableLayoutPanel1.Name = "TableLayoutPanel1" + Me.TableLayoutPanel1.RowCount = 1 + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) + Me.TableLayoutPanel1.Size = New System.Drawing.Size(146, 29) + Me.TableLayoutPanel1.TabIndex = 0 + ' + 'OK_Button + ' + Me.OK_Button.Anchor = System.Windows.Forms.AnchorStyles.None + Me.OK_Button.Location = New System.Drawing.Point(3, 3) + Me.OK_Button.Name = "OK_Button" + Me.OK_Button.Size = New System.Drawing.Size(67, 23) + Me.OK_Button.TabIndex = 0 + Me.OK_Button.Text = "OK" + ' + 'Cancel_Button + ' + Me.Cancel_Button.Anchor = System.Windows.Forms.AnchorStyles.None + Me.Cancel_Button.DialogResult = System.Windows.Forms.DialogResult.Cancel + Me.Cancel_Button.Location = New System.Drawing.Point(76, 3) + Me.Cancel_Button.Name = "Cancel_Button" + Me.Cancel_Button.Size = New System.Drawing.Size(67, 23) + Me.Cancel_Button.TabIndex = 1 + Me.Cancel_Button.Text = "Cancel" + ' + 'OpenFileDialog1 + ' + Me.OpenFileDialog1.FileName = "OpenFileDialog1" + ' + 'lblCaption + ' + Me.lblCaption.AutoSize = True + Me.lblCaption.Location = New System.Drawing.Point(9, 9) + Me.lblCaption.Name = "lblCaption" + Me.lblCaption.Size = New System.Drawing.Size(175, 13) + Me.lblCaption.TabIndex = 1 + Me.lblCaption.Text = "Camera control application location:" + ' + 'Button1 + ' + Me.Button1.Location = New System.Drawing.Point(394, 25) + Me.Button1.Name = "Button1" + Me.Button1.Size = New System.Drawing.Size(26, 20) + Me.Button1.TabIndex = 3 + Me.Button1.Text = "..." + Me.Button1.UseVisualStyleBackColor = True + ' + 'Button2 + ' + Me.Button2.Location = New System.Drawing.Point(394, 68) + Me.Button2.Name = "Button2" + Me.Button2.Size = New System.Drawing.Size(26, 20) + Me.Button2.TabIndex = 6 + Me.Button2.Text = "..." + Me.Button2.UseVisualStyleBackColor = True + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(9, 52) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(79, 13) + Me.Label1.TabIndex = 4 + Me.Label1.Text = "Image location:" + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Location = New System.Drawing.Point(9, 228) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(191, 13) + Me.Label2.TabIndex = 14 + Me.Label2.Text = "Show message while taking picture for:" + ' + 'Label3 + ' + Me.Label3.AutoSize = True + Me.Label3.Location = New System.Drawing.Point(65, 246) + Me.Label3.Name = "Label3" + Me.Label3.Size = New System.Drawing.Size(47, 13) + Me.Label3.TabIndex = 16 + Me.Label3.Text = "seconds" + ' + 'Label4 + ' + Me.Label4.AutoSize = True + Me.Label4.Location = New System.Drawing.Point(9, 271) + Me.Label4.Name = "Label4" + Me.Label4.Size = New System.Drawing.Size(140, 13) + Me.Label4.TabIndex = 17 + Me.Label4.Text = "COM port for camera trigger:" + ' + 'Test + ' + Me.Test.Location = New System.Drawing.Point(87, 287) + Me.Test.Name = "Test" + Me.Test.Size = New System.Drawing.Size(48, 21) + Me.Test.TabIndex = 19 + Me.Test.Text = "Test" + Me.Test.UseVisualStyleBackColor = True + ' + 'TestMessage + ' + Me.TestMessage.AutoSize = True + Me.TestMessage.Location = New System.Drawing.Point(141, 291) + Me.TestMessage.Name = "TestMessage" + Me.TestMessage.Size = New System.Drawing.Size(77, 13) + Me.TestMessage.TabIndex = 20 + Me.TestMessage.Text = "Opening port..." + Me.TestMessage.Visible = False + ' + 'Label5 + ' + Me.Label5.AutoSize = True + Me.Label5.Location = New System.Drawing.Point(9, 138) + Me.Label5.Name = "Label5" + Me.Label5.Size = New System.Drawing.Size(77, 13) + Me.Label5.TabIndex = 9 + Me.Label5.Text = "Wait message:" + ' + 'Button3 + ' + Me.Button3.Location = New System.Drawing.Point(394, 111) + Me.Button3.Name = "Button3" + Me.Button3.Size = New System.Drawing.Size(26, 20) + Me.Button3.TabIndex = 8 + Me.Button3.Text = "..." + Me.Button3.UseVisualStyleBackColor = True + ' + 'Label6 + ' + Me.Label6.AutoSize = True + Me.Label6.Location = New System.Drawing.Point(9, 95) + Me.Label6.Name = "Label6" + Me.Label6.Size = New System.Drawing.Size(112, 13) + Me.Label6.TabIndex = 6 + Me.Label6.Text = "Image cache location:" + ' + 'Label7 + ' + Me.Label7.AutoSize = True + Me.Label7.Location = New System.Drawing.Point(241, 138) + Me.Label7.Name = "Label7" + Me.Label7.Size = New System.Drawing.Size(31, 13) + Me.Label7.TabIndex = 21 + Me.Label7.Text = "Font:" + ' + 'txtMessageFont + ' + Me.txtMessageFont.Enabled = False + Me.txtMessageFont.Location = New System.Drawing.Point(244, 154) + Me.txtMessageFont.Name = "txtMessageFont" + Me.txtMessageFont.Size = New System.Drawing.Size(144, 20) + Me.txtMessageFont.TabIndex = 12 + ' + 'Button4 + ' + Me.Button4.Location = New System.Drawing.Point(394, 154) + Me.Button4.Name = "Button4" + Me.Button4.Size = New System.Drawing.Size(26, 20) + Me.Button4.TabIndex = 13 + Me.Button4.Text = "..." + Me.Button4.UseVisualStyleBackColor = True + ' + 'lblVersion + ' + Me.lblVersion.AutoSize = True + Me.lblVersion.Location = New System.Drawing.Point(12, 364) + Me.lblVersion.Name = "lblVersion" + Me.lblVersion.Size = New System.Drawing.Size(42, 13) + Me.lblVersion.TabIndex = 22 + Me.lblVersion.Text = "Version" + ' + 'txtImageCachePath + ' + Me.txtImageCachePath.DataBindings.Add(New System.Windows.Forms.Binding("Text", Global.PhotoBooth.My.MySettings.Default, "ImageCache", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)) + Me.txtImageCachePath.Location = New System.Drawing.Point(12, 111) + Me.txtImageCachePath.Name = "txtImageCachePath" + Me.txtImageCachePath.Size = New System.Drawing.Size(376, 20) + Me.txtImageCachePath.TabIndex = 7 + Me.txtImageCachePath.Text = Global.PhotoBooth.My.MySettings.Default.ImageCache + ' + 'txtWaitMessage + ' + Me.txtWaitMessage.DataBindings.Add(New System.Windows.Forms.Binding("Text", Global.PhotoBooth.My.MySettings.Default, "WaitMessage", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)) + Me.txtWaitMessage.Location = New System.Drawing.Point(12, 154) + Me.txtWaitMessage.Name = "txtWaitMessage" + Me.txtWaitMessage.Size = New System.Drawing.Size(226, 20) + Me.txtWaitMessage.TabIndex = 10 + Me.txtWaitMessage.Text = Global.PhotoBooth.My.MySettings.Default.WaitMessage + ' + 'COMPorts + ' + Me.COMPorts.DataBindings.Add(New System.Windows.Forms.Binding("Text", Global.PhotoBooth.My.MySettings.Default, "COMPort", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)) + Me.COMPorts.FormattingEnabled = True + Me.COMPorts.Location = New System.Drawing.Point(12, 287) + Me.COMPorts.Name = "COMPorts" + Me.COMPorts.Size = New System.Drawing.Size(69, 21) + Me.COMPorts.TabIndex = 18 + Me.COMPorts.Text = Global.PhotoBooth.My.MySettings.Default.COMPort + ' + 'MessageDuration + ' + Me.MessageDuration.DataBindings.Add(New System.Windows.Forms.Binding("Value", Global.PhotoBooth.My.MySettings.Default, "MessageDuration", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)) + Me.MessageDuration.DecimalPlaces = 1 + Me.MessageDuration.Increment = New Decimal(New Integer() {5, 0, 0, 65536}) + Me.MessageDuration.Location = New System.Drawing.Point(12, 244) + Me.MessageDuration.Name = "MessageDuration" + Me.MessageDuration.Size = New System.Drawing.Size(47, 20) + Me.MessageDuration.TabIndex = 15 + Me.MessageDuration.Value = Global.PhotoBooth.My.MySettings.Default.MessageDuration + ' + 'txtWatchPath + ' + Me.txtWatchPath.DataBindings.Add(New System.Windows.Forms.Binding("Text", Global.PhotoBooth.My.MySettings.Default, "WatchFolder", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)) + Me.txtWatchPath.Location = New System.Drawing.Point(12, 68) + Me.txtWatchPath.Name = "txtWatchPath" + Me.txtWatchPath.Size = New System.Drawing.Size(376, 20) + Me.txtWatchPath.TabIndex = 5 + Me.txtWatchPath.Text = Global.PhotoBooth.My.MySettings.Default.WatchFolder + ' + 'txtCamControlPath + ' + Me.txtCamControlPath.DataBindings.Add(New System.Windows.Forms.Binding("Text", Global.PhotoBooth.My.MySettings.Default, "CameraControlEXE", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)) + Me.txtCamControlPath.Location = New System.Drawing.Point(12, 25) + Me.txtCamControlPath.Name = "txtCamControlPath" + Me.txtCamControlPath.Size = New System.Drawing.Size(376, 20) + Me.txtCamControlPath.TabIndex = 2 + Me.txtCamControlPath.Text = Global.PhotoBooth.My.MySettings.Default.CameraControlEXE + ' + 'Label8 + ' + Me.Label8.AutoSize = True + Me.Label8.Location = New System.Drawing.Point(9, 183) + Me.Label8.Name = "Label8" + Me.Label8.Size = New System.Drawing.Size(92, 13) + Me.Label8.TabIndex = 23 + Me.Label8.Text = "Counter message:" + ' + 'TextBox1 + ' + Me.TextBox1.DataBindings.Add(New System.Windows.Forms.Binding("Text", Global.PhotoBooth.My.MySettings.Default, "CounterMessage", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)) + Me.TextBox1.Location = New System.Drawing.Point(12, 199) + Me.TextBox1.Name = "TextBox1" + Me.TextBox1.Size = New System.Drawing.Size(376, 20) + Me.TextBox1.TabIndex = 24 + Me.TextBox1.Text = Global.PhotoBooth.My.MySettings.Default.CounterMessage + ' + 'Options + ' + Me.AcceptButton = Me.OK_Button + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.CancelButton = Me.Cancel_Button + Me.ClientSize = New System.Drawing.Size(435, 392) + Me.Controls.Add(Me.Label8) + Me.Controls.Add(Me.TextBox1) + Me.Controls.Add(Me.lblVersion) + Me.Controls.Add(Me.Button4) + Me.Controls.Add(Me.txtMessageFont) + Me.Controls.Add(Me.Label7) + Me.Controls.Add(Me.Button3) + Me.Controls.Add(Me.Label6) + Me.Controls.Add(Me.txtImageCachePath) + Me.Controls.Add(Me.Label5) + Me.Controls.Add(Me.txtWaitMessage) + Me.Controls.Add(Me.TestMessage) + Me.Controls.Add(Me.Test) + Me.Controls.Add(Me.COMPorts) + Me.Controls.Add(Me.Label4) + Me.Controls.Add(Me.Label3) + Me.Controls.Add(Me.MessageDuration) + Me.Controls.Add(Me.Label2) + Me.Controls.Add(Me.Button2) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.txtWatchPath) + Me.Controls.Add(Me.Button1) + Me.Controls.Add(Me.lblCaption) + Me.Controls.Add(Me.txtCamControlPath) + Me.Controls.Add(Me.TableLayoutPanel1) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "Options" + Me.ShowInTaskbar = False + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent + Me.Text = "Options" + Me.TableLayoutPanel1.ResumeLayout(False) + CType(Me.MessageDuration, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents TableLayoutPanel1 As System.Windows.Forms.TableLayoutPanel + Friend WithEvents OK_Button As System.Windows.Forms.Button + Friend WithEvents Cancel_Button As System.Windows.Forms.Button + Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog + Friend WithEvents txtCamControlPath As System.Windows.Forms.TextBox + Friend WithEvents lblCaption As System.Windows.Forms.Label + Friend WithEvents Button1 As System.Windows.Forms.Button + Friend WithEvents Button2 As System.Windows.Forms.Button + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents txtWatchPath As System.Windows.Forms.TextBox + Friend WithEvents FolderBrowserDialog1 As System.Windows.Forms.FolderBrowserDialog + Friend WithEvents Label2 As System.Windows.Forms.Label + Friend WithEvents MessageDuration As System.Windows.Forms.NumericUpDown + Friend WithEvents Label3 As System.Windows.Forms.Label + Friend WithEvents Label4 As System.Windows.Forms.Label + Friend WithEvents COMPorts As System.Windows.Forms.ComboBox + Friend WithEvents Test As System.Windows.Forms.Button + Friend WithEvents TestMessage As System.Windows.Forms.Label + Friend WithEvents Label5 As System.Windows.Forms.Label + Friend WithEvents txtWaitMessage As System.Windows.Forms.TextBox + Friend WithEvents Button3 As System.Windows.Forms.Button + Friend WithEvents Label6 As System.Windows.Forms.Label + Friend WithEvents txtImageCachePath As System.Windows.Forms.TextBox + Friend WithEvents Label7 As System.Windows.Forms.Label + Friend WithEvents txtMessageFont As System.Windows.Forms.TextBox + Friend WithEvents FontDialog1 As System.Windows.Forms.FontDialog + Friend WithEvents Button4 As System.Windows.Forms.Button + Friend WithEvents lblVersion As System.Windows.Forms.Label + Friend WithEvents Label8 As System.Windows.Forms.Label + Friend WithEvents TextBox1 As System.Windows.Forms.TextBox + +End Class diff --git a/PhotoBooth/Options.resx b/PhotoBooth/Options.resx new file mode 100644 index 0000000..44ec443 --- /dev/null +++ b/PhotoBooth/Options.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 149, 17 + + + 309, 17 + + \ No newline at end of file diff --git a/PhotoBooth/Options.vb b/PhotoBooth/Options.vb new file mode 100644 index 0000000..1c2412e --- /dev/null +++ b/PhotoBooth/Options.vb @@ -0,0 +1,146 @@ +Imports System.Windows.Forms +Imports System.IO.Ports + +Public Class Options + + Private dataAvailable As Boolean = False + + Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click + Me.DialogResult = System.Windows.Forms.DialogResult.OK + Me.Close() + End Sub + + Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click + Me.DialogResult = System.Windows.Forms.DialogResult.Cancel + Me.Close() + End Sub + + Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click, Button3.Click + If FolderBrowserDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then + If sender.Equals(Button2) Then + txtWatchPath.Text = FolderBrowserDialog1.SelectedPath + ElseIf sender.Equals(Button3) Then + txtImageCachePath.Text = FolderBrowserDialog1.SelectedPath + End If + End If + End Sub + + Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click + If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then + txtCamControlPath.Text = OpenFileDialog1.FileName + End If + End Sub + + Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click + If FontDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then + My.Settings.MessageFont = FontDialog1.Font + txtMessageFont.Text = String.Format("{0}, {1}pt", _ + My.Settings.MessageFont.FontFamily.Name, _ + My.Settings.MessageFont.SizeInPoints) + End If + End Sub + + Private Sub Options_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + 'Fill the COM combobox with a list of the available ports + COMPorts.Items.Clear() + For Each s As String In System.IO.Ports.SerialPort.GetPortNames + COMPorts.Items.Add(s) + Next + + 'Disable the COM port Test button if there are no ports in the combobox + Test.Enabled = (COMPorts.Text <> String.Empty) + + 'Display the message font info + FontDialog1.Font = My.Settings.MessageFont + txtMessageFont.Text = String.Format("{0}, {1}pt", _ + My.Settings.MessageFont.FontFamily.Name, _ + My.Settings.MessageFont.SizeInPoints) + + lblVersion.Text = "Version " & My.Application.Info.Version.ToString + End Sub + + Private Sub Test_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Test.Click + 'Test the selected COM + Const TIME_OUT = 30000 + Dim testPort As SerialPort + Dim testResults As Boolean = False + + Test.Enabled = False + + 'Start showing status messages + TestMessage.Text = String.Empty + TestMessage.Visible = True + + Try + 'Create the port + testPort = New SerialPort(COMPorts.Text, 9600, Parity.None, 8) + + 'Bind to a function to handle receive the test data + AddHandler testPort.DataReceived, AddressOf ReceivePortData + + 'Open the port + If testPort.IsOpen Then + testPort.Close() + End If + TestMessage.Text = "Attempting to open the port..." + TestMessage.Update() + testPort.Open() + TestMessage.Text = "Successfully opened the port" + TestMessage.Update() + + 'Send a predetermined message to the device + TestMessage.Text = "Sending message to the port..." + TestMessage.Update() + testPort.Write("T") 'TODO: Determine what the "handshake" is going to be + TestMessage.Text = "Successfully sent a message to the port" + TestMessage.Update() + + 'Wait up to 30 seconds for a known response + TestMessage.Text = "Waiting for response message..." + TestMessage.Update() + 'Wait for a response + Dim sw As New Stopwatch() + sw.Start() + Do While sw.ElapsedMilliseconds < TIME_OUT + If dataAvailable Then + If testPort.ReadChar = Asc("T") Then + testResults = True + Exit Do + Else + 'We did not receive the expected response + dataAvailable = False + End If + End If + Loop + sw.Stop() + If testResults Then + TestMessage.Text = "Successfully received the expected response" + Else + TestMessage.Text = "Did not receive the expected response" + End If + TestMessage.Update() + + 'Remove the binding to the receive function + RemoveHandler testPort.DataReceived, AddressOf ReceivePortData + + 'Close the port + TestMessage.Text = "Attempting to close the port..." + TestMessage.Update() + testPort.Close() + TestMessage.Text = "Successfully closed the port" + TestMessage.Update() + + + Catch ex As Exception + 'TODO: Report the COM port testing exceptions + Finally + Test.Enabled = True + 'TODO: Use a flag to display the correct message + TestMessage.Text = "Successfully located the camera trigger on port " & COMPorts.Text + End Try + End Sub + + Private Sub ReceivePortData(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) + dataAvailable = True + End Sub +End Class diff --git a/PhotoBooth/PhotoBooth.sln b/PhotoBooth/PhotoBooth.sln new file mode 100644 index 0000000..1022e84 --- /dev/null +++ b/PhotoBooth/PhotoBooth.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "PhotoBooth", "PhotoBooth.vbproj", "{AC8A0784-DCCF-4401-ABC6-D3DD9EC5229E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AC8A0784-DCCF-4401-ABC6-D3DD9EC5229E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AC8A0784-DCCF-4401-ABC6-D3DD9EC5229E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC8A0784-DCCF-4401-ABC6-D3DD9EC5229E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AC8A0784-DCCF-4401-ABC6-D3DD9EC5229E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/PhotoBooth/PhotoBooth.vbproj b/PhotoBooth/PhotoBooth.vbproj new file mode 100644 index 0000000..ccab0c1 --- /dev/null +++ b/PhotoBooth/PhotoBooth.vbproj @@ -0,0 +1,165 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {AC8A0784-DCCF-4401-ABC6-D3DD9EC5229E} + WinExe + PhotoBooth.My.MyApplication + PhotoBooth + PhotoBooth + WindowsForms + 3F776960A0BCDCED64ED2096E0D7C499E5EDD594 + PhotoBooth_TemporaryKey.pfx + true + true + false + D:\programming\PhotoBooth\Deploy\PhotoBooth\ + true + Disk + false + Foreground + 7 + Days + false + false + true + false + false + 1.0.0.%2a + true + + + true + full + true + true + bin\Debug\ + PhotoBooth.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + PhotoBooth.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + + + + + + + + + Debugger.vb + + + Form + + + + Form + + + Main.vb + Form + + + Component + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + Options.vb + + + Form + + + + Usage.vb + + + Form + + + + + Designer + Debugger.vb + + + Designer + Main.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + Designer + Options.vb + + + Designer + Usage.vb + + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + + False + .NET Framework 2.0 + true + + + + + \ No newline at end of file diff --git a/PhotoBooth/Settings.vb b/PhotoBooth/Settings.vb new file mode 100644 index 0000000..94ac0c7 --- /dev/null +++ b/PhotoBooth/Settings.vb @@ -0,0 +1,11 @@ + +Namespace My + + 'This class allows you to handle specific events on the settings class: + ' The SettingChanging event is raised before a setting's value is changed. + ' The PropertyChanged event is raised after a setting's value is changed. + ' The SettingsLoaded event is raised after the setting values are loaded. + ' The SettingsSaving event is raised before the setting values are saved. + Partial Friend NotInheritable Class MySettings + End Class +End Namespace diff --git a/PhotoBooth/Usage.Designer.vb b/PhotoBooth/Usage.Designer.vb new file mode 100644 index 0000000..8c31307 --- /dev/null +++ b/PhotoBooth/Usage.Designer.vb @@ -0,0 +1,265 @@ + _ +Partial Class Usage + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.Label1 = New System.Windows.Forms.Label + Me.Label2 = New System.Windows.Forms.Label + Me.Label3 = New System.Windows.Forms.Label + Me.Label5 = New System.Windows.Forms.Label + Me.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel + Me.Label15 = New System.Windows.Forms.Label + Me.Label12 = New System.Windows.Forms.Label + Me.Label11 = New System.Windows.Forms.Label + Me.Label4 = New System.Windows.Forms.Label + Me.Label10 = New System.Windows.Forms.Label + Me.Label9 = New System.Windows.Forms.Label + Me.Label8 = New System.Windows.Forms.Label + Me.Label6 = New System.Windows.Forms.Label + Me.Label7 = New System.Windows.Forms.Label + Me.Label13 = New System.Windows.Forms.Label + Me.Label14 = New System.Windows.Forms.Label + Me.Label16 = New System.Windows.Forms.Label + Me.TableLayoutPanel1.SuspendLayout() + Me.SuspendLayout() + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(3, 0) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(183, 14) + Me.Label1.TabIndex = 0 + Me.Label1.Text = "Start/stop the photo booth:" + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Location = New System.Drawing.Point(3, 50) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(258, 14) + Me.Label2.TabIndex = 1 + Me.Label2.Text = "Toggle full screen and windowed mode:" + ' + 'Label3 + ' + Me.Label3.AutoSize = True + Me.Label3.Location = New System.Drawing.Point(3, 25) + Me.Label3.Name = "Label3" + Me.Label3.Size = New System.Drawing.Size(61, 14) + Me.Label3.TabIndex = 2 + Me.Label3.Text = "Options:" + ' + 'Label5 + ' + Me.Label5.AutoSize = True + Me.Label5.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label5.ForeColor = System.Drawing.Color.White + Me.Label5.Location = New System.Drawing.Point(37, 30) + Me.Label5.Name = "Label5" + Me.Label5.Size = New System.Drawing.Size(85, 14) + Me.Label5.TabIndex = 4 + Me.Label5.Text = "Photo Booth" + ' + 'TableLayoutPanel1 + ' + Me.TableLayoutPanel1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.TableLayoutPanel1.ColumnCount = 2 + Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 68.32669!)) + Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 31.67331!)) + Me.TableLayoutPanel1.Controls.Add(Me.Label15, 1, 5) + Me.TableLayoutPanel1.Controls.Add(Me.Label12, 1, 4) + Me.TableLayoutPanel1.Controls.Add(Me.Label11, 1, 3) + Me.TableLayoutPanel1.Controls.Add(Me.Label4, 0, 6) + Me.TableLayoutPanel1.Controls.Add(Me.Label10, 1, 2) + Me.TableLayoutPanel1.Controls.Add(Me.Label9, 1, 1) + Me.TableLayoutPanel1.Controls.Add(Me.Label1, 0, 0) + Me.TableLayoutPanel1.Controls.Add(Me.Label3, 0, 1) + Me.TableLayoutPanel1.Controls.Add(Me.Label8, 1, 0) + Me.TableLayoutPanel1.Controls.Add(Me.Label2, 0, 2) + Me.TableLayoutPanel1.Controls.Add(Me.Label6, 0, 3) + Me.TableLayoutPanel1.Controls.Add(Me.Label7, 0, 4) + Me.TableLayoutPanel1.Controls.Add(Me.Label13, 1, 6) + Me.TableLayoutPanel1.Controls.Add(Me.Label14, 0, 5) + Me.TableLayoutPanel1.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.TableLayoutPanel1.ForeColor = System.Drawing.Color.White + Me.TableLayoutPanel1.Location = New System.Drawing.Point(34, 72) + Me.TableLayoutPanel1.Margin = New System.Windows.Forms.Padding(25) + Me.TableLayoutPanel1.Name = "TableLayoutPanel1" + Me.TableLayoutPanel1.RowCount = 7 + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25.0!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25.0!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25.0!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25.0!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25.0!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25.0!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25.0!)) + Me.TableLayoutPanel1.Size = New System.Drawing.Size(447, 193) + Me.TableLayoutPanel1.TabIndex = 5 + ' + 'Label15 + ' + Me.Label15.AutoSize = True + Me.Label15.Location = New System.Drawing.Point(308, 125) + Me.Label15.Name = "Label15" + Me.Label15.Size = New System.Drawing.Size(16, 14) + Me.Label15.TabIndex = 13 + Me.Label15.Text = "U" + ' + 'Label12 + ' + Me.Label12.AutoSize = True + Me.Label12.Location = New System.Drawing.Point(308, 100) + Me.Label12.Name = "Label12" + Me.Label12.Size = New System.Drawing.Size(14, 14) + Me.Label12.TabIndex = 10 + Me.Label12.Text = "T" + ' + 'Label11 + ' + Me.Label11.AutoSize = True + Me.Label11.Location = New System.Drawing.Point(308, 75) + Me.Label11.Name = "Label11" + Me.Label11.Size = New System.Drawing.Size(16, 14) + Me.Label11.TabIndex = 9 + Me.Label11.Text = "D" + ' + 'Label4 + ' + Me.Label4.AutoSize = True + Me.Label4.Location = New System.Drawing.Point(3, 150) + Me.Label4.Name = "Label4" + Me.Label4.Size = New System.Drawing.Size(35, 14) + Me.Label4.TabIndex = 3 + Me.Label4.Text = "Exit:" + ' + 'Label10 + ' + Me.Label10.AutoSize = True + Me.Label10.Location = New System.Drawing.Point(308, 50) + Me.Label10.Name = "Label10" + Me.Label10.Size = New System.Drawing.Size(78, 14) + Me.Label10.TabIndex = 8 + Me.Label10.Text = "Page down" + ' + 'Label9 + ' + Me.Label9.AutoSize = True + Me.Label9.Location = New System.Drawing.Point(308, 25) + Me.Label9.Name = "Label9" + Me.Label9.Size = New System.Drawing.Size(17, 14) + Me.Label9.TabIndex = 7 + Me.Label9.Text = "O" + ' + 'Label8 + ' + Me.Label8.AutoSize = True + Me.Label8.Location = New System.Drawing.Point(308, 0) + Me.Label8.Name = "Label8" + Me.Label8.Size = New System.Drawing.Size(15, 14) + Me.Label8.TabIndex = 6 + Me.Label8.Text = "S" + ' + 'Label6 + ' + Me.Label6.AutoSize = True + Me.Label6.Location = New System.Drawing.Point(3, 75) + Me.Label6.Name = "Label6" + Me.Label6.Size = New System.Drawing.Size(144, 14) + Me.Label6.TabIndex = 4 + Me.Label6.Text = "Show debug window:" + ' + 'Label7 + ' + Me.Label7.AutoSize = True + Me.Label7.Location = New System.Drawing.Point(3, 100) + Me.Label7.Name = "Label7" + Me.Label7.Size = New System.Drawing.Size(95, 14) + Me.Label7.TabIndex = 5 + Me.Label7.Text = "Take a photo:" + ' + 'Label13 + ' + Me.Label13.AutoSize = True + Me.Label13.Location = New System.Drawing.Point(308, 150) + Me.Label13.Name = "Label13" + Me.Label13.Size = New System.Drawing.Size(28, 14) + Me.Label13.TabIndex = 11 + Me.Label13.Text = "Esc" + ' + 'Label14 + ' + Me.Label14.AutoSize = True + Me.Label14.Location = New System.Drawing.Point(3, 125) + Me.Label14.Name = "Label14" + Me.Label14.Size = New System.Drawing.Size(113, 14) + Me.Label14.TabIndex = 12 + Me.Label14.Text = "Show this menu:" + ' + 'Label16 + ' + Me.Label16.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) + Me.Label16.AutoSize = True + Me.Label16.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label16.ForeColor = System.Drawing.Color.White + Me.Label16.Location = New System.Drawing.Point(37, 275) + Me.Label16.Name = "Label16" + Me.Label16.Size = New System.Drawing.Size(226, 14) + Me.Label16.TabIndex = 6 + Me.Label16.Text = "Press any key to close this menu..." + ' + 'Usage + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.BackColor = System.Drawing.Color.Black + Me.ClientSize = New System.Drawing.Size(515, 325) + Me.Controls.Add(Me.Label16) + Me.Controls.Add(Me.TableLayoutPanel1) + Me.Controls.Add(Me.Label5) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None + Me.Name = "Usage" + Me.ShowInTaskbar = False + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent + Me.Text = "Usage" + Me.TableLayoutPanel1.ResumeLayout(False) + Me.TableLayoutPanel1.PerformLayout() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents Label2 As System.Windows.Forms.Label + Friend WithEvents Label3 As System.Windows.Forms.Label + Friend WithEvents Label5 As System.Windows.Forms.Label + Friend WithEvents TableLayoutPanel1 As System.Windows.Forms.TableLayoutPanel + Friend WithEvents Label6 As System.Windows.Forms.Label + Friend WithEvents Label7 As System.Windows.Forms.Label + Friend WithEvents Label4 As System.Windows.Forms.Label + Friend WithEvents Label8 As System.Windows.Forms.Label + Friend WithEvents Label12 As System.Windows.Forms.Label + Friend WithEvents Label11 As System.Windows.Forms.Label + Friend WithEvents Label10 As System.Windows.Forms.Label + Friend WithEvents Label9 As System.Windows.Forms.Label + Friend WithEvents Label13 As System.Windows.Forms.Label + Friend WithEvents Label15 As System.Windows.Forms.Label + Friend WithEvents Label14 As System.Windows.Forms.Label + Friend WithEvents Label16 As System.Windows.Forms.Label +End Class diff --git a/PhotoBooth/Usage.resx b/PhotoBooth/Usage.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/PhotoBooth/Usage.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PhotoBooth/Usage.vb b/PhotoBooth/Usage.vb new file mode 100644 index 0000000..a6fc3d8 --- /dev/null +++ b/PhotoBooth/Usage.vb @@ -0,0 +1,30 @@ +Public Class Usage + + Private Sub Usage_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown + Me.Close() + End Sub + + Private Sub Usage_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load + Me.StartPosition = FormStartPosition.CenterParent + End Sub + + Private Sub Usage_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint + DrawFormBorder() + End Sub + + Private Sub DrawFormBorder() + ' Draw a thin border 10 pixels in on all sides + Const BORDER_MARGIN = 10 + + Dim myPen As New System.Drawing.Pen(System.Drawing.Color.White) + Dim formGraphics As System.Drawing.Graphics + + formGraphics = Me.CreateGraphics() + formGraphics.DrawRectangle(myPen, _ + BORDER_MARGIN, BORDER_MARGIN, _ + Me.Width - BORDER_MARGIN * 2, Me.Height - BORDER_MARGIN * 2) + + myPen.Dispose() + formGraphics.Dispose() + End Sub +End Class \ No newline at end of file diff --git a/PhotoBooth/app.config b/PhotoBooth/app.config new file mode 100644 index 0000000..24a1cf8 --- /dev/null +++ b/PhotoBooth/app.config @@ -0,0 +1,58 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2.5 + + + COM1 + + + Prepare for automagic + + + + + + Arial Black, 18pt + + + {0} kinds of automagic + + + + diff --git a/PhotoBooth_WIA/CountdownPanel.vb b/PhotoBooth_WIA/CountdownPanel.vb new file mode 100644 index 0000000..66074e6 --- /dev/null +++ b/PhotoBooth_WIA/CountdownPanel.vb @@ -0,0 +1,122 @@ +Imports System.Drawing.Imaging + +Public Class CountdownPanel + Inherits Panel + + Private A As Integer = 255 + Private msg As Bitmap + Private msgBackGround As Bitmap + Private _countDown As Integer + Private _duration As Integer = 3 + Private WithEvents _tmr As Timer + Private WithEvents _fadeTmr As Timer + + Public Event Complete(ByVal sender As Object, ByVal e As EventArgs) + + Public Sub New() + Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, True) + Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True) + + _tmr = New Timer + _tmr.Interval = 1000 + + 'Fade out the message in the first half second of the main timer interval + _fadeTmr = New Timer + _fadeTmr.Interval = 10 'The value is derived from this formula (_tmr.Interval/2)/(255/5) + End Sub + + Public Property Duration() As Integer + Get + Return _duration + End Get + Set(ByVal value As Integer) + _duration = value + End Set + End Property + + Public Sub Start() + _countDown = Duration + _tmr.Start() + Me.Visible = True + + MakeMessage(_countDown) + ShowMessage(A) + '_fadeTmr.Start() + End Sub + + Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles _tmr.Tick + _countDown -= 1 + If _countDown > 0 Then + MakeMessage(_countDown) + ShowMessage(A) + '_fadeTmr.Start() + Else + _tmr.Stop() + _countDown = Duration + Me.Visible = False + + RaiseEvent Complete(Me, Nothing) + End If + End Sub + + Private Sub _fadeTmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles _fadeTmr.Tick + A -= 5 + If A < 0 Then + A = 255 + _fadeTmr.Stop() + Else + ShowMessage(A) + End If + End Sub + + Private Sub ShowMessage(ByVal alpha As Byte) + Dim cm As ColorMatrix = New ColorMatrix(New Single()() _ + {New Single() {1, 0, 0, 0, 0}, _ + New Single() {0, 1, 0, 0, 0}, _ + New Single() {0, 0, 1, 0, 0}, _ + New Single() {0, 0, 0, (alpha / 255), 0}, _ + New Single() {0, 0, 0, 0, 1}}) + + Dim IA As New ImageAttributes + IA.SetColorMatrix(cm, ColorMatrixFlag.Default, ColorAdjustType.Bitmap) + + Dim tmp As New Bitmap(msgBackGround) + Dim G As Graphics = Graphics.FromImage(tmp) + G.DrawImage(msg, Me.ClientRectangle, 0, 0, Me.Width, Me.Height, GraphicsUnit.Pixel, IA) + G.Dispose() + IA.Dispose() + + Me.BackgroundImage = tmp + End Sub + + Private Sub MakeMessage(ByVal message As String) + If Me.IsHandleCreated Then + + Me.Visible = True + + msgBackGround = New Bitmap(Me.ClientRectangle.Width, Me.ClientRectangle.Height) + Dim g As Graphics = Graphics.FromImage(msgBackGround) + g.Clear(Me.BackColor) + g.Dispose() + + msg = New Bitmap(msgBackGround.Width, msgBackGround.Height) + g = Graphics.FromImage(msg) + g.Clear(Color.Transparent) + Dim sb As New SolidBrush(Me.ForeColor) + + 'Center the message on screen + Dim xPos As Single + xPos = (Me.Parent.Width - g.MeasureString(message, Me.Font).Width) / 2 + + Dim yPos As Single + yPos = (Me.Parent.Height - g.MeasureString(message, Me.Font).Height) / 2 + + g.DrawString(message, Me.Font, sb, xPos, yPos) + sb.Dispose() + g.Dispose() + + 'Reset the alpha value to full opacity + A = 255 + End If + End Sub +End Class diff --git a/PhotoBooth_WIA/Debugger.Designer.vb b/PhotoBooth_WIA/Debugger.Designer.vb new file mode 100644 index 0000000..ce96da2 --- /dev/null +++ b/PhotoBooth_WIA/Debugger.Designer.vb @@ -0,0 +1,49 @@ + _ +Partial Class Debugger + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.DebugMessages = New System.Windows.Forms.ListBox + Me.SuspendLayout() + ' + 'DebugMessages + ' + Me.DebugMessages.Dock = System.Windows.Forms.DockStyle.Fill + Me.DebugMessages.FormattingEnabled = True + Me.DebugMessages.IntegralHeight = False + Me.DebugMessages.Location = New System.Drawing.Point(0, 0) + Me.DebugMessages.Name = "DebugMessages" + Me.DebugMessages.Size = New System.Drawing.Size(441, 190) + Me.DebugMessages.TabIndex = 0 + ' + 'Debugger + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(441, 190) + Me.Controls.Add(Me.DebugMessages) + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "Debugger" + Me.Text = "Debug" + Me.ResumeLayout(False) + + End Sub + Friend WithEvents DebugMessages As System.Windows.Forms.ListBox +End Class diff --git a/PhotoBooth_WIA/Debugger.resx b/PhotoBooth_WIA/Debugger.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/PhotoBooth_WIA/Debugger.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PhotoBooth_WIA/Debugger.vb b/PhotoBooth_WIA/Debugger.vb new file mode 100644 index 0000000..7ba17c2 --- /dev/null +++ b/PhotoBooth_WIA/Debugger.vb @@ -0,0 +1,22 @@ +Public Class Debugger + Private WithEvents log As EZLogger + Private bm As BindingManagerBase + Private cm As CurrencyManager + + Private Sub log_Updated() Handles log.Updated + If (cm IsNot Nothing) Then + cm.Refresh() + End If + End Sub + + Public Sub BindLogToList(ByRef l As EZLogger) + log = l + + 'Bind the logger to the list box + DebugMessages.DataSource = log.Log + + 'Enable two-way binding + bm = DebugMessages.BindingContext(log.Log) + cm = bm + End Sub +End Class \ No newline at end of file diff --git a/PhotoBooth_WIA/EZLogger.vb b/PhotoBooth_WIA/EZLogger.vb new file mode 100644 index 0000000..4a386fa --- /dev/null +++ b/PhotoBooth_WIA/EZLogger.vb @@ -0,0 +1,408 @@ +Imports System +Imports System.IO + +Public Class EZLogger + + ''/// + ''/// An object that provides basic logging capabilities. + ''/// Copyright (c) 2006 Ravi Bhavnani, ravib@ravib.com + ''/// + ''/// This software may be freely used in any product or + ''/// work, provided this copyright notice is maintained. + ''/// To help ensure a single point of release, please + ''/// email and bug reports, flames and suggestions to + ''/// ravib@ravib.com. + ''/// + +#Region "Events" + Event Updated() +#End Region + +#Region "Attributes" + + ''/// + ''/// Log levels. + ''/// + Public Enum Level + ''/// Log debug messages. + Debug = 1 + + ''/// Log informational messages. + Info = 2 + + ''/// Log success messages. + Success = 4 + + ''/// Log warning messages. + Warning = 8 + + ''/// Log error messages. + Errors = 16 + + ''/// Log fatal errors. + Fatal = 32 + + ''/// Log all messages. + All = 65535 ' 0xFFFF + End Enum + + ''/// + ''/// The logger's state. + ''/// + Public Enum State + ''/// The logger is stopped. + Stopped = 0 + ''/// The logger has been started. + Running + ''/// The logger is paused. + Paused + End Enum + +#End Region + +#Region "Construction/destruction" + + ''/// + ''/// Constructs a EZLogger. + ''/// + ''/// Log file to receive output. + ''/// Flag: append to existing file (if any). + ''/// Flag: cache log in memory. + ''/// Mask indicating log levels of interest. + Public Sub New(ByVal logFilename As String, ByVal bAppend As Boolean, ByVal logLevels As UInteger, ByVal bCacheInMemory As Boolean) + _logFilename = logFilename + _bAppend = bAppend + _bCacheInMemory = bCacheInMemory + _levels = logLevels + + _logMem = New ArrayList + End Sub + + ''/// + ''/// Private default constructor. + ''/// + Private Sub New() + ' + End Sub +#End Region + +#Region "Properties" + + ''/// + ''/// Gets and sets the log level. + ''/// + Public Property Levels() As UInteger + Get + Return _levels + End Get + Set(ByVal value As UInteger) + _levels = value + End Set + End Property + + ''/// + ''/// Retrieves the logger's state. + ''/// + Public ReadOnly Property LoggerState() As State + Get + Return _state + End Get + End Property + + ''/// + ''/// Retrieves the log. + ''/// + Public ReadOnly Property Log() As ArrayList + Get + Return _logMem + End Get + End Property +#End Region + +#Region "Operations" + + ''/// + ''/// Starts logging. + ''/// + ''/// true if successful, false otherwise. + Public Function StartLog() As Boolean + SyncLock Me + '// Fail if logging has already been started + If LoggerState <> State.Stopped Then + Return False + End If + + '// Fail if the log file isn't specified + If String.IsNullOrEmpty(_logFilename) Then + Return False + End If + + '// Delete log file if it exists + If Not _bAppend Then + Try + File.Delete(_logFilename) + Catch ex As Exception + Return False + End Try + End If + + '// Open file for writing - return on error + If File.Exists(_logFilename) = False Then + Try + _logFile = File.CreateText(_logFilename) + Catch ex As Exception + _logFile = Nothing + Return False + End Try + Else + Try + _logFile = File.AppendText(_logFilename) + Catch ex As Exception + _logFile = Nothing + Return False + End Try + End If + + _logFile.AutoFlush = True + + '// Return successfully + _state = EZLogger.State.Running + Return True + End SyncLock + End Function + + ''/// + ''/// Temporarily suspends logging. + ''/// + ''/// true if successful, false otherwise. + Public Function PauseLog() As Boolean + SyncLock Me + '// Fail if logging hasn't been started + If LoggerState <> State.Running Then + Return False + End If + + '// Pause the logger + _state = EZLogger.State.Paused + Return True + End SyncLock + End Function + + + ''/// + ''/// Resumes logging. + ''/// + ''/// true if successful, false otherwise. + Public Function ResumeLog() As Boolean + SyncLock Me + '// Fail if logging hasn't been paused + If LoggerState <> State.Paused Then + Return False + End If + + '// Resume logging + _state = EZLogger.State.Running + Return True + End SyncLock + End Function + + ''/// + ''/// Stops logging. + ''/// + ''/// true if successful, false otherwise. + Public Function StopLog() As Boolean + SyncLock Me + '// Fail if logging hasn't been started + If LoggerState <> State.Running Then + Return False + End If + + '// Stop logging + Try + _logFile.Close() + _logFile = Nothing + + Catch ex As Exception + Return False + End Try + + _state = EZLogger.State.Stopped + Return True + End SyncLock + End Function + + ''/// + ''/// Logs a debug message. + ''/// + ''/// The message. + ''/// true if successful, false otherwise. + Public Function Debug(ByVal msg As String) As Boolean + _debugMsgs += 1 + Return WriteLogMsg(Level.Debug, msg) + End Function + + ''/// + ''/// Logs an informational message. + ''/// + ''/// The message. + ''/// true if successful, false otherwise. + Public Function Info(ByVal msg As String) As Boolean + _infoMsgs += 1 + Return WriteLogMsg(Level.Info, msg) + End Function + + ''/// + ''/// Logs a success message. + ''/// + ''/// The message. + ''/// true if successful, false otherwise. + Public Function Success(ByVal msg As String) As Boolean + _successMsgs += 1 + Return WriteLogMsg(Level.Success, msg) + End Function + + ''/// + ''/// Logs a warning message. + ''/// + ''/// The message. + ''/// true if successful, false otherwise. + Public Function Warning(ByVal msg As String) As Boolean + _warningMsgs += 1 + Return WriteLogMsg(Level.Warning, msg) + End Function + + ''/// + ''/// Logs an error message. + ''/// + ''/// The message. + ''/// true if successful, false otherwise. + Public Function Errors(ByVal msg As String) As Boolean + _errorMsgs += 1 + Return WriteLogMsg(Level.Errors, msg) + End Function + + ''/// + ''/// Logs a fatal error message. + ''/// + ''/// The message. + ''/// true if successful, false otherwise. + Public Function Fatal(ByVal msg As String) As Boolean + _fatalMsgs += 1 + Return WriteLogMsg(Level.Fatal, msg) + End Function + + + ''/// + ''/// Retrieves the count of messages logged at one or more levels. + ''/// + ''/// Mask indicating levels of interest. + ''/// + Public Function GetMessageCount(ByVal levelMask As UInteger) As UInteger + Dim uMessages As UInteger = 0 + If ((levelMask & CUInt(Level.Debug)) <> 0) Then + uMessages += _debugMsgs + End If + If ((levelMask & CUInt(Level.Info)) <> 0) Then + uMessages += _infoMsgs + End If + If ((levelMask & CUInt(Level.Success)) <> 0) Then + uMessages += _successMsgs + End If + If ((levelMask & CUInt(Level.Warning)) <> 0) Then + uMessages += _warningMsgs + End If + If ((levelMask & CUInt(Level.Errors)) <> 0) Then + uMessages += _errorMsgs + End If + If ((levelMask & CUInt(Level.Fatal)) <> 0) Then + uMessages += _fatalMsgs + End If + Return uMessages + End Function + +#End Region + +#Region "Helper methods" + + ''/// + ''/// Writes a log message. + ''/// + ''/// + ''/// + ''/// + Private Function WriteLogMsg(ByVal level As Level, ByVal msg As String) As Boolean + SyncLock Me + '// Fail if logger hasn't been started + If (LoggerState = State.Stopped) Then + Return False + End If + + '// Ignore message logging is paused or it doesn't pass the filter + If ((LoggerState = State.Paused) Or ((_levels And CUInt(level)) <> CUInt(level))) Then + Return True + End If + + '// Write log message + Dim tmNow As DateTime = DateTime.Now + Dim logMsg As String = String.Format("{0} {1} {2}: {3}", _ + tmNow.ToShortDateString(), tmNow.ToLongTimeString(), _ + level.ToString().Substring(0, 1), msg) + _logFile.WriteLine(logMsg) + + If _bCacheInMemory Then + _logMem.Add(logMsg) + End If + + RaiseEvent Updated() + + Return True + End SyncLock + End Function + +#End Region + +#Region "Fields" + + ''/// Name of the log file. + Private _logFilename As String + + ''/// Flag: append to existing file (if any). + Private _bAppend As Boolean = True + + ''/// Flag: append to an array list in memory. + Private _bCacheInMemory As Boolean = True + + ''/// The log file. + Private _logFile As StreamWriter = Nothing + + ''/// The log in memory. + Private _logMem As ArrayList = Nothing + + ''/// Levels to be logged. + Private _levels As UInteger = (Level.Warning Or Level.Errors Or Level.Fatal) + + ''/// The logger's state. + Private _state As State = State.Stopped + + ''/// Number of debug messages that have been logged. + Private _debugMsgs As UInteger = 0 + + ''/// Number of informational messages that have been logged. + Private _infoMsgs As UInteger = 0 + + ''/// Number of success messages that have been logged. + Private _successMsgs As UInteger = 0 + + ''/// Number of warning messages that have been logged. + Private _warningMsgs As UInteger = 0 + + ''/// Number of error messages that have been logged. + Private _errorMsgs As UInteger = 0 + + ''/// Number of fatal messages that have been logged. + Private _fatalMsgs As UInteger = 0 + +#End Region + +End Class + diff --git a/PhotoBooth_WIA/FaderPanel.vb b/PhotoBooth_WIA/FaderPanel.vb new file mode 100644 index 0000000..a33396c --- /dev/null +++ b/PhotoBooth_WIA/FaderPanel.vb @@ -0,0 +1,104 @@ +Imports System.Drawing.Imaging + +Public Class FaderPanel + Inherits Panel + + Private Enum MsgState + Delaying + Fading + End Enum + + Private A As Integer + Private msg As Bitmap + Private msgBackGround As Bitmap + Private currentState As MsgState + Private WithEvents tmr As New Timer + Private fadeDelayInSeconds As Single 'Calculate to be a certain percentage of the display duration + + Public DisplayDuration As Single = 2.5F + + Public Sub New() + Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, True) + Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True) + End Sub + + Public Sub FlashMessage(ByVal message As String) + If Me.IsHandleCreated Then + tmr.Stop() + + Me.Visible = True + + msgBackGround = New Bitmap(Me.ClientRectangle.Width, Me.ClientRectangle.Height) + Dim g As Graphics = Graphics.FromImage(msgBackGround) + g.Clear(Me.BackColor) + g.Dispose() + + msg = New Bitmap(msgBackGround.Width, msgBackGround.Height) + g = Graphics.FromImage(msg) + g.Clear(Color.Transparent) + Dim sb As New SolidBrush(Me.ForeColor) + + 'Center the message on screen + Dim xPos As Single + xPos = (Me.Parent.Width - g.MeasureString(message, Me.Font).Width) / 2 + + g.DrawString(message, Me.Font, sb, xPos, 0) + sb.Dispose() + g.Dispose() + + 'Reset the alpha value to full opacity + A = 255 + ShowMessage(A) + + 'Calculate the delay before starting the fade (25% of the display duration) + fadeDelayInSeconds = DisplayDuration * 0.25 + + currentState = MsgState.Delaying + tmr.Interval = fadeDelayInSeconds * 1000 'Convert to milliseconds + tmr.Start() + End If + End Sub + + Private Sub ShowMessage(ByVal alpha As Byte) + Dim cm As ColorMatrix = New ColorMatrix(New Single()() _ + {New Single() {1, 0, 0, 0, 0}, _ + New Single() {0, 1, 0, 0, 0}, _ + New Single() {0, 0, 1, 0, 0}, _ + New Single() {0, 0, 0, (alpha / 255), 0}, _ + New Single() {0, 0, 0, 0, 1}}) + + Dim IA As New ImageAttributes + IA.SetColorMatrix(cm, ColorMatrixFlag.Default, ColorAdjustType.Bitmap) + + Dim tmp As New Bitmap(msgBackGround) + Dim G As Graphics = Graphics.FromImage(tmp) + G.DrawImage(msg, Me.ClientRectangle, 0, 0, Me.Width, Me.Height, GraphicsUnit.Pixel, IA) + G.Dispose() + IA.Dispose() + + Me.BackgroundImage = tmp + End Sub + + Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick + Select Case currentState + Case MsgState.Delaying + tmr.Stop() + + 'Calculate the number of steps to fade out in the remaining display time + '51 = full opacity - the step value (255/5) + tmr.Interval = ((DisplayDuration - fadeDelayInSeconds) * 1000) / 51 + + 'Change the panel state to fade out + currentState = MsgState.Fading + tmr.Start() + + Case MsgState.Fading + A = A - 5 + If A < 0 Then + tmr.Stop() + Else + ShowMessage(A) + End If + End Select + End Sub +End Class \ No newline at end of file diff --git a/PhotoBooth_WIA/FiveBottomPanel.Designer.vb b/PhotoBooth_WIA/FiveBottomPanel.Designer.vb new file mode 100644 index 0000000..0a62838 --- /dev/null +++ b/PhotoBooth_WIA/FiveBottomPanel.Designer.vb @@ -0,0 +1,176 @@ + _ +Partial Class FiveBottomPanel + Inherits System.Windows.Forms.UserControl + + 'UserControl overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.tlpFilmstrip = New System.Windows.Forms.TableLayoutPanel + Me.thumb1 = New System.Windows.Forms.PictureBox + Me.thumb2 = New System.Windows.Forms.PictureBox + Me.thumb3 = New System.Windows.Forms.PictureBox + Me.thumb4 = New System.Windows.Forms.PictureBox + Me.thumb5 = New System.Windows.Forms.PictureBox + Me.picBox = New System.Windows.Forms.PictureBox + Me.lblCounterMessage = New System.Windows.Forms.Label + Me.tlpFilmstrip.SuspendLayout() + CType(Me.thumb1, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.thumb2, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.thumb3, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.thumb4, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.thumb5, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.picBox, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'tlpFilmstrip + ' + Me.tlpFilmstrip.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.tlpFilmstrip.ColumnCount = 5 + Me.tlpFilmstrip.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20.0!)) + Me.tlpFilmstrip.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20.0!)) + Me.tlpFilmstrip.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20.0!)) + Me.tlpFilmstrip.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20.0!)) + Me.tlpFilmstrip.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20.0!)) + Me.tlpFilmstrip.Controls.Add(Me.thumb1, 0, 0) + Me.tlpFilmstrip.Controls.Add(Me.thumb2, 1, 0) + Me.tlpFilmstrip.Controls.Add(Me.thumb3, 2, 0) + Me.tlpFilmstrip.Controls.Add(Me.thumb4, 3, 0) + Me.tlpFilmstrip.Controls.Add(Me.thumb5, 4, 0) + Me.tlpFilmstrip.Location = New System.Drawing.Point(0, 262) + Me.tlpFilmstrip.Name = "tlpFilmstrip" + Me.tlpFilmstrip.RowCount = 1 + Me.tlpFilmstrip.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100.0!)) + Me.tlpFilmstrip.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 160.0!)) + Me.tlpFilmstrip.Size = New System.Drawing.Size(621, 160) + Me.tlpFilmstrip.TabIndex = 6 + ' + 'thumb1 + ' + Me.thumb1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.thumb1.Location = New System.Drawing.Point(3, 3) + Me.thumb1.Name = "thumb1" + Me.thumb1.Size = New System.Drawing.Size(118, 154) + Me.thumb1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom + Me.thumb1.TabIndex = 5 + Me.thumb1.TabStop = False + ' + 'thumb2 + ' + Me.thumb2.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.thumb2.Location = New System.Drawing.Point(127, 3) + Me.thumb2.Name = "thumb2" + Me.thumb2.Size = New System.Drawing.Size(118, 154) + Me.thumb2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom + Me.thumb2.TabIndex = 6 + Me.thumb2.TabStop = False + ' + 'thumb3 + ' + Me.thumb3.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.thumb3.Location = New System.Drawing.Point(251, 3) + Me.thumb3.Name = "thumb3" + Me.thumb3.Size = New System.Drawing.Size(118, 154) + Me.thumb3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom + Me.thumb3.TabIndex = 7 + Me.thumb3.TabStop = False + ' + 'thumb4 + ' + Me.thumb4.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.thumb4.Location = New System.Drawing.Point(375, 3) + Me.thumb4.Name = "thumb4" + Me.thumb4.Size = New System.Drawing.Size(118, 154) + Me.thumb4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom + Me.thumb4.TabIndex = 8 + Me.thumb4.TabStop = False + ' + 'thumb5 + ' + Me.thumb5.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.thumb5.Location = New System.Drawing.Point(499, 3) + Me.thumb5.Name = "thumb5" + Me.thumb5.Size = New System.Drawing.Size(119, 154) + Me.thumb5.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom + Me.thumb5.TabIndex = 9 + Me.thumb5.TabStop = False + ' + 'picBox + ' + Me.picBox.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.picBox.Location = New System.Drawing.Point(0, 0) + Me.picBox.Name = "picBox" + Me.picBox.Size = New System.Drawing.Size(621, 256) + Me.picBox.TabIndex = 8 + Me.picBox.TabStop = False + ' + 'lblCounterMessage + ' + Me.lblCounterMessage.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) + Me.lblCounterMessage.AutoSize = True + Me.lblCounterMessage.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.lblCounterMessage.ForeColor = System.Drawing.Color.White + Me.lblCounterMessage.Location = New System.Drawing.Point(3, 425) + Me.lblCounterMessage.Name = "lblCounterMessage" + Me.lblCounterMessage.Size = New System.Drawing.Size(0, 16) + Me.lblCounterMessage.TabIndex = 9 + ' + 'FiveBottomPanel + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.Controls.Add(Me.lblCounterMessage) + Me.Controls.Add(Me.picBox) + Me.Controls.Add(Me.tlpFilmstrip) + Me.Name = "FiveBottomPanel" + Me.Size = New System.Drawing.Size(621, 441) + Me.tlpFilmstrip.ResumeLayout(False) + CType(Me.thumb1, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.thumb2, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.thumb3, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.thumb4, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.thumb5, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.picBox, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents tlpFilmstrip As System.Windows.Forms.TableLayoutPanel + Friend WithEvents thumb1 As System.Windows.Forms.PictureBox + Friend WithEvents thumb2 As System.Windows.Forms.PictureBox + Friend WithEvents thumb3 As System.Windows.Forms.PictureBox + Friend WithEvents thumb4 As System.Windows.Forms.PictureBox + Friend WithEvents thumb5 As System.Windows.Forms.PictureBox + Friend WithEvents picBox As System.Windows.Forms.PictureBox + Friend WithEvents lblCounterMessage As System.Windows.Forms.Label + +End Class diff --git a/PhotoBooth_WIA/FiveBottomPanel.resx b/PhotoBooth_WIA/FiveBottomPanel.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/PhotoBooth_WIA/FiveBottomPanel.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PhotoBooth_WIA/FiveBottomPanel.vb b/PhotoBooth_WIA/FiveBottomPanel.vb new file mode 100644 index 0000000..165e633 --- /dev/null +++ b/PhotoBooth_WIA/FiveBottomPanel.vb @@ -0,0 +1,41 @@ +Public Class FiveBottomPanel + Private mainFileName As String + Private previousFileName As String + Private photoCount As Integer = 0 + Private firstPass As Boolean = True + + Public Sub ShowImage(ByVal newImage As Image, ByVal fileName As String) + picBox.SizeMode = PictureBoxSizeMode.Zoom + picBox.Image = newImage + picBox.Refresh() + + 'This will be useful when adding the cached version to the thumbnail + 'strip along the right side of the screen + mainFileName = fileName + photoCount += 1 + + CycleThumbStrip() + + 'Update the message + lblCounterMessage.Text = String.Format(My.Settings.CounterMessage, photoCount) + + firstPass = False + previousFileName = mainFileName + End Sub + + Private Sub CycleThumbStrip() + If firstPass = False Then + Try + thumb5.Image = thumb4.Image + thumb4.Image = thumb3.Image + thumb3.Image = thumb2.Image + thumb2.Image = thumb1.Image + + thumb1.Image = Image.FromFile(My.Settings.ImageCache & "\" & previousFileName) + + Catch ex As Exception + 'TODO: log the errors + End Try + End If + End Sub +End Class diff --git a/PhotoBooth_WIA/Main.Designer.vb b/PhotoBooth_WIA/Main.Designer.vb new file mode 100644 index 0000000..4977051 --- /dev/null +++ b/PhotoBooth_WIA/Main.Designer.vb @@ -0,0 +1,77 @@ + _ +Partial Class Main + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.fsWatcher = New System.IO.FileSystemWatcher + Me.messageDock = New System.Windows.Forms.Panel + Me.FiveBottomPanel1 = New PhotoBooth.FiveBottomPanel + CType(Me.fsWatcher, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'fsWatcher + ' + Me.fsWatcher.EnableRaisingEvents = True + Me.fsWatcher.SynchronizingObject = Me + ' + 'messageDock + ' + Me.messageDock.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.messageDock.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.messageDock.Location = New System.Drawing.Point(12, 160) + Me.messageDock.Name = "messageDock" + Me.messageDock.Size = New System.Drawing.Size(626, 163) + Me.messageDock.TabIndex = 4 + ' + 'FiveBottomPanel1 + ' + Me.FiveBottomPanel1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.FiveBottomPanel1.Location = New System.Drawing.Point(12, 12) + Me.FiveBottomPanel1.Name = "FiveBottomPanel1" + Me.FiveBottomPanel1.Size = New System.Drawing.Size(629, 458) + Me.FiveBottomPanel1.TabIndex = 5 + ' + 'Main + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.BackColor = System.Drawing.Color.Black + Me.ClientSize = New System.Drawing.Size(650, 482) + Me.Controls.Add(Me.messageDock) + Me.Controls.Add(Me.FiveBottomPanel1) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog + Me.KeyPreview = True + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "Main" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Photo Booth" + CType(Me.fsWatcher, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + + End Sub + Friend WithEvents fsWatcher As System.IO.FileSystemWatcher + Friend WithEvents messageDock As System.Windows.Forms.Panel + Friend WithEvents FiveBottomPanel1 As PhotoBooth.FiveBottomPanel + +End Class diff --git a/PhotoBooth_WIA/Main.resx b/PhotoBooth_WIA/Main.resx new file mode 100644 index 0000000..6b4b9bf --- /dev/null +++ b/PhotoBooth_WIA/Main.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 47, 21 + + \ No newline at end of file diff --git a/PhotoBooth_WIA/Main.vb b/PhotoBooth_WIA/Main.vb new file mode 100644 index 0000000..e9e1c12 --- /dev/null +++ b/PhotoBooth_WIA/Main.vb @@ -0,0 +1,393 @@ +Imports System.IO.Ports +Imports WIA + +Public Class Main + Private Enum PhotoBoothState + Unknown = 0 'The state when the application is first started + Ready 'The booth is ready to take another photo + Working 'The booth is taking/processing a photo + Stopped 'The booth is stopped (no folder watching, the COM port is closed) + End Enum + + Private BoothState As PhotoBoothState = PhotoBoothState.Unknown + Private photos As Collection + Private input As SerialPort + Private log As EZLogger + Private logWindow As Debugger + Private previewWindow As Presentation + Private WithEvents messagePanel As CountdownPanel + Private WithEvents dm As DeviceManager + Private camera As Device + Private photoCount As Integer = 0 + + Private Delegate Sub TakePhotoDelegate() + + Private Sub frmMain_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown + Select Case e.KeyCode + Case Keys.D + ToggleDebugWindow() + Case Keys.S + StartPhotoBooth() + Case Keys.T + TakePhoto() + Case Keys.U + ShowUsageMenu() + Case Keys.O + Options.ShowDialog() + LoadSettings() + Case Keys.R + input.Write("R") + Case Keys.G + input.Write("G") + Case Keys.Escape + ExitPhotoBooth() + Case Keys.PageDown + ToggleWindowMode() + End Select + End Sub + + Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + 'Initialize the log + log = New EZLogger(My.Application.Info.DirectoryPath & "\log.txt", True, EZLogger.Level.All, True) + log.StartLog() + + 'Initialize the in-memory list of photos + photos = New Collection() + + 'Initialize the file watcher + 'log.Info("Initializing the file watcher") + 'fsWatcher.EnableRaisingEvents = False + 'fsWatcher.NotifyFilter = (IO.NotifyFilters.CreationTime Or IO.NotifyFilters.LastWrite) + 'fsWatcher.Filter = "*.jpg" + + 'Initialize the serial port + log.Info("Initializing the serial port") + input = New SerialPort + AddHandler input.DataReceived, AddressOf DataReceived + + 'Initialize the message panel + log.Info("Initializing the message panel") + messagePanel = New CountdownPanel + messagePanel.Dock = DockStyle.Fill + messagePanel.BackColor = Color.Black + messagePanel.ForeColor = Color.White + messagePanel.Duration = 3 + messageDock.Visible = False + messageDock.Controls.Add(messagePanel) + + 'Initialize the photo booth settings + 'TODO: move this out of here and only load the settings when the booth is started + LoadSettings() + + 'Show the usage screen + Me.Show() 'Be sure the main form is visible before displaying the usage screen + ShowUsageMenu() + + 'TODO: If this is the first time launching the app, show the options screen + End Sub + + Private Sub StartPhotoBooth() + 'TODO: Put the photo booth in a ready state + log.Info("Starting the photo booth") + + 'Initialize the photos and cache folder + 'Make sure the folder exists and clear it if there are files in it + Dim fileCounter As Collections.ObjectModel.ReadOnlyCollection(Of String) + + 'Inspect the cache folder + fileCounter = My.Computer.FileSystem.GetFiles( _ + My.Settings.ImageCache, FileIO.SearchOption.SearchTopLevelOnly, "*.jpg") + If fileCounter.Count <> 0 Then + For Each file As String In fileCounter + My.Computer.FileSystem.DeleteFile(file) + Next + End If + + 'Inspect the photos folder + fileCounter = My.Computer.FileSystem.GetFiles( _ + My.Settings.WatchFolder, FileIO.SearchOption.SearchTopLevelOnly, "*.jpg") + If fileCounter.Count <> 0 Then + If MessageBox.Show("There are files in the photos folder. Do you want to empty the folder now?", _ + "Clear photo folders", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then + For Each file As String In fileCounter + My.Computer.FileSystem.DeleteFile(file) + Next + End If + End If + + 'Initialize the preview window + 'previewWindow = New Presentation + 'previewWindow.Show() + + 'Find the selected camera + dm = New DeviceManager + For Each dvi As DeviceInfo In dm.DeviceInfos + If dvi.DeviceID = My.Settings.CameraDeviceID Then + camera = dvi.Connect + Exit For + End If + Next + dm.RegisterEvent(EventID.wiaEventItemCreated, camera.DeviceID) + + OpenSerialPort() + + 'Toggle the stop and go LEDs on the input device + input.Write("r") + input.Write("G") + + BoothState = PhotoBoothState.Ready + End Sub + + Private Sub ExitPhotoBooth() + 'Shut down the photo booth + log.Info("Shutting down the application") + + 'Close the debugger window + If logWindow IsNot Nothing Then + logWindow.Close() + logWindow = Nothing + End If + + 'Shut down the serial port for the trigger + CloseSerialPort() + + 'Stop logging events + log.StopLog() + + Application.Exit() + End Sub + + Private Sub LoadSettings() + log.Info("Load settings") + 'messagePanel.DisplayDuration = My.Settings.MessageDuration + messagePanel.Font = My.Settings.MessageFont + 'fsWatcher.Path = My.Settings.WatchFolder + End Sub + + Private Sub ToggleDebugWindow() + If logWindow Is Nothing Then + logWindow = New Debugger + logWindow.BindLogToList(log) + End If + logWindow.Visible = Not logWindow.Visible + End Sub + + Private Sub ToggleWindowMode() + If Me.WindowState <> FormWindowState.Maximized Then + Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None + Me.WindowState = FormWindowState.Maximized + + 'previewWindow.FormBorderStyle = Windows.Forms.FormBorderStyle.None + 'previewWindow.WindowState = FormWindowState.Maximized + + 'Windows.Forms.Cursor.Hide() + Else + Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle + Me.WindowState = FormWindowState.Normal + + 'previewWindow.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle + 'previewWindow.WindowState = FormWindowState.Normal + + 'Windows.Forms.Cursor.Show() + End If + End Sub + + Private Sub ShowUsageMenu() + Using u As New Usage + u.ShowDialog(Me) + End Using + End Sub + + Private Sub CloseSerialPort() + log.Info("Closing the serial port") + If input.IsOpen Then + input.Close() + End If + End Sub + + Private Sub OpenSerialPort() + 'Set up serial communication with the Arduino + log.Info("Opening the serial port") + If input IsNot Nothing Then + If input.IsOpen Then + input.Close() + End If + End If + + Try + input.PortName = My.Settings.COMPort + input.BaudRate = 9600 + input.Parity = Parity.None + input.DataBits = 8 + input.Open() + Catch ex As Exception + 'log the message + log.Errors("OpenSerialPort: " & ex.Message) + End Try + End Sub + + Private Sub ShowNewPicture(ByVal FullPath As String) + log.Info("Show new photo") + messageDock.Visible = False + messagePanel.Visible = False + Try + Dim img As Drawing.Image + img = Image.FromFile(FullPath) + + 'Save a scaled down image in the photo cache + AddPhotoToCache(img) + + 'Show the new image on the presentation panel + FiveBottomPanel1.ShowImage(img, photos(photos.Count).ToString) + FiveBottomPanel1.Visible = True + + Catch ex As Exception + 'log the message + log.Errors("ShowNewPicture: " & ex.Message) + End Try + End Sub + + Private Sub AddPhotoToCache(ByVal NewPhoto As Drawing.Image) + log.Info("Creating cached version") + + Try + Const SCALE_FACTOR As Single = 0.125F + Dim cacheDestination As New Bitmap(CInt(NewPhoto.Size.Width * SCALE_FACTOR), CInt(NewPhoto.Size.Height * SCALE_FACTOR)) + Dim gPhoto As Graphics = Graphics.FromImage(cacheDestination) + gPhoto.DrawImage(NewPhoto, _ + New Rectangle(0, 0, CInt(NewPhoto.Size.Width * SCALE_FACTOR), CInt(NewPhoto.Height * SCALE_FACTOR)), _ + New Rectangle(0, 0, NewPhoto.Width, NewPhoto.Height), _ + GraphicsUnit.Pixel) + cacheDestination.Save(My.Settings.ImageCache & "\" & photoCount & ".jpg", _ + Imaging.ImageFormat.Jpeg) + gPhoto.Dispose() + cacheDestination.Dispose() + Catch ex As Exception + log.Errors("AddPhotoToCache: " & ex.Message) + End Try + End Sub + + Private Sub TakePhoto() + If BoothState = PhotoBoothState.Ready Then + BoothState = PhotoBoothState.Working + log.Info("Take photo") + + 'Toggle the stop and go LEDs on the input device + input.Write("g") + input.Write("R") + + 'Clear the current image + FiveBottomPanel1.Visible = False + Application.DoEvents() + + 'Display a "Get Ready" message + messageDock.Visible = True + messagePanel.Start() + + 'Call the camera control application + 'Shell(My.Settings.CameraControlEXE) + End If + End Sub + + Public Sub New() + ' This call is required by the Windows Form Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + SetStyle(ControlStyles.SupportsTransparentBackColor, True) + End Sub + + Private Sub fsWatcher_Changed(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles fsWatcher.Changed, fsWatcher.Created + If Not photos.Contains(e.Name) Then + log.Info("New photo found in the watched folder") + photos.Add(e.Name, e.Name) + + ShowNewPicture(My.Settings.WatchFolder & "\" & e.Name) + + My.Application.DoEvents() + + BoothState = PhotoBoothState.Ready + End If + End Sub + + Private Sub DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) + Dim newResponse As Integer = input.ReadChar + Select Case newResponse + Case 66 + log.Info("Button pushed") + Me.Invoke(New TakePhotoDelegate(AddressOf TakePhoto), New Object() {}) + Case 80 + log.Info("Pedal pushed") + Me.Invoke(New TakePhotoDelegate(AddressOf TakePhoto), New Object() {}) + Case Else + log.Info("Board responsed with " & Chr(newResponse)) + End Select + End Sub + + Private Sub dm_OnEvent(ByVal EventID As String, ByVal DeviceID As String, ByVal ItemID As String) Handles dm.OnEvent + Select Case EventID + Case WIA.EventID.wiaEventItemCreated + 'Retrieve the new photo from the camera + Dim itm As WIA.Item = camera.GetItem(ItemID) + Dim img As WIA.ImageFile = itm.Transfer(WIA.FormatID.wiaFormatJPEG) + img.SaveFile(My.Settings.WatchFolder & "\" & photoCount & ".jpg") + + 'Keep track of the photos taken + photos.Add(photoCount & ".jpg", photoCount & ".jpg") + + 'Display the new photo on screen + ShowNewPicture(My.Settings.WatchFolder & "\" & photoCount & ".jpg") + + 'Remove the new photo from the camera + Try + camera.Items.Remove(1) + camera.ExecuteCommand(WIA.CommandID.wiaCommandSynchronize) + Catch ex As Exception + log.Errors("dm_OnEvent: " & ex.Message) + End Try + + 'Toggle the stop and go LEDs on the input device + input.Write("r") + input.Write("G") + + 'Update the photo count and carry on + photoCount += 1 + BoothState = PhotoBoothState.Ready + + Case Else + 'Do nothing + End Select + End Sub + + Private Sub messagePanel_Complete(ByVal sender As Object, ByVal e As System.EventArgs) Handles messagePanel.Complete + Try + camera.ExecuteCommand(CommandID.wiaCommandTakePicture) + Catch ex As Exception + log.Errors("Panel Complete: " & ex.Message) + 'Restart the photo booth because the camera miss fired + 'Usually happens when it is unable to find something to focus on + log.Info("Camera miss-fired") + PrintMessage(My.Settings.ErrorMessage) + + 'Toggle the stop and go LEDs on the input device + input.Write("r") + input.Write("G") + + BoothState = PhotoBoothState.Ready + End Try + End Sub + + Private Sub PrintMessage(ByVal Message As String) + FiveBottomPanel1.Visible = False + messageDock.Visible = False + + Dim g As Graphics = Me.CreateGraphics + Dim sb As New SolidBrush(Color.White) + Dim mf As New Font("Arial", 20, FontStyle.Bold, GraphicsUnit.Point) + Dim xPos As Single = (Me.Width / 2) - (g.MeasureString(Message, mf).Width / 2) + Dim yPos As Single = (Me.Height / 2) - (g.MeasureString(Message, mf).Height / 2) + g.DrawString(Message, mf, sb, xPos, yPos) + sb.Dispose() + g.Dispose() + End Sub +End Class diff --git a/PhotoBooth_WIA/My Project/Application.Designer.vb b/PhotoBooth_WIA/My Project/Application.Designer.vb new file mode 100644 index 0000000..96d7add --- /dev/null +++ b/PhotoBooth_WIA/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.5448 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + 'NOTE: This file is auto-generated; do not modify it directly. To make changes, + ' or if you encounter build errors in this file, go to the Project Designer + ' (go to Project Properties or double-click the My Project node in + ' Solution Explorer), and make changes on the Application tab. + ' + Partial Friend Class MyApplication + + _ + Public Sub New() + MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) + Me.IsSingleInstance = true + Me.EnableVisualStyles = true + Me.SaveMySettingsOnExit = true + Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses + End Sub + + _ + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = Global.PhotoBooth.Main + End Sub + End Class +End Namespace diff --git a/PhotoBooth_WIA/My Project/Application.myapp b/PhotoBooth_WIA/My Project/Application.myapp new file mode 100644 index 0000000..6a1b2fa --- /dev/null +++ b/PhotoBooth_WIA/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + Main + true + 0 + true + 0 + true + \ No newline at end of file diff --git a/PhotoBooth_WIA/My Project/AssemblyInfo.vb b/PhotoBooth_WIA/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..0912f50 --- /dev/null +++ b/PhotoBooth_WIA/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' 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. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' 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: +' + + + diff --git a/PhotoBooth_WIA/My Project/Resources.Designer.vb b/PhotoBooth_WIA/My Project/Resources.Designer.vb new file mode 100644 index 0000000..9d50345 --- /dev/null +++ b/PhotoBooth_WIA/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.5448 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Imports System + +Namespace My.Resources + + '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. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("PhotoBooth.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/PhotoBooth_WIA/My Project/Resources.resx b/PhotoBooth_WIA/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/PhotoBooth_WIA/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PhotoBooth_WIA/My Project/Settings.Designer.vb b/PhotoBooth_WIA/My Project/Settings.Designer.vb new file mode 100644 index 0000000..acf187c --- /dev/null +++ b/PhotoBooth_WIA/My Project/Settings.Designer.vb @@ -0,0 +1,193 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.5448 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings),MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + + _ + Public Property WatchFolder() As String + Get + Return CType(Me("WatchFolder"),String) + End Get + Set + Me("WatchFolder") = value + End Set + End Property + + _ + Public Property CameraControlEXE() As String + Get + Return CType(Me("CameraControlEXE"),String) + End Get + Set + Me("CameraControlEXE") = value + End Set + End Property + + _ + Public Property MessageDuration() As Decimal + Get + Return CType(Me("MessageDuration"),Decimal) + End Get + Set + Me("MessageDuration") = value + End Set + End Property + + _ + Public Property COMPort() As String + Get + Return CType(Me("COMPort"),String) + End Get + Set + Me("COMPort") = value + End Set + End Property + + _ + Public Property WaitMessage() As String + Get + Return CType(Me("WaitMessage"),String) + End Get + Set + Me("WaitMessage") = value + End Set + End Property + + _ + Public Property ImageCache() As String + Get + Return CType(Me("ImageCache"),String) + End Get + Set + Me("ImageCache") = value + End Set + End Property + + _ + Public Property MessageFont() As Global.System.Drawing.Font + Get + Return CType(Me("MessageFont"),Global.System.Drawing.Font) + End Get + Set + Me("MessageFont") = value + End Set + End Property + + _ + Public Property CameraDeviceID() As String + Get + Return CType(Me("CameraDeviceID"),String) + End Get + Set + Me("CameraDeviceID") = value + End Set + End Property + + _ + Public Property ErrorMessage() As String + Get + Return CType(Me("ErrorMessage"),String) + End Get + Set + Me("ErrorMessage") = value + End Set + End Property + + _ + Public Property CounterMessage() As String + Get + Return CType(Me("CounterMessage"),String) + End Get + Set + Me("CounterMessage") = value + End Set + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.PhotoBooth.My.MySettings + Get + Return Global.PhotoBooth.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/PhotoBooth_WIA/My Project/Settings.settings b/PhotoBooth_WIA/My Project/Settings.settings new file mode 100644 index 0000000..d38ae16 --- /dev/null +++ b/PhotoBooth_WIA/My Project/Settings.settings @@ -0,0 +1,36 @@ + + + + + + + + + + + + 2.5 + + + COM1 + + + Prepare for automagic + + + + + + Arial Black, 18pt + + + + + + The automagic failed. Try again. + + + {0} kinds of automagic + + + \ No newline at end of file diff --git a/PhotoBooth_WIA/Options.Designer.vb b/PhotoBooth_WIA/Options.Designer.vb new file mode 100644 index 0000000..c4d2038 --- /dev/null +++ b/PhotoBooth_WIA/Options.Designer.vb @@ -0,0 +1,435 @@ + _ +Partial Class Options + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel + Me.OK_Button = New System.Windows.Forms.Button + Me.Cancel_Button = New System.Windows.Forms.Button + Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog + Me.lblCaption = New System.Windows.Forms.Label + Me.Button1 = New System.Windows.Forms.Button + Me.Button2 = New System.Windows.Forms.Button + Me.Label1 = New System.Windows.Forms.Label + Me.FolderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog + Me.Label2 = New System.Windows.Forms.Label + Me.Label3 = New System.Windows.Forms.Label + Me.Label4 = New System.Windows.Forms.Label + Me.Test = New System.Windows.Forms.Button + Me.TestMessage = New System.Windows.Forms.Label + Me.Label5 = New System.Windows.Forms.Label + Me.Button3 = New System.Windows.Forms.Button + Me.Label6 = New System.Windows.Forms.Label + Me.Label7 = New System.Windows.Forms.Label + Me.txtMessageFont = New System.Windows.Forms.TextBox + Me.FontDialog1 = New System.Windows.Forms.FontDialog + Me.Button4 = New System.Windows.Forms.Button + Me.SelectCamera = New System.Windows.Forms.Button + Me.txtCamera = New System.Windows.Forms.TextBox + Me.Label8 = New System.Windows.Forms.Label + Me.Label9 = New System.Windows.Forms.Label + Me.Label10 = New System.Windows.Forms.Label + Me.txtCounterMessage = New System.Windows.Forms.TextBox + Me.txtErrorMessage = New System.Windows.Forms.TextBox + Me.txtImageCachePath = New System.Windows.Forms.TextBox + Me.txtWaitMessage = New System.Windows.Forms.TextBox + Me.COMPorts = New System.Windows.Forms.ComboBox + Me.MessageDuration = New System.Windows.Forms.NumericUpDown + Me.txtWatchPath = New System.Windows.Forms.TextBox + Me.txtCamControlPath = New System.Windows.Forms.TextBox + Me.TableLayoutPanel1.SuspendLayout() + CType(Me.MessageDuration, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'TableLayoutPanel1 + ' + Me.TableLayoutPanel1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.TableLayoutPanel1.ColumnCount = 2 + Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) + Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) + Me.TableLayoutPanel1.Controls.Add(Me.OK_Button, 0, 0) + Me.TableLayoutPanel1.Controls.Add(Me.Cancel_Button, 1, 0) + Me.TableLayoutPanel1.Location = New System.Drawing.Point(277, 420) + Me.TableLayoutPanel1.Name = "TableLayoutPanel1" + Me.TableLayoutPanel1.RowCount = 1 + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) + Me.TableLayoutPanel1.Size = New System.Drawing.Size(146, 29) + Me.TableLayoutPanel1.TabIndex = 0 + ' + 'OK_Button + ' + Me.OK_Button.Anchor = System.Windows.Forms.AnchorStyles.None + Me.OK_Button.Location = New System.Drawing.Point(3, 3) + Me.OK_Button.Name = "OK_Button" + Me.OK_Button.Size = New System.Drawing.Size(67, 23) + Me.OK_Button.TabIndex = 0 + Me.OK_Button.Text = "OK" + ' + 'Cancel_Button + ' + Me.Cancel_Button.Anchor = System.Windows.Forms.AnchorStyles.None + Me.Cancel_Button.DialogResult = System.Windows.Forms.DialogResult.Cancel + Me.Cancel_Button.Location = New System.Drawing.Point(76, 3) + Me.Cancel_Button.Name = "Cancel_Button" + Me.Cancel_Button.Size = New System.Drawing.Size(67, 23) + Me.Cancel_Button.TabIndex = 1 + Me.Cancel_Button.Text = "Cancel" + ' + 'OpenFileDialog1 + ' + Me.OpenFileDialog1.FileName = "OpenFileDialog1" + ' + 'lblCaption + ' + Me.lblCaption.AutoSize = True + Me.lblCaption.Location = New System.Drawing.Point(9, 53) + Me.lblCaption.Name = "lblCaption" + Me.lblCaption.Size = New System.Drawing.Size(175, 13) + Me.lblCaption.TabIndex = 2 + Me.lblCaption.Text = "Camera control application location:" + ' + 'Button1 + ' + Me.Button1.Location = New System.Drawing.Point(394, 69) + Me.Button1.Name = "Button1" + Me.Button1.Size = New System.Drawing.Size(26, 20) + Me.Button1.TabIndex = 3 + Me.Button1.Text = "..." + Me.Button1.UseVisualStyleBackColor = True + ' + 'Button2 + ' + Me.Button2.Location = New System.Drawing.Point(394, 112) + Me.Button2.Name = "Button2" + Me.Button2.Size = New System.Drawing.Size(26, 20) + Me.Button2.TabIndex = 6 + Me.Button2.Text = "..." + Me.Button2.UseVisualStyleBackColor = True + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(9, 96) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(79, 13) + Me.Label1.TabIndex = 5 + Me.Label1.Text = "Image location:" + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Location = New System.Drawing.Point(9, 311) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(191, 13) + Me.Label2.TabIndex = 7 + Me.Label2.Text = "Show message while taking picture for:" + ' + 'Label3 + ' + Me.Label3.AutoSize = True + Me.Label3.Location = New System.Drawing.Point(65, 329) + Me.Label3.Name = "Label3" + Me.Label3.Size = New System.Drawing.Size(47, 13) + Me.Label3.TabIndex = 10 + Me.Label3.Text = "seconds" + ' + 'Label4 + ' + Me.Label4.AutoSize = True + Me.Label4.Location = New System.Drawing.Point(9, 354) + Me.Label4.Name = "Label4" + Me.Label4.Size = New System.Drawing.Size(140, 13) + Me.Label4.TabIndex = 11 + Me.Label4.Text = "COM port for camera trigger:" + ' + 'Test + ' + Me.Test.Location = New System.Drawing.Point(87, 370) + Me.Test.Name = "Test" + Me.Test.Size = New System.Drawing.Size(48, 21) + Me.Test.TabIndex = 13 + Me.Test.Text = "Test" + Me.Test.UseVisualStyleBackColor = True + ' + 'TestMessage + ' + Me.TestMessage.AutoSize = True + Me.TestMessage.Location = New System.Drawing.Point(141, 374) + Me.TestMessage.Name = "TestMessage" + Me.TestMessage.Size = New System.Drawing.Size(77, 13) + Me.TestMessage.TabIndex = 14 + Me.TestMessage.Text = "Opening port..." + Me.TestMessage.Visible = False + ' + 'Label5 + ' + Me.Label5.AutoSize = True + Me.Label5.Location = New System.Drawing.Point(9, 182) + Me.Label5.Name = "Label5" + Me.Label5.Size = New System.Drawing.Size(77, 13) + Me.Label5.TabIndex = 16 + Me.Label5.Text = "Wait message:" + ' + 'Button3 + ' + Me.Button3.Location = New System.Drawing.Point(394, 155) + Me.Button3.Name = "Button3" + Me.Button3.Size = New System.Drawing.Size(26, 20) + Me.Button3.TabIndex = 19 + Me.Button3.Text = "..." + Me.Button3.UseVisualStyleBackColor = True + ' + 'Label6 + ' + Me.Label6.AutoSize = True + Me.Label6.Location = New System.Drawing.Point(9, 139) + Me.Label6.Name = "Label6" + Me.Label6.Size = New System.Drawing.Size(112, 13) + Me.Label6.TabIndex = 18 + Me.Label6.Text = "Image cache location:" + ' + 'Label7 + ' + Me.Label7.AutoSize = True + Me.Label7.Location = New System.Drawing.Point(241, 182) + Me.Label7.Name = "Label7" + Me.Label7.Size = New System.Drawing.Size(31, 13) + Me.Label7.TabIndex = 20 + Me.Label7.Text = "Font:" + ' + 'txtMessageFont + ' + Me.txtMessageFont.Enabled = False + Me.txtMessageFont.Location = New System.Drawing.Point(244, 198) + Me.txtMessageFont.Name = "txtMessageFont" + Me.txtMessageFont.Size = New System.Drawing.Size(144, 20) + Me.txtMessageFont.TabIndex = 21 + ' + 'Button4 + ' + Me.Button4.Location = New System.Drawing.Point(394, 198) + Me.Button4.Name = "Button4" + Me.Button4.Size = New System.Drawing.Size(26, 20) + Me.Button4.TabIndex = 22 + Me.Button4.Text = "..." + Me.Button4.UseVisualStyleBackColor = True + ' + 'SelectCamera + ' + Me.SelectCamera.Location = New System.Drawing.Point(334, 25) + Me.SelectCamera.Name = "SelectCamera" + Me.SelectCamera.Size = New System.Drawing.Size(89, 22) + Me.SelectCamera.TabIndex = 24 + Me.SelectCamera.Text = "Select camera" + Me.SelectCamera.UseVisualStyleBackColor = True + ' + 'txtCamera + ' + Me.txtCamera.Location = New System.Drawing.Point(12, 26) + Me.txtCamera.Name = "txtCamera" + Me.txtCamera.Size = New System.Drawing.Size(316, 20) + Me.txtCamera.TabIndex = 25 + ' + 'Label8 + ' + Me.Label8.AutoSize = True + Me.Label8.Location = New System.Drawing.Point(9, 10) + Me.Label8.Name = "Label8" + Me.Label8.Size = New System.Drawing.Size(46, 13) + Me.Label8.TabIndex = 26 + Me.Label8.Text = "Camera:" + ' + 'Label9 + ' + Me.Label9.AutoSize = True + Me.Label9.Location = New System.Drawing.Point(9, 268) + Me.Label9.Name = "Label9" + Me.Label9.Size = New System.Drawing.Size(77, 13) + Me.Label9.TabIndex = 28 + Me.Label9.Text = "Error message:" + ' + 'Label10 + ' + Me.Label10.AutoSize = True + Me.Label10.Location = New System.Drawing.Point(9, 225) + Me.Label10.Name = "Label10" + Me.Label10.Size = New System.Drawing.Size(92, 13) + Me.Label10.TabIndex = 29 + Me.Label10.Text = "Counter message:" + ' + 'txtCounterMessage + ' + Me.txtCounterMessage.DataBindings.Add(New System.Windows.Forms.Binding("Text", Global.PhotoBooth.My.MySettings.Default, "CounterMessage", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)) + Me.txtCounterMessage.Location = New System.Drawing.Point(12, 241) + Me.txtCounterMessage.Name = "txtCounterMessage" + Me.txtCounterMessage.Size = New System.Drawing.Size(376, 20) + Me.txtCounterMessage.TabIndex = 30 + Me.txtCounterMessage.Text = Global.PhotoBooth.My.MySettings.Default.CounterMessage + ' + 'txtErrorMessage + ' + Me.txtErrorMessage.DataBindings.Add(New System.Windows.Forms.Binding("Text", Global.PhotoBooth.My.MySettings.Default, "ErrorMessage", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)) + Me.txtErrorMessage.Location = New System.Drawing.Point(12, 284) + Me.txtErrorMessage.Name = "txtErrorMessage" + Me.txtErrorMessage.Size = New System.Drawing.Size(376, 20) + Me.txtErrorMessage.TabIndex = 27 + Me.txtErrorMessage.Text = Global.PhotoBooth.My.MySettings.Default.ErrorMessage + ' + 'txtImageCachePath + ' + Me.txtImageCachePath.DataBindings.Add(New System.Windows.Forms.Binding("Text", Global.PhotoBooth.My.MySettings.Default, "ImageCache", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)) + Me.txtImageCachePath.Location = New System.Drawing.Point(12, 155) + Me.txtImageCachePath.Name = "txtImageCachePath" + Me.txtImageCachePath.Size = New System.Drawing.Size(376, 20) + Me.txtImageCachePath.TabIndex = 17 + Me.txtImageCachePath.Text = Global.PhotoBooth.My.MySettings.Default.ImageCache + ' + 'txtWaitMessage + ' + Me.txtWaitMessage.DataBindings.Add(New System.Windows.Forms.Binding("Text", Global.PhotoBooth.My.MySettings.Default, "WaitMessage", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)) + Me.txtWaitMessage.Location = New System.Drawing.Point(12, 198) + Me.txtWaitMessage.Name = "txtWaitMessage" + Me.txtWaitMessage.Size = New System.Drawing.Size(226, 20) + Me.txtWaitMessage.TabIndex = 15 + Me.txtWaitMessage.Text = Global.PhotoBooth.My.MySettings.Default.WaitMessage + ' + 'COMPorts + ' + Me.COMPorts.DataBindings.Add(New System.Windows.Forms.Binding("Text", Global.PhotoBooth.My.MySettings.Default, "COMPort", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)) + Me.COMPorts.FormattingEnabled = True + Me.COMPorts.Location = New System.Drawing.Point(12, 370) + Me.COMPorts.Name = "COMPorts" + Me.COMPorts.Size = New System.Drawing.Size(69, 21) + Me.COMPorts.TabIndex = 12 + Me.COMPorts.Text = Global.PhotoBooth.My.MySettings.Default.COMPort + ' + 'MessageDuration + ' + Me.MessageDuration.DataBindings.Add(New System.Windows.Forms.Binding("Value", Global.PhotoBooth.My.MySettings.Default, "MessageDuration", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)) + Me.MessageDuration.DecimalPlaces = 1 + Me.MessageDuration.Increment = New Decimal(New Integer() {5, 0, 0, 65536}) + Me.MessageDuration.Location = New System.Drawing.Point(12, 327) + Me.MessageDuration.Name = "MessageDuration" + Me.MessageDuration.Size = New System.Drawing.Size(47, 20) + Me.MessageDuration.TabIndex = 9 + Me.MessageDuration.Value = Global.PhotoBooth.My.MySettings.Default.MessageDuration + ' + 'txtWatchPath + ' + Me.txtWatchPath.DataBindings.Add(New System.Windows.Forms.Binding("Text", Global.PhotoBooth.My.MySettings.Default, "WatchFolder", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)) + Me.txtWatchPath.Location = New System.Drawing.Point(12, 112) + Me.txtWatchPath.Name = "txtWatchPath" + Me.txtWatchPath.Size = New System.Drawing.Size(376, 20) + Me.txtWatchPath.TabIndex = 4 + Me.txtWatchPath.Text = Global.PhotoBooth.My.MySettings.Default.WatchFolder + ' + 'txtCamControlPath + ' + Me.txtCamControlPath.DataBindings.Add(New System.Windows.Forms.Binding("Text", Global.PhotoBooth.My.MySettings.Default, "CameraControlEXE", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)) + Me.txtCamControlPath.Location = New System.Drawing.Point(12, 69) + Me.txtCamControlPath.Name = "txtCamControlPath" + Me.txtCamControlPath.Size = New System.Drawing.Size(376, 20) + Me.txtCamControlPath.TabIndex = 1 + Me.txtCamControlPath.Text = Global.PhotoBooth.My.MySettings.Default.CameraControlEXE + ' + 'Options + ' + Me.AcceptButton = Me.OK_Button + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.CancelButton = Me.Cancel_Button + Me.ClientSize = New System.Drawing.Size(435, 461) + Me.Controls.Add(Me.Label10) + Me.Controls.Add(Me.txtCounterMessage) + Me.Controls.Add(Me.Label9) + Me.Controls.Add(Me.txtErrorMessage) + Me.Controls.Add(Me.Label8) + Me.Controls.Add(Me.txtCamera) + Me.Controls.Add(Me.SelectCamera) + Me.Controls.Add(Me.Button4) + Me.Controls.Add(Me.txtMessageFont) + Me.Controls.Add(Me.Label7) + Me.Controls.Add(Me.Button3) + Me.Controls.Add(Me.Label6) + Me.Controls.Add(Me.txtImageCachePath) + Me.Controls.Add(Me.Label5) + Me.Controls.Add(Me.txtWaitMessage) + Me.Controls.Add(Me.TestMessage) + Me.Controls.Add(Me.Test) + Me.Controls.Add(Me.COMPorts) + Me.Controls.Add(Me.Label4) + Me.Controls.Add(Me.Label3) + Me.Controls.Add(Me.MessageDuration) + Me.Controls.Add(Me.Label2) + Me.Controls.Add(Me.Button2) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.txtWatchPath) + Me.Controls.Add(Me.Button1) + Me.Controls.Add(Me.lblCaption) + Me.Controls.Add(Me.txtCamControlPath) + Me.Controls.Add(Me.TableLayoutPanel1) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "Options" + Me.ShowInTaskbar = False + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent + Me.Text = "Options" + Me.TableLayoutPanel1.ResumeLayout(False) + CType(Me.MessageDuration, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents TableLayoutPanel1 As System.Windows.Forms.TableLayoutPanel + Friend WithEvents OK_Button As System.Windows.Forms.Button + Friend WithEvents Cancel_Button As System.Windows.Forms.Button + Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog + Friend WithEvents txtCamControlPath As System.Windows.Forms.TextBox + Friend WithEvents lblCaption As System.Windows.Forms.Label + Friend WithEvents Button1 As System.Windows.Forms.Button + Friend WithEvents Button2 As System.Windows.Forms.Button + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents txtWatchPath As System.Windows.Forms.TextBox + Friend WithEvents FolderBrowserDialog1 As System.Windows.Forms.FolderBrowserDialog + Friend WithEvents Label2 As System.Windows.Forms.Label + Friend WithEvents MessageDuration As System.Windows.Forms.NumericUpDown + Friend WithEvents Label3 As System.Windows.Forms.Label + Friend WithEvents Label4 As System.Windows.Forms.Label + Friend WithEvents COMPorts As System.Windows.Forms.ComboBox + Friend WithEvents Test As System.Windows.Forms.Button + Friend WithEvents TestMessage As System.Windows.Forms.Label + Friend WithEvents Label5 As System.Windows.Forms.Label + Friend WithEvents txtWaitMessage As System.Windows.Forms.TextBox + Friend WithEvents Button3 As System.Windows.Forms.Button + Friend WithEvents Label6 As System.Windows.Forms.Label + Friend WithEvents txtImageCachePath As System.Windows.Forms.TextBox + Friend WithEvents Label7 As System.Windows.Forms.Label + Friend WithEvents txtMessageFont As System.Windows.Forms.TextBox + Friend WithEvents FontDialog1 As System.Windows.Forms.FontDialog + Friend WithEvents Button4 As System.Windows.Forms.Button + Friend WithEvents SelectCamera As System.Windows.Forms.Button + Friend WithEvents txtCamera As System.Windows.Forms.TextBox + Friend WithEvents Label8 As System.Windows.Forms.Label + Friend WithEvents Label9 As System.Windows.Forms.Label + Friend WithEvents txtErrorMessage As System.Windows.Forms.TextBox + Friend WithEvents Label10 As System.Windows.Forms.Label + Friend WithEvents txtCounterMessage As System.Windows.Forms.TextBox + +End Class diff --git a/PhotoBooth_WIA/Options.resx b/PhotoBooth_WIA/Options.resx new file mode 100644 index 0000000..44ec443 --- /dev/null +++ b/PhotoBooth_WIA/Options.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 149, 17 + + + 309, 17 + + \ No newline at end of file diff --git a/PhotoBooth_WIA/Options.vb b/PhotoBooth_WIA/Options.vb new file mode 100644 index 0000000..7733fa1 --- /dev/null +++ b/PhotoBooth_WIA/Options.vb @@ -0,0 +1,154 @@ +Imports System.Windows.Forms +Imports System.IO.Ports + +Public Class Options + + Private dataAvailable As Boolean = False + + Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click + Me.DialogResult = System.Windows.Forms.DialogResult.OK + Me.Close() + End Sub + + Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click + Me.DialogResult = System.Windows.Forms.DialogResult.Cancel + Me.Close() + End Sub + + Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click, Button3.Click + If FolderBrowserDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then + If sender.Equals(Button2) Then + txtWatchPath.Text = FolderBrowserDialog1.SelectedPath + ElseIf sender.Equals(Button3) Then + txtImageCachePath.Text = FolderBrowserDialog1.SelectedPath + End If + End If + End Sub + + Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click + If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then + txtCamControlPath.Text = OpenFileDialog1.FileName + End If + End Sub + + Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click + If FontDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then + My.Settings.MessageFont = FontDialog1.Font + txtMessageFont.Text = String.Format("{0}, {1}pt", _ + My.Settings.MessageFont.FontFamily.Name, _ + My.Settings.MessageFont.SizeInPoints) + End If + End Sub + + Private Sub Options_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + 'Fill the COM combobox with a list of the available ports + COMPorts.Items.Clear() + For Each s As String In System.IO.Ports.SerialPort.GetPortNames + COMPorts.Items.Add(s) + Next + Test.Enabled = (COMPorts.Text <> String.Empty) + + 'Display the message font info + FontDialog1.Font = My.Settings.MessageFont + txtMessageFont.Text = String.Format("{0}, {1}pt", _ + My.Settings.MessageFont.FontFamily.Name, _ + My.Settings.MessageFont.SizeInPoints) + End Sub + + Private Sub Test_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Test.Click + 'Test the selected COM + Const TIME_OUT = 30000 + Dim testPort As SerialPort + Dim testResults As Boolean = False + + Test.Enabled = False + + 'Start showing status messages + TestMessage.Text = String.Empty + TestMessage.Visible = True + + Try + 'Create the port + testPort = New SerialPort(COMPorts.Text, 9600, Parity.None, 8) + + 'Bind to a function to handle receive the test data + AddHandler testPort.DataReceived, AddressOf ReceivePortData + + 'Open the port + If testPort.IsOpen Then + testPort.Close() + End If + TestMessage.Text = "Attempting to open the port..." + TestMessage.Update() + testPort.Open() + TestMessage.Text = "Successfully opened the port" + TestMessage.Update() + + 'Send a predetermined message to the device + TestMessage.Text = "Sending message to the port..." + TestMessage.Update() + testPort.Write("T") 'TODO: Determine what the "handshake" is going to be + TestMessage.Text = "Successfully sent a message to the port" + TestMessage.Update() + + 'Wait up to 30 seconds for a known response + TestMessage.Text = "Waiting for response message..." + TestMessage.Update() + 'Wait for a response + Dim sw As New Stopwatch() + sw.Start() + Do While sw.ElapsedMilliseconds < TIME_OUT + If dataAvailable Then + If testPort.ReadChar = Asc("T") Then + testResults = True + Exit Do + Else + 'We did not receive the expected response + dataAvailable = False + End If + End If + Loop + sw.Stop() + If testResults Then + TestMessage.Text = "Successfully received the expected response" + Else + TestMessage.Text = "Did not receive the expected response" + End If + TestMessage.Update() + + 'Remove the binding to the receive function + RemoveHandler testPort.DataReceived, AddressOf ReceivePortData + + 'Close the port + TestMessage.Text = "Attempting to close the port..." + TestMessage.Update() + testPort.Close() + TestMessage.Text = "Successfully closed the port" + TestMessage.Update() + + + Catch ex As Exception + 'TODO: Report the COM port testing exceptions + Finally + Test.Enabled = True + 'TODO: Use a flag to display the correct message + TestMessage.Text = "Successfully located the camera trigger on port " & COMPorts.Text + End Try + End Sub + + Private Sub ReceivePortData(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) + dataAvailable = True + End Sub + + Private Sub SelectCamera_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectCamera.Click + Try + Dim c As New WIA.CommonDialog + Dim camera As WIA.Device = c.ShowSelectDevice(WIA.WiaDeviceType.CameraDeviceType, True) + txtCamera.Text = camera.Properties.Item("Name").Value + My.Settings.CameraDeviceID = camera.DeviceID + + Catch ex As Exception + MessageBox.Show("Could not connect to any cameras." & vbCrLf & ex.Message) + End Try + End Sub +End Class diff --git a/PhotoBooth_WIA/PhotoBooth.sln b/PhotoBooth_WIA/PhotoBooth.sln new file mode 100644 index 0000000..800fb09 --- /dev/null +++ b/PhotoBooth_WIA/PhotoBooth.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "PhotoBooth", "PhotoBooth.vbproj", "{AC8A0784-DCCF-4401-ABC6-D3DD9EC5229E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AC8A0784-DCCF-4401-ABC6-D3DD9EC5229E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AC8A0784-DCCF-4401-ABC6-D3DD9EC5229E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC8A0784-DCCF-4401-ABC6-D3DD9EC5229E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AC8A0784-DCCF-4401-ABC6-D3DD9EC5229E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/PhotoBooth_WIA/PhotoBooth.vbproj b/PhotoBooth_WIA/PhotoBooth.vbproj new file mode 100644 index 0000000..afc7055 --- /dev/null +++ b/PhotoBooth_WIA/PhotoBooth.vbproj @@ -0,0 +1,216 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {AC8A0784-DCCF-4401-ABC6-D3DD9EC5229E} + WinExe + PhotoBooth.My.MyApplication + PhotoBooth + PhotoBooth + WindowsForms + 7B1EE7549F5DC64BC5F4853D6B882D1245690C98 + PhotoBooth_TemporaryKey.pfx + true + true + false + false + false + + + + + 2.0 + D:\programming\PhotoBooth\Deploy\PhotoBooth WIA\ + true + Disk + false + Foreground + 7 + Days + false + false + true + false + 11 + 1.0.0.%2a + false + true + + + true + full + true + true + bin\Debug\ + PhotoBooth.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + PhotoBooth.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + + + + + + + + + + Component + + + Debugger.vb + + + Form + + + + Form + + + Main.vb + Form + + + Component + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + Options.vb + + + Form + + + Presentation.vb + + + Form + + + Usage.vb + + + Form + + + FiveBottomPanel.vb + + + UserControl + + + + + Designer + Debugger.vb + + + Designer + Main.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + Designer + Options.vb + + + Designer + Presentation.vb + + + Designer + Usage.vb + + + Designer + FiveBottomPanel.vb + + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + {94A0E92D-43C0-494E-AC29-FD45948A5221} + 1 + 0 + 0 + tlbimp + False + + + + + \ No newline at end of file diff --git a/PhotoBooth_WIA/Presentation.Designer.vb b/PhotoBooth_WIA/Presentation.Designer.vb new file mode 100644 index 0000000..11a8ed6 --- /dev/null +++ b/PhotoBooth_WIA/Presentation.Designer.vb @@ -0,0 +1,163 @@ + _ +Partial Class Presentation + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel + Me.thumb2 = New System.Windows.Forms.PictureBox + Me.picBox = New System.Windows.Forms.PictureBox + Me.thumb1 = New System.Windows.Forms.PictureBox + Me.thumb4 = New System.Windows.Forms.PictureBox + Me.thumb3 = New System.Windows.Forms.PictureBox + Me.Label1 = New System.Windows.Forms.Label + Me.TableLayoutPanel1.SuspendLayout() + CType(Me.thumb2, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.picBox, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.thumb1, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.thumb4, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.thumb3, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'TableLayoutPanel1 + ' + Me.TableLayoutPanel1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.TableLayoutPanel1.ColumnCount = 2 + Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 75.0!)) + Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25.0!)) + Me.TableLayoutPanel1.Controls.Add(Me.thumb2, 1, 1) + Me.TableLayoutPanel1.Controls.Add(Me.picBox, 0, 0) + Me.TableLayoutPanel1.Controls.Add(Me.thumb1, 1, 0) + Me.TableLayoutPanel1.Controls.Add(Me.thumb4, 1, 3) + Me.TableLayoutPanel1.Controls.Add(Me.thumb3, 1, 2) + Me.TableLayoutPanel1.Controls.Add(Me.Label1, 0, 4) + Me.TableLayoutPanel1.Location = New System.Drawing.Point(12, 12) + Me.TableLayoutPanel1.Name = "TableLayoutPanel1" + Me.TableLayoutPanel1.RowCount = 5 + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25.0!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25.0!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25.0!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25.0!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20.0!)) + Me.TableLayoutPanel1.Size = New System.Drawing.Size(637, 489) + Me.TableLayoutPanel1.TabIndex = 3 + ' + 'thumb2 + ' + Me.thumb2.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.thumb2.Location = New System.Drawing.Point(480, 120) + Me.thumb2.Name = "thumb2" + Me.thumb2.Size = New System.Drawing.Size(154, 111) + Me.thumb2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom + Me.thumb2.TabIndex = 5 + Me.thumb2.TabStop = False + ' + 'picBox + ' + Me.picBox.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.picBox.Location = New System.Drawing.Point(3, 3) + Me.picBox.Name = "picBox" + Me.TableLayoutPanel1.SetRowSpan(Me.picBox, 4) + Me.picBox.Size = New System.Drawing.Size(471, 462) + Me.picBox.TabIndex = 3 + Me.picBox.TabStop = False + ' + 'thumb1 + ' + Me.thumb1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.thumb1.Location = New System.Drawing.Point(480, 3) + Me.thumb1.Name = "thumb1" + Me.thumb1.Size = New System.Drawing.Size(154, 111) + Me.thumb1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom + Me.thumb1.TabIndex = 4 + Me.thumb1.TabStop = False + ' + 'thumb4 + ' + Me.thumb4.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.thumb4.Location = New System.Drawing.Point(480, 354) + Me.thumb4.Name = "thumb4" + Me.thumb4.Size = New System.Drawing.Size(154, 111) + Me.thumb4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom + Me.thumb4.TabIndex = 4 + Me.thumb4.TabStop = False + ' + 'thumb3 + ' + Me.thumb3.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.thumb3.Location = New System.Drawing.Point(480, 237) + Me.thumb3.Name = "thumb3" + Me.thumb3.Size = New System.Drawing.Size(154, 111) + Me.thumb3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom + Me.thumb3.TabIndex = 4 + Me.thumb3.TabStop = False + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Font = New System.Drawing.Font("Arial Black", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label1.ForeColor = System.Drawing.Color.White + Me.Label1.Location = New System.Drawing.Point(3, 468) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(0, 18) + Me.Label1.TabIndex = 6 + ' + 'Presentation + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.BackColor = System.Drawing.Color.Black + Me.ClientSize = New System.Drawing.Size(661, 513) + Me.Controls.Add(Me.TableLayoutPanel1) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog + Me.Name = "Presentation" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Presentation" + Me.TableLayoutPanel1.ResumeLayout(False) + Me.TableLayoutPanel1.PerformLayout() + CType(Me.thumb2, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.picBox, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.thumb1, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.thumb4, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.thumb3, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + + End Sub + Friend WithEvents TableLayoutPanel1 As System.Windows.Forms.TableLayoutPanel + Friend WithEvents picBox As System.Windows.Forms.PictureBox + Friend WithEvents thumb1 As System.Windows.Forms.PictureBox + Friend WithEvents thumb2 As System.Windows.Forms.PictureBox + Friend WithEvents thumb4 As System.Windows.Forms.PictureBox + Friend WithEvents thumb3 As System.Windows.Forms.PictureBox + Friend WithEvents Label1 As System.Windows.Forms.Label +End Class diff --git a/PhotoBooth_WIA/Presentation.resx b/PhotoBooth_WIA/Presentation.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/PhotoBooth_WIA/Presentation.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PhotoBooth_WIA/Presentation.vb b/PhotoBooth_WIA/Presentation.vb new file mode 100644 index 0000000..3c84574 --- /dev/null +++ b/PhotoBooth_WIA/Presentation.vb @@ -0,0 +1,36 @@ +Public Class Presentation + Private mainFileName As String + Private previousFileName As String + Private photoCount As Integer = 0 + Private firstPass As Boolean = True + + Public Sub ShowImage(ByVal newImage As Image, ByVal fileName As String) + picBox.SizeMode = PictureBoxSizeMode.Zoom + picBox.Image = newImage + picBox.Refresh() + + 'This will be useful when adding the cached version to the thumbnail + 'strip along the right side of the screen + mainFileName = fileName + photoCount += 1 + + CycleThumbStrip() + + 'Update the message + Label1.Text = String.Format(My.Settings.CounterMessage, photoCount) + + firstPass = False + previousFileName = mainFileName + End Sub + + Private Sub CycleThumbStrip() + If firstPass = False Then + thumb4.Image = thumb3.Image + thumb3.Image = thumb2.Image + thumb2.Image = thumb1.Image + + thumb1.Image = Image.FromFile(My.Settings.ImageCache & "\" & previousFileName) + End If + End Sub + +End Class \ No newline at end of file diff --git a/PhotoBooth_WIA/Usage.Designer.vb b/PhotoBooth_WIA/Usage.Designer.vb new file mode 100644 index 0000000..8c31307 --- /dev/null +++ b/PhotoBooth_WIA/Usage.Designer.vb @@ -0,0 +1,265 @@ + _ +Partial Class Usage + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.Label1 = New System.Windows.Forms.Label + Me.Label2 = New System.Windows.Forms.Label + Me.Label3 = New System.Windows.Forms.Label + Me.Label5 = New System.Windows.Forms.Label + Me.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel + Me.Label15 = New System.Windows.Forms.Label + Me.Label12 = New System.Windows.Forms.Label + Me.Label11 = New System.Windows.Forms.Label + Me.Label4 = New System.Windows.Forms.Label + Me.Label10 = New System.Windows.Forms.Label + Me.Label9 = New System.Windows.Forms.Label + Me.Label8 = New System.Windows.Forms.Label + Me.Label6 = New System.Windows.Forms.Label + Me.Label7 = New System.Windows.Forms.Label + Me.Label13 = New System.Windows.Forms.Label + Me.Label14 = New System.Windows.Forms.Label + Me.Label16 = New System.Windows.Forms.Label + Me.TableLayoutPanel1.SuspendLayout() + Me.SuspendLayout() + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(3, 0) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(183, 14) + Me.Label1.TabIndex = 0 + Me.Label1.Text = "Start/stop the photo booth:" + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Location = New System.Drawing.Point(3, 50) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(258, 14) + Me.Label2.TabIndex = 1 + Me.Label2.Text = "Toggle full screen and windowed mode:" + ' + 'Label3 + ' + Me.Label3.AutoSize = True + Me.Label3.Location = New System.Drawing.Point(3, 25) + Me.Label3.Name = "Label3" + Me.Label3.Size = New System.Drawing.Size(61, 14) + Me.Label3.TabIndex = 2 + Me.Label3.Text = "Options:" + ' + 'Label5 + ' + Me.Label5.AutoSize = True + Me.Label5.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label5.ForeColor = System.Drawing.Color.White + Me.Label5.Location = New System.Drawing.Point(37, 30) + Me.Label5.Name = "Label5" + Me.Label5.Size = New System.Drawing.Size(85, 14) + Me.Label5.TabIndex = 4 + Me.Label5.Text = "Photo Booth" + ' + 'TableLayoutPanel1 + ' + Me.TableLayoutPanel1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.TableLayoutPanel1.ColumnCount = 2 + Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 68.32669!)) + Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 31.67331!)) + Me.TableLayoutPanel1.Controls.Add(Me.Label15, 1, 5) + Me.TableLayoutPanel1.Controls.Add(Me.Label12, 1, 4) + Me.TableLayoutPanel1.Controls.Add(Me.Label11, 1, 3) + Me.TableLayoutPanel1.Controls.Add(Me.Label4, 0, 6) + Me.TableLayoutPanel1.Controls.Add(Me.Label10, 1, 2) + Me.TableLayoutPanel1.Controls.Add(Me.Label9, 1, 1) + Me.TableLayoutPanel1.Controls.Add(Me.Label1, 0, 0) + Me.TableLayoutPanel1.Controls.Add(Me.Label3, 0, 1) + Me.TableLayoutPanel1.Controls.Add(Me.Label8, 1, 0) + Me.TableLayoutPanel1.Controls.Add(Me.Label2, 0, 2) + Me.TableLayoutPanel1.Controls.Add(Me.Label6, 0, 3) + Me.TableLayoutPanel1.Controls.Add(Me.Label7, 0, 4) + Me.TableLayoutPanel1.Controls.Add(Me.Label13, 1, 6) + Me.TableLayoutPanel1.Controls.Add(Me.Label14, 0, 5) + Me.TableLayoutPanel1.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.TableLayoutPanel1.ForeColor = System.Drawing.Color.White + Me.TableLayoutPanel1.Location = New System.Drawing.Point(34, 72) + Me.TableLayoutPanel1.Margin = New System.Windows.Forms.Padding(25) + Me.TableLayoutPanel1.Name = "TableLayoutPanel1" + Me.TableLayoutPanel1.RowCount = 7 + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25.0!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25.0!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25.0!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25.0!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25.0!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25.0!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25.0!)) + Me.TableLayoutPanel1.Size = New System.Drawing.Size(447, 193) + Me.TableLayoutPanel1.TabIndex = 5 + ' + 'Label15 + ' + Me.Label15.AutoSize = True + Me.Label15.Location = New System.Drawing.Point(308, 125) + Me.Label15.Name = "Label15" + Me.Label15.Size = New System.Drawing.Size(16, 14) + Me.Label15.TabIndex = 13 + Me.Label15.Text = "U" + ' + 'Label12 + ' + Me.Label12.AutoSize = True + Me.Label12.Location = New System.Drawing.Point(308, 100) + Me.Label12.Name = "Label12" + Me.Label12.Size = New System.Drawing.Size(14, 14) + Me.Label12.TabIndex = 10 + Me.Label12.Text = "T" + ' + 'Label11 + ' + Me.Label11.AutoSize = True + Me.Label11.Location = New System.Drawing.Point(308, 75) + Me.Label11.Name = "Label11" + Me.Label11.Size = New System.Drawing.Size(16, 14) + Me.Label11.TabIndex = 9 + Me.Label11.Text = "D" + ' + 'Label4 + ' + Me.Label4.AutoSize = True + Me.Label4.Location = New System.Drawing.Point(3, 150) + Me.Label4.Name = "Label4" + Me.Label4.Size = New System.Drawing.Size(35, 14) + Me.Label4.TabIndex = 3 + Me.Label4.Text = "Exit:" + ' + 'Label10 + ' + Me.Label10.AutoSize = True + Me.Label10.Location = New System.Drawing.Point(308, 50) + Me.Label10.Name = "Label10" + Me.Label10.Size = New System.Drawing.Size(78, 14) + Me.Label10.TabIndex = 8 + Me.Label10.Text = "Page down" + ' + 'Label9 + ' + Me.Label9.AutoSize = True + Me.Label9.Location = New System.Drawing.Point(308, 25) + Me.Label9.Name = "Label9" + Me.Label9.Size = New System.Drawing.Size(17, 14) + Me.Label9.TabIndex = 7 + Me.Label9.Text = "O" + ' + 'Label8 + ' + Me.Label8.AutoSize = True + Me.Label8.Location = New System.Drawing.Point(308, 0) + Me.Label8.Name = "Label8" + Me.Label8.Size = New System.Drawing.Size(15, 14) + Me.Label8.TabIndex = 6 + Me.Label8.Text = "S" + ' + 'Label6 + ' + Me.Label6.AutoSize = True + Me.Label6.Location = New System.Drawing.Point(3, 75) + Me.Label6.Name = "Label6" + Me.Label6.Size = New System.Drawing.Size(144, 14) + Me.Label6.TabIndex = 4 + Me.Label6.Text = "Show debug window:" + ' + 'Label7 + ' + Me.Label7.AutoSize = True + Me.Label7.Location = New System.Drawing.Point(3, 100) + Me.Label7.Name = "Label7" + Me.Label7.Size = New System.Drawing.Size(95, 14) + Me.Label7.TabIndex = 5 + Me.Label7.Text = "Take a photo:" + ' + 'Label13 + ' + Me.Label13.AutoSize = True + Me.Label13.Location = New System.Drawing.Point(308, 150) + Me.Label13.Name = "Label13" + Me.Label13.Size = New System.Drawing.Size(28, 14) + Me.Label13.TabIndex = 11 + Me.Label13.Text = "Esc" + ' + 'Label14 + ' + Me.Label14.AutoSize = True + Me.Label14.Location = New System.Drawing.Point(3, 125) + Me.Label14.Name = "Label14" + Me.Label14.Size = New System.Drawing.Size(113, 14) + Me.Label14.TabIndex = 12 + Me.Label14.Text = "Show this menu:" + ' + 'Label16 + ' + Me.Label16.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) + Me.Label16.AutoSize = True + Me.Label16.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label16.ForeColor = System.Drawing.Color.White + Me.Label16.Location = New System.Drawing.Point(37, 275) + Me.Label16.Name = "Label16" + Me.Label16.Size = New System.Drawing.Size(226, 14) + Me.Label16.TabIndex = 6 + Me.Label16.Text = "Press any key to close this menu..." + ' + 'Usage + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.BackColor = System.Drawing.Color.Black + Me.ClientSize = New System.Drawing.Size(515, 325) + Me.Controls.Add(Me.Label16) + Me.Controls.Add(Me.TableLayoutPanel1) + Me.Controls.Add(Me.Label5) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None + Me.Name = "Usage" + Me.ShowInTaskbar = False + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent + Me.Text = "Usage" + Me.TableLayoutPanel1.ResumeLayout(False) + Me.TableLayoutPanel1.PerformLayout() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents Label2 As System.Windows.Forms.Label + Friend WithEvents Label3 As System.Windows.Forms.Label + Friend WithEvents Label5 As System.Windows.Forms.Label + Friend WithEvents TableLayoutPanel1 As System.Windows.Forms.TableLayoutPanel + Friend WithEvents Label6 As System.Windows.Forms.Label + Friend WithEvents Label7 As System.Windows.Forms.Label + Friend WithEvents Label4 As System.Windows.Forms.Label + Friend WithEvents Label8 As System.Windows.Forms.Label + Friend WithEvents Label12 As System.Windows.Forms.Label + Friend WithEvents Label11 As System.Windows.Forms.Label + Friend WithEvents Label10 As System.Windows.Forms.Label + Friend WithEvents Label9 As System.Windows.Forms.Label + Friend WithEvents Label13 As System.Windows.Forms.Label + Friend WithEvents Label15 As System.Windows.Forms.Label + Friend WithEvents Label14 As System.Windows.Forms.Label + Friend WithEvents Label16 As System.Windows.Forms.Label +End Class diff --git a/PhotoBooth_WIA/Usage.resx b/PhotoBooth_WIA/Usage.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/PhotoBooth_WIA/Usage.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PhotoBooth_WIA/Usage.vb b/PhotoBooth_WIA/Usage.vb new file mode 100644 index 0000000..a6fc3d8 --- /dev/null +++ b/PhotoBooth_WIA/Usage.vb @@ -0,0 +1,30 @@ +Public Class Usage + + Private Sub Usage_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown + Me.Close() + End Sub + + Private Sub Usage_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load + Me.StartPosition = FormStartPosition.CenterParent + End Sub + + Private Sub Usage_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint + DrawFormBorder() + End Sub + + Private Sub DrawFormBorder() + ' Draw a thin border 10 pixels in on all sides + Const BORDER_MARGIN = 10 + + Dim myPen As New System.Drawing.Pen(System.Drawing.Color.White) + Dim formGraphics As System.Drawing.Graphics + + formGraphics = Me.CreateGraphics() + formGraphics.DrawRectangle(myPen, _ + BORDER_MARGIN, BORDER_MARGIN, _ + Me.Width - BORDER_MARGIN * 2, Me.Height - BORDER_MARGIN * 2) + + myPen.Dispose() + formGraphics.Dispose() + End Sub +End Class \ No newline at end of file diff --git a/PhotoBooth_WIA/app.config b/PhotoBooth_WIA/app.config new file mode 100644 index 0000000..8d890e1 --- /dev/null +++ b/PhotoBooth_WIA/app.config @@ -0,0 +1,64 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2.5 + + + COM1 + + + Prepare for automagic + + + + + + Arial Black, 18pt + + + + + + The automagic failed. Try again. + + + {0} kinds of automagic + + + + diff --git a/Presentation/EZLogger.vb b/Presentation/EZLogger.vb new file mode 100644 index 0000000..4a386fa --- /dev/null +++ b/Presentation/EZLogger.vb @@ -0,0 +1,408 @@ +Imports System +Imports System.IO + +Public Class EZLogger + + ''/// + ''/// An object that provides basic logging capabilities. + ''/// Copyright (c) 2006 Ravi Bhavnani, ravib@ravib.com + ''/// + ''/// This software may be freely used in any product or + ''/// work, provided this copyright notice is maintained. + ''/// To help ensure a single point of release, please + ''/// email and bug reports, flames and suggestions to + ''/// ravib@ravib.com. + ''/// + +#Region "Events" + Event Updated() +#End Region + +#Region "Attributes" + + ''/// + ''/// Log levels. + ''/// + Public Enum Level + ''/// Log debug messages. + Debug = 1 + + ''/// Log informational messages. + Info = 2 + + ''/// Log success messages. + Success = 4 + + ''/// Log warning messages. + Warning = 8 + + ''/// Log error messages. + Errors = 16 + + ''/// Log fatal errors. + Fatal = 32 + + ''/// Log all messages. + All = 65535 ' 0xFFFF + End Enum + + ''/// + ''/// The logger's state. + ''/// + Public Enum State + ''/// The logger is stopped. + Stopped = 0 + ''/// The logger has been started. + Running + ''/// The logger is paused. + Paused + End Enum + +#End Region + +#Region "Construction/destruction" + + ''/// + ''/// Constructs a EZLogger. + ''/// + ''/// Log file to receive output. + ''/// Flag: append to existing file (if any). + ''/// Flag: cache log in memory. + ''/// Mask indicating log levels of interest. + Public Sub New(ByVal logFilename As String, ByVal bAppend As Boolean, ByVal logLevels As UInteger, ByVal bCacheInMemory As Boolean) + _logFilename = logFilename + _bAppend = bAppend + _bCacheInMemory = bCacheInMemory + _levels = logLevels + + _logMem = New ArrayList + End Sub + + ''/// + ''/// Private default constructor. + ''/// + Private Sub New() + ' + End Sub +#End Region + +#Region "Properties" + + ''/// + ''/// Gets and sets the log level. + ''/// + Public Property Levels() As UInteger + Get + Return _levels + End Get + Set(ByVal value As UInteger) + _levels = value + End Set + End Property + + ''/// + ''/// Retrieves the logger's state. + ''/// + Public ReadOnly Property LoggerState() As State + Get + Return _state + End Get + End Property + + ''/// + ''/// Retrieves the log. + ''/// + Public ReadOnly Property Log() As ArrayList + Get + Return _logMem + End Get + End Property +#End Region + +#Region "Operations" + + ''/// + ''/// Starts logging. + ''/// + ''/// true if successful, false otherwise. + Public Function StartLog() As Boolean + SyncLock Me + '// Fail if logging has already been started + If LoggerState <> State.Stopped Then + Return False + End If + + '// Fail if the log file isn't specified + If String.IsNullOrEmpty(_logFilename) Then + Return False + End If + + '// Delete log file if it exists + If Not _bAppend Then + Try + File.Delete(_logFilename) + Catch ex As Exception + Return False + End Try + End If + + '// Open file for writing - return on error + If File.Exists(_logFilename) = False Then + Try + _logFile = File.CreateText(_logFilename) + Catch ex As Exception + _logFile = Nothing + Return False + End Try + Else + Try + _logFile = File.AppendText(_logFilename) + Catch ex As Exception + _logFile = Nothing + Return False + End Try + End If + + _logFile.AutoFlush = True + + '// Return successfully + _state = EZLogger.State.Running + Return True + End SyncLock + End Function + + ''/// + ''/// Temporarily suspends logging. + ''/// + ''/// true if successful, false otherwise. + Public Function PauseLog() As Boolean + SyncLock Me + '// Fail if logging hasn't been started + If LoggerState <> State.Running Then + Return False + End If + + '// Pause the logger + _state = EZLogger.State.Paused + Return True + End SyncLock + End Function + + + ''/// + ''/// Resumes logging. + ''/// + ''/// true if successful, false otherwise. + Public Function ResumeLog() As Boolean + SyncLock Me + '// Fail if logging hasn't been paused + If LoggerState <> State.Paused Then + Return False + End If + + '// Resume logging + _state = EZLogger.State.Running + Return True + End SyncLock + End Function + + ''/// + ''/// Stops logging. + ''/// + ''/// true if successful, false otherwise. + Public Function StopLog() As Boolean + SyncLock Me + '// Fail if logging hasn't been started + If LoggerState <> State.Running Then + Return False + End If + + '// Stop logging + Try + _logFile.Close() + _logFile = Nothing + + Catch ex As Exception + Return False + End Try + + _state = EZLogger.State.Stopped + Return True + End SyncLock + End Function + + ''/// + ''/// Logs a debug message. + ''/// + ''/// The message. + ''/// true if successful, false otherwise. + Public Function Debug(ByVal msg As String) As Boolean + _debugMsgs += 1 + Return WriteLogMsg(Level.Debug, msg) + End Function + + ''/// + ''/// Logs an informational message. + ''/// + ''/// The message. + ''/// true if successful, false otherwise. + Public Function Info(ByVal msg As String) As Boolean + _infoMsgs += 1 + Return WriteLogMsg(Level.Info, msg) + End Function + + ''/// + ''/// Logs a success message. + ''/// + ''/// The message. + ''/// true if successful, false otherwise. + Public Function Success(ByVal msg As String) As Boolean + _successMsgs += 1 + Return WriteLogMsg(Level.Success, msg) + End Function + + ''/// + ''/// Logs a warning message. + ''/// + ''/// The message. + ''/// true if successful, false otherwise. + Public Function Warning(ByVal msg As String) As Boolean + _warningMsgs += 1 + Return WriteLogMsg(Level.Warning, msg) + End Function + + ''/// + ''/// Logs an error message. + ''/// + ''/// The message. + ''/// true if successful, false otherwise. + Public Function Errors(ByVal msg As String) As Boolean + _errorMsgs += 1 + Return WriteLogMsg(Level.Errors, msg) + End Function + + ''/// + ''/// Logs a fatal error message. + ''/// + ''/// The message. + ''/// true if successful, false otherwise. + Public Function Fatal(ByVal msg As String) As Boolean + _fatalMsgs += 1 + Return WriteLogMsg(Level.Fatal, msg) + End Function + + + ''/// + ''/// Retrieves the count of messages logged at one or more levels. + ''/// + ''/// Mask indicating levels of interest. + ''/// + Public Function GetMessageCount(ByVal levelMask As UInteger) As UInteger + Dim uMessages As UInteger = 0 + If ((levelMask & CUInt(Level.Debug)) <> 0) Then + uMessages += _debugMsgs + End If + If ((levelMask & CUInt(Level.Info)) <> 0) Then + uMessages += _infoMsgs + End If + If ((levelMask & CUInt(Level.Success)) <> 0) Then + uMessages += _successMsgs + End If + If ((levelMask & CUInt(Level.Warning)) <> 0) Then + uMessages += _warningMsgs + End If + If ((levelMask & CUInt(Level.Errors)) <> 0) Then + uMessages += _errorMsgs + End If + If ((levelMask & CUInt(Level.Fatal)) <> 0) Then + uMessages += _fatalMsgs + End If + Return uMessages + End Function + +#End Region + +#Region "Helper methods" + + ''/// + ''/// Writes a log message. + ''/// + ''/// + ''/// + ''/// + Private Function WriteLogMsg(ByVal level As Level, ByVal msg As String) As Boolean + SyncLock Me + '// Fail if logger hasn't been started + If (LoggerState = State.Stopped) Then + Return False + End If + + '// Ignore message logging is paused or it doesn't pass the filter + If ((LoggerState = State.Paused) Or ((_levels And CUInt(level)) <> CUInt(level))) Then + Return True + End If + + '// Write log message + Dim tmNow As DateTime = DateTime.Now + Dim logMsg As String = String.Format("{0} {1} {2}: {3}", _ + tmNow.ToShortDateString(), tmNow.ToLongTimeString(), _ + level.ToString().Substring(0, 1), msg) + _logFile.WriteLine(logMsg) + + If _bCacheInMemory Then + _logMem.Add(logMsg) + End If + + RaiseEvent Updated() + + Return True + End SyncLock + End Function + +#End Region + +#Region "Fields" + + ''/// Name of the log file. + Private _logFilename As String + + ''/// Flag: append to existing file (if any). + Private _bAppend As Boolean = True + + ''/// Flag: append to an array list in memory. + Private _bCacheInMemory As Boolean = True + + ''/// The log file. + Private _logFile As StreamWriter = Nothing + + ''/// The log in memory. + Private _logMem As ArrayList = Nothing + + ''/// Levels to be logged. + Private _levels As UInteger = (Level.Warning Or Level.Errors Or Level.Fatal) + + ''/// The logger's state. + Private _state As State = State.Stopped + + ''/// Number of debug messages that have been logged. + Private _debugMsgs As UInteger = 0 + + ''/// Number of informational messages that have been logged. + Private _infoMsgs As UInteger = 0 + + ''/// Number of success messages that have been logged. + Private _successMsgs As UInteger = 0 + + ''/// Number of warning messages that have been logged. + Private _warningMsgs As UInteger = 0 + + ''/// Number of error messages that have been logged. + Private _errorMsgs As UInteger = 0 + + ''/// Number of fatal messages that have been logged. + Private _fatalMsgs As UInteger = 0 + +#End Region + +End Class + diff --git a/Presentation/FrameRate.vb b/Presentation/FrameRate.vb new file mode 100644 index 0000000..3653855 --- /dev/null +++ b/Presentation/FrameRate.vb @@ -0,0 +1,20 @@ +Public Class FrameRate + + Private Shared lastTick As Integer + Private Shared lastFrameRate As Integer + Private Shared frameRate As Integer + + Public Shared Function CalculateFrameRate() As Integer + + If System.Environment.TickCount - lastTick >= 1000 Then + lastFrameRate = frameRate + frameRate = 0 + lastTick = System.Environment.TickCount + End If + + frameRate += 1 + + Return lastFrameRate + + End Function 'CalculateFrameRate +End Class diff --git a/Presentation/HiResTimer.vb b/Presentation/HiResTimer.vb new file mode 100644 index 0000000..64f2348 --- /dev/null +++ b/Presentation/HiResTimer.vb @@ -0,0 +1,139 @@ +Imports System.Runtime.InteropServices + +Class HiResTimer + + Private Sub New() + End Sub + + Shared Sub New() + isTimerStopped = True + ticksPerSecond = 0 + stopTime = 0 + lastElapsedTime = 0 + baseTime = 0 + isUsingQPF = QueryPerformanceFrequency(ticksPerSecond) + End Sub + + Public Shared Sub Reset() + If Not isUsingQPF Then + Return + End If + Dim time As Long = 0 + If Not (stopTime = 0) Then + time = stopTime + Else + QueryPerformanceCounter(time) + End If + baseTime = time + lastElapsedTime = time + stopTime = 0 + isTimerStopped = False + End Sub + + Public Shared Sub Start() + If Not isUsingQPF Then + Return + End If + Dim time As Long = 0 + If Not (stopTime = 0) Then + time = stopTime + Else + QueryPerformanceCounter(time) + End If + If isTimerStopped Then + baseTime += (time - stopTime) + End If + stopTime = 0 + lastElapsedTime = time + isTimerStopped = False + End Sub + + Public Shared Sub StopTimer() + If Not isUsingQPF Then + Return + End If + If Not isTimerStopped Then + Dim time As Long = 0 + If Not (stopTime = 0) Then + time = stopTime + Else + QueryPerformanceCounter(time) + End If + stopTime = time + lastElapsedTime = time + isTimerStopped = True + End If + End Sub + + Public Shared Sub Advance() + If Not isUsingQPF Then + Return + End If + stopTime += ticksPerSecond / 10 + End Sub + + Public Shared Function GetAbsoluteTime() As Single + If Not isUsingQPF Then + Return -1 + End If + Dim time As Long = 0 + If Not (stopTime = 0) Then + time = stopTime + Else + QueryPerformanceCounter(time) + End If + Dim absolueTime As Double = time / CType(ticksPerSecond, Double) + Return CType(absolueTime, Single) + End Function + + Public Shared Function GetTime() As Double + If Not isUsingQPF Then + Return -1 + End If + Dim time As Long = 0 + If Not (stopTime = 0) Then + time = stopTime + Else + QueryPerformanceCounter(time) + End If + Dim appTime As Double = CType((time - baseTime), Double) / CType(ticksPerSecond, Double) + Return appTime + End Function + + Public Shared Function GetElapsedTime() As Double + If Not isUsingQPF Then + Return -1 + End If + Dim time As Long = 0 + If Not (stopTime = 0) Then + time = stopTime + Else + QueryPerformanceCounter(time) + End If + Dim elapsedTime As Double = CType((time - lastElapsedTime), Double) / CType(ticksPerSecond, Double) + lastElapsedTime = time + Return elapsedTime + End Function + + Public Shared ReadOnly Property IsStopped() As Boolean + Get + Return isTimerStopped + End Get + End Property + Private Shared isUsingQPF As Boolean + Private Shared isTimerStopped As Boolean + Private Shared ticksPerSecond As Long + Private Shared stopTime As Long + Private Shared lastElapsedTime As Long + Private Shared baseTime As Long + + _ + _ + Public Shared Function QueryPerformanceFrequency(ByRef PerformanceFrequency As Long) As Boolean + End Function + + _ + _ + Public Shared Function QueryPerformanceCounter(ByRef PerformanceCount As Long) As Boolean + End Function +End Class diff --git a/Presentation/Main.vb b/Presentation/Main.vb new file mode 100644 index 0000000..5009442 --- /dev/null +++ b/Presentation/Main.vb @@ -0,0 +1,20 @@ +Module Main + Public Sub Main() + Dim theOptions As New Options + If theOptions.ShowDialog() = DialogResult.Cancel Then + Exit Sub + End If + + Randomize() + + Dim frm As New RenderForm + If frm.InitializeGraphics() Then + frm.Show() + + Do While frm.Created + frm.Render() + Application.DoEvents() + Loop + End If + End Sub +End Module diff --git a/Presentation/My Project/Application.Designer.vb b/Presentation/My Project/Application.Designer.vb new file mode 100644 index 0000000..40fce7c --- /dev/null +++ b/Presentation/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/Presentation/My Project/Application.myapp b/Presentation/My Project/Application.myapp new file mode 100644 index 0000000..ff73056 --- /dev/null +++ b/Presentation/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + Form1 + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/Presentation/My Project/AssemblyInfo.vb b/Presentation/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..356a2dc --- /dev/null +++ b/Presentation/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' 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. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' 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: +' + + + diff --git a/Presentation/My Project/Resources.Designer.vb b/Presentation/My Project/Resources.Designer.vb new file mode 100644 index 0000000..3ad4e33 --- /dev/null +++ b/Presentation/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Imports System + +Namespace My.Resources + + '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. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("PhotoShow.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Presentation/My Project/Resources.resx b/Presentation/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Presentation/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Presentation/My Project/Settings.Designer.vb b/Presentation/My Project/Settings.Designer.vb new file mode 100644 index 0000000..33d79ce --- /dev/null +++ b/Presentation/My Project/Settings.Designer.vb @@ -0,0 +1,85 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.1433 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings),MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + + _ + Public Property WatchFolder() As String + Get + Return CType(Me("WatchFolder"),String) + End Get + Set + Me("WatchFolder") = value + End Set + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.PhotoShow.My.MySettings + Get + Return Global.PhotoShow.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Presentation/My Project/Settings.settings b/Presentation/My Project/Settings.settings new file mode 100644 index 0000000..beba7dd --- /dev/null +++ b/Presentation/My Project/Settings.settings @@ -0,0 +1,9 @@ + + + + + + c:\ + + + \ No newline at end of file diff --git a/Presentation/Options.Designer.vb b/Presentation/Options.Designer.vb new file mode 100644 index 0000000..669194b --- /dev/null +++ b/Presentation/Options.Designer.vb @@ -0,0 +1,127 @@ + _ +Partial Class Options + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel + Me.OK_Button = New System.Windows.Forms.Button + Me.Cancel_Button = New System.Windows.Forms.Button + Me.Button2 = New System.Windows.Forms.Button + Me.Label1 = New System.Windows.Forms.Label + Me.txtWatchPath = New System.Windows.Forms.TextBox + Me.FolderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog + Me.TableLayoutPanel1.SuspendLayout() + Me.SuspendLayout() + ' + 'TableLayoutPanel1 + ' + Me.TableLayoutPanel1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.TableLayoutPanel1.ColumnCount = 2 + Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) + Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) + Me.TableLayoutPanel1.Controls.Add(Me.OK_Button, 0, 0) + Me.TableLayoutPanel1.Controls.Add(Me.Cancel_Button, 1, 0) + Me.TableLayoutPanel1.Location = New System.Drawing.Point(286, 75) + Me.TableLayoutPanel1.Name = "TableLayoutPanel1" + Me.TableLayoutPanel1.RowCount = 1 + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) + Me.TableLayoutPanel1.Size = New System.Drawing.Size(146, 29) + Me.TableLayoutPanel1.TabIndex = 0 + ' + 'OK_Button + ' + Me.OK_Button.Anchor = System.Windows.Forms.AnchorStyles.None + Me.OK_Button.Location = New System.Drawing.Point(3, 3) + Me.OK_Button.Name = "OK_Button" + Me.OK_Button.Size = New System.Drawing.Size(67, 23) + Me.OK_Button.TabIndex = 0 + Me.OK_Button.Text = "OK" + ' + 'Cancel_Button + ' + Me.Cancel_Button.Anchor = System.Windows.Forms.AnchorStyles.None + Me.Cancel_Button.DialogResult = System.Windows.Forms.DialogResult.Cancel + Me.Cancel_Button.Location = New System.Drawing.Point(76, 3) + Me.Cancel_Button.Name = "Cancel_Button" + Me.Cancel_Button.Size = New System.Drawing.Size(67, 23) + Me.Cancel_Button.TabIndex = 1 + Me.Cancel_Button.Text = "Cancel" + ' + 'Button2 + ' + Me.Button2.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.Button2.Location = New System.Drawing.Point(403, 28) + Me.Button2.Name = "Button2" + Me.Button2.Size = New System.Drawing.Size(26, 20) + Me.Button2.TabIndex = 9 + Me.Button2.Text = "..." + Me.Button2.UseVisualStyleBackColor = True + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(9, 12) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(82, 13) + Me.Label1.TabIndex = 8 + Me.Label1.Text = "Watch location:" + ' + 'txtWatchPath + ' + Me.txtWatchPath.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.txtWatchPath.DataBindings.Add(New System.Windows.Forms.Binding("Text", Global.PhotoShow.My.MySettings.Default, "WatchFolder", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)) + Me.txtWatchPath.Location = New System.Drawing.Point(12, 28) + Me.txtWatchPath.Name = "txtWatchPath" + Me.txtWatchPath.Size = New System.Drawing.Size(385, 20) + Me.txtWatchPath.TabIndex = 7 + Me.txtWatchPath.Text = Global.PhotoShow.My.MySettings.Default.WatchFolder + ' + 'Options + ' + Me.AcceptButton = Me.OK_Button + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.CancelButton = Me.Cancel_Button + Me.ClientSize = New System.Drawing.Size(444, 116) + Me.Controls.Add(Me.Button2) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.txtWatchPath) + Me.Controls.Add(Me.TableLayoutPanel1) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "Options" + Me.ShowInTaskbar = False + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Options" + Me.TableLayoutPanel1.ResumeLayout(False) + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents TableLayoutPanel1 As System.Windows.Forms.TableLayoutPanel + Friend WithEvents OK_Button As System.Windows.Forms.Button + Friend WithEvents Cancel_Button As System.Windows.Forms.Button + Friend WithEvents Button2 As System.Windows.Forms.Button + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents txtWatchPath As System.Windows.Forms.TextBox + Friend WithEvents FolderBrowserDialog1 As System.Windows.Forms.FolderBrowserDialog + +End Class diff --git a/Presentation/Options.resx b/Presentation/Options.resx new file mode 100644 index 0000000..dd4486b --- /dev/null +++ b/Presentation/Options.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Presentation/Options.vb b/Presentation/Options.vb new file mode 100644 index 0000000..d41340c --- /dev/null +++ b/Presentation/Options.vb @@ -0,0 +1,20 @@ +Imports System.Windows.Forms + +Public Class Options + + Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click + Me.DialogResult = System.Windows.Forms.DialogResult.OK + Me.Close() + End Sub + + Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click + Me.DialogResult = System.Windows.Forms.DialogResult.Cancel + Me.Close() + End Sub + + Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click + If FolderBrowserDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then + txtWatchPath.Text = FolderBrowserDialog1.SelectedPath + End If + End Sub +End Class diff --git a/Presentation/Photo.vb b/Presentation/Photo.vb new file mode 100644 index 0000000..b21c4ae --- /dev/null +++ b/Presentation/Photo.vb @@ -0,0 +1,185 @@ +Imports Microsoft.DirectX +Imports Microsoft.DirectX.Direct3D + +Public Class Photo + Private Const m_ScatterRadius = 75.0F + Private Const m_ScatterUpperLimit = m_ScatterRadius + Private Const m_ScatterLowerLimtit = -m_ScatterRadius + + Private m_Height As Single = 20.0F + Private m_Width As Single = 20.0F + Private m_XOffset As Single = 0.0F + Private m_YOffset As Single = 0.0F + Private m_ZOffset As Single = 0.0F + + Private m_InMotion As Boolean = False + Private m_T As Single = 0.0F + Private m_TimeElapsed As Single = 0.0F + + Private m_Device As Device + Private m_Texture As Texture + Private m_Photo As VertexBuffer + Private m_Vertices As CustomVertex.PositionNormalTextured() + Private m_Position As Vector3 + Private m_Home As Vector3 + + Public Sub New(ByVal device As Device, ByVal position As Vector3) + m_Device = device + m_Home = position + m_Position = position + SetupPhotoFaces() + End Sub + + Public Sub New(ByVal device As Device, ByVal position As Vector3, ByVal texture As Texture) + Me.New(device, position) + m_Texture = texture + End Sub + + Public Sub Update(ByVal deltaTime As Single) + + If m_InMotion Then + m_T += (1.0F / (2.0F / deltaTime)) + If m_T <= 1.0F Then + m_Position.X = (m_Home.X - m_XOffset) * m_T + m_XOffset + m_Position.Y = (m_Home.Y - m_YOffset) * m_T + m_YOffset + m_Position.Z = (m_Home.Z - m_ZOffset) * m_T + m_ZOffset + Else + 'Me.MoveHome() + 'm_Position.X = m_Home.X + 'm_Position.Y = m_Home.Y + 'm_Position.Z = m_Home.Z + m_InMotion = False + m_T = 0.0F + End If + + ' Hold the current jitter position for a little while + If m_TimeElapsed > 0.025F Then + 'm_Position.X += CType(Rnd() * 0.1, Single) + 'm_Position.Y += CType(Rnd() * 0.1, Single) + + m_TimeElapsed = 0 + Else + m_TimeElapsed += deltaTime + End If + End If + End Sub + + Public Sub Render() + Me.Render(m_Texture) + End Sub + + Public Sub Render(ByVal texture As Texture) + m_Texture = texture + + m_Device.Transform.World = Matrix.Translation(m_Position) + + m_Device.RenderState.ZBufferWriteEnable = False + m_Device.RenderState.ZBufferEnable = False + + RenderPhoto() + + m_Device.RenderState.ZBufferWriteEnable = True + m_Device.RenderState.ZBufferEnable = True + End Sub + + ' Move the partical to a random point in space + Public Sub Scatter() + m_XOffset = (m_ScatterUpperLimit - m_ScatterLowerLimtit + 1) * Rnd() + m_ScatterLowerLimtit + m_XOffset += 100 * Math.Sign(m_XOffset) + + m_YOffset = (m_ScatterUpperLimit - m_ScatterLowerLimtit + 1) * Rnd() + m_ScatterLowerLimtit + m_YOffset += 100 * Math.Sign(m_YOffset) + + m_ZOffset = m_Home.Z + + m_T = 0 + m_InMotion = True + End Sub + + Public Sub Scatter(ByVal returnTo As Vector3) + Me.Scatter() + m_Home = returnTo + End Sub + + ' Move the photo to its home location + Public Sub MoveHome() + m_XOffset = m_Home.X + m_YOffset = m_Home.Y + m_ZOffset = m_Home.Z + m_InMotion = True + End Sub + + ' Send the particle from its current home location to a new home location + Public Sub MoveTo(ByVal position As Vector3) + m_XOffset = m_Home.X + m_YOffset = m_Home.Y + m_ZOffset = m_Home.Z + m_Home = position + m_T = 0 + m_InMotion = True + End Sub + + Private Sub RenderPhoto() + m_Device.SetStreamSource(0, m_Photo, 0) + m_Device.VertexFormat = CustomVertex.PositionNormalTextured.Format + m_Device.SetTexture(0, m_Texture) + m_Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2) + End Sub + + Private Sub SetupPhotoFaces() + m_Vertices = New CustomVertex.PositionNormalTextured(4) {} + + m_Vertices(0).X = m_Home.X - (m_Width / 2) + m_Vertices(0).Y = m_Home.Y + (m_Height / 2) + m_Vertices(0).Z = m_Home.Z + m_Vertices(0).Tu = 0.0F + m_Vertices(0).Tv = 0.0F + m_Vertices(0).Nx = 0.0F + m_Vertices(0).Ny = 0.0F + m_Vertices(0).Nz = -1.0F + m_Vertices(1).X = m_Home.X + (m_Width / 2) + m_Vertices(1).Y = m_Home.Y + (m_Height / 2) + m_Vertices(1).Z = m_Home.Z + m_Vertices(1).Tu = 1.0F + m_Vertices(1).Tv = 0.0F + m_Vertices(1).Nx = 0.0F + m_Vertices(1).Ny = 0.0F + m_Vertices(1).Nz = -1.0F + m_Vertices(2).X = m_Home.X - (m_Width / 2) + m_Vertices(2).Y = m_Home.Y - (m_Height / 2) + m_Vertices(2).Z = m_Home.Z + m_Vertices(2).Tu = 0.0F + m_Vertices(2).Tv = 1.0F + m_Vertices(2).Nx = 0.0F + m_Vertices(2).Ny = 0.0F + m_Vertices(2).Nz = -1.0F + m_Vertices(3).X = m_Home.X + (m_Width / 2) + m_Vertices(3).Y = m_Home.Y - (m_Height / 2) + m_Vertices(3).Z = m_Home.Z + m_Vertices(3).Tu = 1.0F + m_Vertices(3).Tv = 1.0F + m_Vertices(3).Nx = 0.0F + m_Vertices(3).Ny = 0.0F + m_Vertices(3).Nz = -1.0F + + m_Photo = New VertexBuffer(GetType(CustomVertex.PositionNormalTextured), _ + 4, m_Device, Usage.WriteOnly, CustomVertex.PositionNormalTextured.Format, Pool.Default) + + m_Photo.SetData(m_Vertices, 0, 0) + End Sub + + Public ReadOnly Property Home() As Vector3 + Get + Return m_Home + End Get + End Property + + Friend Property Texture() As Texture + Get + Return m_Texture + End Get + Set(ByVal value As Texture) + m_Texture = value + End Set + End Property +End Class diff --git a/Presentation/PhotoShow.sln b/Presentation/PhotoShow.sln new file mode 100644 index 0000000..b4e714c --- /dev/null +++ b/Presentation/PhotoShow.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "PhotoShow", "PhotoShow.vbproj", "{E6CE1EF2-2982-4FA2-8428-7E71D7800485}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E6CE1EF2-2982-4FA2-8428-7E71D7800485}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E6CE1EF2-2982-4FA2-8428-7E71D7800485}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E6CE1EF2-2982-4FA2-8428-7E71D7800485}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E6CE1EF2-2982-4FA2-8428-7E71D7800485}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Presentation/PhotoShow.vbproj b/Presentation/PhotoShow.vbproj new file mode 100644 index 0000000..62f1268 --- /dev/null +++ b/Presentation/PhotoShow.vbproj @@ -0,0 +1,148 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {E6CE1EF2-2982-4FA2-8428-7E71D7800485} + WinExe + PhotoShow.Main + PhotoShow + PhotoShow + WindowsFormsWithCustomSubMain + D2222A9EED6B4895D8B921D39FF9453A6AACD40C + PhotoShow_TemporaryKey.pfx + true + true + D:\programming\PhotoBooth\Deploy\Presentation\ + true + Disk + false + Foreground + 7 + Days + false + false + true + false + 1.0.0.%2a + false + true + + + true + full + true + true + bin\Debug\ + PhotoShow.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + PhotoShow.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + + + + + + + + + + + + + + + Options.vb + + + Form + + + + + Form + + + RenderForm.vb + Form + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + Designer + Options.vb + + + Designer + RenderForm.vb + + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + + False + .NET Framework 2.0 + true + + + + + \ No newline at end of file diff --git a/Presentation/PhotoSystem.vb b/Presentation/PhotoSystem.vb new file mode 100644 index 0000000..a7910ae --- /dev/null +++ b/Presentation/PhotoSystem.vb @@ -0,0 +1,51 @@ +Imports Microsoft.DirectX +Imports Microsoft.DirectX.Direct3D + +Public Class PhotoSystem + Private Const MAX_PHOTOS = 20 + + Private m_Device As Device + Private m_Photos As List(Of Photo) + Private m_Home As Vector3 + + Public Sub New(ByVal device As Device, ByVal position As Vector3) + m_Device = device + m_Home = position + + m_Photos = New List(Of Photo) + End Sub + + Public Sub AddPhoto(ByVal texture As Texture) + 'Create the new photo and add it to the stack + m_Photos.Add(New Photo(m_Device, New Vector3(m_Home.X, m_Home.Y, m_Home.Z - (m_Photos.Count * 5)), texture)) + + 'Scatter the stack + For Each p As Photo In m_Photos + p.Scatter() + 'If there are more photos in the stack than we want, + 'start passing the textures down the stack + If m_Photos.Count > MAX_PHOTOS Then + If m_Photos.Count > m_Photos.IndexOf(p) + 1 Then + p.Texture = m_Photos(m_Photos.IndexOf(p) + 1).Texture + End If + End If + Next + + 'Drop the last photo from the stack (but the stack is reverse ordered so actually drop the first item) + If m_Photos.Count > MAX_PHOTOS Then + m_Photos.RemoveAt(MAX_PHOTOS - 1) + End If + End Sub + + Public Sub Render() + For Each p As Photo In m_Photos + p.Render() + Next + End Sub + + Public Sub Update(ByVal deltaTime As Single) + For Each p As Photo In m_Photos + p.Update(deltaTime) + Next + End Sub +End Class diff --git a/Presentation/RenderForm.Designer.vb b/Presentation/RenderForm.Designer.vb new file mode 100644 index 0000000..ec0926d --- /dev/null +++ b/Presentation/RenderForm.Designer.vb @@ -0,0 +1,47 @@ + _ +Partial Class RenderForm + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.fsWatcher = New System.IO.FileSystemWatcher + CType(Me.fsWatcher, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'fsWatcher + ' + Me.fsWatcher.EnableRaisingEvents = True + Me.fsWatcher.Filter = "*.jpg" + Me.fsWatcher.Path = "c:\" + Me.fsWatcher.SynchronizingObject = Me + ' + 'RenderForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.BackColor = System.Drawing.SystemColors.ControlDark + Me.ClientSize = New System.Drawing.Size(360, 326) + Me.Name = "RenderForm" + Me.Text = "Form1" + CType(Me.fsWatcher, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + + End Sub + Friend WithEvents fsWatcher As System.IO.FileSystemWatcher + +End Class diff --git a/Presentation/RenderForm.resx b/Presentation/RenderForm.resx new file mode 100644 index 0000000..971b5e5 --- /dev/null +++ b/Presentation/RenderForm.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Presentation/RenderForm.vb b/Presentation/RenderForm.vb new file mode 100644 index 0000000..7fae3f7 --- /dev/null +++ b/Presentation/RenderForm.vb @@ -0,0 +1,170 @@ +Imports Microsoft.DirectX +Imports Microsoft.DirectX.Direct3D + +Public Class RenderForm + Inherits Form + + Private i As Integer = 1 + Private m_Watcher As IO.FileSystemWatcher + + Private m_Log As EZLogger + + Private m_DeltaTime As Double + Private m_Device As Device + Private m_PhotoSystem As PhotoSystem + Private m_PhotoList As Collection + + Public Function InitializeGraphics() As Boolean + Dim params As New PresentParameters + params.Windowed = True + params.SwapEffect = SwapEffect.Discard + params.EnableAutoDepthStencil = True + params.AutoDepthStencilFormat = DepthFormat.D16 + params.PresentationInterval = PresentInterval.Immediate + + ' Uncomment to enable Full Screen + 'params.BackBufferWidth = 1024 + 'params.BackBufferHeight = 768 + 'params.BackBufferFormat = Format.R5G6B5 + 'params.Windowed = False + + Try + m_Device = New Device(0, DeviceType.Hardware, Me, CreateFlags.HardwareVertexProcessing, params) + Debug.WriteLine("Hardware, HardwardVertexProcessing") + Catch + End Try + + If m_Device Is Nothing Then + Try + m_Device = New Device(0, DeviceType.Hardware, Me, CreateFlags.SoftwareVertexProcessing, params) + Debug.WriteLine("Hardware, SoftwareVertexProcessing") + Catch + End Try + End If + + If m_Device Is Nothing Then + Try + m_Device = New Device(0, DeviceType.Reference, Me, CreateFlags.SoftwareVertexProcessing, params) + Debug.WriteLine("Reference, SoftwareVertexProcessing") + Catch ex As Exception + MessageBox.Show("Error initializing Direct3D" & vbCrLf & vbCrLf & ex.Message, _ + "Direct3D Error", MessageBoxButtons.OK) + Return False + End Try + End If + + m_Device.RenderState.Lighting = False + m_Device.RenderState.CullMode = Cull.CounterClockwise + m_Device.RenderState.FillMode = FillMode.Solid + + 'AddHandler m_Device.DeviceLost, AddressOf OnDeviceLost + 'AddHandler m_Device.DeviceReset, AddressOf OnDeviceReset + 'AddHandler m_Device.Disposing, AddressOf OnDeviceDisposing + + 'OnDeviceReset(Me, Nothing) + + BuildPhotos() + + ' Setup the file system watcher + fsWatcher.EnableRaisingEvents = False + fsWatcher.Path = My.Settings.WatchFolder + fsWatcher.NotifyFilter = (IO.NotifyFilters.CreationTime Or IO.NotifyFilters.LastWrite) + fsWatcher.Filter = "*.jpg" + fsWatcher.EnableRaisingEvents = True + + m_PhotoList = New Collection + + HiResTimer.Start() + + Return True + End Function + + Private Sub OnDeviceReset(ByVal sender As Object, ByVal e As EventArgs) + m_Device.Transform.Projection = Matrix.PerspectiveFovLH(Math.PI / 4, 1, 1, 500) + End Sub + + Private Sub OnDeviceLost(ByVal sender As Object, ByVal e As EventArgs) + ' + End Sub + + Private Sub OnDeviceDisposing(ByVal sender As Object, ByVal e As EventArgs) + ' + End Sub + + Private Sub OnCancelResizing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) + e.Cancel = True + End Sub + + Public Sub Render() + m_DeltaTime = HiResTimer.GetElapsedTime + + m_PhotoSystem.Update(m_DeltaTime) + + m_Device.Clear(ClearFlags.Target, Color.Black, 1, 0) + + m_Device.BeginScene() + + ' Draw stuff here... + SetupMatrices() + + m_PhotoSystem.Render() + + m_Device.EndScene() + m_Device.Present() + End Sub + + Private Sub SetupMatrices() + ' World matrix + 'Const TICKS_PER_REV As Integer = 2000 + 'Dim angle As Double = Environment.TickCount * (2 * Math.PI) / TICKS_PER_REV + 'm_Device.Transform.World = Matrix.RotationY(CSng(angle)) + m_Device.Transform.World = Matrix.Identity() + + ' View matrix + m_Device.Transform.View = Matrix.LookAtLH( _ + New Vector3(0, 0, 0), _ + New Vector3(0, 0, 160), _ + New Vector3(0, 1, 0)) + + ' Projection matrix + m_Device.Transform.Projection = Matrix.PerspectiveFovLH(Math.PI / 4, 1, 1, 2000) + End Sub + + Public Sub BuildPhotos() + m_PhotoSystem = New PhotoSystem(m_Device, New Vector3(0, 0, 150)) + End Sub + + Public Sub New() + ' This call is required by the Windows Form Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + Me.Size = New Size(1024, 768) + + ' Start logging events + m_Log = New EZLogger(My.Application.Info.DirectoryPath & "\log.txt", True, EZLogger.Level.All, False) + m_Log.StartLog() + End Sub + + Private Sub RenderForm_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown + Select Case e.KeyCode + Case Keys.Escape + Application.Exit() + End Select + End Sub + + Private Sub fsWatcher_Changed(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles fsWatcher.Changed, fsWatcher.Created + If Not m_PhotoList.Contains(e.Name) Then + m_PhotoList.Add(e.Name, e.Name) + + Try + m_PhotoSystem.AddPhoto(TextureLoader.FromFile(m_Device, My.Settings.WatchFolder & "\" & e.Name, _ + 800, 531, -1, 0, Format.Unknown, Pool.Managed, _ + Filter.Mirror Or Filter.Triangle, _ + Filter.Mirror Or Filter.Triangle, 0)) + Catch ex As Exception + Debug.Print(ex.Message) + End Try + End If + End Sub +End Class diff --git a/Presentation/app.config b/Presentation/app.config new file mode 100644 index 0000000..60266c3 --- /dev/null +++ b/Presentation/app.config @@ -0,0 +1,37 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + c:\ + + + + diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..4bef412 --- /dev/null +++ b/README.MD @@ -0,0 +1,45 @@ +* Photo Booth + +June 2009 + +The whole system is mostly cobbled together from spare parts. + +*** Hardware +- old laptop with at least two USB ports; screen removed +- 17" LCD monitor with the stand removed +- camera is an Olympus C-5060 +- Arduino microcontroller (switches are wired to this then the Arduino sends commands to the computer) +- various switches and pedals (for triggering the software/camera) +- hard shell suitcase +- mount from a really cheap table top tripod +- 25' of black fabric +- 20' of PVC pipe +- various PVC pipe fittings + +*** Software +- Windows 2000 +- Photobooth (custom VB.NET application; source at http://www.assembla.com/wiki/show/photobooth) +- Cam2Com + +A very high level view of the system is this: A button is pressed which sends a command to the Photobooth software. The software interprets the command and sends another command to Cam2Com. Cam2Com triggers the camera. The camera takes a picture. Cam2Com downloads the photo from the camera to the computer. The Photobooth software detects the new photo then displays it on the screen. + +# button is pushed +# serial command is received by the Photobooth software +# screen is cleared +# "Get Ready" message is displayed +# Photobooth invokes Cam2Com +# Cam2Com triggers the camera +# camera takes the picture +# Cam2Com downloads the image from the camera to a specified folder +# Photobooth watches for a new image file to appear in the specified folder +# Photobooth loads the image for display +# Photobooth creates a cached thumbnail version +# the system is put back in a ready state + +All of the source code for Photobooth and for the Arduino microcontroller is available here http://www.assembla.com/wiki/show/photobooth. The Cam2Com software I had to buy. The reason for that is because I'm using the older Olympus C-5060 camera which doesn't support newer computer-to-camera protocols. There is an alternate version of Photobooth (Photobooh_WIA) that does not require Cam2Com but it does require a camera that can operate in PTP mode and Windows XP or higher. I've used it quite successfully with a Nikon D40. The software the principles are the same as teh non-WIA version. The nice thing is that Photobooth_WIA is capable of triggering the camera and downloading the photos so you can cut out the Cam2Com layer. + +As for the physical setup I just got an old hard shell suitcase from the Goodwill. I mounted the monitor in the lid and used dense foam to make a cradle for the laptop in the bottom half of the suitcase. There are a few photos of the setup here http://cardboardrobotics.com/photobooth.asp. And a few additional photos of its various iterations here http://www.flickr.com/photos/robotsareeverywhere/sets/72157605111189961/. + +I looked at the software alternative gPhoto which looks great but only runs on unix/linux operating systems. You could probably do something much simpler on a Mac. It comes down to how clean you want the interface to be. I wanted to strip it down to just the photo and a status message and the quickest way for me to do that was writing the Photobooth application. + +I intend to post a wiring diagram for the Arduino and switches/pedals in the near future. diff --git a/SoulCounter/SoulCounter.sln b/SoulCounter/SoulCounter.sln new file mode 100644 index 0000000..e964500 --- /dev/null +++ b/SoulCounter/SoulCounter.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SoulCounter", "SoulCounter\SoulCounter.vbproj", "{AC8A0784-DCCF-4401-ABC6-D3DD9EC5229E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AC8A0784-DCCF-4401-ABC6-D3DD9EC5229E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AC8A0784-DCCF-4401-ABC6-D3DD9EC5229E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC8A0784-DCCF-4401-ABC6-D3DD9EC5229E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AC8A0784-DCCF-4401-ABC6-D3DD9EC5229E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/SoulCounter/SoulCounter/My Project/Application.Designer.vb b/SoulCounter/SoulCounter/My Project/Application.Designer.vb new file mode 100644 index 0000000..9d755b4 --- /dev/null +++ b/SoulCounter/SoulCounter/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.832 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + 'NOTE: This file is auto-generated; do not modify it directly. To make changes, + ' or if you encounter build errors in this file, go to the Project Designer + ' (go to Project Properties or double-click the My Project node in + ' Solution Explorer), and make changes on the Application tab. + ' + Partial Friend Class MyApplication + + _ + Public Sub New() + MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) + Me.IsSingleInstance = false + Me.EnableVisualStyles = true + Me.SaveMySettingsOnExit = true + Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses + End Sub + + _ + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = Global.SoulWatcher.frmMain + End Sub + End Class +End Namespace diff --git a/SoulCounter/SoulCounter/My Project/Application.myapp b/SoulCounter/SoulCounter/My Project/Application.myapp new file mode 100644 index 0000000..5907301 --- /dev/null +++ b/SoulCounter/SoulCounter/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + frmMain + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/SoulCounter/SoulCounter/My Project/AssemblyInfo.vb b/SoulCounter/SoulCounter/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..9c37085 --- /dev/null +++ b/SoulCounter/SoulCounter/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' 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. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' 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: +' + + + diff --git a/SoulCounter/SoulCounter/My Project/Resources.Designer.vb b/SoulCounter/SoulCounter/My Project/Resources.Designer.vb new file mode 100644 index 0000000..3167c50 --- /dev/null +++ b/SoulCounter/SoulCounter/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.832 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + '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. + ' + ' A strongly-typed resource class, for looking up localized strings, etc. + ' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ' + ' Returns the cached ResourceManager instance used by this class. + ' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("SoulWatcher.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ' + ' Overrides the current thread's CurrentUICulture property for all + ' resource lookups using this strongly typed resource class. + ' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/SoulCounter/SoulCounter/My Project/Resources.resx b/SoulCounter/SoulCounter/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/SoulCounter/SoulCounter/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SoulCounter/SoulCounter/My Project/Settings.Designer.vb b/SoulCounter/SoulCounter/My Project/Settings.Designer.vb new file mode 100644 index 0000000..dc4a9fb --- /dev/null +++ b/SoulCounter/SoulCounter/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.832 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.SoulWatcher.My.MySettings + Get + Return Global.SoulWatcher.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/SoulCounter/SoulCounter/My Project/Settings.settings b/SoulCounter/SoulCounter/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/SoulCounter/SoulCounter/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/SoulCounter/SoulCounter/SoulCounter.vbproj b/SoulCounter/SoulCounter/SoulCounter.vbproj new file mode 100644 index 0000000..e2c6e29 --- /dev/null +++ b/SoulCounter/SoulCounter/SoulCounter.vbproj @@ -0,0 +1,106 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {AC8A0784-DCCF-4401-ABC6-D3DD9EC5229E} + WinExe + SoulWatcher.My.MyApplication + SoulWatcher + SoulCounter + WindowsForms + + + true + full + true + true + bin\Debug\ + SoulCounter.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + SoulCounter.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + + + + + + + + + + + + + + + + Form + + + frmMain.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Designer + frmMain.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/SoulCounter/SoulCounter/frmMain.Designer.vb b/SoulCounter/SoulCounter/frmMain.Designer.vb new file mode 100644 index 0000000..833ac76 --- /dev/null +++ b/SoulCounter/SoulCounter/frmMain.Designer.vb @@ -0,0 +1,82 @@ + _ +Partial Class frmMain + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.FileSystemWatcher1 = New System.IO.FileSystemWatcher + Me.flpPics = New System.Windows.Forms.FlowLayoutPanel + Me.Label1 = New System.Windows.Forms.Label + CType(Me.FileSystemWatcher1, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'FileSystemWatcher1 + ' + Me.FileSystemWatcher1.EnableRaisingEvents = True + Me.FileSystemWatcher1.Path = "g:\" + Me.FileSystemWatcher1.SynchronizingObject = Me + ' + 'flpPics + ' + Me.flpPics.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.flpPics.BackColor = System.Drawing.Color.Transparent + Me.flpPics.Location = New System.Drawing.Point(12, 12) + Me.flpPics.Name = "flpPics" + Me.flpPics.Size = New System.Drawing.Size(782, 467) + Me.flpPics.TabIndex = 1 + ' + 'Label1 + ' + Me.Label1.Anchor = CType((System.Windows.Forms.AnchorStyles.Left Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.Label1.BackColor = System.Drawing.Color.Transparent + Me.Label1.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.Label1.Font = New System.Drawing.Font("Bookman Old Style", 20.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label1.ForeColor = System.Drawing.Color.White + Me.Label1.Location = New System.Drawing.Point(12, 220) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(782, 39) + Me.Label1.TabIndex = 3 + Me.Label1.Text = "0 souls taken." + Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + ' + 'frmMain + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.BackColor = System.Drawing.Color.Black + Me.ClientSize = New System.Drawing.Size(806, 491) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.flpPics) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog + Me.KeyPreview = True + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "frmMain" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Soul Counter" + CType(Me.FileSystemWatcher1, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + + End Sub + Friend WithEvents FileSystemWatcher1 As System.IO.FileSystemWatcher + Friend WithEvents flpPics As System.Windows.Forms.FlowLayoutPanel + Friend WithEvents Label1 As System.Windows.Forms.Label + +End Class diff --git a/SoulCounter/SoulCounter/frmMain.resx b/SoulCounter/SoulCounter/frmMain.resx new file mode 100644 index 0000000..4b527d9 --- /dev/null +++ b/SoulCounter/SoulCounter/frmMain.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/SoulCounter/SoulCounter/frmMain.vb b/SoulCounter/SoulCounter/frmMain.vb new file mode 100644 index 0000000..b541f83 --- /dev/null +++ b/SoulCounter/SoulCounter/frmMain.vb @@ -0,0 +1,78 @@ +Public Class frmMain + + Dim souls As Collection + + Private Sub frmMain_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown + Select Case e.KeyCode + Case Keys.Escape + Application.Exit() + Case Keys.PageDown + Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None + Me.WindowState = FormWindowState.Maximized + Case Keys.PageUp + Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle + Me.WindowState = FormWindowState.Normal + End Select + End Sub + + + Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + + souls = New Collection() + Label1.Text = "Waiting to consume a few souls." + flpPics.WrapContents = True + + FileSystemWatcher1.EnableRaisingEvents = True + FileSystemWatcher1.Path = "g:\" + + TestLoad() + End Sub + + Private Sub TestLoad() + Dim file As String + For Each file In IO.Directory.GetFiles("G:\test") + ShowNewPicture(file) + Next + End Sub + + Private Sub ShowNewPicture(ByVal FullPath As String) + Try + Dim picBox As PictureBox + picBox = New PictureBox + + With picBox + .SizeMode = PictureBoxSizeMode.Zoom + .Load(FullPath) + .Height = 100 + .Width = 100 + End With + flpPics.Controls.Add(picBox) + + Catch ex As Exception + + End Try + End Sub + + Private Sub FileSystemWatcher1_Created(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Created + If Not souls.Contains(e.Name) Then + 'souls.Add(e.Name, e.Name) + + 'Label1.Text = souls.Count.ToString & " soul" & IIf(souls.Count = 1, "", "s") & " taken." + + 'IO.File.Copy(e.FullPath, "\\robbie\drop\halloween_2\" & e.Name, True) + 'ShowNewPicture("\\robbie\drop\halloween_2\" & e.Name) + + 'My.Application.DoEvents() + End If + End Sub + + Public Sub New() + + ' This call is required by the Windows Form Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + SetStyle(ControlStyles.SupportsTransparentBackColor, True) + Label1.BackColor = Color.Transparent + End Sub +End Class diff --git a/Trigger/photo_booth_button.pde b/Trigger/photo_booth_button.pde new file mode 100644 index 0000000..c52ffea --- /dev/null +++ b/Trigger/photo_booth_button.pde @@ -0,0 +1,183 @@ +//Pins +#define PIN_STATUS_LED 13 +#define PIN_PEDAL 12 +#define PIN_BUTTON 2 +#define PIN_RED_LED 11 +#define PIN_GRN_LED 10 +//Commands (serial input) +#define CMD_TEST 'T' +#define CMD_RED_ON 'R' +#define CMD_RED_OFF 'r' +#define CMD_GRN_ON 'G' +#define CMD_GRN_OFF 'g' +#define CMD_DISPLAY '"' //start and stop character for input strings +//Replies (serial output) +#define REP_OK 'K' +#define REP_TEST 'T' +#define REP_BUTTON 'B' +#define REP_PEDAL 'P' +//States +#define ST_DEFAULT 0 +#define ST_DISPLAY 1 //when waiting for more serial data to display +//Errors +#define ERR_INVALID_INPUT 1 +#define ERR_INPUT_TIMEOUT 2 +#define ERR_INPUT_TOO_LONG 3 +//Misc. +#define DEBOUNCE 300 //milliseconds of debounce +#define SERIAL_TIMEOUT 500 //timeout when waiting to finish a display command +#define DISPLAY_SIZE 10 + +long pedal_time, button_time, serial_time; //timers for debounce and timeout +int state; +char displayString[DISPLAY_SIZE + 1]; //+1 for the '\0' at the end +int displayStringLength; //index of the '\0' character at the end of the string + +void setup() { + pinMode(PIN_STATUS_LED, OUTPUT); + pinMode(PIN_PEDAL, INPUT); + pinMode(PIN_BUTTON, INPUT); + pinMode(PIN_RED_LED, OUTPUT); + pinMode(PIN_GRN_LED, OUTPUT); + pedal_time = 0; + button_time = 0; + state = ST_DEFAULT; + displayStringLength = 0; + for (int i = 0; i < DISPLAY_SIZE + 1; i++) { + displayString[i] = '\0'; //null character + } + Serial.begin(9600); + //Blink reassuringly + digitalWrite(PIN_STATUS_LED, HIGH); + delay(500); + digitalWrite(PIN_STATUS_LED, LOW); +} + +void loop() { + button_task(); + serial_input_task(); +} + +void button_task() { + int button_input = digitalRead(PIN_BUTTON); + int pedal_input = digitalRead(PIN_PEDAL); + + //if button is pushed and hasn't been in the previous DEBOUNCE milliseconds, send the command + //FIXME: what about timer roll-over from millis()? + if (button_input == HIGH && millis()-button_time > DEBOUNCE) { + Serial.print(REP_BUTTON); + button_time = millis(); + } + //same for pedal + if (pedal_input == HIGH && millis()-pedal_time > DEBOUNCE) { + Serial.print(REP_PEDAL); + pedal_time = millis(); + } +} + +void serial_input_task() { + char input = '\0'; //null character + + switch (state) { + case ST_DEFAULT: + if (Serial.available()) { + input = Serial.read(); + switch (input) { + case CMD_TEST: + Serial.print(REP_TEST); + break; + case CMD_RED_ON: + digitalWrite(PIN_RED_LED, HIGH); + Serial.print(REP_OK); + break; + case CMD_RED_OFF: + digitalWrite(PIN_RED_LED, LOW); + Serial.print(REP_OK); + break; + case CMD_GRN_ON: + digitalWrite(PIN_GRN_LED, HIGH); + Serial.print(REP_OK); + break; + case CMD_GRN_OFF: + digitalWrite(PIN_GRN_LED, LOW); + Serial.print(REP_OK); + break; + case CMD_DISPLAY: + state = ST_DISPLAY; //start looking for input to display + serial_time = millis(); //start timeout timer + displayString[0] = '\0'; //zero the display string for new data + displayStringLength = 0; + break; + default: + reportError(ERR_INVALID_INPUT); + break; + } + } + break; + case ST_DISPLAY: + //check for a timeout + if (millis() > serial_time + SERIAL_TIMEOUT) { //timeout waiting for input to end + //FIXME: what about timer roll-over from millis()? + displayString[0] = '\0'; + displayStringLength = 0; + state = ST_DEFAULT; + reportError(ERR_INPUT_TIMEOUT); + } + //check if a character is available + if (Serial.available()) { + input = Serial.read(); + //see what the character is + switch (input) { + case CMD_DISPLAY: //found the end of the input + state = ST_DEFAULT; //return to normal operating state + display(); //display the input + Serial.print(REP_OK); //acknowledge + break; + default: //any other input + //make sure another character can fit + if (displayStringLength >= DISPLAY_SIZE) { //error condition: input too long + //zero the display string + displayString[0] = '\0'; + displayStringLength = 0; + Serial.flush(); + state = ST_DEFAULT; + //report the error + reportError(ERR_INPUT_TOO_LONG); + } + else { //everything is OK. append the character to the display string + displayString[displayStringLength] = input; + displayStringLength++; + displayString[displayStringLength] = '\0'; + } + break; + } + } + break; + default: //unexpected state number + digitalWrite(PIN_STATUS_LED, HIGH); + Serial.println("ERROR: Invalid state found in serial_input_task function."); + } +} + +void reportError(int err) { + switch (err) { + case ERR_INVALID_INPUT: + Serial.println("ERROR: Invalid input received."); + break; + case ERR_INPUT_TIMEOUT: + Serial.println("ERROR: Timeout while waiting for display input."); + Serial.println("Display input must end with '\"'."); + break; + case ERR_INPUT_TOO_LONG: + Serial.print("ERROR: Display input is too long. Max length is "); + Serial.println(DISPLAY_SIZE); + break; + default: + Serial.println("ERROR: unknown error code."); + break; + } +} + +void display() { + Serial.print("DISPLAYING: "); Serial.println(displayString); +} diff --git a/Trigger/photo_booth_button/applet/HardwareSerial.cpp.o b/Trigger/photo_booth_button/applet/HardwareSerial.cpp.o new file mode 100644 index 0000000..2539429 Binary files /dev/null and b/Trigger/photo_booth_button/applet/HardwareSerial.cpp.o differ diff --git a/Trigger/photo_booth_button/applet/Print.cpp.o b/Trigger/photo_booth_button/applet/Print.cpp.o new file mode 100644 index 0000000..b7d32bc Binary files /dev/null and b/Trigger/photo_booth_button/applet/Print.cpp.o differ diff --git a/Trigger/photo_booth_button/applet/WInterrupts.c.o b/Trigger/photo_booth_button/applet/WInterrupts.c.o new file mode 100644 index 0000000..f5b50d5 Binary files /dev/null and b/Trigger/photo_booth_button/applet/WInterrupts.c.o differ diff --git a/Trigger/photo_booth_button/applet/WMath.cpp.o b/Trigger/photo_booth_button/applet/WMath.cpp.o new file mode 100644 index 0000000..2d2ca7d Binary files /dev/null and b/Trigger/photo_booth_button/applet/WMath.cpp.o differ diff --git a/Trigger/photo_booth_button/applet/core.a b/Trigger/photo_booth_button/applet/core.a new file mode 100644 index 0000000..de104b0 Binary files /dev/null and b/Trigger/photo_booth_button/applet/core.a differ diff --git a/Trigger/photo_booth_button/applet/photo_booth_button.cpp b/Trigger/photo_booth_button/applet/photo_booth_button.cpp new file mode 100644 index 0000000..871ddf0 --- /dev/null +++ b/Trigger/photo_booth_button/applet/photo_booth_button.cpp @@ -0,0 +1,207 @@ +//Pins +#define PIN_STATUS_LED 13 +#define PIN_PEDAL 12 +#define PIN_BUTTON 2 +#define PIN_RED_LED 11 +#define PIN_GRN_LED 10 +//Commands (serial input) +#define CMD_TEST 'T' +#define CMD_RED_ON 'R' +#define CMD_RED_OFF 'r' +#define CMD_GRN_ON 'G' +#define CMD_GRN_OFF 'g' +#define CMD_DISPLAY '"' //start and stop character for input strings +//Replies (serial output) +#define REP_OK 'K' +#define REP_TEST 'T' +#define REP_BUTTON 'B' +#define REP_PEDAL 'P' +//States +#define ST_DEFAULT 0 +#define ST_DISPLAY 1 //when waiting for more serial data to display +//Errors +#define ERR_INVALID_INPUT 1 +#define ERR_INPUT_TIMEOUT 2 +#define ERR_INPUT_TOO_LONG 3 +//Misc. +#define DEBOUNCE 300 //milliseconds of debounce +#define SERIAL_TIMEOUT 500 //timeout when waiting to finish a display command +#define DISPLAY_SIZE 10 + +#include "WProgram.h" +void setup(); +void loop(); +void button_task(); +void serial_input_task(); +void reportError(int err); +void display(); +long pedal_time, button_time, serial_time; //timers for debounce and timeout +int state; +char displayString[DISPLAY_SIZE + 1]; //+1 for the '\0' at the end +int displayStringLength; //index of the '\0' character at the end of the string + +void setup() { + pinMode(PIN_STATUS_LED, OUTPUT); + pinMode(PIN_PEDAL, INPUT); + pinMode(PIN_BUTTON, INPUT); + pinMode(PIN_RED_LED, OUTPUT); + pinMode(PIN_GRN_LED, OUTPUT); + pedal_time = 0; + button_time = 0; + state = ST_DEFAULT; + displayStringLength = 0; + for (int i = 0; i < DISPLAY_SIZE + 1; i++) { + displayString[i] = '\0'; //null character + } + Serial.begin(9600); + //Blink reassuringly + digitalWrite(PIN_STATUS_LED, HIGH); + digitalWrite(PIN_RED_LED, HIGH); + digitalWrite(PIN_GRN_LED, HIGH); + delay(500); + digitalWrite(PIN_STATUS_LED, LOW); + digitalWrite(PIN_RED_LED, LOW); + digitalWrite(PIN_GRN_LED, LOW); +} + +void loop() { + button_task(); + serial_input_task(); +} + +void button_task() { + int button_input = digitalRead(PIN_BUTTON); + int pedal_input = digitalRead(PIN_PEDAL); + + //if button is pushed and hasn't been in the previous DEBOUNCE milliseconds, send the command + //FIXME: what about timer roll-over from millis()? + if (button_input == HIGH && millis()-button_time > DEBOUNCE) { + Serial.print(REP_BUTTON); + button_time = millis(); + } + //same for pedal + if (pedal_input == HIGH && millis()-pedal_time > DEBOUNCE) { + Serial.print(REP_PEDAL); + pedal_time = millis(); + } +} + +void serial_input_task() { + char input = '\0'; //null character + + switch (state) { + case ST_DEFAULT: + if (Serial.available()) { + input = Serial.read(); + switch (input) { + case CMD_TEST: + Serial.print(REP_TEST); + break; + case CMD_RED_ON: + digitalWrite(PIN_RED_LED, HIGH); + //Serial.print(REP_OK); + break; + case CMD_RED_OFF: + digitalWrite(PIN_RED_LED, LOW); + //Serial.print(REP_OK); + break; + case CMD_GRN_ON: + digitalWrite(PIN_GRN_LED, HIGH); + //Serial.print(REP_OK); + break; + case CMD_GRN_OFF: + digitalWrite(PIN_GRN_LED, LOW); + //Serial.print(REP_OK); + break; + case CMD_DISPLAY: + state = ST_DISPLAY; //start looking for input to display + serial_time = millis(); //start timeout timer + displayString[0] = '\0'; //zero the display string for new data + displayStringLength = 0; + break; + default: + reportError(ERR_INVALID_INPUT); + break; + } + } + break; + case ST_DISPLAY: + //check for a timeout + if (millis() > serial_time + SERIAL_TIMEOUT) { //timeout waiting for input to end + //FIXME: what about timer roll-over from millis()? + displayString[0] = '\0'; + displayStringLength = 0; + state = ST_DEFAULT; + reportError(ERR_INPUT_TIMEOUT); + } + //check if a character is available + if (Serial.available()) { + input = Serial.read(); + //see what the character is + switch (input) { + case CMD_DISPLAY: //found the end of the input + state = ST_DEFAULT; //return to normal operating state + display(); //display the input + Serial.print(REP_OK); //acknowledge + break; + default: //any other input + //make sure another character can fit + if (displayStringLength >= DISPLAY_SIZE) { //error condition: input too long + //zero the display string + displayString[0] = '\0'; + displayStringLength = 0; + Serial.flush(); + state = ST_DEFAULT; + //report the error + reportError(ERR_INPUT_TOO_LONG); + } + else { //everything is OK. append the character to the display string + displayString[displayStringLength] = input; + displayStringLength++; + displayString[displayStringLength] = '\0'; + } + break; + } + } + break; + default: //unexpected state number + digitalWrite(PIN_STATUS_LED, HIGH); + Serial.println("ERROR: Invalid state found in serial_input_task function."); + } +} + +void reportError(int err) { + switch (err) { + case ERR_INVALID_INPUT: + Serial.println("ERROR: Invalid input received."); + break; + case ERR_INPUT_TIMEOUT: + Serial.println("ERROR: Timeout while waiting for display input."); + Serial.println("Display input must end with '\"'."); + break; + case ERR_INPUT_TOO_LONG: + Serial.print("ERROR: Display input is too long. Max length is "); + Serial.println(DISPLAY_SIZE); + break; + default: + Serial.println("ERROR: unknown error code."); + break; + } +} + +void display() { + Serial.print("DISPLAYING: "); Serial.println(displayString); +} + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/Trigger/photo_booth_button/applet/photo_booth_button.cpp.eep b/Trigger/photo_booth_button/applet/photo_booth_button.cpp.eep new file mode 100644 index 0000000..7c166a1 --- /dev/null +++ b/Trigger/photo_booth_button/applet/photo_booth_button.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/Trigger/photo_booth_button/applet/photo_booth_button.cpp.elf b/Trigger/photo_booth_button/applet/photo_booth_button.cpp.elf new file mode 100644 index 0000000..2a08f31 Binary files /dev/null and b/Trigger/photo_booth_button/applet/photo_booth_button.cpp.elf differ diff --git a/Trigger/photo_booth_button/applet/photo_booth_button.cpp.hex b/Trigger/photo_booth_button/applet/photo_booth_button.cpp.hex new file mode 100644 index 0000000..488ba8f --- /dev/null +++ b/Trigger/photo_booth_button/applet/photo_booth_button.cpp.hex @@ -0,0 +1,229 @@ +:1000000040C064C063C062C061C060C05FC05EC009 +:100010005DC0E7C15BC014C359C058C057C056C0CB +:1000200055C054C053C000000000370034003100F8 +:1000300000000000380035003200000000003600EB +:100040003300300004040404040404040202020225 +:10005000020203030303030301020408102040808B +:100060000102040810200102040810200000000012 +:100070000000000000030405000000000000000074 +:10008000A10411241FBECFE5D4E0DEBFCDBF11E037 +:10009000A0E6B0E0EEE2FDE002C005900D92AE36C3 +:1000A000B107D9F712E0AEE6B1E001C01D92A93266 +:1000B000B107E1F710E0C2E8D0E003C02297FE01EB +:1000C00030D6C038D107D1F788D12FC699CF0F933A +:1000D0001F9306E112E0C80160E670E0ABD4C801EE +:1000E0006CE771E0C6D41F910F910895823091059D +:1000F00051F08330910589F00197D1F486E192E0C7 +:100100006DE670E019C086E192E06CE870E0B1D471 +:1001100086E192E06CEB70E00FC086E192E06DED5D +:1001200070E088D486E192E06AE070E067D50895D7 +:1001300086E192E06EE071E09CD4089580917A01AE +:1001400090917B01009721F0019709F09BC041C07D +:1001500086E192E09DD3882309F49CC086E192E079 +:10016000AAD3843571F085353CF4873491F082351B +:1001700061F0823259F514C0873671F0823731F55B +:1001800006C086E192E064E555C08BE003C08BE0D9 +:1001900004C08AE061E002C08AE060E0E1D1089535 +:1001A00081E090E090937B0180937A0162D160932B +:1001B0007601709377018093780190937901109282 +:1001C0007C011092880110928701089581E090E0EF +:1001D00049C04FD12091760130917701409178014B +:1001E000509179012C503E4F4F4F5F4F26173707E4 +:1001F0004807590768F410927C0110928801109208 +:10020000870110927B0110927A0182E090E06EDF0C +:1002100086E192E03DD38823E9F186E192E04BD379 +:10022000823251F410927B0110927A0150DF86E104 +:1002300092E06BE4F7D30895209187013091880113 +:100240002A3031058CF010927C01109288011092B6 +:10025000870186E192E056D310927B0110927A01D9 +:1002600083E090E043DF0895F901E458FE4F808376 +:10027000F9013196F0938801E0938701E458FE4F2D +:10028000108208958DE061E06BD186E192E069E231 +:1002900071E0EFD308950F931F93CF93DF9382E024 +:1002A00096D18C018CE093D1EC0101301105F9F469 +:1002B000E0D020917201309173014091740150910E +:1002C0007501621B730B840B950B6D52714080405E +:1002D000904068F086E192E062E4A4D3CAD06093D3 +:1002E000720170937301809374019093750121974B +:1002F000F9F4BFD020916E0130916F0140917001EF +:1003000050917101621B730B840B950B6D52714000 +:100310008040904068F086E192E060E583D3A9D008 +:1003200060936E0170936F018093700190937101DF +:10033000DF91CF911F910F910895ADDFFFDE0895FA +:100340008DE061E0EDD08CE060E0EAD082E060E03A +:10035000E7D08BE061E0E4D08AE061E0E1D0109288 +:100360006E0110926F011092700110927101109243 +:100370007201109273011092740110927501109223 +:100380007B0110927A011092880110928701ECE7AC +:10039000F1E0119281E0E738F807D9F786E192E0C1 +:1003A00040E855E260E070E086D18DE061E0D8D0B1 +:1003B0008BE061E0D5D08AE061E0D2D064EF71E0FB +:1003C00080E090E064D08DE060E0CAD08BE060E037 +:1003D000C7D08AE060E0C4D0089583D0B1DFADDF3C +:1003E000FECF1F920F920FB60F9211242F933F93BF +:1003F0008F939F93AF93BF9380918D0190918E01C6 +:10040000A0918F01B0919001309191010196A11DB1 +:10041000B11D232F2D5F2D3720F02D570196A11DE3 +:10042000B11D2093910180938D0190938E01A09333 +:100430008F01B09390018091890190918A01A091E0 +:100440008B01B0918C010196A11DB11D8093890192 +:1004500090938A01A0938B01B0938C01BF91AF91CF +:100460009F918F913F912F910F900FBE0F901F90F2 +:1004700018958FB7F89420918D0130918E0140919D +:100480008F01509190018FBFB901CA010895EF9279 +:10049000FF920F931F937B018C018FB7F8944091CB +:1004A0008D0150918E0160918F01709190018FBFED +:1004B0002FB7F89480918D0190918E01A0918F01BA +:1004C000B09190012FBF841B950BA60BB70BE816BC +:1004D000F9060A071B0760F71F910F91FF90EF9035 +:1004E0000895789483B7826083BF83B7816083BFA8 +:1004F00089B7816089BF8EB582608EBD8EB58160FF +:100500008EBD8FB581608FBD85B5846085BD85B595 +:10051000806485BD329A319A309A379A1AB8089514 +:10052000282F30E0C901885A9F4FFC0194912C5B21 +:100530003F4FF9018491882391F0E82FF0E0EE0F0E +:10054000FF1FEA5DFF4FA591B491662329F48C91BA +:10055000909589238C9308958C91892B8C93089581 +:10056000482F50E0CA0184599F4FFC012491CA01D1 +:10057000885A9F4FFC0194914C5B5F4FFA01349174 +:10058000332321F1222381F0233019F48FB58F77A3 +:1005900004C0243021F48FB58F7D8FBD05C0253078 +:1005A00019F485B58F7D85BDE32FF0E0EE0FFF1FB9 +:1005B000E05DFF4FA591B491662329F48C9190954D +:1005C00089238C9308958C91892B8C930895682F9F +:1005D00070E0CB0184599F4FFC012491CB01885AD4 +:1005E0009F4FFC0144916C5B7F4FFB0194919923D9 +:1005F00019F420E030E022C0222381F0233019F4E6 +:100600008FB58F7704C0243021F48FB58F7D8FBDD7 +:1006100005C0253019F485B58F7D85BD892F90E003 +:10062000880F991F865C9F4FFC01A591B4918C9116 +:1006300020E030E0842311F021E030E0C90108958A +:100640001F920F920FB60F9211242F933F934F9347 +:100650005F936F937F938F939F93AF93BF93EF932A +:10066000FF934CB1E0911202F0911302CF01019679 +:1006700060E870E0F0D29C01809114029091150224 +:100680002817390739F0EE56FE4F40833093130296 +:1006900020931202FF91EF91BF91AF919F918F91A3 +:1006A0007F916F915F914F913F912F910F900FBE6E +:1006B0000F901F9018955F926F927F928F929F92EA +:1006C000AF92BF92CF92DF92EF92FF920F931F9360 +:1006D000CF93DF93EC013A014B01413482E4580798 +:1006E0008FE0680780E078070CF075C060E874E878 +:1006F0008EE190E0A4019301E3D2215030404040CC +:100700005040CA01B90122E030E040E050E0D8D2C8 +:1007100059016A01A60195012095309540955095A3 +:1007200094E0220F331F441F551F9A95D1F760E0C4 +:1007300074E284EF90E0C4D2CA01B9012FEF30E037 +:1007400040E050E069D2A4019301BAD2C9018150BE +:100750009F4F181619061CF4522E5A9403C05524A4 +:100760005394521A60E079E08DE390E0A401930184 +:10077000A7D22150304040405040CA01B90122E088 +:1007800030E040E050E09CD2209530954095509567 +:1007900083E0220F331F441F551F8A95D1F760E075 +:1007A00074E284EF90E08CD2CA01B9012FEF30E0FF +:1007B00040E050E031D2A401930182D2C9018150BE +:1007C0009F4F181619061CF4822F815002C081E039 +:1007D000821B8515F0F4E885F98581E090E00A88B0 +:1007E00002C0880F991F0A94E2F7808360E079E0E5 +:1007F0008DE390E0A401930163D22150304040404A +:100800005040CA01B90122E030E040E050E058D247 +:1008100004C0E885F98510829501EC81FD81308363 +:10082000EE81FF812083EA85FB85208141E050E055 +:10083000CA010E8402C0880F991F0A94E2F7282B80 +:100840002083EA85FB852081CA010F8402C0880FBE +:10085000991F0A94E2F7282B2083EA85FB85808183 +:10086000088802C0440F551F0A94E2F7842B808346 +:10087000DF91CF911F910F91FF90EF90DF90CF907C +:10088000BF90AF909F908F907F906F905F900895F2 +:10089000DC011296ED91FC911397E058FF4F819186 +:1008A000919180589F4F20813181821B930B60E88A +:1008B00070E0D1D10895CF93DF93DC011296ED91D2 +:1008C000FC911397EF01CE57DF4F48815981E058D3 +:1008D000FF4F80819181E058F0408417950719F40B +:1008E0002FEF3FEF0BC0E40FF51F2081CA010196E7 +:1008F00060E870E0B0D19983888330E0C901DF916E +:10090000CF910895DC011296ED91FC911397EE576B +:10091000FF4F80819181929382930895FC01A0857D +:10092000B18521898C9190E0022E02C09595879522 +:100930000A94E2F780FFF6CF0484F585E02D60830A +:10094000089587E691E0909317028093160282E95A +:1009500091E0909319028093180280E490E09093C4 +:100960001B0280931A0289E290E090931D0280930B +:100970001C028BE290E090931F0280931E028AE299 +:1009800090E090932102809320028CE290E090937B +:1009900023028093220284E08093240283E08093E8 +:1009A000250287E08093260285E08093270281E07C +:1009B0008093280208950F931F93CF93DF938C01A8 +:1009C000EB0109C02196D801ED91FC910190F081D5 +:1009D000E02DC801099568816623A1F7DF91CF91C9 +:1009E0001F910F910895EF92FF920F931F93CF9352 +:1009F000DF938C017B01EA010CC0D7016D917D0171 +:100A0000D801ED91FC910190F081E02DC80109958C +:100A10002197209791F7DF91CF911F910F91FF9030 +:100A2000EF900895DC01ED91FC910190F081E02DB3 +:100A300009950895DC01ED91FC910280F381E02D90 +:100A4000099508950F931F938C01DC01ED91FC91A2 +:100A50000190F081E02D6DE00995D801ED91FC91B8 +:100A60000190F081E02DC8016AE009951F910F9176 +:100A700008950F931F938C01DDDFC801E3DF1F9101 +:100A80000F9108952F923F924F925F926F927F92B3 +:100A90008F929F92AF92BF92CF92DF92EF92FF928E +:100AA0000F931F93DF93CF93CDB7DEB7A0970FB609 +:100AB000F894DEBF0FBECDBF1C016A017B0141155A +:100AC00051056105710549F4DC01ED91FC9101903E +:100AD000F081E02D60E3099552C0882499245401E7 +:100AE000422E55246624772401E010E00C0F1D1FD0 +:100AF000080D191DC701B601A3019201BFD0F8016D +:100B000060830894811C911CA11CB11CC701B60113 +:100B1000A3019201B3D0C901DA016C017D01C114B6 +:100B2000D104E104F10401F781E0E82EF12CEC0E90 +:100B3000FD1EE80CF91C3E010894611C711CD501D6 +:100B4000C4010197A109B1096C01C818D90814C0E2 +:100B5000F601EE0DFF1D60816A3010F4605D01C08A +:100B6000695CD101ED91FC910190F081E02DC10112 +:100B700009950894E108F1086E147F0449F7A096DE +:100B80000FB6F894DEBF0FBECDBFCF91DF911F919E +:100B90000F91FF90EF90DF90CF90BF90AF909F901C +:100BA0008F907F906F905F904F903F902F9008951F +:100BB000EF92FF920F931F93CF93DF93EC017A0193 +:100BC0008B0177FF0FC0E881F9810190F081E02D62 +:100BD0006DE2099510950095F094E094E11CF11CEC +:100BE000011D111DCE01B801A7012AE04BDFDF91E5 +:100BF000CF911F910F91FF90EF9008950F931F9346 +:100C00008C01AB01662757FD6095762FD1DFC801B7 +:100C100019DF1F910F910895629FD001739FF0011A +:100C2000829FE00DF11D649FE00DF11D929FF00D7C +:100C3000839FF00D749FF00D659FF00D9927729FB3 +:100C4000B00DE11DF91F639FB00DE11DF91FBD013E +:100C5000CF011124089597FB092E07260AD077FDAE +:100C600004D049D006D000201AF4709561957F4FCA +:100C70000895F6F7909581959F4F0895A1E21A2E59 +:100C8000AA1BBB1BFD010DC0AA1FBB1FEE1FFF1F30 +:100C9000A217B307E407F50720F0A21BB30BE40B80 +:100CA000F50B661F771F881F991F1A9469F76095C7 +:100CB0007095809590959B01AC01BD01CF01089581 +:100CC00097FB092E05260ED057FD04D0D7DF0AD09A +:100CD000001C38F450954095309521953F4F4F4F6B +:100CE0005F4F0895F6F790958095709561957F4FC9 +:100CF0008F4F9F4F0895AA1BBB1B51E107C0AA1F2E +:100D0000BB1FA617B70710F0A61BB70B881F991FAC +:100D10005A95A9F780959095BC01CD010895EE0FE5 +:0E0D2000FF1F0590F491E02D0994F894FFCF89 +:100D2E00444953504C4159494E473A20004552527E +:100D3E004F523A20496E76616C696420696E707507 +:100D4E00742072656365697665642E004552524F54 +:100D5E00523A2054696D656F7574207768696C65B9 +:100D6E002077616974696E6720666F72206469739B +:100D7E00706C617920696E7075742E0044697370A1 +:100D8E006C617920696E707574206D757374206551 +:100D9E006E642077697468202722272E00455252F0 +:100DAE004F523A20446973706C617920696E707588 +:100DBE007420697320746F6F206C6F6E672E204DD8 +:100DCE006178206C656E67746820697320004552E7 +:100DDE00524F523A20756E6B6E6F776E206572723F +:100DEE006F7220636F64652E004552524F523A2047 +:100DFE00496E76616C696420737461746520666FE8 +:100E0E00756E6420696E2073657269616C5F696EC0 +:100E1E007075745F7461736B2066756E6374696F41 +:0E0E2E006E2E00000000008E04DB04F30400B2 +:00000001FF diff --git a/Trigger/photo_booth_button/applet/photo_booth_button.cpp.o b/Trigger/photo_booth_button/applet/photo_booth_button.cpp.o new file mode 100644 index 0000000..0d0902a Binary files /dev/null and b/Trigger/photo_booth_button/applet/photo_booth_button.cpp.o differ diff --git a/Trigger/photo_booth_button/applet/pins_arduino.c.o b/Trigger/photo_booth_button/applet/pins_arduino.c.o new file mode 100644 index 0000000..36921f5 Binary files /dev/null and b/Trigger/photo_booth_button/applet/pins_arduino.c.o differ diff --git a/Trigger/photo_booth_button/applet/wiring.c.o b/Trigger/photo_booth_button/applet/wiring.c.o new file mode 100644 index 0000000..3d53958 Binary files /dev/null and b/Trigger/photo_booth_button/applet/wiring.c.o differ diff --git a/Trigger/photo_booth_button/applet/wiring_analog.c.o b/Trigger/photo_booth_button/applet/wiring_analog.c.o new file mode 100644 index 0000000..a87ec13 Binary files /dev/null and b/Trigger/photo_booth_button/applet/wiring_analog.c.o differ diff --git a/Trigger/photo_booth_button/applet/wiring_digital.c.o b/Trigger/photo_booth_button/applet/wiring_digital.c.o new file mode 100644 index 0000000..36989fb Binary files /dev/null and b/Trigger/photo_booth_button/applet/wiring_digital.c.o differ diff --git a/Trigger/photo_booth_button/applet/wiring_pulse.c.o b/Trigger/photo_booth_button/applet/wiring_pulse.c.o new file mode 100644 index 0000000..8f35718 Binary files /dev/null and b/Trigger/photo_booth_button/applet/wiring_pulse.c.o differ diff --git a/Trigger/photo_booth_button/applet/wiring_shift.c.o b/Trigger/photo_booth_button/applet/wiring_shift.c.o new file mode 100644 index 0000000..b4d533c Binary files /dev/null and b/Trigger/photo_booth_button/applet/wiring_shift.c.o differ diff --git a/Trigger/photo_booth_button/photo_booth_button.pde b/Trigger/photo_booth_button/photo_booth_button.pde new file mode 100644 index 0000000..269aa39 --- /dev/null +++ b/Trigger/photo_booth_button/photo_booth_button.pde @@ -0,0 +1,187 @@ +//Pins +#define PIN_STATUS_LED 13 +#define PIN_PEDAL 12 +#define PIN_BUTTON 2 +#define PIN_RED_LED 11 +#define PIN_GRN_LED 10 +//Commands (serial input) +#define CMD_TEST 'T' +#define CMD_RED_ON 'R' +#define CMD_RED_OFF 'r' +#define CMD_GRN_ON 'G' +#define CMD_GRN_OFF 'g' +#define CMD_DISPLAY '"' //start and stop character for input strings +//Replies (serial output) +#define REP_OK 'K' +#define REP_TEST 'T' +#define REP_BUTTON 'B' +#define REP_PEDAL 'P' +//States +#define ST_DEFAULT 0 +#define ST_DISPLAY 1 //when waiting for more serial data to display +//Errors +#define ERR_INVALID_INPUT 1 +#define ERR_INPUT_TIMEOUT 2 +#define ERR_INPUT_TOO_LONG 3 +//Misc. +#define DEBOUNCE 300 //milliseconds of debounce +#define SERIAL_TIMEOUT 500 //timeout when waiting to finish a display command +#define DISPLAY_SIZE 10 + +long pedal_time, button_time, serial_time; //timers for debounce and timeout +int state; +char displayString[DISPLAY_SIZE + 1]; //+1 for the '\0' at the end +int displayStringLength; //index of the '\0' character at the end of the string + +void setup() { + pinMode(PIN_STATUS_LED, OUTPUT); + pinMode(PIN_PEDAL, INPUT); + pinMode(PIN_BUTTON, INPUT); + pinMode(PIN_RED_LED, OUTPUT); + pinMode(PIN_GRN_LED, OUTPUT); + pedal_time = 0; + button_time = 0; + state = ST_DEFAULT; + displayStringLength = 0; + for (int i = 0; i < DISPLAY_SIZE + 1; i++) { + displayString[i] = '\0'; //null character + } + Serial.begin(9600); + //Blink reassuringly + digitalWrite(PIN_STATUS_LED, HIGH); + digitalWrite(PIN_RED_LED, HIGH); + digitalWrite(PIN_GRN_LED, HIGH); + delay(500); + digitalWrite(PIN_STATUS_LED, LOW); + digitalWrite(PIN_RED_LED, LOW); + digitalWrite(PIN_GRN_LED, LOW); +} + +void loop() { + button_task(); + serial_input_task(); +} + +void button_task() { + int button_input = digitalRead(PIN_BUTTON); + int pedal_input = digitalRead(PIN_PEDAL); + + //if button is pushed and hasn't been in the previous DEBOUNCE milliseconds, send the command + //FIXME: what about timer roll-over from millis()? + if (button_input == HIGH && millis()-button_time > DEBOUNCE) { + Serial.print(REP_BUTTON); + button_time = millis(); + } + //same for pedal + if (pedal_input == HIGH && millis()-pedal_time > DEBOUNCE) { + Serial.print(REP_PEDAL); + pedal_time = millis(); + } +} + +void serial_input_task() { + char input = '\0'; //null character + + switch (state) { + case ST_DEFAULT: + if (Serial.available()) { + input = Serial.read(); + switch (input) { + case CMD_TEST: + Serial.print(REP_TEST); + break; + case CMD_RED_ON: + digitalWrite(PIN_RED_LED, HIGH); + //Serial.print(REP_OK); + break; + case CMD_RED_OFF: + digitalWrite(PIN_RED_LED, LOW); + //Serial.print(REP_OK); + break; + case CMD_GRN_ON: + digitalWrite(PIN_GRN_LED, HIGH); + //Serial.print(REP_OK); + break; + case CMD_GRN_OFF: + digitalWrite(PIN_GRN_LED, LOW); + //Serial.print(REP_OK); + break; + case CMD_DISPLAY: + state = ST_DISPLAY; //start looking for input to display + serial_time = millis(); //start timeout timer + displayString[0] = '\0'; //zero the display string for new data + displayStringLength = 0; + break; + default: + reportError(ERR_INVALID_INPUT); + break; + } + } + break; + case ST_DISPLAY: + //check for a timeout + if (millis() > serial_time + SERIAL_TIMEOUT) { //timeout waiting for input to end + //FIXME: what about timer roll-over from millis()? + displayString[0] = '\0'; + displayStringLength = 0; + state = ST_DEFAULT; + reportError(ERR_INPUT_TIMEOUT); + } + //check if a character is available + if (Serial.available()) { + input = Serial.read(); + //see what the character is + switch (input) { + case CMD_DISPLAY: //found the end of the input + state = ST_DEFAULT; //return to normal operating state + display(); //display the input + Serial.print(REP_OK); //acknowledge + break; + default: //any other input + //make sure another character can fit + if (displayStringLength >= DISPLAY_SIZE) { //error condition: input too long + //zero the display string + displayString[0] = '\0'; + displayStringLength = 0; + Serial.flush(); + state = ST_DEFAULT; + //report the error + reportError(ERR_INPUT_TOO_LONG); + } + else { //everything is OK. append the character to the display string + displayString[displayStringLength] = input; + displayStringLength++; + displayString[displayStringLength] = '\0'; + } + break; + } + } + break; + default: //unexpected state number + digitalWrite(PIN_STATUS_LED, HIGH); + Serial.println("ERROR: Invalid state found in serial_input_task function."); + } +} + +void reportError(int err) { + switch (err) { + case ERR_INVALID_INPUT: + Serial.println("ERROR: Invalid input received."); + break; + case ERR_INPUT_TIMEOUT: + Serial.println("ERROR: Timeout while waiting for display input."); + Serial.println("Display input must end with '\"'."); + break; + case ERR_INPUT_TOO_LONG: + Serial.print("ERROR: Display input is too long. Max length is "); + Serial.println(DISPLAY_SIZE); + break; + default: + Serial.println("ERROR: unknown error code."); + break; + } +} + +void display() { + Serial.print("DISPLAYING: "); Serial.println(displayString); +} diff --git a/Trigger/photo_booth_robot_head.pde b/Trigger/photo_booth_robot_head.pde new file mode 100644 index 0000000..c8521bd --- /dev/null +++ b/Trigger/photo_booth_robot_head.pde @@ -0,0 +1,394 @@ +/* +Digital output goes out through two cascaded shift registers. +This includes the control outputs that runt he multiplexer (MUX) +and LCD. There are a bunch of shift register ouptuts left over for LEDs. +Digital input comes in through a multiplexer. The multiplexer output is +conected to the arduino, but the multiplexer outputs run through the +shift registers. +The contents of the shift registers are held in the global variable int +shiftData. Any function can put data into shiftData and have it +"output" by the shift registers by calling regCommit, which loads shiftData +into the shift registers and then latches the outputs. + +Each bit in int shiftData controls one output pin on the shift registers. +The order is: +High byte +7 +6 +5 +4 +3 MUX C +2 MUX B +1 MUX A +0 +Low byte +7 LCD DB7 +6 LCD DB6 +5 LCD DB5 +4 LCD DB4 +3 LCD ENABLE +2 LCD RW +1 LCD RS +0 LED for menu state +*/ + +// +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~robot head defines~~~~~~~~~~~~~~~~~~~~~~~ +//mask definitions for using shiftData +//high nibble is free +#define MUXC 0x0800 //multiplexer select bits A, B, C +#define MUXB 0x0400 +#define MUXA 0x0200 +//no def for 0x0100 +#define LCD7 0x0080 //LCD data bus bit 7, 6, 5, 4 (used in 4-bit mode) +#define LCD6 0x0040 +#define LCD5 0x0020 +#define LCD4 0x0010 +#define LCDENABLE 0x0008 //LCD enable +#define LCDRW 0x0004 //LCD read/write +#define LCDRS 0x0002 //LCD register select +#define LEDMENU 0x0001 //LED for showing menu state + +//pin definitions +//knob pins +#define KNOBRED 4 +#define KNOBGREEN 3 +#define KNOBBLUE 2 +//button pins +#define MUXY 5 //Non-inverted data from multiplexer +//shift register pins +#define REGSER 6 //serial input to shift register +#define REGRCK 7 //storage register clock (for output latches) - load on rising edge +#define REGSCK 8 //shift register clock - shift on rising edge +//multicolor LED pins +#define LEDRED 11 +#define LEDGREEN 10 +#define LEDBLUE 9 +//LCD pin +#define LCDDB7 //Data bus 7 is also buy flag +//default LED pin +#define LED 13 + +//LCD command definitions +#define CLEAR 0x01 //should also put DDRAM address 0x00 in the adress counter, but may not??? +#define HOME 0x02 +//command definitions with toggles--add the constants together to make a full command +//for example LCDwriteCommand(ENTRY+ID+S); should set the entry mode to increment the cursor +//and shift the display. LCDwriteCommand(ENTRY); should set the entry mode to decrement and not shift. +//ENTRY +#define ENTRY 0x04 //sets cursor move direction and display shift, used with ID and S +#define ID 0x02 //Increment or decrement cursor/display shift: use to increment, omit to decrement +#define S 0x01 //Shift display: use to shift, omit to not shift +//ON_OFF +#define ON_OFF 0x08 //turn display on or off, use with D, C, and B +#define D 0x04 //use for on, omit for off +#define C 0x02 //use to show cursor as an underline, omit to not show cursor +#define B 0x01 //use to blink cursor location, omit to not blink cursor location +//SHIFT +#define SHIFT 0x10 //moves cursor or shifts display without changing the display RAM contents, use with SC and RL +#define SC 0x08 //use to shift display, omit to move cursor +#define RL 0x04 //use to go right, omit to go left +//Address setting: set an address, then write or read to it in the next command +//for example, LCDwriteCommand(DDRAM + 0x00); LCDwriteData('A'); should write an 'A' into the first position +//of the first line (DDRAM address 0x00) +#define CGRAM 0x40 //set character generator RAM address, use with 6-bit address +#define DDRAM 0x80 //set display RAM address, use with 7-bit address--see note above on invalid addresses + +//button names +#define TOPLEFT 2 +#define BOTLEFT 1 +#define TOPRIGHT 3 +#define BOTRIGHT 6 +#define FARLEFT 8 +#define MIDLEFT 7 +#define MIDRIGHT 4 +#define FARRIGHT 5 + + +byte state; +byte holdColor; //flag to keep the LED color steady +int shiftData = 0; //holds bits for shift register output + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +//setup: +void setup() { + Serial.begin(9600); + //LED pins + pinMode(LED, OUTPUT); + //Shift register pins + pinMode(REGSER, OUTPUT); + pinMode(REGRCK, OUTPUT); + pinMode(REGSCK, OUTPUT); + //analog pins and digital input pins don't need their modes set + + LCDInit(); + digitalWrite(LED, HIGH); + delay(500); + digitalWrite(LED, LOW); + LCDprint("Hello, World."); + eyeColor(255, 0, 20); +} //end setup() + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +//main loop: +void loop() { + char input = '\0'; + byte butt = 0; + + butt = pollButtons(); + if (butt == 1) { + Serial.print('B'); + writeLine(1, "BUTTON"); + writeLine(2, ""); + eyeColor(0, 0, 255); + } + else { + writeLine(1, "No Button"); + writeLine(2, ""); + eyeColor(255, 20, 0); + } + + if (Serial.available()) { + input = Serial.read(); + if (input == 'T') { + Serial.print('T'); + writeLine(1, "TEST OK"); + writeLine(2, ""); + } + } +} //end loop() + +void eyeColor(int red, int green, int blue) { + analogWrite(LEDRED, 255-red); + analogWrite(LEDGREEN, 255-green); + analogWrite(LEDBLUE, 255-blue); +} + +void writeLine(byte line, char* data) { + //writes "data" to the LCD on line "line" + //centers the text if it is shorter than the line + char charIn; + byte length; + byte padding = 0; + //set cursor position + if(line == 1) LCDwriteCommand(HOME); + else if (line == 2) LCDwriteCommand(DDRAM + 0x40); + else return; //invalid line number + //count characters + length = 0; + charIn = data[0]; //assumes a non-empty string **FIXME + while(charIn != '\0') { + length++; + charIn = data[length]; + } + //pad front end of line + if (length < 16) padding = (16-length)/2; + for (int i = 0; i < padding; i++) LCDwriteData(' '); //write blanks + //print the data + for (int i = 0; i < length; i++) LCDwriteData(data[i]); + //pad the back end of the line + for (int i = 0; i <= padding; i++) LCDwriteData(' '); //write blanks, one extra on the end to cover rounding +} + +byte getButton() { + //returns the number (1-8) of any button pushed. Stalls execution + //until all buttons are released. If multiple buttons are pressed, + //it returns the last button released. If there is a conflict, + //the lower number wins. + byte buttons, temp; + buttons = pollButtons(); //stores the state of the 8 buttons in the bits of "buttons" + if (buttons > 0) { //if anything is pressed + delay(1); //wait for button bounce to end--no idea what right period would be + //poll until all buttons are released, store last nonzero value in buttons + temp = pollButtons(); + while (temp != 0) { //while any button is still pushed + Serial.println("stalled in getButton function"); + buttons = temp; //store nonzero value in buttons + temp = pollButtons(); //see if there is still a button pressed + } //when we escape, temp is 0 and buttons is the last poll with a button still down + //return smallest button # + for (temp = 0; temp <= 7; temp++) { + if ((buttons & (1< 0) { //if the "temp"th bit of buttons is 1 + return(temp+1); + } + } + } + return 0; //if no buttons were pressed +} + +//########################### Utility Functions ############################# +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +//Shift register functions + +void regCommit() { + //puts the contents of the global variable int shiftData on the register outputs + byte temp; + temp = ((shiftData>>8) & 0x00FF); //high byte + regShiftByte(temp); + temp = shiftData & 0x00FF; //low byte + regShiftByte(temp); + regLatch(); + //Serial.println("regCommit taking up time..."); + delayMicroseconds(100); + //The LCD doesn't work without at least a 95 uS delay here (or a Serial print) + //it's probably because LCDbusy() is disabled--should figure out where + //the timing problem really is and put the delay in the LCD code instead + //of here. FIXME +} + +void regShiftByte(byte data) { + //shifts one byte of data into the shift registers--does NOT set the outputs + //bytes go out bigendian: most significant bit first + for (byte mask = 0x80; mask > 0; mask = mask >> 1) { //shift mask until the 1 shifts out of the byte + digitalWrite(REGSCK, LOW); + if ((data & mask) > 0) digitalWrite(REGSER, HIGH); else digitalWrite(REGSER, LOW); + digitalWrite(REGSCK, HIGH); //shift + } +} + +void regLatch() { + //transfers the contents of the shift registers to the output latches + digitalWrite(REGRCK, LOW); + delayMicroseconds(1); + digitalWrite(REGRCK, HIGH); //load output latches +} + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +//MUX functions + +byte pollButtons() { + //Serial.println("pollButtons"); + //executes one poll of the buttons through a MUX (74HC151) + byte buttons = 0; + //poll through the MUX addresses to put current button values into byte buttons + for (int i = 0; i <= 0; i++) { //fucked with + if ((i & 1) == 1) shiftData = shiftData | MUXA; //set the MUXA bit to 1 + else shiftData = shiftData & (~MUXA); //set the MUXA bit to 0 + if ((i & 2) == 2) shiftData = shiftData | MUXB; + else shiftData = shiftData & (~MUXB); + if ((i & 4) == 4) shiftData = shiftData | MUXC; + else shiftData = shiftData & (~MUXC); + regCommit(); //output shiftData through the shift registers + delayMicroseconds(1); + if (digitalRead(MUXY)==HIGH) buttons = (buttons | (1 << i)); + } + //Serial.println("...end pollButtons"); + return buttons; +} +//%%%%%%%%%%%%%%%%%%%%%%%%%%% LCD Functions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +//high level LCD functions: + +void LCDprint(char data[]) { //start concise version without wrapping + int index = 0; + char temp = data[0]; + while (temp != '\0') { //assumes that data[] is a string ending with '\O' (= 0x00) + LCDwriteData(temp); + index++; + temp = data[index]; + } +} //end concise version + + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +//LCD write functions: +void LCDwriteCommand(byte data) { + while (LCDbusy()) {} //check busy flag until LCD is not busy + shiftData = shiftData & (~LCDRS); //put 0s in LCDRS and LCDRW + shiftData = shiftData & (~LCDRW); + regCommit(); //assert the new shiftData on the registers + LCDwrite(data); +} //end LCDwriteCommand + + +void LCDwriteData(byte data) { + //Serial.println("LCDwriteData"); + while (LCDbusy()) {} + shiftData = shiftData | LCDRS; //put 1 in LCDRS and 0 in LCDRW + shiftData = shiftData & (~LCDRW); + regCommit(); //assert the new shiftData on the registers + LCDwrite(data); + //Serial.println("...end LCDwriteData"); +} //end LCDwriteData + + +void LCDwrite(byte data) { + //Serial.println("LCDwrite"); + //sends an ENABLE signal and writes data to the data bus. + //this function assumes that the calling function has just set up the RS and RW pins + for (int nibble = 0; nibble < 2; nibble++) { //for the low and high nibble of the byte + delayMicroseconds(1); //only 140 nS needed for RS, RW setup time + shiftData = shiftData | LCDENABLE; //1 in LCDENABLE + regCommit(); //LCD will accept data on the down transition of LCDENABLE + //put data on the data pins + //clear the bits of shiftData that correspond to the LCD data bus + shiftData = shiftData & ~(LCD7+LCD6+LCD5+LCD4); + //add back in the values of the high nibble of data + //always reference LCD7-4 by name in case they change in the definitions + if ((data & 0x80)>0) shiftData = shiftData + LCD7; + if ((data & 0x40)>0) shiftData = shiftData + LCD6; + if ((data & 0x20)>0) shiftData = shiftData + LCD5; + if ((data & 0x10)>0) shiftData = shiftData + LCD4; + regCommit(); //assert the LCD data bus on the shift registers + delayMicroseconds(1); //only 195 nS needed for data setup time + shiftData = (shiftData & (~LCDENABLE)); //0 in LCDENABLE + regCommit(); //assert the low on LCD enable + data <<= 4; //shift low nibble to high nibble + } + //Serial.println("...end LCDwrite"); +} //end LCDwrite + +//*************FIXME******************goofy LCDbusy() function +byte LCDbusy() { + //delayMicroseconds(1); + return 0; +} + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +//Initialization +void LCDInit() { + //Initialize the LCD + delay(20); //min 15 ms needed after power-up + shiftData = shiftData & (~LCDRS); //put 0s in LCDRS and LCDRW + shiftData = shiftData & (~LCDRW); + regCommit(); //assert the new shiftData on the registers + //Send the high nibble of a function set for 8-bit data bus 3 times. Don't ask why; it's what the datasheet says. + // Set data pins + shiftData = shiftData | LCD4; + shiftData = shiftData | LCD5; + shiftData = shiftData & (~LCD6); + shiftData = shiftData & (~LCD7); + regCommit(); //assert the new shiftData on the registers + // send the data 3 times + for (int i = 0; i < 4; i++) { //toggle LCDENABLE 3 times + delayMicroseconds(1); //only 140 nS needed for RS, RW setup time + shiftData = shiftData | LCDENABLE; //1 in LCDENABLE + regCommit(); //LCD will accept data on the down transition + delayMicroseconds(1); //only 195 nS needed for data setup time + shiftData = shiftData & ~LCDENABLE; //0 in LCDENABLE + regCommit(); //LCD accepts data now + delayMicroseconds(5); //datasheet calls for 4.1ms in first pause, 100us in second pause + } + //reset data pins to a function set for 4-bit data bus. (This command is still 8-bit, so only one send is needed). + shiftData = shiftData & (~LCD4); //0 in LCD4, other pins stay as they are + regCommit(); + shiftData = shiftData | LCDENABLE; //1 in LCDENABLE + regCommit(); //LCD will accept data on the down transition + delayMicroseconds(1); //only 195 nS needed for data setup time + shiftData = shiftData & ~LCDENABLE; //0 in LCDENABLE + regCommit(); //LCD accepts data now + delayMicroseconds(1); //function set min delay is 37us + //subsequent commands use the 4-bit data bus, so LCDwriteCommand can be used + LCDwriteCommand(0x28); //function set: 4 bit interface, 2 lines, 5x7 pixel characters -- for LM044L + delay(1); //min 37 uS delay + LCDwriteCommand(0x08); //display off + delay(1); //min 37 uS delay + LCDwriteCommand(0x01); //display clear + delay(1); //don't know if this one is needed + LCDwriteCommand(0x06); //entry mode set: increment address, do not shift display + delay(1); //min 37 uS delay + //Initialization is complete + LCDwriteCommand(0x0C); //turn on display + delay(1); + LCDwriteCommand(0x02); //cursor home--may be redundant +} diff --git a/textures/1.jpg b/textures/1.jpg new file mode 100644 index 0000000..eb266c2 Binary files /dev/null and b/textures/1.jpg differ diff --git a/textures/10.jpg b/textures/10.jpg new file mode 100644 index 0000000..13f19c5 Binary files /dev/null and b/textures/10.jpg differ diff --git a/textures/11.jpg b/textures/11.jpg new file mode 100644 index 0000000..d0995de Binary files /dev/null and b/textures/11.jpg differ diff --git a/textures/12.jpg b/textures/12.jpg new file mode 100644 index 0000000..97b5d01 Binary files /dev/null and b/textures/12.jpg differ diff --git a/textures/13.jpg b/textures/13.jpg new file mode 100644 index 0000000..79730a4 Binary files /dev/null and b/textures/13.jpg differ diff --git a/textures/14.jpg b/textures/14.jpg new file mode 100644 index 0000000..f159890 Binary files /dev/null and b/textures/14.jpg differ diff --git a/textures/15.JPG b/textures/15.JPG new file mode 100644 index 0000000..e232b41 Binary files /dev/null and b/textures/15.JPG differ diff --git a/textures/16.JPG b/textures/16.JPG new file mode 100644 index 0000000..07ed753 Binary files /dev/null and b/textures/16.JPG differ diff --git a/textures/17.JPG b/textures/17.JPG new file mode 100644 index 0000000..bdd6cff Binary files /dev/null and b/textures/17.JPG differ diff --git a/textures/18.JPG b/textures/18.JPG new file mode 100644 index 0000000..4af4039 Binary files /dev/null and b/textures/18.JPG differ diff --git a/textures/19.JPG b/textures/19.JPG new file mode 100644 index 0000000..d14905d Binary files /dev/null and b/textures/19.JPG differ diff --git a/textures/2.jpg b/textures/2.jpg new file mode 100644 index 0000000..25be909 Binary files /dev/null and b/textures/2.jpg differ diff --git a/textures/20.JPG b/textures/20.JPG new file mode 100644 index 0000000..ff744fb Binary files /dev/null and b/textures/20.JPG differ diff --git a/textures/21.JPG b/textures/21.JPG new file mode 100644 index 0000000..7515d60 Binary files /dev/null and b/textures/21.JPG differ diff --git a/textures/22.JPG b/textures/22.JPG new file mode 100644 index 0000000..b4c1e88 Binary files /dev/null and b/textures/22.JPG differ diff --git a/textures/3.jpg b/textures/3.jpg new file mode 100644 index 0000000..dcdd372 Binary files /dev/null and b/textures/3.jpg differ diff --git a/textures/4.jpg b/textures/4.jpg new file mode 100644 index 0000000..13f19c5 Binary files /dev/null and b/textures/4.jpg differ diff --git a/textures/5.jpg b/textures/5.jpg new file mode 100644 index 0000000..d0995de Binary files /dev/null and b/textures/5.jpg differ diff --git a/textures/6.jpg b/textures/6.jpg new file mode 100644 index 0000000..079f295 Binary files /dev/null and b/textures/6.jpg differ diff --git a/textures/7.jpg b/textures/7.jpg new file mode 100644 index 0000000..eb266c2 Binary files /dev/null and b/textures/7.jpg differ diff --git a/textures/8.jpg b/textures/8.jpg new file mode 100644 index 0000000..25be909 Binary files /dev/null and b/textures/8.jpg differ diff --git a/textures/9.jpg b/textures/9.jpg new file mode 100644 index 0000000..dcdd372 Binary files /dev/null and b/textures/9.jpg differ