コード例 #1
0
        /// <summary>
        /// Applies a label to a group of substrokes.
        /// </summary>
        public override void Execute()
        {
            foreach (Sketch.Substroke substroke in this.substrokes)
            {
                substroke.RemoveLabel(this.label);
            }

            for (int i = 0; i < this.inkStrokes.Count; i++)
            {
                Microsoft.Ink.Stroke stroke = this.inkStrokes[i];

                int currColorRank = 0;
                if (this.origColors[i] == System.Drawing.Color.Black)
                {
                    currColorRank = Int32.MinValue;
                }
                else
                {
                    currColorRank = (int)this.domainInfo.ColorHierarchy[this.origColors[i]];
                }

                int labelColorRank = (int)this.domainInfo.ColorHierarchy[this.labelColor];

                if (labelColorRank > currColorRank)
                {
                    stroke.DrawingAttributes.Color = this.labelColor;
                }
                else
                {
                    stroke.DrawingAttributes.Color = this.origColors[i];
                }
            }

            this.labeledShape = this.sketch.AddLabel(this.substrokes, this.label);
        }
コード例 #2
0
 //constructor
 public MyStroke(Microsoft.Ink.Stroke stroke)
 {
     this.endTime           = DateTime.Now;       //set time to the current time
     this.points            = stroke.GetPoints(); //record the points of stroke
     this.startPoint        = stroke.GetPoint(0);
     this.endPoint          = stroke.GetPoint(stroke.GetPoints().Length - 1);
     this.direction         = new Point(endPoint.X - startPoint.X, endPoint.Y - startPoint.Y);
     this.slope             = direction.Y / direction.X; ///if direction.X = 0 , ...
     this.inflexions        = null;                      //////////////////////////////////////////////////////////////////////////
     this.DrawingAttributes = stroke.DrawingAttributes;  //record the drawingAttributes
     this.inkstroke         = stroke;
 }
コード例 #3
0
 /// <summary>
 /// Adds an Ink Stroke and updates the Sketch.  NOTE: Does NOT check
 /// to ensure that the given Ink stroke is contained within the
 /// Ink object associated with this InkSketch.
 /// </summary>
 /// <param name="iStroke">The Ink Stroke to add</param>
 public void AddInkStroke(Microsoft.Ink.Stroke iStroke)
 {
     Sketch.Stroke sStroke = mReadJnt.InkStroke2SketchStroke(iStroke);
     ink2sketchStr.Add(iStroke.Id, sStroke.Substrokes[0].XmlAttrs.Id); // Converted stroke will always have
                                                                       // exactly one substroke.
     sketchStr2ink.Add(sStroke.Substrokes[0].XmlAttrs.Id, iStroke.Id);
     substrokeIdMap.Add(sStroke.Substrokes[0].XmlAttrs.Id, sStroke.Substrokes[0]);
     Sketch.AddStroke(sStroke);
     if (StrokeAdded != null)
     {
         StrokeAdded(sStroke);
     }
 }
コード例 #4
0
        /// <summary>
        /// Creates a Substroke from Microsoft point data
        /// </summary>
        /// <param name="stroke"></param>
        /// <returns></returns>
        static public Sketch.Substroke MakeSubstroke(Microsoft.Ink.Stroke stroke)
        {
            Sketch.Point[] SketchPoints = stripStroke(stroke);
            Sketch.XmlStructs.XmlShapeAttrs XmlAttrs = new Sketch.XmlStructs.XmlShapeAttrs(true);
            XmlAttrs.Time      = SketchPoints[0].Time;
            XmlAttrs.Source    = "InkOverlay";
            XmlAttrs.PenHeight = stroke.DrawingAttributes.Height;
            XmlAttrs.PenTip    = stroke.DrawingAttributes.PenTip.ToString();
            XmlAttrs.PenWidth  = stroke.DrawingAttributes.Width;
            XmlAttrs.Color     = stroke.DrawingAttributes.Color.ToArgb();
            Sketch.Substroke s = new Sketch.Substroke(SketchPoints, XmlAttrs);

            return(s);
        }
