// Hook the objectReceived event and process it private void objectReceived(object o, ObjectReceivedEventArgs orea) { if (orea.Data is String) { ViewMessage(orea.Participant.Name + ": " + orea.Data.ToString()); } }
private void OnObjectReceived(object sender, ObjectReceivedEventArgs ea) { // We only expect one kind of data (a url in the form of a string) // if you were expecting other data, you would parse the data type here object flags = null, targetFrameName = null, postData = null, headers = null; ie.Navigate((string)ea.Data, ref flags, ref targetFrameName, ref postData, ref headers); }
private void OnObjectReceived(object o, ObjectReceivedEventArgs orea) { if (!(orea.Data is String)) { string msg = string.Format("Unexpected data type for - orea.Data. " + "Expected type 'string' received type '{0}'", orea.Data.GetType().ToString()); Debug.Assert(false, msg); throw new ArgumentException(msg); } ViewMessage(orea.Participant.Name, (string)orea.Data); }
private void OnObjectReceived(object o, ObjectReceivedEventArgs orea) { try { // Don't receive your own data if (orea.Participant != Conference.LocalParticipant) { if (orea.Data is SerializedInk) { Strokes strokes = ((SerializedInk)orea.Data).Strokes; // This call fails, claiming the strokes are in 2 ink objects // inkOverlay.Ink.Strokes.Add(strokes); // But this call works inkOverlay.Ink.AddStrokesAtRectangle(strokes, strokes.GetBoundingBox()); } else if (orea.Data is DeletedStrokes) { string[] identifiers = ((DeletedStrokes)orea.Data).Identifiers; Ink ink = inkOverlay.Ink; for (int i = 0; i < identifiers.Length; i++) { for (int j = ink.Strokes.Count - 1; j >= 0; j--) { Stroke stroke = ink.Strokes[j]; if ((string)stroke.ExtendedProperties[StrokeIdentifier].Data == identifiers[i]) { ink.DeleteStroke(stroke); break; } } } } else if (orea.Data is EraseAllInk) { inkOverlay.Ink.DeleteStrokes(); } // Update the screen when data arrives pbInk.Refresh(); } } catch (Exception e) { Log(string.Format(CultureInfo.CurrentCulture, "Exception: {0}", e.ToString())); } }
/// <summary> /// Hook the objectReceived event and process it. /// </summary> private void OnObjectReceived(object o, ObjectReceivedEventArgs orea) { // Don't receive your own messages (objects) if (orea.Participant != Conference.LocalParticipant) { Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Message recieved of type: {0}", orea.Data.ToString())); // Check to see if there are waiting messages lock (this.receiveQueue) { // Messages in the queue signals that there's a thread working on a current // message, thus we don't want to start processing another message receiveQueue.Enqueue(orea); if (receiveQueue.Count != 1) { // There are other messages waiting on the user. Return and let the // currently processing message finish. return; } } // There are no messages waiting, so we're free to process this one while (true) { this.ConsumeObject(orea); // Check for messages added while we were processing that one. lock (this.receiveQueue) { receiveQueue.Dequeue(); // that was this message if (receiveQueue.Count != 0) { orea = (ObjectReceivedEventArgs)receiveQueue.Peek(); } else // .Count == 0 { return; } } } } }
private void OnObjectReceived(object sender, ObjectReceivedEventArgs ea) { object flags = null, targetFrameName = null, postData = null, headers = null; string url = null; if (ea.Data is NavigationData) { NavigationData nd = (NavigationData)ea.Data; url = nd.Url; flags = (object)nd.Flags; targetFrameName = (object)nd.TargetFrame; postData = nd.PostData; headers = (object)nd.Headers; } else if (ea.Data is string) { //Older versions just sent a string -- maintain compatibility url = (string)ea.Data; } ie.Navigate(url, ref flags, ref targetFrameName, ref postData, ref headers); }
private void ObjectReceived(object capability, ObjectReceivedEventArgs ea) { if (ea.Data is FileObject) { FileObject fileObject = ea.Data as FileObject; FileInfo fileInfo = new FileInfo(fileObject.Name); Type tCapability = null; ItemReceivedDialog dlgFileReceived = null; if (tCapability != null) { Capability.NameAttribute attrName = (Capability.NameAttribute) Attribute.GetCustomAttribute(tCapability, typeof(Capability.NameAttribute)); Capability.PayloadTypeAttribute attrPT = (Capability.PayloadTypeAttribute) Attribute.GetCustomAttribute(tCapability, typeof(Capability.PayloadTypeAttribute)); dlgFileReceived = new ItemReceivedDialog(Strings.CapabilityReceived, Strings.UserSentYouCapability); dlgFileReceived.Button1Label = Strings.InstallHotkey; dlgFileReceived.FileIconTip = string.Format(CultureInfo.CurrentCulture, Strings.CapabilityNamePayloadType, attrName.Name, attrPT.PayloadType.ToString()); } else { dlgFileReceived = new ItemReceivedDialog(Strings.FileReceived, Strings.UserSentYouFile); } dlgFileReceived.Image = Image.FromStream( System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MSR.LST.ConferenceXP.Images.FileReceived.gif")); dlgFileReceived.From = ea.Participant.Name; dlgFileReceived.Avatar = ea.Participant.Icon; dlgFileReceived.AvatarTip = Strings.AvatarTipText; dlgFileReceived.File = fileInfo.Name; dlgFileReceived.FileIcon = fileObject.Icon; dlgFileReceived.FileIconTip += string.Format(CultureInfo.CurrentCulture, Strings.FileSize, ((double)fileObject.Data.Length / 1024.0).ToString("#,#.00", CultureInfo.CurrentCulture)); dlgFileReceived.Time = DateTime.Now.ToString("h:mm:ss tt", CultureInfo.CurrentCulture); if (dlgFileReceived.ShowDialog() != DialogResult.OK) { return; } if (tCapability != null) { RtlAwareMessageBox.Show(this, Strings.NotYetImplemented, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0); } else { SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.FileName = fileInfo.Name; if (Directory.Exists(fileInfo.DirectoryName)) { saveDialog.InitialDirectory = fileInfo.DirectoryName; } saveDialog.Filter = "All files (*.*)|*.*"; saveDialog.CheckPathExists = true; saveDialog.OverwritePrompt = true; saveDialog.RestoreDirectory = true; if (saveDialog.ShowDialog() != DialogResult.OK) { return; } FileStream fileStream = File.OpenWrite(saveDialog.FileName); fileStream.Write(fileObject.Data, 0, fileObject.Data.Length); fileStream.Close(); } } }
private void OnObjectReceived(object o, ObjectReceivedEventArgs orea) { if(! (orea.Data is String)) { string msg = string.Format("Unexpected data type for - orea.Data. " + "Expected type 'string' received type '{0}'", orea.Data.GetType().ToString()); Debug.Assert(false, msg); throw new ArgumentException(msg); } ViewMessage(orea.Participant.Name, (string)orea.Data); }
/// <summary> /// Hook the objectReceived event and process it. /// </summary> /// <param name="o">The object received</param> /// <param name="orea">The object event arguments</param> private void ObjectReceived(object o, ObjectReceivedEventArgs orea) { Log("ObjectReceived,"); Log("Object orea.Data:" + orea.Data.ToString()); try { // Don't receive your own messages (objects) if (orea.Participant != Conference.LocalParticipant) { Log("Not a local participant,"); if (orea.Data is RTStrokeRemove) { RTStrokeRemoveReceived((RTStrokeRemove)orea.Data); } else if (orea.Data is RTStroke) { RTStrokeReceived((RTStroke)orea.Data); } else if (orea.Data is Page) { PageReceived((Page)orea.Data); } else if (orea.Data is RTPageAdd) { RTPageAddReceived((RTPageAdd)orea.Data); } else if (orea.Data is RTNodeChanged) { RTNodeChangedReceived( (RTNodeChanged)orea.Data); } else if (orea.Data is RTDocument) { RTDocumentReceived((RTDocument)orea.Data); } else if (orea.Data is RTFrame) { RTFrameReceived((RTFrame)orea.Data); } } } catch ( Exception e) { Log(string.Format(CultureInfo.CurrentCulture, "Exception: {0}", e.ToString())); } }
private void ObjectReceived(object capability, ObjectReceivedEventArgs ea) { if (ea.Data is FileObject) { FileObject fileObject = ea.Data as FileObject; FileInfo fileInfo = new FileInfo(fileObject.Name); Type tCapability = null; ItemReceivedDialog dlgFileReceived = null; if (tCapability != null) { Capability.NameAttribute attrName = (Capability.NameAttribute) Attribute.GetCustomAttribute(tCapability, typeof(Capability.NameAttribute)); Capability.PayloadTypeAttribute attrPT = (Capability.PayloadTypeAttribute) Attribute.GetCustomAttribute(tCapability, typeof(Capability.PayloadTypeAttribute)); dlgFileReceived = new ItemReceivedDialog(Strings.CapabilityReceived, Strings.UserSentYouCapability); dlgFileReceived.Button1Label = Strings.InstallHotkey; dlgFileReceived.FileIconTip = string.Format(CultureInfo.CurrentCulture, Strings.CapabilityNamePayloadType, attrName.Name, attrPT.PayloadType.ToString()); } else { dlgFileReceived = new ItemReceivedDialog(Strings.FileReceived, Strings.UserSentYouFile); } dlgFileReceived.Image = Image.FromStream( System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MSR.LST.ConferenceXP.Images.FileReceived.gif")); dlgFileReceived.From = ea.Participant.Name; dlgFileReceived.Avatar = ea.Participant.Icon; dlgFileReceived.AvatarTip = Strings.AvatarTipText; dlgFileReceived.File = fileInfo.Name; dlgFileReceived.FileIcon = fileObject.Icon; dlgFileReceived.FileIconTip += string.Format(CultureInfo.CurrentCulture, Strings.FileSize, ((double)fileObject.Data.Length / 1024.0).ToString("#,#.00", CultureInfo.CurrentCulture)); dlgFileReceived.Time = DateTime.Now.ToString("h:mm:ss tt", CultureInfo.CurrentCulture); if (dlgFileReceived.ShowDialog() != DialogResult.OK) return; if (tCapability != null) { RtlAwareMessageBox.Show(this, Strings.NotYetImplemented, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0); } else { SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.FileName = fileInfo.Name; if (Directory.Exists(fileInfo.DirectoryName)) saveDialog.InitialDirectory = fileInfo.DirectoryName; saveDialog.Filter = "All files (*.*)|*.*"; saveDialog.CheckPathExists = true; saveDialog.OverwritePrompt = true; saveDialog.RestoreDirectory = true; if (saveDialog.ShowDialog() != DialogResult.OK) return; FileStream fileStream = File.OpenWrite(saveDialog.FileName); fileStream.Write(fileObject.Data, 0, fileObject.Data.Length); fileStream.Close(); } } }
// Hook the objectReceived event and process it private void objectReceived(object o, ObjectReceivedEventArgs orea) { if(orea.Data is String) { ViewMessage(orea.Participant.Name + ": " + orea.Data.ToString()); } }
private void ObjectReceived(object capability, ObjectReceivedEventArgs ea) { if (ea.Data is FileObject) { FileObject fileObject = ea.Data as FileObject; FileInfo fileInfo = new FileInfo(fileObject.Name); Type tCapability = null; // if (fileInfo.Extension.ToLower() == ".dll") // tCapability = GetCapability(fileObject.Data); ItemReceivedDialog dlgFileReceived = null; if (tCapability != null) { Capability.NameAttribute attrName = (Capability.NameAttribute) Attribute.GetCustomAttribute(tCapability, typeof(Capability.NameAttribute)); Capability.PayloadTypeAttribute attrPT = (Capability.PayloadTypeAttribute) Attribute.GetCustomAttribute(tCapability, typeof(Capability.PayloadTypeAttribute)); dlgFileReceived = new ItemReceivedDialog("Capability received", "A user has just sent you a capability"); dlgFileReceived.Button1Label = "&Install"; dlgFileReceived.FileIconTip = "Capability name: " + attrName.Name + Environment.NewLine + "Payload type: " + attrPT.PayloadType.ToString() + Environment.NewLine; } else { dlgFileReceived = new ItemReceivedDialog("File received", "A user has just sent you a file"); } dlgFileReceived.Image = Image.FromStream( System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MSR.LST.ConferenceXP.Images.FileReceived.gif")); dlgFileReceived.From = ea.Participant.Name; dlgFileReceived.Avatar = ea.Participant.Icon; dlgFileReceived.AvatarTip = "IP: " + ea.Participant.RtpParticipant.IPAddress.ToString() + Environment.NewLine + "Id: " + ea.Participant.Identifier + Environment.NewLine + "Email: " + ea.Participant.Email + Environment.NewLine + "Phone: " + ea.Participant.Phone; dlgFileReceived.File = fileInfo.Name; dlgFileReceived.FileIcon = fileObject.Icon; dlgFileReceived.FileIconTip += "File size: " + ((double)fileObject.Data.Length / 1024.0).ToString("#,#.00") + " KB"; dlgFileReceived.Time = DateTime.Now.ToString("h:mm:ss tt"); if (dlgFileReceived.ShowDialog() != DialogResult.OK) return; if (tCapability != null) { MessageBox.Show("Not yet implemented"); } else { SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.FileName = fileInfo.Name; if (Directory.Exists(fileInfo.DirectoryName)) saveDialog.InitialDirectory = fileInfo.DirectoryName; saveDialog.Filter = "All files (*.*)|*.*"; saveDialog.CheckPathExists = true; saveDialog.OverwritePrompt = true; saveDialog.RestoreDirectory = true; if (saveDialog.ShowDialog() != DialogResult.OK) return; FileStream fileStream = File.OpenWrite(saveDialog.FileName); fileStream.Write(fileObject.Data, 0, fileObject.Data.Length); fileStream.Close(); } } }
private void ObjectReceived(object capability, ObjectReceivedEventArgs ea) { if (ea.Data is FileObject) { FileObject fileObject = ea.Data as FileObject; FileInfo fileInfo = new FileInfo(fileObject.Name); Type tCapability = null; // if (fileInfo.Extension.ToLower() == ".dll") // tCapability = GetCapability(fileObject.Data); ItemReceivedDialog dlgFileReceived = null; if (tCapability != null) { Capability.NameAttribute attrName = (Capability.NameAttribute) Attribute.GetCustomAttribute(tCapability, typeof(Capability.NameAttribute)); Capability.PayloadTypeAttribute attrPT = (Capability.PayloadTypeAttribute) Attribute.GetCustomAttribute(tCapability, typeof(Capability.PayloadTypeAttribute)); dlgFileReceived = new ItemReceivedDialog("Capability received", "A user has just sent you a capability"); dlgFileReceived.Button1Label = "&Install"; dlgFileReceived.FileIconTip = "Capability name: " + attrName.Name + Environment.NewLine + "Payload type: " + attrPT.PayloadType.ToString() + Environment.NewLine; } else { dlgFileReceived = new ItemReceivedDialog("File received", "A user has just sent you a file"); } dlgFileReceived.Image = Image.FromStream( System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MSR.LST.ConferenceXP.Images.FileReceived.gif")); dlgFileReceived.From = ea.Participant.Name; dlgFileReceived.Avatar = ea.Participant.Icon; dlgFileReceived.AvatarTip = "IP: " + ea.Participant.RtpParticipant.IPAddress.ToString() + Environment.NewLine + "Id: " + ea.Participant.Identifier + Environment.NewLine + "Email: " + ea.Participant.Email + Environment.NewLine + "Phone: " + ea.Participant.Phone; dlgFileReceived.File = fileInfo.Name; dlgFileReceived.FileIcon = fileObject.Icon; dlgFileReceived.FileIconTip += "File size: " + ((double)fileObject.Data.Length / 1024.0).ToString("#,#.00") + " KB"; dlgFileReceived.Time = DateTime.Now.ToString("h:mm:ss tt"); if (dlgFileReceived.ShowDialog() != DialogResult.OK) { return; } if (tCapability != null) { MessageBox.Show("Not yet implemented"); } else { SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.FileName = fileInfo.Name; if (Directory.Exists(fileInfo.DirectoryName)) { saveDialog.InitialDirectory = fileInfo.DirectoryName; } saveDialog.Filter = "All files (*.*)|*.*"; saveDialog.CheckPathExists = true; saveDialog.OverwritePrompt = true; saveDialog.RestoreDirectory = true; if (saveDialog.ShowDialog() != DialogResult.OK) { return; } FileStream fileStream = File.OpenWrite(saveDialog.FileName); fileStream.Write(fileObject.Data, 0, fileObject.Data.Length); fileStream.Close(); } } }
// Hook the objectReceived event and process it private void objectReceived(object o, ObjectReceivedEventArgs orea) { if (m_CapabilitySender != null) { m_CapabilitySender.Receive(orea.Data, orea.Participant.RtpParticipant); } }
private void ConsumeObject(ObjectReceivedEventArgs orea) { // Create RTDoc with one slide & put it in ON if (rtDoc == null && !(orea.Data is RTDocument || orea.Data is RTFrame)) { // Create blank RTDocument rtDoc = new RTDocument(); rtDoc.Identifier = new Guid(constWhiteboardGuid); rtDoc.Metadata.Title = "Whiteboard Session " + DateTime.Now.ToString("u"); rtDoc.Metadata.Creator = Conference.LocalParticipant.Name; // Add a blank page Page pg = new Page(); pg.Identifier = new Guid(constWhiteboardGuid); TOCNode tn = new TOCNode(); tn.Title = "Whiteboard 1"; tn.Resource = pg; tn.ResourceIdentifier = pg.Identifier; tn.Identifier = new Guid(constWhiteboardGuid); rtDoc.Organization.TableOfContents.Add(tn); rtDoc.Resources.Pages.Add(pg.Identifier, pg); // Add the page to the strokes hash strokesPerPage.Add(pg.Identifier, new ArrayList()); // Init necessary vars this.crntPage = pg.Identifier; // Pri2: re-enable this feature (removed due to PS 2063) //string folderInON = Options.GetFolderForAuthor("Unknown / Whiteboard Session"); //this.crntONFile = folderInON + " " + DateTime.Now.ToString("u").Replace(":", ".").Replace("Z","") + ".one"; this.crntONFile = "Whiteboard - " + DateTime.Now.ToString("u").Replace(":", ".").Replace("Z", "") + ".one"; // Import the page this.InsertPageInON(pg, tn.Title, Guid.Empty); // Show first page System.Threading.Thread.Sleep(50); importer.NavigateToPage(crntONFile, crntPage.ToString("B")); } if (orea.Data is RTStrokeRemove) { RTStrokeRemoveReceived((RTStrokeRemove)orea.Data); } else if (orea.Data is RTStroke) { RTStrokeReceived((RTStroke)orea.Data); } else if (orea.Data is Page) { PageReceived((Page)orea.Data); } else if (orea.Data is RTPageAdd) { RTPageAddReceived((RTPageAdd)orea.Data); } else if (orea.Data is RTNodeChanged) { RTNodeChangedReceived( (RTNodeChanged)orea.Data); } else if (orea.Data is RTDocument) { RTDocumentReceived((RTDocument)orea.Data); } else if (orea.Data is RTFrame) { RTFrameReceived((RTFrame)orea.Data); } }
private void ConsumeObject( ObjectReceivedEventArgs orea ) { // Create RTDoc with one slide & put it in ON if (rtDoc == null && !(orea.Data is RTDocument || orea.Data is RTFrame)) { // Create blank RTDocument rtDoc = new RTDocument(); rtDoc.Identifier = new Guid(constWhiteboardGuid); rtDoc.Metadata.Title = "Whiteboard Session " + DateTime.Now.ToString("u"); rtDoc.Metadata.Creator = Conference.LocalParticipant.Name; // Add a blank page Page pg = new Page(); pg.Identifier = new Guid(constWhiteboardGuid); TOCNode tn = new TOCNode(); tn.Title = "Whiteboard 1"; tn.Resource = pg; tn.ResourceIdentifier = pg.Identifier; tn.Identifier = new Guid(constWhiteboardGuid); rtDoc.Organization.TableOfContents.Add(tn); rtDoc.Resources.Pages.Add(pg.Identifier, pg); // Add the page to the strokes hash strokesPerPage.Add( pg.Identifier, new ArrayList() ); // Init necessary vars this.crntPage = pg.Identifier; // Pri2: re-enable this feature (removed due to PS 2063) //string folderInON = Options.GetFolderForAuthor("Unknown / Whiteboard Session"); //this.crntONFile = folderInON + " " + DateTime.Now.ToString("u").Replace(":", ".").Replace("Z","") + ".one"; this.crntONFile = "Whiteboard - " + DateTime.Now.ToString("u").Replace(":", ".").Replace("Z","") + ".one"; // Import the page this.InsertPageInON( pg, tn.Title, Guid.Empty ); // Show first page System.Threading.Thread.Sleep(50); importer.NavigateToPage( crntONFile, crntPage.ToString("B") ); } if (orea.Data is RTStrokeRemove) { RTStrokeRemoveReceived((RTStrokeRemove)orea.Data); } else if (orea.Data is RTStroke) { RTStrokeReceived((RTStroke)orea.Data); } else if (orea.Data is Page) { PageReceived((Page)orea.Data); } else if (orea.Data is RTPageAdd) { RTPageAddReceived((RTPageAdd)orea.Data); } else if (orea.Data is RTNodeChanged) { RTNodeChangedReceived( (RTNodeChanged)orea.Data); } else if (orea.Data is RTDocument) { RTDocumentReceived((RTDocument)orea.Data); } else if (orea.Data is RTFrame) { RTFrameReceived( (RTFrame)orea.Data ); } }
private void OnObjectReceived(object o, ObjectReceivedEventArgs orea) { try { // Don't receive your own data if (orea.Participant != Conference.LocalParticipant) { if (orea.Data is SerializedInk) { Strokes strokes = ((SerializedInk)orea.Data).Strokes; // This call fails, claiming the strokes are in 2 ink objects // inkOverlay.Ink.Strokes.Add(strokes); // But this call works inkOverlay.Ink.AddStrokesAtRectangle(strokes, strokes.GetBoundingBox()); } else if(orea.Data is DeletedStrokes) { string[] identifiers = ((DeletedStrokes)orea.Data).Identifiers; Ink ink = inkOverlay.Ink; for(int i = 0; i < identifiers.Length; i++) { for(int j = ink.Strokes.Count - 1; j >= 0; j--) { Stroke stroke = ink.Strokes[j]; if((string)stroke.ExtendedProperties[StrokeIdentifier].Data == identifiers[i]) { ink.DeleteStroke(stroke); break; } } } } else if(orea.Data is EraseAllInk) { inkOverlay.Ink.DeleteStrokes(); } // Update the screen when data arrives pbInk.Refresh(); } } catch ( Exception e) { Log(string.Format(CultureInfo.CurrentCulture, "Exception: {0}", e.ToString())); } }
/// <summary> /// Hook the objectReceived event and process it. /// </summary> private void OnObjectReceived(object o, ObjectReceivedEventArgs orea) { // Don't receive your own messages (objects) if (orea.Participant != Conference.LocalParticipant) { Debug.WriteLine("Message recieved of type: " + orea.Data.ToString() ); // Check to see if there are waiting messages lock( this.receiveQueue ) { // Messages in the queue signals that there's a thread working on a current // message, thus we don't want to start processing another message receiveQueue.Enqueue( orea ); if( receiveQueue.Count != 1 ) { // There are other messages waiting on the user. Return and let the // currently processing message finish. return; } } // There are no messages waiting, so we're free to process this one while(true) { this.ConsumeObject( orea ); // Check for messages added while we were processing that one. lock( this.receiveQueue ) { receiveQueue.Dequeue(); // that was this message if( receiveQueue.Count != 0 ) { orea = (ObjectReceivedEventArgs) receiveQueue.Peek(); } else // .Count == 0 { return; } } } } }