Пример #1
0
        /// <summary>
        /// Adding multiple strokes (which can't be erased individually because there are no Guids)
        /// Specifically, this is for student submission overlays.
        /// There are also some CP3 scenarios such as when the instructor opens a CP3 file that has pre-existing ink.
        /// </summary>
        /// <param name="ink"></param>
        public void AddInk(Microsoft.Ink.Ink newInk)
        {
            if ((newInk != null) && (newInk.Strokes.Count > 0))
            {
                //separate transparent and opaque strokes
                List <int> transparentStrokes = new List <int>();
                List <int> opaqueStrokes      = new List <int>();

                //iterate over strokes, adding the ink ids to the correct list
                foreach (Microsoft.Ink.Stroke s in newInk.Strokes)
                {
                    if ((s.DrawingAttributes.Transparency != 0) && (s.DrawingAttributes.Transparency != 255))
                    {
                        transparentStrokes.Add(s.Id);
                    }
                    else
                    {
                        opaqueStrokes.Add(s.Id);
                    }
                }

                //Add transparent strokes to transparentInk.
                if (transparentStrokes.Count > 0)
                {
                    Microsoft.Ink.Strokes tStrokes = newInk.CreateStrokes((int[])transparentStrokes.ToArray());
                    if (transparentInk == null)
                    {
                        transparentInk = new Microsoft.Ink.Ink();
                    }
                    transparentInk.AddStrokesAtRectangle(tStrokes, tStrokes.GetBoundingBox());
                    dirtyBit = true;
                }

                //Add opaque strokes to opaqueInk.
                if (opaqueStrokes.Count > 0)
                {
                    Microsoft.Ink.Strokes oStrokes = newInk.CreateStrokes((int[])opaqueStrokes.ToArray());
                    if (opaqueInk == null)
                    {
                        opaqueInk = new Microsoft.Ink.Ink();
                    }
                    opaqueInk.AddStrokesAtRectangle(oStrokes, oStrokes.GetBoundingBox());
                    dirtyBit = true;
                }
            }
        }
Пример #2
0
        private void addTransparentInkOverlay(Image img, double size)
        {
            //Ink transparency is in the range 0-255 with 0==opaque and 255==invisible.
            //In practice CP sets transparency to 160, but we should be prepared for
            //arbitrary values.
            //We have no assurance that individual strokes won't have different transparencies, so we'll
            //do each stroke as a separate overlay.

            if ((transparentInk != null) && (transparentInk.Strokes.Count > 0))
            {
                foreach (Microsoft.Ink.Stroke s in transparentInk.Strokes)
                {
                    Microsoft.Ink.Strokes strokes = transparentInk.CreateStrokes(new int[] { s.Id });
                    addTransparentStroke(img, strokes, size);
                }
            }
        }