コード例 #5
0
        /// <summary>
        /// Transforms (e.g. moves or resizes) an Ink Stroke in the Sketch.
        /// Converts the given Ink Stroke into a Sketch stroke and then
        /// updates the Sketch to point to the new Ink Stroke instead of the old one.
        /// </summary>
        /// <param name="iStroke">The Ink Stroke to modify</param>
        public void TransformInkStroke(Microsoft.Ink.Stroke iStroke)
        {
            if (!ink2sketchStr.ContainsKey(iStroke.Id))
            {
                return;
            }

            if (!substrokeIdMap.ContainsKey(ink2sketchStr[iStroke.Id]))
            {
                return;
            }

            Sketch.Stroke newSStroke = mReadJnt.InkStroke2SketchStroke(iStroke);
            Substroke     oldSStroke = substrokeIdMap[ink2sketchStr[iStroke.Id]];

            // FIXME need to masquerade Substroke Ids.  Here
            // we abitrarily synchronize the Ids of the first
            // substroke in each stroke.  We do this because
            // ReadJnt will always return a stroke with one
            // substroke.  In some use cases (e.g. fragmenting),
            // matching Ids like this might cause problems.
            //
            // Eric Peterson: June 30, 2009: When loading an old
            // xml sketch, we need to preserve the time data for
            // each point.
            newSStroke.Substrokes[0].XmlAttrs.Id = oldSStroke.XmlAttrs.Id;
            for (int i = 0; i < oldSStroke.Points.Length; i++)
            {
                newSStroke.Substrokes[0].Points[i].Time = oldSStroke.Points[i].Time;
            }

            // Update mapping between strokes
            ink2sketchStr.Remove(iStroke.Id);
            ink2sketchStr.Add(iStroke.Id, newSStroke.Substrokes[0].XmlAttrs.Id);
            sketchStr2ink.Remove(oldSStroke.XmlAttrs.Id);
            sketchStr2ink.Add(newSStroke.Substrokes[0].XmlAttrs.Id, iStroke.Id);
            substrokeIdMap.Remove(newSStroke.Substrokes[0].XmlAttrs.Id);
            substrokeIdMap.Add(newSStroke.Substrokes[0].XmlAttrs.Id, newSStroke.Substrokes[0]);

            // Update pointers in Sketch
            Sketch.Substroke newSSubstroke = newSStroke.Substrokes[0];
            foreach (Sketch.Shape shape in oldSStroke.ParentShapes)
            {
                shape.AddSubstroke(newSSubstroke);
            }

            Sketch.RemoveSubstroke(oldSStroke);
            Sketch.AddStroke(newSStroke);
        }
コード例 #6
0
        public FormInput(string caption, string label, string txt, bool ML, gInk.Root rt = null, Microsoft.Ink.Stroke stk = null)
        {
            InitializeComponent();

            // local
            this.btOK.Text     = rt.Local.ButtonOkText;
            this.btCancel.Text = rt.Local.ButtonCancelText;
            this.FontBtn.Text  = rt.Local.ButtonFontText;

            Text            = caption;
            captionLbl.Text = label;
            if (ML)
            {
                InputML.Visible = true;
                InputML.Text    = txt;
                ActiveControl   = InputML;
            }
            else
            {
                InputSL.Visible = true;
                InputSL.Text    = txt;
                ActiveControl   = InputSL;
            }
            Root   = rt;
            stroke = stk;
            if (stroke == null)
            {
                FontBtn.Visible = false;
            }
            else
            {
                FontBtn.Visible = true;
                FontDlg.Font    = new Font((string)stk.ExtendedProperties[Root.TEXTFONT_GUID].Data, (float)stk.ExtendedProperties[Root.TEXTFONTSIZE_GUID].Data,
                                           (System.Drawing.FontStyle)stk.ExtendedProperties[Root.TEXTFONTSTYLE_GUID].Data);
                InputML.TextChanged += new System.EventHandler(this.InputML_TextChanged);
            }
        }
