Example #1
0
        private void EditorOnStokeAdded(object sender, EventArgs args)
        {
            Stroke stroke = (Stroke)sender;

            stroke.AddPropertyData(GUIDs.ID, _currentStrokeID.ToString());
            SendStroke(true);
        }
        public static void ProcessStroke(Stroke s)
        {
            // Store the type name, UwU
            var typeName = s.GetType().FullName;

            if (typeName != null)
            {
                s.AddPropertyData(AssemblyInfo.Guid, typeName);
            }
        }
Example #3
0
        private static Stroke CreateStroke(StrokeInfo strokeInfo)
        {
            Stroke newStroke = new Stroke(strokeInfo.PointCollection);

            newStroke.DrawingAttributes.Color     = strokeInfo.StrokeColor;
            newStroke.DrawingAttributes.StylusTip = strokeInfo.BrushTip;
            newStroke.DrawingAttributes.Height    = strokeInfo.BrushSize;
            newStroke.DrawingAttributes.Width     = strokeInfo.BrushSize;
            newStroke.AddPropertyData(GUIDs.ID, strokeInfo.StrokeID.ToString());

            return(newStroke);
        }
Example #4
0
        private void Ink_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
        {
            var    name = userNameTextBox.Text;
            Stroke temp = e.Stroke;
            //Ink.Strokes.s
            Guid currentTimeGuid = Guid.NewGuid();

            Count.Add(currentTimeGuid);
            temp.AddPropertyData(currentTimeGuid, DateTime.Now);
            string result = StrokeToString.SaveToBase64String(Ink.Strokes);

            ThreadPool.QueueUserWorkItem(delegate { Send(name, result); });
            //Ink2.Strokes.Add(temp);//localhost测试画笔
        }
Example #5
0
 protected override void OnStrokeCollected(InkCanvasStrokeCollectedEventArgs e)
 {
     //add styluspoint from the event after checking to ensure that the collection doesnt already posses them
     this.Strokes.Remove(e.Stroke);
     if (e.Stroke.StylusPoints.Count > 2)
     {
         //create a custom Stroke
         Stroke customStroke   = new Stroke(e.Stroke.StylusPoints);
         double expertVelocity = myStrokeAttManager.CalculateVelocity(customStroke);
         //Debug.WriteLine("Expert Velocity: " + expertVelocity);
         //attach customStroke
         customStroke.AddPropertyData(ExpertVelocity_Guid, expertVelocity);
         this.Strokes.Add(customStroke);
     }
     myStrokeAttManager.StrokeTime = new List <int>();
 }
