/// <remarks> /// If an app stores the RTStroke, it can remove it easily using this ctor /// </remarks> public RTStrokeRemove(DateTime deletionTime, RTStroke rtStroke, object extension) { DeletionTime = deletionTime; DocumentIdentifier = rtStroke.DocumentIdentifier; PageIdentifier = rtStroke.PageIdentifier; StrokeIdentifier = rtStroke.StrokeIdentifier; Extension = extension; }
/// <summary> /// Handle the reception of a RTStroke object. /// </summary> /// <param name="rtStroke">Stroke received</param> private void RTStrokeReceived(RTStroke rtStroke) { Page pg = rtDoc.Resources.Pages[rtStroke.PageIdentifier]; if( pg == null ) // if the page is missing, ignore the stroke :( return; SizeF imageSize = GetSlideSize( pg.Image ); // Resize the received stroke float xRatio = (imageSize.Width / constWidthPageSend)*inkSpaceToPixel; float yRatio = (imageSize.Height / constHeightPageSend)*inkSpaceToPixel; Rectangle bounds = rtStroke.Stroke.GetBoundingBox(); RectangleF newBounds = new RectangleF( bounds.X*xRatio, bounds.Y*yRatio, bounds.Width*xRatio, bounds.Height*yRatio ); // Add the stroke to the page StringBuilder importData = new StringBuilder(2000); XmlTextWriter xml = CreateInitdXml(importData); xml.WriteStartElement( "PlaceObjects" ); xml.WriteAttributeString( "pagePath", crntONFile ); xml.WriteAttributeString( "pageGuid", rtStroke.PageIdentifier.ToString("B") ); xml.WriteStartElement( "Object" ); xml.WriteAttributeString( "guid", rtStroke.StrokeIdentifier.ToString("B") ); xml.WriteStartElement( "Position" ); xml.WriteAttributeString( "x", newBounds.X.ToString() ); xml.WriteAttributeString( "y", newBounds.Y.ToString() ); xml.WriteEndElement(); // end Position xml.WriteStartElement( "Ink" ); xml.WriteAttributeString( "width", newBounds.Width.ToString() ); xml.WriteAttributeString( "height", newBounds.Height.ToString() ); Ink ink = new Ink(); ink.AddStrokesAtRectangle( rtStroke.Strokes, rtStroke.Strokes.GetBoundingBox() ); byte[] base64ISF_bytes = ink.Save( PersistenceFormat.Base64InkSerializedFormat ); xml.WriteStartElement( "Data" ); xml.WriteBase64( base64ISF_bytes, 0, base64ISF_bytes.Length ); xml.WriteEndElement(); // end Data xml.WriteEndDocument(); string finalData = importData.ToString(); LogAsLastCommand( finalData ); importer.Import( finalData ); // prevents ink & objects from getting inserted too quickly after a page System.Threading.Thread.Sleep(50); // Store the stroke ID in strokesPerPage ((ArrayList)strokesPerPage[rtStroke.PageIdentifier]).Add(rtStroke.StrokeIdentifier); }
/// <remarks> /// If an app stores the RTStroke, it can remove it easily using this ctor /// </remarks> public RTStrokeRemove( DateTime deletionTime, RTStroke rtStroke, object extension ) { DeletionTime = deletionTime; DocumentIdentifier = rtStroke.DocumentIdentifier; PageIdentifier = rtStroke.PageIdentifier; StrokeIdentifier = rtStroke.StrokeIdentifier; Extension = extension; }
/// <summary> /// Handle the reception of a RTStroke object. /// </summary> /// <param name="rtStroke">Stroke received</param> private void RTStrokeReceived(RTStroke rtStroke) { Log("It's an RTStroke object,"); Log(string.Format(CultureInfo.CurrentCulture, "Stroke ID: rtStroke.StrokeIdentifier.ToString()={0}", rtStroke.StrokeIdentifier.ToString())); // Pri2: Check to make sure we have the right page & document // If the stroke already exists, delete the existing one and replace it RemoveStroke(rtStroke.StrokeIdentifier); // Resize the received stroke Log("Resize the stroke,"); DisplaySizeInfo(); float ratioWidthReceive = (float)pbRTDoc.Width / (float)constWidthPageSend; float ratioHeightReceive = (float)pbRTDoc.Height / (float)constHeightPageSend; for (int i = 0; i < rtStroke.Strokes.Count; i++) { rtStroke.Strokes[i].Scale( ratioWidthReceive, ratioHeightReceive); } // Draw the stroke inkOverlay.Ink.AddStrokesAtRectangle(rtStroke.Strokes, rtStroke.Strokes.GetBoundingBox()); // Refresh is needed if your stroke is inside a control like here in the picture box: pbRTDoc Refresh(); }