public void messageLoop() { while (true) { //try to connect to OpenCOVER if (!COVER.Instance.isConnected()) { string host = Globals.Ribbons.Ribbon2.host.Text; int port = Convert.ToInt32(Globals.Ribbons.Ribbon2.port.Text); if (COVER.Instance.ConnectToOpenCOVER(host, port)) { sendApplicationType(); Globals.Ribbons.Ribbon2.connected.Checked = true; } else { Thread.Sleep(3000); Globals.Ribbons.Ribbon2.connected.Checked = false; } } COVER.Instance.checkForMessages(); while (COVER.Instance.messageQueue.Count > 0) { COVERMessage m = COVER.Instance.messageQueue.Dequeue(); if ((COVER.MessageTypes)m.messageType == COVER.MessageTypes.StringMessage) { string input = m.message.readString(); if (input.StartsWith("startSlideShow")) { ppt.startSlideShow(); sendStringMessage("OK"); } else if (input.StartsWith("stopSlideShow")) { ppt.stopSlideShow(); sendStringMessage("OK"); } else if (input.StartsWith("next")) { ppt.next(); sendStringMessage("OK"); } else if (input.StartsWith("previous")) { ppt.previous(); sendStringMessage("OK"); } else if (input.StartsWith("currentSlide")) { int cs = ppt.CurrentSlide; sendStringMessage("currentSlide " + cs.ToString()); } else if (input.StartsWith("quit")) { ppt.quit(); sendStringMessage("OK"); } else if (input.StartsWith("load")) { string[] parameters = input.Split(' '); ppt.load(parameters[1]); sendStringMessage("OK"); } else if (input.StartsWith("save")) { string[] parameters = input.Split(' '); ppt.save(parameters[1]); sendStringMessage("OK"); } else if (input.StartsWith("setCurrentSlide")) { string[] parameters = input.Split(' '); if (parameters.Length > 1) { int cs = ppt.CurrentSlide = int.Parse(parameters[1]); sendStringMessage(cs.ToString()); } } /*else if (input.StartsWith("gotoPage ")) * { * string[] parameters = input.Split(' '); * bool result; * if (parameters.Length > 2) * result = word.gotoPage(int.Parse(parameters[1]), int.Parse(parameters[2])); * else * result = word.gotoPage(int.Parse(parameters[1])); * * if (result) * sendStringMessage("OK"); * else * sendStringMessage("FAIL"); * * }*/ } else if ((COVER.MessageTypes)m.messageType == COVER.MessageTypes.MSG_PNGSnapshot) { int numBytes = m.message.readInt(); string fn = System.IO.Path.GetTempFileName(); fn += (".png"); Byte[] bytes = m.message.readBytes(numBytes); ByteArrayToFile(fn, bytes); string transform = m.message.readString(); addImage(fn, transform); } } } }