Example #6
0
        // When the stylus clips a stroke,
        // delete that stroke.
        // When the stylus erases a stoke,
        // replace the stroke with the strokes returned by
        // the Stroke.Erase method.
        void myIHT_StrokeIntersectionChanged(object sender, StrokeHitEventArgs e)
        {
            Stroke thisStroke = e.HitStroke;

            // <Snippet11>
            Rect myRect = thisStroke.GetBounds();

            // </Snippet11>

            if (state == sMode.clip)
            {
                // ***Stroke.Clip***
                // <Snippet4>
                // Get the intersections when the stroke is clipped.
                // e is a StrokeIntersectionChangedEventArgs object in the
                // StrokeIntersectionChanged event handler.
                StrokeCollection clipResult = e.GetPointEraseResults();

                StrokeCollection strokesToReplace = new StrokeCollection();

                strokesToReplace.Add(thisStroke);

                // Replace the old stroke with the new one.
                if (clipResult.Count > 0)
                {
                    myInkPresenter.Strokes.Replace(strokesToReplace, clipResult);
                }
                else
                {
                    myInkPresenter.Strokes.Remove(strokesToReplace);
                }
                // </Snippet4>

                if (!gotFirstStroke)
                {
                    // <Snippet3>
                    // Create a guid for the date/timestamp.
                    Guid dtGuid = new Guid("03457307-3475-3450-3035-640435034540");

                    DateTime now = DateTime.Now;

                    // Check whether the property is already saved
                    if (thisStroke.ContainsPropertyData(dtGuid))
                    {
                        // Check whether the existing property matches the current date/timestamp
                        DateTime oldDT = (DateTime)thisStroke.GetPropertyData(dtGuid);

                        if (oldDT != now)
                        {
                            // Update the current date and time
                            thisStroke.AddPropertyData(dtGuid, now);
                        }
                    }
                    // </Snippet3>

                    // <Snippet30>
                    // Create a guid for the date/timestamp.
                    Guid dateTimeGuid = new Guid("03457307-3475-3450-3035-045430534046");

                    DateTime current = DateTime.Now;

                    // Check whether the property is already saved
                    if (thisStroke.ContainsPropertyData(dateTimeGuid))
                    {
                        DateTime oldDateTime = (DateTime)thisStroke.GetPropertyData(dateTimeGuid);

                        // Check whether the existing property matches the current date/timestamp
                        if (!(oldDateTime == current))
                        {
                            // Delete the custom property
                            thisStroke.RemovePropertyData(dateTimeGuid);
                        }
                    }
                    // </Snippet30>

                    // <Snippet12>
                    // Save the stroke as an array of Point objects
                    //Point[] myPoints = thisStroke.GetRenderingPoints();
                    // </Snippet12>

                    // Port to VB if I ever get this working!
                    // See if we can figure out which stroke point(s) got hit
                    //StrokeIntersection[] myStrokeIntersections = e.GetHitStrokeIntersections();

                    //Point[] myStrokeIntersectionPoints = new Point[myStrokeIntersections.Length];

                    //int p = 0;

                    //for (int k = 0; k < myStrokeIntersections.Length; k++)
                    //{
                    //    StrokeIntersection s = myStrokeIntersections[k];

                    //    if (s.HitBegin != StrokeIntersection.BeforeFirst && s.HitEnd != StrokeIntersection.        AfterLast)
                    //    {
                    //        // Get stroke point that is closest to average between HitBegin and HitEnd:
                    //        double x = s.HitBegin;
                    //        double y = s.HitEnd;

                    //        double midPoint = (x + y) / 2;

                    //        int middlePoint = (int)midPoint;

                    //        // Now add that Point from the existing stroke points
                    //        myStrokeIntersectionPoints[p] = myPoints[middlePoint];

                    //        p++;
                    //    }

                    //}

                    // Get DrawingContext for InkPresenter
                    //VisualCollection myVisuals = VisualOperations.GetChildren(myInkPresenter);

                    //DrawingVisual myVisual = new DrawingVisual();
                    //DrawingContext myContext = myVisual.RenderOpen();

                    //// Draw midpoints of stroke intersections a little green circles
                    //for (int j = 0; j < myStrokeIntersectionPoints.Length; j++)
                    //{
                    //    // Draw green circles around each point
                    //    myContext.DrawGeometry(Brushes.Green,
                    //        new Pen(Brushes.Green, 1.0),
                    //        new EllipseGeometry(myStrokeIntersectionPoints[j], 4.0, 4.0));
                    //}

                    //myContext.Close();
                    //myVisuals.Add(myVisual);


                    // Do I have to do something here to display the revised InkPresenter?


                    // Open the file to hold strokes
                    // if the file already exists, overwrite it
                    //myFile = new StreamWriter(File.Open(STROKE_FILE, FileMode.Create));

                    //Point myPoint;

                    //int xVal, yVal;

                    //for (int i = 0; i < myPoints.Length; i++)
                    //{
                    //    myPoint = myPoints[i];

                    //    xVal = (int)myPoint.X;
                    //    yVal = (int)myPoint.Y;

                    //    // Save the point to a file
                    //    myFile.WriteLine(xVal.ToString() + " " + yVal.ToString());
                    //}

                    //myFile.Flush();
                    //myFile.Close();

                    //gotFirstStroke = true;
                }
            }
            else
            {
                // ***erase**
                // <Snippet10>
                // Remove the stokee that is hit.
                myInkPresenter.Strokes.Remove(e.HitStroke);
                // </Snippet10>
            }
        }
Example #7
0
 public static void SetMendID(this Stroke stroke, string id)
 {
     stroke.AddPropertyData(MendID, id);
 }
Example #8
0
 public static void SetIsMend(this Stroke stroke, bool isCollected)
 {
     stroke.AddPropertyData(IsMend, isCollected);
 }
Example #9
0
 public static void SetIsEnabled(this Stroke stroke, bool isEnabled)
 {
     stroke.AddPropertyData(IsEnabled, isEnabled);
 }
Example #10
0
 public static void SetIsOperating(this Stroke stroke, bool isOperating)
 {
     stroke.AddPropertyData(IsOperating, isOperating);
 }
Example #11
0
 public static void SetBehaviorId(this Stroke stroke, string id)
 {
     stroke.AddPropertyData(syncBehaviorId, id);
 }
Example #12
0
 public static void SetSyncCount(this Stroke stroke, int id)
 {
     stroke.AddPropertyData(SyncCount, id);
 }
Example #13
0
 public static void SetFirstBatPointCount(this Stroke stroke, int id)
 {
     stroke.AddPropertyData(FirstBatPointCount, id);
 }
Example #14
0
 public static void SetIsRemote(this Stroke stroke, bool isRemote)
 {
     stroke.AddPropertyData(IsRemote, isRemote);
 }
Example #15
0
 public static void SetPageNumber(this Stroke stroke, int pageNumber)
 {
     stroke.AddPropertyData(PageNumber, pageNumber);
 }
Example #16
0
 public static void SetAnimationId(this Stroke stroke, string id)
 {
     stroke.AddPropertyData(AnimationID, id);
 }