コード例 #7
0
        /// <summary>
        /// Grabs the (x, y, time) data from the inkStroke
        /// </summary>
        /// <param name="inkStroke"></param>
        /// <returns></returns>
        static public Sketch.Point[] stripStroke(Microsoft.Ink.Stroke inkStroke)
        {
            ulong theTime;
            int   strokeLength = inkStroke.PacketCount;

            ulong[] time = new ulong[strokeLength];

            if (inkStroke.ExtendedProperties.DoesPropertyExist(Utilities.General.theTimeGuid))
            {
                time = (ulong[])inkStroke.ExtendedProperties[Utilities.General.theTimeGuid].Data;
                if (time.Length > 0)
                {
                    theTime = time[0];
                }
                else
                {
                    theTime = ((ulong)DateTime.Now.ToFileTime() - 116444736000000000) / 10000;
                    for (int i = 0; i < strokeLength; i++)
                    {
                        // The multiplication by 1,000 is to convert from
                        // seconds to milliseconds.
                        //
                        // Our time is in the form of milliseconds since Jan 1, 1970
                        //
                        // NOTE: The timestamp for the stroke is made WHEN THE PEN IS LIFTED
                        time[i] = theTime - (ulong)((1 / Utilities.General.SAMPLE_RATE * 1000) * (strokeLength - i));
                    }
                }
            }
            else
            {
                theTime = ((ulong)DateTime.Now.ToFileTime() - 116444736000000000) / 10000;
                for (int i = 0; i < strokeLength; i++)
                {
                    // The multiplication by 1,000 is to convert from
                    // seconds to milliseconds.
                    //
                    // Our time is in the form of milliseconds since Jan 1, 1970
                    //
                    // NOTE: The timestamp for the stroke is made WHEN THE PEN IS LIFTED
                    time[i] = theTime - (ulong)((1 / Utilities.General.SAMPLE_RATE * 1000) * (strokeLength - i));
                }
            }

            bool        includePressure  = false;
            List <Guid> packetProperties = new List <Guid>(inkStroke.PacketDescription);

            if (packetProperties.Contains(Microsoft.Ink.PacketProperty.NormalPressure))
            {
                includePressure = true;
            }

            int[] x        = inkStroke.GetPacketValuesByProperty(Microsoft.Ink.PacketProperty.X);
            int[] y        = inkStroke.GetPacketValuesByProperty(Microsoft.Ink.PacketProperty.Y);
            int[] pressure = new int[x.Length];
            if (includePressure)
            {
                pressure = inkStroke.GetPacketValuesByProperty(Microsoft.Ink.PacketProperty.NormalPressure);
            }

            Sketch.Point[] points = new Sketch.Point[x.Length];
            for (int i = 0; i < x.Length; i++)
            {
                if (includePressure)
                {
                    points[i] = new Sketch.Point((float)x[i], (float)y[i], (float)pressure[i]);
                }
                else
                {
                    points[i] = new Sketch.Point((float)x[i], (float)y[i]);
                }

                points[i].Time = time[i];
            }

            return(points);
        }
