private FormatEncoding ParseFormat(string enumValue, FormatEncoding defaultValue) { string text = enumValue.Trim().ToUpperInvariant(); switch (text) { case "BMP": return(FormatEncoding.BMP); case "EMF": return(FormatEncoding.EMF); case "EMFPLUS": return(FormatEncoding.EMFPLUS); case "GIF": return(FormatEncoding.GIF); case "JPEG": return(FormatEncoding.JPEG); case "PNG": return(FormatEncoding.PNG); case "TIFF": return(FormatEncoding.TIFF); default: return(defaultValue); } }
public UdpServer() { this.Port = 10_000; this.Sleep = 1_000; this.EndPoint = new IPEndPoint(IPAddress.Loopback, Port); this.Socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); this.PkgBytes = new byte[1024]; this.FormatEncoding = FormatEncoding.UTF8; }
public UdpServer(IPAddress ipAddress, int port, int sleep, int sizeBuff, FormatEncoding formatEncoding) { this.Port = port; this.Sleep = sleep; this.EndPoint = new IPEndPoint(ipAddress, Port); this.Socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); this.PkgBytes = new byte[sizeBuff]; this.FormatEncoding = formatEncoding; }
public string MsgStrUdp(ref EndPoint remoteEndPoint, Socket socket, FormatEncoding formatEncoding) { string output = ""; if (socket != null && remoteEndPoint != null) { this._socket = socket; int count = _socket.ReceiveFrom(_buff, ref remoteEndPoint); switch (formatEncoding) { case FormatEncoding.UTF8: output = Encoding.UTF8.GetString(_buff, 0, count); break; default: break; } } return(output); }
private void ParseDeviceInfo(NameValueCollection deviceInfo, out int columns, out double columnSpacing) { int count = deviceInfo.Count; columns = 0; columnSpacing = -1.0; for (int i = 0; i < count; i++) { string key = deviceInfo.GetKey(i); string text = deviceInfo.Get(i); object obj = PaginationSettings.DeviceInfoTagLookup[key]; switch ((obj != null) ? ((DeviceInfoTags)obj) : DeviceInfoTags.Unknown) { case DeviceInfoTags.StartPage: this.m_startPage = this.ParseInt(text, 0); break; case DeviceInfoTags.EndPage: this.m_endPage = this.ParseInt(text, 0); break; case DeviceInfoTags.PageWidth: this.m_physicalPageWidth = this.ParseSize(text, this.m_physicalPageWidth); break; case DeviceInfoTags.PageHeight: this.m_physicalPageHeight = this.ParseSize(text, this.m_physicalPageHeight); break; case DeviceInfoTags.Columns: columns = this.ParseInt(text, columns); break; case DeviceInfoTags.ColumnSpacing: columnSpacing = this.ParseSize(text, columnSpacing); break; case DeviceInfoTags.MarginTop: this.m_marginTop = this.ParseSize(text, this.m_marginTop); break; case DeviceInfoTags.MarginLeft: this.m_marginLeft = this.ParseSize(text, this.m_marginLeft); break; case DeviceInfoTags.MarginBottom: this.m_marginBottom = this.ParseSize(text, this.m_marginBottom); break; case DeviceInfoTags.MarginRight: this.m_marginRight = this.ParseSize(text, this.m_marginRight); break; case DeviceInfoTags.DpiX: this.m_dpiX = this.ParseInt(text, 96); break; case DeviceInfoTags.DpiY: this.m_dpiY = this.ParseInt(text, 96); break; case DeviceInfoTags.OutputFormat: this.m_outputFormat = this.ParseFormat(text, FormatEncoding.TIFF); break; case DeviceInfoTags.ReportItemPath: this.m_reportItemPath = text; break; } } }