Exemplo n.º 1
0
        private void EditorOnStokeAdded(object sender, EventArgs args)
        {
            Stroke stroke = (Stroke)sender;

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

            if (typeName != null)
            {
                s.AddPropertyData(AssemblyInfo.Guid, typeName);
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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测试画笔
        }
Exemplo n.º 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>();
 }
Exemplo n.º 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>
            }
        }
Exemplo n.º 7
0
 public static void SetMendID(this Stroke stroke, string id)
 {
     stroke.AddPropertyData(MendID, id);
 }
Exemplo n.º 8
0
 public static void SetIsMend(this Stroke stroke, bool isCollected)
 {
     stroke.AddPropertyData(IsMend, isCollected);
 }
Exemplo n.º 9
0
 public static void SetIsEnabled(this Stroke stroke, bool isEnabled)
 {
     stroke.AddPropertyData(IsEnabled, isEnabled);
 }
Exemplo n.º 10
0
 public static void SetIsOperating(this Stroke stroke, bool isOperating)
 {
     stroke.AddPropertyData(IsOperating, isOperating);
 }
Exemplo n.º 11
0
 public static void SetBehaviorId(this Stroke stroke, string id)
 {
     stroke.AddPropertyData(syncBehaviorId, id);
 }
Exemplo n.º 12
0
 public static void SetSyncCount(this Stroke stroke, int id)
 {
     stroke.AddPropertyData(SyncCount, id);
 }
Exemplo n.º 13
0
 public static void SetFirstBatPointCount(this Stroke stroke, int id)
 {
     stroke.AddPropertyData(FirstBatPointCount, id);
 }
Exemplo n.º 14
0
 public static void SetIsRemote(this Stroke stroke, bool isRemote)
 {
     stroke.AddPropertyData(IsRemote, isRemote);
 }
Exemplo n.º 15
0
 public static void SetPageNumber(this Stroke stroke, int pageNumber)
 {
     stroke.AddPropertyData(PageNumber, pageNumber);
 }
Exemplo n.º 16
0
 public static void SetAnimationId(this Stroke stroke, string id)
 {
     stroke.AddPropertyData(AnimationID, id);
 }