コード例 #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="server"></param>
        /// <param name="deckIndex"></param>
        /// <param name="slideIndex"></param>
        /// <param name="strokes">SimpleWebInk objects that make up the strokes.</param>
        public void HandleStudentSubmission(object server, int deckIndex, int slideIndex, ArrayList strokes)
        {
            SlideModel slide = null;
            DeckModel  deck  = null;

            using (Synchronizer.Lock(this.m_Presentation.SyncRoot))
            {
                using (Synchronizer.Lock(this.m_Presentation.DeckTraversals[deckIndex].SyncRoot))
                {
                    using (Synchronizer.Lock(this.m_Presentation.DeckTraversals[deckIndex].Current.SyncRoot)) {
                        // Get the slide model
                        slide = this.m_Presentation.DeckTraversals[deckIndex].Current.Slide;
                    }

                    deck = this.m_Presentation.DeckTraversals[deckIndex].Deck;
                }
            }

            // Get the student submissions deck or create it if it doesn't exist
            DeckModel ssDeck = this.m_Presentation.GetStudentSubmissionDeck();

            if (ssDeck == null)
            {
                // Create the student submissions deck
                Guid ssGuid          = new Guid("{78696D29-AA11-4c5b-BCF8-8E6406077FD4}");
                Guid ssTraversalGuid = new Guid("{4884044B-DAE1-4249-AEF2-3A2304F52E97}");
                ssDeck              = new DeckModel(ssGuid, DeckDisposition.StudentSubmission, "Student Submissions");
                ssDeck.Group        = Group.Submissions;
                ssDeck.current_subs = true;
//                AddLocalRef(ssGuid, ssDeck);
                DeckTraversalModel traversal = new SlideDeckTraversalModel(ssTraversalGuid, ssDeck);
//                AddLocalRef(ssTraversalGuid, traversal);

                // Add the new student submission deck to the presentation
                using (Synchronizer.Lock(this.m_Presentation.SyncRoot)) {
                    this.m_Presentation.DeckTraversals.Add(traversal);
                }
            }

            // Create the new slide to add
            SlideModel newSlide = new SlideModel(new Guid(), new LocalId(), SlideDisposition.Remote | SlideDisposition.StudentSubmission);

            // Make a list of image content sheets that need to be added to the deck.
            List <ImageSheetModel> images = new List <ImageSheetModel>();

            // Update the fields of the slide
            using (Synchronizer.Lock(newSlide.SyncRoot))
            {
                using (Synchronizer.Lock(slide.SyncRoot))
                {
                    newSlide.Title               = slide.Title;
                    newSlide.Bounds              = slide.Bounds;
                    newSlide.Zoom                = slide.Zoom;
                    newSlide.BackgroundColor     = slide.BackgroundColor;
                    newSlide.BackgroundTemplate  = slide.BackgroundTemplate;
                    newSlide.SubmissionSlideGuid = slide.SubmissionSlideGuid;
                    newSlide.SubmissionStyle     = slide.SubmissionStyle;

                    //If the slide background is null, then update the slide background with deck setting
                    using (Synchronizer.Lock(deck.SyncRoot))
                    {
                        if (slide.BackgroundColor == System.Drawing.Color.Empty)
                        {
                            newSlide.BackgroundColor = deck.DeckBackgroundColor;
                        }
                        if (slide.BackgroundTemplate == null)
                        {
                            newSlide.BackgroundTemplate = deck.DeckBackgroundTemplate;
                        }
                    }

                    // Copy all of the content sheets.
                    // Because ContentSheets do not change, there is no
                    // need to do a deep copy (special case for ImageSheetModels).
                    foreach (SheetModel s in slide.ContentSheets)
                    {
                        newSlide.ContentSheets.Add(s);

                        // Queue up any image content to be added the deck below.
                        ImageSheetModel ism = s as ImageSheetModel;
                        if (ism != null)
                        {
                            images.Add(ism);
                        }
                    }

                    // Make a deep copy of all the ink sheets
                    foreach (SheetModel s in slide.AnnotationSheets)
                    {
                        SheetModel newSheet = UW.ClassroomPresenter.Model.Presentation.SheetModel.SheetDeepRemoteCopyHelper(s);
                        newSlide.AnnotationSheets.Add(newSheet);

                        // Queue up any image content to be added the deck below.
                        ImageSheetModel ism = s as ImageSheetModel;
                        if (ism != null)
                        {
                            images.Add(ism);
                        }
                    }
                }
            }

            // Add the slide content to the deck.
            using (Synchronizer.Lock(ssDeck.SyncRoot)) {
                foreach (ImageSheetModel ism in images)
                {
                    System.Drawing.Image image = ism.Image;
                    if (image == null)
                    {
                        using (Synchronizer.Lock(ism.Deck.SyncRoot))
                            using (Synchronizer.Lock(ism.SyncRoot))
                                image = ism.Deck.GetSlideContent(ism.MD5);
                    }
                    if (image != null)
                    {
                        ssDeck.AddSlideContent(ism.MD5, image);
                    }
                }

                // Add the slide to the deck.
                ssDeck.InsertSlide(newSlide);
            }

            // Add an entry to the deck traversal so that we can navigate to the slide
            using (Synchronizer.Lock(ssDeck.TableOfContents.SyncRoot)) {
                TableOfContentsModel.Entry e = new TableOfContentsModel.Entry(new Guid(), ssDeck.TableOfContents, newSlide);
                ssDeck.TableOfContents.Entries.Add(e);
            }


            // Add the ink to the slide now
            using (Synchronizer.Lock(newSlide.SyncRoot))
            {
                RealTimeInkSheetModel sheet = new RealTimeInkSheetModel(new Guid(), SheetDisposition.All | SheetDisposition.Remote, newSlide.Bounds);

                // Add the sheet
                newSlide.AnnotationSheets.Add(sheet);

                // Now add the ink
                using (Synchronizer.Lock(sheet.Ink.Strokes.SyncRoot))
                {
                    foreach (SimpleWebInk stroke in strokes)
                    {
                        Microsoft.Ink.Stroke s = sheet.Ink.CreateStroke(stroke.Pts);
                        s.DrawingAttributes.Color =
                            System.Drawing.Color.FromArgb(stroke.R, stroke.G, stroke.B);
                        s.DrawingAttributes.RasterOperation =
                            (stroke.Opacity < 255) ?
                            Microsoft.Ink.RasterOperation.MaskPen :
                            Microsoft.Ink.RasterOperation.CopyPen;
                        s.DrawingAttributes.Width = stroke.Width * 30.00f;
                    }
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// HACK TEMP replaces shapes
        /// </summary>
        protected virtual void replaceStrokes()
        {
            // Create labels
            ///xxxList<Microsoft.Ink.Stroke> strokes2Delete = new List<Microsoft.Ink.Stroke>();
            foreach (Shape sh in sketchPanel.InkSketch.Sketch.Shapes)
            {
                if (!sh.XmlAttrs.Type.Equals("Label") &&
                    !sh.XmlAttrs.Type.Equals("HorizontalDivider") &&
                    !sh.XmlAttrs.Type.Equals("VerticalDivider") &&
                    !sh.XmlAttrs.Type.Equals("Divider") &&
                    !sh.XmlAttrs.Type.Contains("I"))
                {
                    Label l = new Label();
                    if (sh.XmlAttrs.Type.Equals("True"))
                    {
                        l.Text = "1";
                    }
                    else if (sh.XmlAttrs.Type.Equals("False"))
                    {
                        l.Text = "0";
                    }
                    // TODO don't cares
                    else
                    {
                        l.Text = sh.XmlAttrs.Type;
                    }
                    System.Drawing.Point loc = new System.Drawing.Point((int)sh.XmlAttrs.X, (int)sh.XmlAttrs.Y);
                    using (Graphics g = sketchPanel.InkPicture.CreateGraphics())
                    {
                        sketchPanel.InkPicture.Renderer.InkSpaceToPixel(g, ref loc);
                    }
                    l.Location    = loc;
                    l.AutoSize    = true;
                    l.Width       = (int)sh.XmlAttrs.Width;
                    l.Height      = (int)sh.XmlAttrs.Height;
                    l.Font        = new Font(l.Font.FontFamily, (int)(sh.XmlAttrs.Height / 50.0));
                    l.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                    l.Enabled     = true;
                    sketchPanel.InkPicture.Controls.Add(l);
                    l.BringToFront();

                    labels.Add(l);

                    int labelID = labels.Count - 1;

                    foreach (Substroke sub in sh.Substrokes)
                    {
                        Microsoft.Ink.Stroke iStroke = sketchPanel.InkSketch.GetInkStrokeBySubstrokeId(sub.XmlAttrs.Id);
                        if (iStroke != null)
                        {
                            //strokes2LabelIDs.Add(iStroke.Id, labelID);
                        }
                    }
                }
            }

            // xxxDelete strokes


            sketchPanel.InkCanvas.InvalidateVisual();
        }
コード例 #10
0
        void InkPicture_MouseMove(object sender, MouseEventArgs e)
        {
            if (!enabled)
            {
                return;
            }

            // Get the current mouse position and convert it into InkSpace
            System.Drawing.Point mousePt  = new System.Drawing.Point(e.X, e.Y);
            Graphics             graphics = sketchPanel.InkPicture.CreateGraphics();

            sketchPanel.InkPicture.Renderer.PixelToInkSpace(graphics, ref mousePt);

            // Get the Microsoft Stroke closest to the mouse pointer
            float strokePt, distance;

            Microsoft.Ink.Stroke closestMSubstroke = sketchPanel.InkPicture.Ink.NearestPoint(mousePt, out strokePt, out distance);

            if (closestMSubstroke == null)
            {
                return;
            }


            // Fire tooltip if the mouse pointer is close enough
            if (distance < MeshHighlightingFeedback.MeshHighlightDistanceThreshold)
            {
                // Get the stroke's label, if it has one
                Substroke sub = sketchPanel.InkSketch.GetSketchSubstrokeByInkId(closestMSubstroke.Id);

                if (sub == null)
                {
                    return;
                }

                string label = sub.FirstLabel;

//Console.WriteLine(label);

                /*foreach (Shape sh in sub.ParentShapes)
                 * {
                 *  Console.WriteLine(sh.XmlAttrs.Type);
                 * }*/

                if (label == null || label.Equals("unlabeled"))
                {
                    return;
                }

                // HACK!!

                /*if (label.Equals("Label"))
                 * {
                 *  label = sub.ParentShapes[0].XmlAttrs.Text;
                 *
                 *  /*foreach (Shape sh in sub.ParentShapes)
                 *  {
                 *      if (!sh.XmlAttrs.Type.Equals("Label"))
                 *          label = sh.XmlAttrs.Type;
                 *  }
                 * }*/


                // Show the ToolTip
                this.toolTip.SetToolTip(sketchPanel.InkPicture, label);
                this.toolTip.Active = true;
            }
            else
            {
                // Don't show the ToolTip if the mouse pointer is not close
                this.toolTip.Active = false;
            }
        }
コード例 #11
0
        /// <summary>
        /// Loads a Sketch and synchronizes Ink.  Clears the current contents
        /// of this InkSketch.
        /// </summary>
        /// <param name="sketch">The sketch to load</param>
        public void LoadFeatureSketch(FeatureSketch featureSketch)
        {
            unsubscribeToInk();

            this.Clear();

            mFeatureSketch = featureSketch;

            #region Create Collection - Load Ink Properties

            #region X

            Microsoft.Ink.TabletPropertyMetrics xMet = new Microsoft.Ink.TabletPropertyMetrics();
            xMet.Minimum    = 0;
            xMet.Maximum    = 24780;
            xMet.Resolution = 3003.63647f; //TABLET PEN ONLY 100.0f for mouse i think
            xMet.Units      = Microsoft.Ink.TabletPropertyMetricUnit.Inches;

            System.Guid xGuid = Microsoft.Ink.PacketProperty.X;

            Microsoft.Ink.TabletPropertyDescription xDesc = new Microsoft.Ink.TabletPropertyDescription(xGuid, xMet);

            #endregion

            #region Y

            Microsoft.Ink.TabletPropertyMetrics yMet = new Microsoft.Ink.TabletPropertyMetrics();
            yMet.Minimum    = 0;
            yMet.Maximum    = 18630;
            yMet.Resolution = 3010.66577f; //TABLET PEN ONLY 100.0f for mouse i think
            yMet.Units      = Microsoft.Ink.TabletPropertyMetricUnit.Inches;

            System.Guid yGuid = Microsoft.Ink.PacketProperty.Y;

            Microsoft.Ink.TabletPropertyDescription yDesc = new Microsoft.Ink.TabletPropertyDescription(yGuid, yMet);

            #endregion

            #region Pressure

            // Get max pressure in Sketch
            // Different input devices have different ranges of pressures
            int max = 0;
            foreach (Sketch.Point pt in Sketch.Points)
            {
                max = Math.Max(max, pt.Pressure);
            }

            Microsoft.Ink.TabletPropertyMetrics pMet = new Microsoft.Ink.TabletPropertyMetrics();
            pMet.Minimum = 0;
            if (max > 1024)
            {
                pMet.Maximum = 32767;
            }
            else if (max > 256)
            {
                pMet.Maximum = 1023;
            }
            else
            {
                pMet.Maximum = 255;
            }
            pMet.Resolution = float.PositiveInfinity;
            pMet.Units      = Microsoft.Ink.TabletPropertyMetricUnit.Default;

            System.Guid pGuid = Microsoft.Ink.PacketProperty.NormalPressure;

            Microsoft.Ink.TabletPropertyDescription pDesc = new Microsoft.Ink.TabletPropertyDescription(pGuid, pMet);

            #endregion

            Microsoft.Ink.TabletPropertyDescriptionCollection coll = new Microsoft.Ink.TabletPropertyDescriptionCollection();
            coll.Add(xDesc);
            coll.Add(yDesc);
            coll.Add(pDesc);

            #endregion

            // Load Sketch strokes into Ink
            List <int> points = new List <int>();
            foreach (Substroke sub in Sketch.Substrokes)
            {
                points.Clear();
                foreach (Sketch.Point point in sub.Points)
                {
                    points.Add((int)point.X);
                    points.Add((int)point.Y);
                    points.Add((int)point.Pressure);
                }

                Microsoft.Ink.Stroke stroke = mInk.CreateStroke(points.ToArray(), coll);
                ink2sketchStr.Add(stroke.Id, sub.XmlAttrs.Id);
                sketchStr2ink.Add(sub.XmlAttrs.Id, stroke.Id);
                substrokeIdMap.Add(sub.XmlAttrs.Id, sub);

                stroke.DrawingAttributes.AntiAliased    = true;
                stroke.DrawingAttributes.FitToCurve     = true;
                stroke.DrawingAttributes.IgnorePressure = false;


                //see ReadJnt.cs for opposite transformation

                /*
                 * if (sub.XmlAttrs.Time != null)
                 * {
                 *  stroke.ExtendedProperties.Add(Microsoft.Ink.StrokeProperty.TimeID,
                 *      (long)((ulong)sub.XmlAttrs.Time * 10000 + 116444736000000000));
                 * }
                 */

                if (sub.XmlAttrs.Color != null)
                {
                    stroke.DrawingAttributes.Color = Color.FromArgb((int)sub.XmlAttrs.Color);
                }
                if (sub.XmlAttrs.PenWidth != null)
                {
                    stroke.DrawingAttributes.Width = Convert.ToSingle(sub.XmlAttrs.PenWidth);
                }
                if (sub.XmlAttrs.PenHeight != null)
                {
                    stroke.DrawingAttributes.Height = Convert.ToSingle(sub.XmlAttrs.PenHeight);
                }
                if (sub.XmlAttrs.PenTip != null)
                {
                    if (sub.XmlAttrs.PenTip.Equals("Ball"))
                    {
                        stroke.DrawingAttributes.PenTip = Microsoft.Ink.PenTip.Ball;
                    }
                    else if (sub.XmlAttrs.PenTip.Equals("Rectangle"))
                    {
                        stroke.DrawingAttributes.PenTip = Microsoft.Ink.PenTip.Rectangle;
                    }
                }
                if (sub.XmlAttrs.Raster != null)
                {
                    if (sub.XmlAttrs.Raster.Equals("Black"))
                    {
                        stroke.DrawingAttributes.RasterOperation = Microsoft.Ink.RasterOperation.Black;
                    }
                    else if (sub.XmlAttrs.Raster.Equals("CopyPen"))
                    {
                        stroke.DrawingAttributes.RasterOperation = Microsoft.Ink.RasterOperation.CopyPen;
                    }
                    else if (sub.XmlAttrs.Raster.Equals("MakePenNot"))
                    {
                        stroke.DrawingAttributes.RasterOperation = Microsoft.Ink.RasterOperation.MakePenNot;
                    }
                    else if (sub.XmlAttrs.Raster.Equals("MaskNotPen"))
                    {
                        stroke.DrawingAttributes.RasterOperation = Microsoft.Ink.RasterOperation.MaskNotPen;
                    }
                    else if (sub.XmlAttrs.Raster.Equals("MaskPen"))
                    {
                        stroke.DrawingAttributes.RasterOperation = Microsoft.Ink.RasterOperation.MaskPen;
                    }
                    else if (sub.XmlAttrs.Raster.Equals("MergeNotPen"))
                    {
                        stroke.DrawingAttributes.RasterOperation = Microsoft.Ink.RasterOperation.MergeNotPen;
                    }
                    else if (sub.XmlAttrs.Raster.Equals("MergePen"))
                    {
                        stroke.DrawingAttributes.RasterOperation = Microsoft.Ink.RasterOperation.MergePen;
                    }
                    else if (sub.XmlAttrs.Raster.Equals("MergePenNot"))
                    {
                        stroke.DrawingAttributes.RasterOperation = Microsoft.Ink.RasterOperation.MergePenNot;
                    }
                    else if (sub.XmlAttrs.Raster.Equals("NoOperation"))
                    {
                        stroke.DrawingAttributes.RasterOperation = Microsoft.Ink.RasterOperation.NoOperation;
                    }
                    else if (sub.XmlAttrs.Raster.Equals("Not"))
                    {
                        stroke.DrawingAttributes.RasterOperation = Microsoft.Ink.RasterOperation.Not;
                    }
                    else if (sub.XmlAttrs.Raster.Equals("NotCopyPen"))
                    {
                        stroke.DrawingAttributes.RasterOperation = Microsoft.Ink.RasterOperation.NotCopyPen;
                    }
                    else if (sub.XmlAttrs.Raster.Equals("NotMaskPen"))
                    {
                        stroke.DrawingAttributes.RasterOperation = Microsoft.Ink.RasterOperation.NotMaskPen;
                    }
                    else if (sub.XmlAttrs.Raster.Equals("NetMergePen"))
                    {
                        stroke.DrawingAttributes.RasterOperation = Microsoft.Ink.RasterOperation.NotMergePen;
                    }
                    else if (sub.XmlAttrs.Raster.Equals("NotXOrPen"))
                    {
                        stroke.DrawingAttributes.RasterOperation = Microsoft.Ink.RasterOperation.NotXOrPen;
                    }
                    else if (sub.XmlAttrs.Raster.Equals("White"))
                    {
                        stroke.DrawingAttributes.RasterOperation = Microsoft.Ink.RasterOperation.White;
                    }
                    else if (sub.XmlAttrs.Raster.Equals("XOrPen"))
                    {
                        stroke.DrawingAttributes.RasterOperation = Microsoft.Ink.RasterOperation.XOrPen;
                    }
                }
            }


            subscribeToInk();
            if (SketchLoaded != null)
            {
                SketchLoaded();
            }
        }
コード例 #12
0
 /// <summary>
 /// Deletes an Ink Stroke and updates the Sketch.
 /// </summary>
 /// <param name="iStroke">The Ink Stroke to delete</param>
 public void DeleteInkStroke(Microsoft.Ink.Stroke iStroke)
 {
     DeleteInkStroke(iStroke.Id);
 }