//play a sound for the client internal static void PlaySound(SoundType type) { //create resource manager to handle the files Resourcer rm = new Resourcer(LoadMethod.CallingCode); System.Media.SoundPlayer sound = new System.Media.SoundPlayer(); switch (type) { case (SoundType.NewClient): sound.Stream = rm.GetResourceStream("Knock.wav"); sound.Play(); break; case (SoundType.Exit): sound.Stream = rm.GetResourceStream("Door.wav"); sound.Play(); break; case (SoundType.NewMsg): sound.Stream = rm.GetResourceStream("Message.wav"); sound.Play(); break; case (SoundType.NewMsgPow): sound.Stream = rm.GetResourceStream("Pow.wav"); sound.Play(); break; } }
//this function saves the chat history as an HTML file internal static void SaveAsHTML(string fileName, string[] lines, string titleString) { string htmlString = "<HTML>" + Environment.NewLine; string dateTime = "( " + DateTime.Now.ToLongTimeString() + " )"; //generate the header for the HTML file htmlString += "<meta charset=utf-8/>" + Environment.NewLine; htmlString += "<Title>" + titleString + "</Title>" + Environment.NewLine; htmlString += "<link rel='stylesheet' href='Files/Styles.css' type='Text/Css'" + Environment.NewLine; htmlString += "<Body>" + Environment.NewLine; htmlString += "<Table align='center'><TR><TD class='Header'>" + titleString + "</TD><TD class='Header'>" + dateTime + "</TD><TD><IMG src='Files/face.gif'/></TD></TR></Table><HR width='60%'>"; htmlString += Environment.NewLine + "<Table>"; //convert the messages to the html file foreach (string line in lines) { if (line.Trim() != "") { htmlString += "<TR><TD><IMG src='Files/arrow.gif'/></TD><TD>" + line + "</TD></TR>" + Environment.NewLine; } } htmlString += "</Table>"; htmlString += Environment.NewLine + "</Body></HTML>"; string dirName = fileName.Substring(0, fileName.LastIndexOf('\\')); //create resource manager and load resources into files Directory.CreateDirectory(dirName + "\\Files"); Resourcer rm = new Resourcer(LoadMethod.CallingCode); rm.ExtractAndSave("face.gif", dirName + "\\Files\\face.gif"); rm.ExtractAndSave("arrow.gif", dirName + "\\Files\\arrow.gif"); rm.ExtractAndSave("Styles.css", dirName + "\\Files\\Styles.css"); FileStream fs = new FileStream(fileName, FileMode.Create); StreamWriter sw = new StreamWriter(fs); sw.Write(htmlString); sw.Flush(); sw.Close(); }