private static extern void sendWallMessage(IntPtr port, [MarshalAs(UnmanagedType.LPStr)] String sayit, position pos, mode style, colour col, specialStyle special, bool dumppkt);
private void friendlySendWallMessage(String sayit, position pos, mode useMode, colour col, specialStyle useStyle) { IntPtr portHwd = IntPtr.Zero; if (string.IsNullOrEmpty(_options.port)) throw new NullReferenceException("No Port set for wallboard"); try { portHwd = connectWallboard(_options.port); sendWallMessage(portHwd, sayit, pos, useMode, col, useStyle, false); } catch(wallboardException ex) { errorHandler(ex); } catch (Exception ex) { _options.state = wallboardErrorState.Unknown; //attempt to get additional info about the error if the handle was successfully opened if (portHwd != IntPtr.Zero) _options.state = checkWallboardErrorState(portHwd); errorHandler(new wallboardException("An exception occurred while sending " + sayit + " to the wallboard", _options.state, ex)); } finally { friendlyClosePort(ref portHwd); } }
public static wallboardErrorState testWallboardConnectivity(string port, position testPos, mode testMode, colour testCol, specialStyle testSpecial) { if (string.IsNullOrEmpty(port)) throw new Exception("No port set for wallboard"); IntPtr portHwd = IntPtr.Zero; wallboardErrorState state; try { portHwd = connectWallboard(port); if (portHwd == IntPtr.Zero) return wallboardErrorState.Unknown; state = checkWallboardErrorState(portHwd); if (state == wallboardErrorState.None) { sendWallMessage(portHwd, "Hello World", testPos, testMode, testCol, testSpecial, false); } } finally { friendlyClosePort(ref portHwd); } return state; }