Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Copies strokes to the clipboard in InkSerializedFormat.  Copies selected strokes;
        /// if there is no selection, then all Ink is copied.
        /// </summary>
        public void CopyStrokes()
        {
            if (inkPic.Selection.Count == 0)
            {
                return;
            }

            copyStrokes = new Ink();
            copyStrokes.AddStrokesAtRectangle(inkPic.Selection, inkPic.Selection.GetBoundingBox());

            inkPic.Refresh();
        }
Exemplo n.º 3
0
        /// <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);
        }